SMIP: spacemeshos/SMIPS#71
Overview
Existing blocks will be replaced by three types of objects: ballots, proposals and blocks.
When a smesher is eligible to vote, they publish a Proposal of transactions to be included in the layer. The Proposal includes a Ballot, where the smesher votes for Blocks from previous layers. A single Block is constructed for each layer from transactions in the set of Proposals which the Hare agreed are valid.
Data Structures
Ballot
The message that includes the smesher's vote for blocks in previous layers.
type Ballot struct {
InnerBallot
Signature []byte
ballotID BallotID
smesherID *signing.PublicKey
}
type InnerBallot struct {
ATXID ATXID
EligibilityProof VotingEligibilityProof
layerID LayerID // private cache, derived from proof
BaseBallot BallotID
AgainstDiff []BlockID
ForDiff []BlockID
NeutralDiff []BlockID
RefBallot *BallotID
ActiveSet []ATXID
TortoiseBeacon []byte
}
type VotingEligibilityProof struct {
J uint32
Sig []byte
}
Proposal
The list of transactions nominated by the smesher for inclusion in the layer's Block. The Ballot is embedded in the Proposal, since they are always published together and the Ballot includes the VotingEligibilityProof required to assert the Proposal's validity.
type Proposal struct {
InnerProposal
Signature []byte
id types.ProposalID
}
type InnerProposal struct {
Ballot
TxIDs []TransactionID
}
type ProposalID Hash20
Block
The object containing the ordered list of rewards and transactions to be applied in a layer.
type Block struct {
LayerID LayerID
Rewards []Reward
TxIDs []TransactionID
blockID BlockID
}
type Reward struct {
Address Address
Amount Amount
}
Methods and Interfaces
All data structures should implement appropriate constructors and accessors, as well as the LoggableField interface.
Proposal and Ballot Publication
We'll keep most of the logic and only change the data structures for now.
Proposal
When a smesher is eligible to vote in a layer they publish a Proposal which has an embedded Ballot. For now, we can keep the existing mechanism for picking transactions from the mempool.
Ballot
The Ballot includes the smesher's vote for Blocks in previous layers. It's based on the existing mechanism - a base block from the previous layer is selected and a diff is added to the vote, mostly for the block in the new layer. As previously, the block an honest smesher votes for in the current layer is determined by the Hare. The difference is that we don't directly vote for the Hare results, but need to do a post-processing stage to compute and persist a unified block, based on the Proposals the Hare agreed on.
Proposal Processing and Block Construction
Unlike current blocks, Proposals are ephemeral. They must be temporarily stored for hdist layers. Once the Hare converges the node should construct and persist a Block and after the hdist window closes - discard the Proposals.
At this point we should use the existing mechanism for selecting and ordering transactions when executing a layer to construct the list of transactions in the Block. This logic is subject to change, though, so if we can isolate it, so it's later easily replaceable---that's a plus.
Ballot Processing
Ballots are the input to the Tortoise. They are processed in the Tortoise like today's blocks.
Implementation Breakdown
As always, we'll start with a series of small (mostly) refactor pull requests that should be worked on for a short time and merged quickly, to minimize conflicts with work in other areas. The goal is to prepare the ground for a later longer pull request on code that has already been isolated, again, minimizing conflicts.
SMIP: spacemeshos/SMIPS#71
Overview
Existing blocks will be replaced by three types of objects: ballots, proposals and blocks.
When a smesher is eligible to vote, they publish a
Proposalof transactions to be included in the layer. TheProposalincludes aBallot, where the smesher votes forBlocks from previous layers. A singleBlockis constructed for each layer from transactions in the set ofProposals which the Hare agreed are valid.Data Structures
Ballot
The message that includes the smesher's vote for blocks in previous layers.
Proposal
The list of transactions nominated by the smesher for inclusion in the layer's
Block. TheBallotis embedded in theProposal, since they are always published together and theBallotincludes theVotingEligibilityProofrequired to assert theProposal's validity.Block
The object containing the ordered list of rewards and transactions to be applied in a layer.
Methods and Interfaces
All data structures should implement appropriate constructors and accessors, as well as the
LoggableFieldinterface.Proposal and Ballot Publication
We'll keep most of the logic and only change the data structures for now.
Proposal
When a smesher is eligible to vote in a layer they publish a
Proposalwhich has an embeddedBallot. For now, we can keep the existing mechanism for picking transactions from the mempool.Ballot
The
Ballotincludes the smesher's vote forBlocksin previous layers. It's based on the existing mechanism - a base block from the previous layer is selected and a diff is added to the vote, mostly for the block in the new layer. As previously, the block an honest smesher votes for in the current layer is determined by the Hare. The difference is that we don't directly vote for the Hare results, but need to do a post-processing stage to compute and persist a unified block, based on theProposals the Hare agreed on.Proposal Processing and Block Construction
Unlike current blocks,
Proposals are ephemeral. They must be temporarily stored forhdistlayers. Once the Hare converges the node should construct and persist aBlockand after thehdistwindow closes - discard theProposals.At this point we should use the existing mechanism for selecting and ordering transactions when executing a layer to construct the list of transactions in the
Block. This logic is subject to change, though, so if we can isolate it, so it's later easily replaceable---that's a plus.Ballot Processing
Ballots are the input to the Tortoise. They are processed in the Tortoise like today's blocks.Implementation Breakdown
As always, we'll start with a series of small (mostly) refactor pull requests that should be worked on for a short time and merged quickly, to minimize conflicts with work in other areas. The goal is to prepare the ground for a later longer pull request on code that has already been isolated, again, minimizing conflicts.
Block→Proposalgo-spacemesh#2902ProposalStoreunder Hare go-spacemesh#2903Proposals from Peers go-spacemesh#2904BallotDBand UseBallotIDfor Referring to Ballots go-spacemesh#2905Blockfrom Hare Output Set go-spacemesh#2906