-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from starknet-io/matan/consensus
Initial draft of consensus messages.
- Loading branch information
Showing
3 changed files
with
65 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,72 @@ | ||
syntax = "proto3"; | ||
|
||
import "p2p/proto/common.proto"; | ||
import "p2p/proto/header.proto"; | ||
import "p2p/proto/transaction.proto"; | ||
import "p2p/proto/state.proto"; | ||
import "google/protobuf/timestamp.proto"; | ||
|
||
|
||
// WIP - will change | ||
|
||
message Proposal { | ||
uint64 block_number = 1; | ||
uint32 round = 2; | ||
uint32 pol = 3; // proof of lock | ||
Hash block_header_hash = 4; | ||
google protobuf Timestamp timestamp = 5; | ||
ConsensusSignature signature = 6; | ||
} | ||
|
||
// A block proposal is a series of (Transactions+, StateDiff)* BlockHeader | ||
|
||
message Vote { | ||
enum Type { | ||
UNKNOWN = 0; | ||
Proposal = 1; | ||
Prevote = 2; | ||
Precommit = 3; | ||
enum VoteType { | ||
Prevote = 0; | ||
Precommit = 1; | ||
}; | ||
|
||
Proposal proposal = 1; | ||
Address validator_address = 2; | ||
int32 validator_index = 3; // ??? | ||
ConsensusSignature signature = 4; | ||
// We use a type field to distinguish between prevotes and precommits instead of different | ||
// messages, to make sure the data, and therefore the signatures, are unambiguous between | ||
// Prevote and Precommit. | ||
VoteType vote_type = 1; | ||
uint64 block_number = 3; | ||
uint64 fork_id = 4; | ||
uint32 round = 5; | ||
// This is optional since a vote can be NIL. | ||
optional Hash block_hash = 6; | ||
// Identifies the voter. | ||
Address voter = 7; | ||
} | ||
|
||
message ProposalInit { | ||
uint64 block_number = 2; | ||
uint64 fork_id = 3; | ||
uint32 proposal_round = 4; | ||
} | ||
|
||
message CreateBlock { | ||
// Finalize the Tendermint Proposal. When a validator receives this message it will presume that no | ||
// more content for the proposal should be sent. The signature supplied with ProposalFin should be | ||
// for the full Tendermint proposal: | ||
// 1. height | ||
// 2. fork_id | ||
// 3. proposal_round | ||
// 4. valid_round | ||
// 5. block_hash - the validator calculates the block_hash on its own from the content stream and | ||
// confirms the signature with that value. | ||
message ProposalFin { | ||
optional uint32 valid_round = 1; | ||
} | ||
|
||
// The timestamp of a proposal can impact consensus, specifically the lower bound applied. If nodes | ||
// apply a lower bound validation based on their local time, then we risk a scenario where in round | ||
// `R` proposal P is locked. Then in a later round the timestamp in P has gone stale. Therefore the | ||
// lower bound should be "greater than the previous timestamp". Upper bounds don't suffer from this | ||
// problem. | ||
message Proposal { | ||
oneof messages { | ||
Transactions transactions = 1; | ||
StateDiff state_diff = 2; | ||
Proposal proposal = 3; | ||
ProposalInit init = 1; | ||
ProposalFin fin = 2; | ||
// Once block `H` is decided there remains a question; which set of validators receive a | ||
// reward? More specifically, what is the canonical set of precommits for block `H`? Our | ||
// current plan is for the proposer to set the first transaction in `H+1` to be writing the | ||
// list of precommits for `H` to the staking contract in startknet. | ||
Transactions transactions = 3; | ||
BlockProof proof = 4; | ||
} | ||
} | ||
|
||
message ConsensusMessage { | ||
oneof messages { | ||
Vote vote = 1; | ||
Proposal proposal = 2; | ||
} | ||
// Signature by the initial sender (e.g. proposer, voter) of the message. | ||
ConsensusSignature signature = 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters