Bitcoin full node and query server

February 2018

Archive of the libbitcoin Slack #general channel.

Tuesday, February 6, 2018

fpelliccioni07:02
Fernando Pelliccioni
Guys, are zlib and bzip2 (through boost iostreams) used in libbitcoin?
^^^ thanks!!
evoskuil07:05
Hey, looks like I’ve been missing messages in this section. I’ll try and catch up.
@fpelliccioni I doubt there is an inherited dependency on either compression library. We have a conditional dependency on ZLib for QRCode support in libbitcoin and explorer. We must install ZLib in that case, and we don’t have to in any other.
Also our iostream scenarios should not require compression.
fpelliccioni07:15
Hey @evoskuil... how are you! Thanks!
evoskuil07:16
@Ty the litecoin consensus change pertains to the “time warp attack” - https://bitcointalk.org/index.php?topic=114751.0
bitcointalk.org
Blocking the time warp attack
@fpelliccioni Good, enjoying speaking with some great meetups in Europe.
fpelliccioni07:18
meetups about crypto? or something else?
evoskuil07:19
@Ty We can add in the time warp patch as a disabled-by-default hard fork.
evoskuil07:32
@fpelliccioni Bitcoin meetups, with some “blockchain” discussion mixed in.
@Ty Nice work on Litecoin. That will make it easy to generalize the parameters into config, and to add the two necessary “hard forks” (time warp and scrypt).
fpelliccioni07:48
I think with this line you are enabling boost iostrems to use zlib... although I'm not sure if this is implies performance penalty:
GitHub
libbitcoin - Bitcoin Cross-Platform C++ Development Toolkit
same with ICU and Boost.Regex and Boost.Locale... Is libbitcoin taking advantage of this?
evoskuil07:52
Of what?
fpelliccioni07:53
the usage of ICU with boost, is it neccesary?
evoskuil07:53
When ICU is required, yes. But that is conditional (not enabled unless you set —with-icu).
(edited)
See install.sh comment: # boost_iostreams # The zlib options prevent boost linkage to system libs in the case where # we have built zlib in a prefix dir. Disabling zlib in boost is broken in # all versions (through 1.60). https://svn.boost.org/trac/boost/ticket/9156 # The bzip2 auto-detection is not implemented, but disabling it works.
fpelliccioni07:55
oh, nice!
evoskuil07:56
So boost may link ZLib if it finds it, but we don’t require it for iostreams. We set the path so that we get consistent linkage in the case where we have linked ZLib for qrcode.
We would disable it if that worked, but it does not.
(edited)
fpelliccioni07:57
I didn't see that problem in our platforms... I will check it...
evoskuil07:57
You may not notice it.
fpelliccioni07:57
I think boost build tells
evoskuil07:59
It would not cause a problem unless you built —with-zlib (for qrcode) and boost linked another version of zlib (because you hadn’t set the path to match).
(edited)
fpelliccioni08:00
but I can check if Boost takes a "system" zlib
evoskuil08:00
Sure, it can’t be disabled.
fpelliccioni08:01
I will check with recent versions... thanks!
evoskuil08:01
But should succeed if there is not zlib (given we don’t use it in iostreams).
fpelliccioni14:04
Disabling zlib and bzip2 works with Boost 1.66.0. No need for the workaround with that version.

Wednesday, February 7, 2018

evoskuil12:05
Good info, but as long as we support lower versions it’s easier to just apply the patch generally.
👍 1

Thursday, February 8, 2018

fpelliccioni12:50
Guys, are the libbitcoin unit tests running OK with GCC (Linux&GCC or MinGW) ? I think I found an error in the libpng unit test. I will send the PR. But I want to confirm with you...
neillm13:03
they appeared well to me, will try again today
evoskuil13:03
All unit tests are passing, history is in Travis. MinGW is not yet supported.
GitHub
There is a bug in the PNG library when using space optimization levels, such as CXXFLAGS=-Os which will show up in a test run failure. Should check back with libpng at some point.
neillm19:06
the png test is confirmed working here
is visual studio the only support windows build environment at the moment?
supported

Friday, February 9, 2018

@choidujour has joined the channel03:51
neillm04:08
greetings
1 reply · choidujour · last Feb 09, 2018
C
choidujour04:18
hi @neillm
neillm13:35
@fpelliccioni good find on the png bug. I'm re-testing https://github.com/libbitcoin/libbitcoin/issues/715 and will report back, as I suspect it's solved by the fix
GitHub
There is a bug in the PNG library when using space optimization levels, such as CXXFLAGS=-Os which will show up in a test run failure. Should check back with libpng at some point.
fpelliccioni13:38
I hope so! Thank you!
neillm14:01
yeah, that did it
when the space optimization is used, there is less room for overwrite bugs to luckily succeed
fpelliccioni14:06
Nice!
neillm14:06
agreed, good find!
fpelliccioni14:13
😉
I think tests have to be done in "debug" mode and "release" mode (with several optimization flags)
neillm14:17
there are many combinations that are possible. travis has a good subset, but all configurations would really slow down the CI process
fpelliccioni14:17
it is tue
*true
neillm14:18
at least for now, i think it's up to us to try to stay on top of this. eventually, it would be good to get something additional going. perhaps more travis integrations, not sure yet
i've had decent experiences with buildbot, which can be run from a private setup, but the results exposed via web. not sure it's worth the effort now because travis-ci has been working pretty well so far
but i do agree that the more coverage, the better :-)
if anyone has some free time, can you test bx against the ips listed for mainnet1/testnet1 and mainnet2/testnet2 listed here: https://github.com/libbitcoin/libbitcoin-server/wiki/Community-Servers
GitHub
libbitcoin-server - Bitcoin Full Node and Query Server
the dns isn't setup yet, so please don't use the names mainnet1.libbitcoin.net etc, just ips for now
hrm, travis builds are still stalling for the gcc static build. not sure why just yet, as that's the config i tend to use most often

Saturday, February 10, 2018

neillm12:36
@pmienk ah, nice, thanks
do you remember why we wanted the space optimized builds for travis a while back? did it help them to complete faster, or am i remembering that wrong?
fpelliccioni18:38
Guys, what is the Compact Blocks status? If you tell me what is missing I could work on it.

Monday, February 12, 2018

lclc15:04
@evoskuil: Regarding the settings from constants.hpp: Do you want us to create a new settings-class similar to the ones that exist for libbitcoin-protocol, network, etc ? ( see https://github.com/libbitcoin/libbitcoin-protocol/blob/master/include/bitcoin/protocol/settings.hpp )
GitHub
libbitcoin-protocol - Bitcoin Blockchain Query Protocol
evoskuil15:08
That will be necessary and you are welcome to do so.
lclc15:15
Ok, great. Thanks for the swift answer
evoskuil15:16
Compact blocks is behind the current large chunk of v4 work in my repo, which when merged will connect up with @pmienk work in master to maintain the tx pool index. Once those are complete it will make sense to move forward with cb, but prob not before. One exception would be the math to compute short ids (siphash).
fpelliccioni21:54
Thanks

Tuesday, February 13, 2018

pmienk06:19
@neillm I can't recall, though if I'd put it there it was likely speed of the travis job.
neillm12:20
@pmienk ok, that sounds about right, thanks
lclc14:53
Roger is now serving instant coffee at roger.coffe: bx fetch-height tcp://roger.coffee:9091 bx fetch-height tcp://roger.coffee:9081 ‘8=mvk8!F=+>$k&-.65NCPp}4e4j)<N3wk{+N!*hM’ 😉
evoskuil15:05
Nice!
neillm18:04
@lclc 👍
evoskuil18:06
Let’s get it added to community servers when you can.
fpelliccioni18:10
Sorry, What is Roger?
evoskuil18:11
Apparently a barista.
fpelliccioni18:11
Nice

Wednesday, February 14, 2018

lclc07:16
@fpelliccioni Roger Ver, obsessed with buying coffee on-chain 😉
I don’t have any monitoring yet so it might be not so stable
fpelliccioni12:22
heheheheh
lclc12:26
I setup the bitnodes email notification now for ‘monitoring’ but I don’t trust it and it only tells me if they can connect to my node or not What are you guys using to monitor your libbitcoin-server ?
(edited)
neillm12:29
@lclc i'm not using anything fancy at the moment. in the past (running v2), i had a script that would restart the nodes that went down, but that's a bad idea for libbitcoin since corruption is more or less guaranteed on non-graceful stop. i also didn't need it to send me mails because i was unable to investigate before having access, at which point, i can just see that it had stopped
while not ideal, i run the nodes in screen sessions that i can always see, so it would be obvious if something went down. but if it goes down while i'm away, it can't properly be resolved until i'm back anyway
lclc12:33
Ok. I start / stop & autostart on failure with systemd (assuming disk corruption gets catched by having the lock file). Seems to work fine so far. But I hope to later integrate something like Prometheus etc to monitor and log to know more about the usage of the server 🙂
neillm12:34
ah, ok. for status while running, i just top or htop for the moment.
let me know what you find :-)
once up and running properly, i've found bs to be very reliable/stable, so that's a plus and helps quite a lot
the main issue i've seen is failures after an upgrade (due to some regression) or power outages, which i'm working to resolve as well
lclc12:39
I hope to not seen any power outages as my server runs in a hosted datacenter
neillm12:39
then there's little to worry about on that end :-)
lclc12:53
Maybe I should put a warning in the USER_AGENT so people are aware that they are not just trusting me but also the datacenter operator regarding IP logging etc
neillm12:54
i think that's a known risk of using any externally public system, no?
lclc13:51
Also true. You never know anyway
evoskuil15:38
I just tell people I will steal their money.
Auto restart is prob not too useful.
Also, deploy version3, not master.
1 reply · lclc · last Feb 16, 2018
lclc09:09
Yes I’ve used 3.5
neillm15:41
well, there's some benefit to having a readily available master node or two up, just not for production uses
evoskuil15:41
I’m just referring to community servers.
neillm15:42
right, wasn't sure by the naming if it was one ;-)
evoskuil15:42
Running master is helpful in early identification of regressions not caught by unit testing.
neillm15:43
or just testing new features
but in those cases, i suppose it doesn't need to be public
neillm16:07
speaking of which, mainnet1/mainnet2 were lost due to that rebuild zmq regression, but are nearly done syncing and should be back online in the next couple of days
i usually rebuild one at a time, but i did both at once for some reason ...
evoskuil16:17
It would be good at this point to look into load balancing/failover for the public servers.
neillm16:18
agreed
evoskuil16:18
Address subscription is stateful, and uses the query endpoint, which is a bit problematic.
Actually, prob not. When a connection is lost the client can safely transition to another server.
neillm16:20
what if the settings took a list of servers and operations automatically try/retry until one works
evoskuil16:20
Bx settings?
neillm16:20
sure
evoskuil16:21
That won’t help zmq callers.
neillm16:21
true, they're on their own, or can do the same thing :-P
evoskuil16:22
This is something you do on the server end to increase uptime.
neillm16:22
right, but won't work across servers on different networks
as far as i know
evoskuil16:23
Sure it can, as long as they are reachable.
neillm16:23
ah, ok haven't tried it. i've use haproxy before for balancing between servers on the same network
evoskuil16:24
Of course if the proxy is down...
neillm16:24
heh. if it can truly do across the internet, could run it on some 'always on' cloud node
evoskuil16:24
BS doesn’t really need load balancing, it’s too fast. It needs failover.
neillm16:25
haproxy does both, so i don't think it would hurt
evoskuil16:28
With an http endpoint you can probably configure a get-height call and trigger DNS failover from that.
With no need for custom code.
DNS failover is what I’ve been doing manually.
neillm16:29
right. sounds good, but didn't expect it would failover that quickly
(given client caches, etc)
evoskuil16:29
Can be very low with low TTL
Say 10 sec
Client caching cannot exceed TTL
neillm16:31
i'm good with trying that. i don't know if that last statement is actually true ;-)
'should not exceed', sure
evoskuil16:32
If they do they are broken.
neillm16:32
most software is
evoskuil16:32
“must not” is correct
But who knows, some will prob break.
neillm16:34
i remember being bit by this: https://bugzilla.redhat.com/show_bug.cgi?id=656014 (not on redhat, just ncsd issues)
evoskuil16:34
Like I said, broken :).
neillm16:35
like i said, most software is :-)
but yes, worth a shot, can't hurt
so a get-height to mainnet would trigger failover to 1/2/3/etc
evoskuil16:36
Not using DNS failover because there may be buggy clients, therefore creating a more complex dependency and potentially buggy implementation would not be my first choice.
neillm16:37
fair enough. but if dns failover doesn't resolve the issue, users are in the same spot (all those users with broken dns caches)
evoskuil16:37
Presumably the tool that monitors the endpoints would remove the failing endpoint from DNS.
Then they can fix their platforms.
neillm16:38
or do failover how they do it now: update bx settings
evoskuil16:39
Given this technique is used commercially I don’t think that platform issues would be very common on current environments.
neillm16:39
we'll find out soon :-)
evoskuil16:40
BX and client can certainly support an internal round-robin based on config and timeout. But the more general solution would be preferable, and much faster (BX is stateless).
neillm16:40
agreed
evoskuil16:51
Ideally you want to subscribe to the heartbeat endpoint, that way you get a push notification, with timing based on config.
But polling isn’t so bad in this case.
neillm16:52
true for something that's generally running longer than bx
evoskuil16:53
Right, wallets should use the heartbeat but a dns failover monitor could use either.
fpelliccioni22:55
@evoskuil what is the last version of Compact Blocks? v2, right?
Bip152 says v2 but you send a message (here) about v4.
Oh, sorry, v4 of libbitcoin. 😐
evoskuil23:04
I’m sorry, I don’t understand your question.
evoskuil23:32
Libbitcoin doesn't implement bip152, that is slated for v4.
fpelliccioni23:35
You said that and I was confused by v4. You meant Libbitcoin v4 I thought Bip152 v4.
Eric Voskuil
Compact blocks is behind the current large chunk of v4 work in my repo, which when merged will connect up with @pmienk work in master to maintain the tx pool index. Once those are complete it will make sense to move forward with cb, but prob not before. One exception would be the math to compute short ids (siphash).
evoskuil23:35
bips don't have versions.
fpelliccioni23:36
well, Bip152 specifies CB version1 and CB version2
don't worry, I was confused... now I understand the libbitcoin status.
We (Bitprim) need to implement CB as soon as possible, so, we will be working on it in the next weeks.

Thursday, February 15, 2018

fpelliccioni12:39
Guys a couple of questions: Libbitcoin now supports up to protocol version 70002, right? With the support of CompactBlocks the protocol to be supported is going to be 70014 (or 70015). Does this imply that protocols between 70002 and 70014 must be supported? (70011:bip111, 70012:bip130 70013:bip133) Or can they be omitted?
neillm18:16
@fpelliccioni anything can be omitted. there's no obligation for a peer to do much of anything
evoskuil18:22
These are all properly supported in v3.5. BIP111 is supported by not setting the NODE_BLOOM service flag.
(edited)
evoskuil18:28
All network protocols up to and including 70013 are fully implemented: https://github.com/libbitcoin/libbitcoin/blob/master/include/bitcoin/bitcoin/message/messages.hpp
(edited)
GitHub
libbitcoin - Bitcoin Cross-Platform C++ Development Toolkit
fpelliccioni20:00
Thanks guys!
(edited)
fpelliccioni23:12
I was confused because I found bitcoin/network/protocols/protocol_version_70002.hpp but I did not find the next ones (70011, 70012 and 70013)
evoskuil23:39
See comments in the protocol classes.
fpelliccioni23:40
let me see
fpelliccioni23:46
Do you mean Construct a version protocol instance using configured minimums.?
That 70002 (for example) is the minimum version supported ?

Friday, February 16, 2018

evoskuil00:00
No, I mean that the comments explain why there isn’t a versioned class for every protocol extension.

Wednesday, February 21, 2018

Thursday, February 22, 2018

lclc10:10
Thanks Eric! Good idea to share it in the place with most libbitcoin-knowledge 😄

Sunday, February 25, 2018

James C.16:09
@evoskuil thanks for your email reply, I am excited to work on Libbitcoin!
Currently working on a short explainer on byte_array/data_chunk/data_slice when working directly with bytes and have a question.
Lets say I have a function(data_slice input), and i pass in a input of type byte_array, data_chunk or any iterable container. How does the compiler know the data_slice can actually wrap these other iterable types without explicitly instantiating them as data_slice(var) in the function for example? It's a neat wrapper design, but I don't understand how its compiled. Thanks in advance!
evoskuil21:24
This is the nature of c++ templates. The array_slice (generalization of data_slice) is a template. The compiler only requires that the template parameter satisfy all of its compiled uses.
Oh, looks like I may have missed the actual question.
The construction of the data_slice occurs as a result of an implicit conversion. http://en.cppreference.com/w/cpp/language/implicit_conversion
As long as the compiler can satisfy all of the template expectations of the data_slice then the type can be converted to it.

