Skip to content

Optional checksum rebase#26

Open
sickpig wants to merge 13 commits into
gandrewstone:optionalChecksumfrom
sickpig:optionalChecksum
Open

Optional checksum rebase#26
sickpig wants to merge 13 commits into
gandrewstone:optionalChecksumfrom
sickpig:optionalChecksum

Conversation

@sickpig

@sickpig sickpig commented Nov 16, 2018

Copy link
Copy Markdown

No description provided.

awemany and others added 13 commits November 16, 2018 14:44
This function will take an enum (cast to uint64_t) and a map
of bit values to strings and produce a string describing the OR-ed
enum value.

To be used in the following xversion commits.
A version value of 10300 is below the MIN_PEER_PROTO_VERSION,
which will generate an error already further up in the code.
This is a proposal and implementation for augmenting the `version`
message in the BCH protocol with an `xversion` message to provide
a key value map of 64bit integers to `std::vector<uint8_t>` values
(called `xmap`) that can be used to signal general configuration
and version options to connected peers.

This implementation comes with a specification document in
doc/xversionmessage.md, a simple unit test and a fuzzer test
case. It also comes with a proposal on how to organize and
name the `xmap` key space between implementations, as well as a tool
to process a key space definition file (xversionkeys.dat) into
a C++ header.

Furthermore, the BU-specific BUVERSION message has been retired (but
is still handled) and replaced with an appropriate entry in this map.

Thanks to everyone who gave me input on this PR:

@gandrewstone, @Greg-Griffith, @dgenr8, @sickpig, @dagurval,
@jasonbcox, @schancel, @deadalnix
This is a rather comprehensive rework of the initial connection
set up logic. Instead of having various flags that track the individual
sending and receiving of messages, the set up sequencing for a connection
has been replaced with two state machines and corresponding state
variables (state_incoming, state_outgoing) that track the status of
the incoming and outgoing connection setup parts, and of sending
any kind of version message (version, buversion, xversion) around.

This change comes with a few behavioral changes and thus needs to be
tested comprehensively in a test net as well as live nodes for reasonable
certainty as to bug scarcity.

The incoming and outgoing state variables and their allowed
transitions are as follows:

For INCOMING versioning message from the remote peer, using
the ConnectionStateIncoming enum as defined in net.h:

CONNECTED_WAIT_VERSION: Initial state. The TCP connection is up and
the node is waiting for the version message from the remote peer. Only
a version message is valid here. All other messages are invalid and
will either lead to disconnection and banning or are silently ignored.

SENT_VERACK_READY_FOR_XVERSION: After receiving the version message (and
sending the verack out in the event handler). Only now it is permissible
to receive and extended version message 'xversion' from the remote peer.
If any other message comes in, the state transitions to READY automatically,
which will make receipt of xversion messages invalid.

READY: The version handshake is complete and normal message exchange can
commence.

For OUTGOING versioning messages to the remote peer, using the
ConnectionStateOutgoing enum as defined in net.h:

CONNECTED: Initial state after TCP connection is up.

SENT_VERSION: The initial version message has been sent to the remote peer.

READY: The verack has been received and the buversion as well as xversion
messages have been sent to the remote peer.

Any regular message that is coming in the initial version message, before both
incoming and outgoing connection state transitioned to "READY" will be dropped now.
Only enable parallel message processing when all version information has
been exchanged.
Allow to set the pushbuf argument also in the send_message(..)s
methods that build on top of the basic one.
To allow for accessing files other than the log file in a node's
working directory as well.
There's some duplicated code handling with the compact integer format
that can now be reworked to use this implementation. However, this commit
doesn't contain the rework yet - it just adds one more implementation ...
Add xversion / xverack messages to mininode and handle their receipt in a
simply but likely sufficient way. No changes have been made to the sending
side of the mininode in here.
Wait for proper xversion setup before testing the sendheaders functionality.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants