Skip to content

Spec of consensus/gossip protocol#1039

Merged
ebuchman merged 1 commit intodevelopfrom
add_consensus_spec
Dec 31, 2017
Merged

Spec of consensus/gossip protocol#1039
ebuchman merged 1 commit intodevelopfrom
add_consensus_spec

Conversation

@milosevic
Copy link
Contributor

No description provided.


### Heartbeat
Heartbeat contains validator information (address and index),
height, round and sequence number (?). It is signed by the private key of the validator.
Copy link
Contributor

Choose a reason for hiding this comment

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

(?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was wondering what is the sequence field, but it's probably as it says sequence number :)

Copy link
Contributor

@ebuchman ebuchman left a comment

Choose a reason for hiding this comment

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

Great start! Thanks Zarko.

executed steps of the core consensus algorithm (`NewRoundStepMessage` and `CommitStepMessage`), and
also messages that inform peers what votes the process has seen (`HasVoteMessage`,
`VoteSetMaj23Message` and `VoteSetBitsMessage`).

Copy link
Contributor

Choose a reason for hiding this comment

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

These opening paragraphs are wonderful <3

Copy link
Contributor

Choose a reason for hiding this comment

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

Though I might add a note about only proposal/vote being signed, and about how the gossip msgs are used to determine how we send data to other peers

next block in the blockchain should be.
```
type ProposalMessage struct {
Proposal *types.Proposal
Copy link
Contributor

Choose a reason for hiding this comment

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

let's drop all pointers and package names.

The goal with the spec is to lay out the data structures in a way that makes their encoding clear. We don't want the fact that it's a pointer to change the encoding, so it shouldn't be relevant (currently it does matter, but we plan to fix that!)

type Proposal struct {
Height int64
Round int
Timestamp time.Time
Copy link
Contributor

Choose a reason for hiding this comment

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

int64 (thats what its encoded as)

BlockID BlockID
POLRound int
POLBlockID BlockID
Signature crypto.Signature
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's drop the pkg name prefixes. This spec is defining the data structures, not referencing the code, and it all lives in one namespace. I defined Signature in blockchain.md


NOTE: In the current version of the Tendermint, the consensus value in proposal is represented with
PartSetHeader, and with BlockID in vote message. It should be aligned as suggested in this spec as
BlockID contains PartSetHeader.
Copy link
Contributor

Choose a reason for hiding this comment

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

++


```
type Heartbeat struct {
ValidatorAddress data.Bytes
Copy link
Contributor

Choose a reason for hiding this comment

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

[]byte

type NewRoundStepMessage struct {
Height int64
Round int
Step cstypes.RoundStepType
Copy link
Contributor

Choose a reason for hiding this comment

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

lets be clear about the basic type here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean? Should we define RoundStepType?It's somehow implementation detail and can change, so I am not sure if it should be part of spec.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's just give a concrete type - int8

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean we shouldn't use int type? Because we use it in Vote so I thought that's fine.

```
type CommitStepMessage struct {
Height int64
BlockPartsHeader types.PartSetHeader
Copy link
Contributor

Choose a reason for hiding this comment

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

lets make it BlockID ?

type CommitStepMessage struct {
Height int64
BlockPartsHeader types.PartSetHeader
BlockParts *cmn.BitArray
Copy link
Contributor

Choose a reason for hiding this comment

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

Mmm - we need to define BitArray and how it's encoded!

}
```

TODO: Maybe use BlockID instead of BlockPartsHeader for symmetry.
Copy link
Contributor

Choose a reason for hiding this comment

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

++

@milosevic milosevic changed the title WIP: Spec of consensus/gossip protocol Spec of consensus/gossip protocol Dec 30, 2017
@milosevic
Copy link
Contributor Author

milosevic commented Dec 30, 2017

I have tried to address your comments. The encoding part needs to be improved (BitArray and Part), but it's probably easier for someone else to define it (it could be done in different PR). Please take a look if new version is fine so we can merge it @ebuchman @melekes .

@codecov-io
Copy link

codecov-io commented Dec 30, 2017

Codecov Report

Merging #1039 into develop will increase coverage by 0.09%.
The diff coverage is n/a.

@@             Coverage Diff             @@
##           develop    #1039      +/-   ##
===========================================
+ Coverage    59.66%   59.75%   +0.09%     
===========================================
  Files          116      116              
  Lines        10667    10667              
===========================================
+ Hits          6364     6374      +10     
+ Misses        3725     3719       -6     
+ Partials       578      574       -4

# Tendermint Consensus

Tendermint consensus is a distributed protocol executed by validator processes to agree on
the next block to be added to the Tendermint blockchain. The protocol proceeds in rounds, where
Copy link
Contributor

Choose a reason for hiding this comment

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

... to be added to a blockchain.

Theoretically it could be any blockchain. For example, Polkdadot might use Tendermint consensus.

Also, we should be consistent with naming and always call it Tendermint Consensus.

the `ProposalMessage`.
The processes respond by voting for a block with `VoteMessage` (there are two kinds of vote messages, prevote
and precommit votes). Note that a proposal message is just a suggestion what the next block should be; a
validator might vote with a `VoteMessage` for a different block. If in some round, enough number
Copy link
Contributor

Choose a reason for hiding this comment

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

... in some round enough processes vote for the same block, ...

and precommit votes). Note that a proposal message is just a suggestion what the next block should be; a
validator might vote with a `VoteMessage` for a different block. If in some round, enough number
of processes vote for the same block, then this block is committed and later added to the blockchain.
`ProposalMessage` and `VoteMessage` are signed by the private key of the validator.
Copy link
Contributor

Choose a reason for hiding this comment

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

... by the private key of each process. We haven't explained validator before.

@ebuchman ebuchman merged commit 008de93 into develop Dec 31, 2017
@ebuchman ebuchman deleted the add_consensus_spec branch December 31, 2017 19:59
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.

5 participants