Monday, February 26, 2018

James C.09:47
Ah got it! So this single argument constructor will be used in an implicit conversion: template <typename Container> array_slice(const Container& container);
(edited)
unless, I put an -> explicit array_slice(const Container& container)
👍
evoskuil09:55
👍
evoskuil10:01
Though I'm not sure how explicit would apply to a template parameter, since the parameter is inherently implicit.
(edited)
evoskuil10:08
I think that my initial answer (implicit conversion) is incorrect. The data_slice is a typedef of array_slice<uint8_t>. It's constructor is a template method, so the type passed defines the type of the parameter (as opposed to being converted to it in the case of implicit conversion).
James C.10:21
Hmm. So lets say I declare "data_chunk myChunk", fill it with several bytes of entropy and use it as argument in "bitcoin_short_hash(data_slice data);" When that hash function is called, and the input is a data_chunk instead of data_slice, the implicit conversion happens, using the single argument constructor with template <typename Container> The template for array_slice will take "data_chunk" as "Container type". And so the array_slice constructor will be: array_slice(const data_chunk& container) for this implicit conversion.
(edited)
... and since data_chunk is an container with .data() / .size() methods, this constructor works out fine? That's my understanding so far...
evoskuil11:06
Yes, that's correct (my initial response). there is a constructed instance of array_slice<uint8_t>(const data_chunk& container) passed to bitcoin_short_hash(...).
And as you have surmised, all of the requirements of the Container type are here: begin_(container.data()), end_(container.data() + container.size())
evoskuil11:21
And to be clear, you have both implicit conversion (to array_slice/data_slice) and template definition (defining Container) being used to pass the parameter to bitcoin_short_hash(data_slice value).
James C.11:59
👍 perfect - great learning, thank you!
evoskuil17:55
NP, good questions.

Tuesday, February 27, 2018

evoskuil00:37
master has been updated with latest v4 work in progress
neillm13:12
nice work on sync progress, particularly with bn!
it's been a while since i've tried that out. what are the disk space requirements of bn fully sync'd (ballpark)?
James C.13:36
@evoskuil and Libbitcoin maintainer team, I have drafted a intro chapter on working with byte containers in Libbitcoin: https://github.com/jachiang/LibbitcoinDocumentation/blob/master/02_WorkingWithBinaryData.md Shall I push directly to the wiki so change history are captured there? Comments & guidance welcome! I will move on to EC types/operators next ...
(edited)
James C.13:43
@evoskuil @neillm where could I potentially start to learn more about the block memory-less Libbitcoin daemon? Such as, how it is even possible to operate without tx-mem and block-mem pool? Thx in advance.
neillm13:45
@James C. @evoskuil has all of the details, but the idea is that instead of storing those in physical memory, they are placed in the store just like 'valid' transactions and blocks. it does consume more space, but simplifies the architecture
one of the requirements of course is backing to SSD, so the disk heavy approach is mitigated by underlying hardware
it's true that the store then contains some txs and blocks that may never appear in the strong chain, but it appears in practice the amount of 'wasted' space is negligible
nice work on the docs, btw, i am reviewing now. i don't know if you should push straight to the wiki, but i think that's the answer. @evoskuil can confirm
James C.13:48
@neillm ah super interesting! So more memory allocated to other syncing processes... at the cost of slower access to mem/tx pool stored on SSD. Strong chain refers to the mined chain?
neillm13:49
currently mined chain, yes, although it's susceptible to re-orgs of course
in the doc, search "In Libbitcoin, the the" (2 'the's)
afk a bit, but be back soon
James C.13:51
👍 typo corrected. I will check in a couple hours and make any adjustments. thx neill!
neillm14:09
search "short_hash secondHash = bitcoin_short_hash(myArray); //ok" <-- myArray should be myChunk
👍 1
1 reply · James C. · last Feb 27, 2018
James C.16:31
Thanks for review Neill!
neillm15:37
@evoskuil: 👍 testnet syncs quickly via bs. didn't get an exact timing, but it was < 20 minutes
so how long until validation is enabled (or anything stopping at this point)? :-)
evoskuil23:26
Sorry, just saw this. slack is so lame with notifications.
The strong chain is the branch of the "mined" tree that has the most cumulative proven work.
Validation and reorganization into the strong chain is my next major work, hopefully all done within the next couple of weeks.
I would argue that there is no "wasted" space in storing valid unconfirmed txs that conform to the node's policy. More resource wasting arises from discarding them.
(edited)
Unconfirmed doesn't mean not validated, we only store valid data.
Description of these mechanisms really belongs to libbitcoin-blockchain.
only formalised at the binary level, where private & public keys
There's no (consensus/p2p) protocol requirement pertaining to private key formatting.
(edited)
3 replies · James C., evoskuil · last Feb 28, 2018
James C.09:24
I see. So only the data formats exposed in potentially broadcast serialised tx's/network messages are...?
(edited)
evoskuil19:15
In the tx, including script.
evoskuil19:16
And other messages. Note that no message includes a private key, since it’s private. :).
(edited)
evoskuil23:41
I'd recommend making example code conform to style: https://github.com/libbitcoin/libbitcoin/wiki/Style-Guide
(edited)
👍 1
2 replies · James C., evoskuil · last Feb 28, 2018
James C.16:36
Reading this now ... there might be a small typo: Fixed-Length "Un"signed Integers (int8_t...) vs Fixed-Length Signed Integers (uint8_t...) are swapped.
(edited)
evoskuil19:14
Feel free to fix.
evoskuil23:51
The images are very nice looking, but are not searchable or diffable, and very hard to edit (especially for other contributors). In the case where you are presenting a textual idea (such as the existing examples) I would stick to formatted text. I have some experience with this in the bx wiki:
2 replies · James C., evoskuil · last Feb 28, 2018
James C.16:44
...I will definitely need to familiarise myself with the bx documentation to achieve consistency with API doc over time...
evoskuil19:16
No worries, it takes time.
evoskuil23:52
These are out of date for the recent/v4 electrum additions.
👍 1
Invalid: size_t arraySize = 16; byte_array<arraySize> myArray; Valid: constexpr size_t arraySize = 16; byte_array<arraySize> myArray;
👍 1
Not ok (temporary copy passed): pseudo_random_fill(to_chunk(myArray)) //ok
👍 1
We never instantiate a data_slice (just for parameters): data_slice dataSlice0(myArray); //ok
This avoids a copy assignment: data_chunk myChunk{0, 1, 2, 3}; vs: data_chunk myChunk = {0, 1, 2, 3};
👍 1

Wednesday, February 28, 2018

evoskuil00:00
And for array: byte_array<4u> myArray{ { 0, 1, 2, 3} }; vs. byte_array<4u> myArray = {0, 1, 2, 3}; (the initializer syntax is different for vector)
👍 1
This isn't a "throw" (runtime) it's a compiler error: std::cout << (myArray == myChunk); //throws error
👍 1
Use auto here (style): auto firstHash = bitcoin_short_hash(myArray); //ok
2 replies · James C., evoskuil · last Feb 28, 2018
James C.09:23
auto because bitcoin_short_hash implies return type of short_hash?
evoskuil19:19
Yes, c++11 has type inference. Use of auto is easier to write, read, more compact, easier to refactor, and generally safer.
evoskuil00:03
I recommend avoiding numbered titles. Renumbering will get hard and it will drift.
👍 1
Obviously we'll want to move comments to another system. It's too bad that GitHub doesn't provide pull request workflow for wiki pages.
I recommend that you incorporate all examples as either test cases (I do this with the bx wiki) or as example functions (in the build). If they don't get compiled they will eventually break unnoticed.
(edited)
2 replies · James C., evoskuil · last Feb 28, 2018
James C.16:28
@evoskuil Many thanks for your review. There are some careless mistakes in the draft, but I will rework with with your feedback in mind. Happy to include examples in the tests. I will rethink/rework this piece again, especially over time as I progress!
evoskuil19:20
👍
neillm16:31
@James C. 👍
😄 1
evoskuil19:20
replied to a thread: view
👍