Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi: Add initialstate peer messages. #2349

Merged
merged 3 commits into from
Sep 23, 2020
Merged

Conversation

matheusd
Copy link
Member

@matheusd matheusd commented Sep 3, 2020

Rebased on top of #2170 #2350

Includes #2348

This is part of the treasury decentralization work.

This adds a new pair of messages to the peer protocol named getinitstate/initstate. These messages are meant to be used as replacements for the getminingstate/miningstate messages.

The new messages are more generic and meant to be used for both the existing mining information (head blocks and votes) and other ephemeral data that nodes of the peer network might need. The initial implementation in dcrd additionally offers and responds with treasury spend transactions.

tpends are special transactions in that they are meant to be long-lived in the mempool and not only miner nodes but also voting wallet nodes need to discover them in a timely manner. Thus we introduce this new set of messages in order to relay them in the network as nodes startup.

This work isn't strictly consensus-related and thus has been extracted from the main treasury PR to ease review by external developers.

@davecgh davecgh changed the title Add InitialState peer messages multi: Add initialstate peer messages. Sep 3, 2020
wire/msginitialstate.go Outdated Show resolved Hide resolved
@davecgh davecgh added this to the 1.6.0 milestone Sep 4, 2020
wire/common.go Outdated Show resolved Hide resolved
wire/msggetinitstate.go Outdated Show resolved Hide resolved
wire/msggetinitstate_test.go Outdated Show resolved Hide resolved
wire/msginitialstate.go Outdated Show resolved Hide resolved
@matheusd matheusd force-pushed the initialstatemsg branch 2 times, most recently from a42b2ac to aceef3f Compare September 21, 2020 20:30
Copy link
Member

@davecgh davecgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really great job overall! The only thing I see are just consistency. casting, and unneeded call nits. Comments inline.

wire/error.go Outdated Show resolved Hide resolved
wire/protocol.go Outdated Show resolved Hide resolved
wire/msggetinitstate.go Outdated Show resolved Hide resolved
wire/msggetinitstate.go Outdated Show resolved Hide resolved
wire/msggetinitstate.go Outdated Show resolved Hide resolved
wire/msggetinitstate.go Outdated Show resolved Hide resolved
wire/msggetinitstate_test.go Outdated Show resolved Hide resolved
wire/msggetinitstate_test.go Outdated Show resolved Hide resolved
wire/msginitstate_test.go Outdated Show resolved Hide resolved
server.go Outdated Show resolved Hide resolved
server.go Outdated Show resolved Hide resolved
server.go Outdated Show resolved Hide resolved
server.go Outdated Show resolved Hide resolved
Copy link
Member

@davecgh davecgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updates reviewed and look good. Thanks!

This adds the GetInitState and InitState messages along with appropriate
tests. It also adds a new protocol version (version 8) and bumps the
current wire version to it.

This set of messages will be used to allow peers to exchange ephemeral
startup information in a more general manner than the current existing
GetMiningState/MiningState pair.

In particular, peers will be able to selectively request only the
specific startup info they're insterested in so that different types of
nodes (such as SPV clients) may only request relevant startup
information.

Compared to the existing MiningState message, the InitState message
already offers a new type of data: tspend hashes, that nodes may use to
fetch tspend transactions for inspecting, generating templates and
voting on their approval.
This modifies the peer package to handle GetInitState/InitState
messages by adding the appropriate listeners. It also bumps the max
supported protocol version to version 8, which is needed to be able to
decode the messages.

Note this modifies the peer package's go.mod to use the local copy of
the wire module in order to have access to the new messages.
This changes the server to support the most recent protocol version (v8
or InitStateVersion).

On this version, instead of using the getminingstate/miningstate pair of
messages, peers use getinitstate/initstate messages which allow for
finer grained control over what information is sent upon startup.

The older protocol versions are still supported so that the node may
continue to both request and serve initial mining state to older nodes
of the network.
@davecgh davecgh merged commit 3fbdfea into decred:master Sep 23, 2020
@matheusd matheusd deleted the initialstatemsg branch November 25, 2020 21:45
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.

None yet

5 participants