Skip to content

Add consensus reactor doc - #1092

Merged
ebuchman merged 1 commit into
developfrom
add-consensus-reactor-doc
Jan 21, 2018
Merged

ebuchman merged 1 commit into
developfrom
add-consensus-reactor-doc

Conversation

@milosevic

Copy link
Copy Markdown
Contributor

This is the first version of several important part of consensus reactor.

@milosevic
milosevic force-pushed the add-consensus-reactor-doc branch from c5bdf2f to bc179c6 Compare January 10, 2018 15:52
@milosevic
milosevic changed the base branch from master to develop January 10, 2018 15:53
@milosevic
milosevic force-pushed the add-consensus-reactor-doc branch from bc179c6 to f9c9fd1 Compare January 10, 2018 15:55
@codecov-io

codecov-io commented Jan 10, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #1092 into develop will decrease coverage by 0.3%.
The diff coverage is n/a.

@@             Coverage Diff             @@
##           develop    #1092      +/-   ##
===========================================
- Coverage    60.22%   59.91%   -0.31%     
===========================================
  Files          118      116       -2     
  Lines        10890    10748     -142     
===========================================
- Hits          6558     6440     -118     
+ Misses        3739     3730       -9     
+ Partials       593      578      -15


## Broadcast routine

The Broadcast routine subscribes to internal event buss to receive new round steps, votes messages and proposal

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

bus

LockedBlock Block
LockedBlockParts PartSet
Votes HeightVoteSet
LastCommit VoteSet

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is LastCommit already part of ProposalBlock?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yes but if we're the proposer we need to get it from somewhere to include in the proposal, so it's here. maybe we can find a better place

if send returns true, record that the peer knows the corresponding block Part
Continue

1b) if (0 < prs.Height) and (prs.Height < rs.Height) then

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What if processes p1 and p4 are at height 5, and are connected over processes p2 and p3 that are at height 3 (p1 -> p2,p3 -> p4). Then p1 can't gossip messages to p4 (and vice versa) before p2 or p3 catch up to height 5. Can this be problem?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's right. Why would it be a problem? So long as they eventually catch up, we can start making progress again.

It is a problem if eg validators are only connected by peers that are always lagging, but that's an issue to be dealt with elsewhere, I would think.

How else could we handle this ?

and the known PeerRoundState (denotes prs). The routine repeats forever the logic shown below:

```
1a) if rs.Height == prs.Height then

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If our peer is lagging behind (it is in smaller round) why we send him messages from his round. Shouldn't we help him to catch up asap to the round where we are? Although we need to be sure that important messages (those with Polkas are being transmitted). Also, does it make sense sending Prevotes for prs.ProposalPOLRound if we are in higher round?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If prs.Step == RoundStepNewHeight, it's actually in a waiting period before starting the new height's first round. During this period, it still wants more straggler votes from the last commit (prs.Height-1), because when it's a proposer, it will want to include as many precommits in the proposal block's "lastCommit" as possible.

(It wants to include more precommits in the proposal block's lastCommit because it gets slightly more block rewards. this is to encourage validators to invest in gossip network robustness. If the peer wants to stop receiving lastCommit precommits, it can signal so via a NewRoundStep message of (H,0,RoundStepNewRound). Some validators may tweak the "timeoutCommit" parameter to try to wait more or less, I suppose. They would be trading off the risk of their proposal not getting out in time, vs the risk of losing out on precommit inclusion rewards.

Sidenote... If say Tendermint V2 allows all proposers to propose simultaneously with some randomness of some sort at height H, round 0, (and each node would only gossip the "most fit" proposal, so this need not hurt the propagation time of the winning proposal too much).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I understand your point about straggler votes and it's valid comment. I was having something different on mind: if we are at round 5 and our peer is at round 3. Should we send him messages from round 3 although we failed to commit at that round (as we are in round 5)? If we are in round 5 this means we received 2f+1 (for simplicity lets assume n = 3f+1) votes from round 4 so we know at least f+1 correct processes also failed to commit at round 3 as they moved to round 4. If we send to the peer messages from round 3 we will need to wait (potentially) significant time before we have all correct processes in the same round, so we can decide and commit a block. With protocols where there is full connectivity between processes, we normally have catchup mechanisms where a process jump to higher round if it sees f+1 messages from higher round. This guarantees that after GST we have bounded (relatively short) time period after which all correct processes are in the same round. It's more tricky to ensure such property with p2p communication as we need to be careful with DDoS attacks.

Send VoteMessage(vote) to the peer
if send returns true, continue

if prs.Step <= RoundStepPrevote and prs.Round != -1 and prs.Round <= rs.Round then

@milosevic milosevic Jan 11, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If we are lagging behind peer (prs.Round > rs.Round), we are not forwarding messages to him before we catch up. Let consider that p1 is in round 5, p2 in round 3 and p3 in round 5 and they are connected like this p1 <-> p2 <-> p3. In this case it might be more beneficial if p1 could send to p2 vote message with round 5 so p2 could catch up to round 5 and then p2 could be able to immediately forward message to p3 as it would be beneficial for p3 to receive this message in a timely fashion.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That makes sense.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

But, we need to be aware of memory issues. See the comment below.

Send VoteMessage(vote) to the peer
if send returns true, continue

if prs.Step <= RoundStepPrecommit and prs.Round != -1 and prs.Round <= rs.Round then

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As we always send Vote from peer current round (even if we are in higher round), we are effectively making catchup path implemented in code impossible. See https://github.com/tendermint/tendermint/blob/develop/consensus/state.go#L1393. Honest node will according to code always send us Vote message only for our current round. Am I misunderstanding something?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's not impossible... If prs.Round == rs.Round, then we will send the peer precommits from our current round, and if this is the next round after GST, that means everyone will be on the same round and completely gossiping all precommits, thus enabling +2/3 any to be shared. Then the next event happens, whether that be a precommit_timeout into the next round, or a commit.

If we share votes that don't match the peer's round, then we need to take care to not "overload" the peer with too much data. For example, imagine what happens if 1% of validators start to prevote for height H, round R where R = 0, 1, 2, 3, 4, 5, ... 10,000,000,000 etc... The peer needs to collect these votes intelligently and also not run out of memory. One way to do that is to penalize a peer for giving me prevotes/precommits from rounds that come after my current round, with the exception of a constant number of rounds, for each peer; This is what we do in our code, and this makes it so that the amount of votes we ever have to keep in memory from future-rounds is on the order of O(P) where P is the number of peers. Other strategies are also possible but I think require further analysis...

We could be trying to send precommits before trying to send prevotes... perhaps we could just check if roundStepPrecommit <= rs.Step and try to send a precommit, otherwise try to send a prevote for our current round.

@milosevic milosevic Jan 13, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You are right, if prs.Round == rs.Round we could receive a message from a higher step, i.e. Precommit message before Prevote as a process haven't received any Prevote message yet. But we can't receive a message from a higher round. I will try to come up with proposal that will provide also this in resource bounded way.

Send VoteMessage(vote) to the peer
if send returns true, continue

1c) if prs.Height != 0 and rs.Height >= prs.Height+2 then

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should we manage catchup logic at one place? Maybe in a separate routine? Right now it appears in several routines. We might also want to have separate channel for catch up messages so we can bound the resources used for that activity as it might be resource intensive.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe. I'm not sure what would be simpler. If we're sending catchup votes, we don't need to send any other votes, so it's also sensible to include it here... we could move the Maj23 routine here maybe?

```

Internally, consensus will run as a state machine with the following states:
RoundStepNewHeight, RoundStepNewRound, RoundStepPropose, RoundStepPropose, RoundStepPrevote,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

RoundStepProposeWait

@xla xla Jan 19, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like RoundStepPropose is twice in the list.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep, it should be RoundStepProposeWait second time.

@milosevic
milosevic force-pushed the add-consensus-reactor-doc branch from bff05e7 to 70b1d80 Compare January 19, 2018 18:52
@milosevic milosevic changed the title WIP: Add consensus reactor doc Add consensus reactor doc Jan 19, 2018
@milosevic
milosevic force-pushed the add-consensus-reactor-doc branch from 70b1d80 to d36e118 Compare January 19, 2018 18:57
@milosevic

Copy link
Copy Markdown
Contributor Author

@ebuchman @melekes This PR is ready to be reviewed for merge. The discussion we had on the PR is taken into account and will be addressed afterward.

@ebuchman
ebuchman merged commit 813bb6a into develop Jan 21, 2018
@ebuchman
ebuchman deleted the add-consensus-reactor-doc branch January 21, 2018 17:40
firelizzard18 pushed a commit to AccumulateNetwork/tendermint that referenced this pull request Feb 1, 2024
* Add first draft

Signed-off-by: Thane Thomson <[email protected]>

* Expand comment on actor receive method

Signed-off-by: Thane Thomson <[email protected]>

* Fix grammar

Signed-off-by: Thane Thomson <[email protected]>

* Emphasize/clarify conclusions

Signed-off-by: Thane Thomson <[email protected]>

---------

Signed-off-by: Thane Thomson <[email protected]>
firelizzard18 pushed a commit to AccumulateNetwork/tendermint that referenced this pull request Feb 1, 2024
…endermint#1010)

* Move senders from txs to txSenders

* Move resCbFirstTime to globalCb

* Fix typo

* Remove callback argument from CheckTx

* Fix lint

* make mocks

* lock isSender

* Change sync.Map for map with lock; add test

* fix lint

* comments

* move senders to reactor and add txsRemoved channel

* Record sender only on valid txs

* fix MConnection panicked

* notifyTxRemoved when removeAllTxs

* Add TxsRemoved and EnableTxsRemoved to interface

* Increase channel buffer size

* forgot emptyMempool

* Change Mempool interface

* Revert "Change Mempool interface"

This reverts commit d3468a12843b11269a180c9f889f1ec79c55b1d3.

* Simplify if/else

* Channel buffer size

* notify txRemoved even when txKey is not in txsMap

* Remove redundant update to map

* add callback for removing txs

* Add tests

* Use Mutex intead of RWMutex

* Fix TestMempoolNoCacheOverflow

* Fix lint

* Fix TestMempoolTxConcurrentWithCommit

* Fix TestReactorConcurrency

* Comment

* Remove references to implemenation details (cache)

* Rename removeTxOnReactor

* Comment

* Rename removeFromCache

* Comment

* Remove test line forgotten in tendermint#934.

* Comment

* revert mempool test size

* ci: Trigger workflows on merge group (tendermint#1118)

Signed-off-by: Thane Thomson <[email protected]>

* Revert "config: add bootstrap peers (tendermint#9680)" (tendermint#1109)

* Revert "config: add bootstrap peers (tendermint#9680)"

This reverts commit f12588a.

* docs/p2p: bootstrap_peers config flag removed

* node: Revert removal of public reactor accessors (tendermint#1120)

* Revert "Remove unused code (tendermint#286)"

This reverts commit a2d9915.

Signed-off-by: Thane Thomson <[email protected]>

* node: Remove access to consensus state

Consensus state should only ever be accessible via the consensus
reactor.

Signed-off-by: Thane Thomson <[email protected]>

* Add changelog entry

Signed-off-by: Thane Thomson <[email protected]>

* Fix mistake in changelog entry

Signed-off-by: Thane Thomson <[email protected]>

---------

Signed-off-by: Thane Thomson <[email protected]>

* ci: Disable CodeQL check in merge queues (tendermint#1123)

Signed-off-by: Thane Thomson <[email protected]>

* p2p: Remove UPnP functionality (tendermint#1114)

* Remove UPnP functionality

Signed-off-by: Thane Thomson <[email protected]>

* Update documentation and specs to reflect UPnP removal

Signed-off-by: Thane Thomson <[email protected]>

* Add changelog entry

Signed-off-by: Thane Thomson <[email protected]>

---------

Signed-off-by: Thane Thomson <[email protected]>

* ADR 107: Rename proto versions to pre-v1 betas (tendermint#1110)

* ADR 107: Rename proto versions to pre-v1 betas

* ADR 107: fix hyperlinks to ADR 103

* ADR 107: authorship of the revision

Co-authored-by: Thane Thomson <[email protected]>

* ADR 107: change status to Accepted

---------

Co-authored-by: Thane Thomson <[email protected]>

* RFC 104: Internal messaging using the actor model (tendermint#1092)

* Add first draft

Signed-off-by: Thane Thomson <[email protected]>

* Expand comment on actor receive method

Signed-off-by: Thane Thomson <[email protected]>

* Fix grammar

Signed-off-by: Thane Thomson <[email protected]>

* Emphasize/clarify conclusions

Signed-off-by: Thane Thomson <[email protected]>

---------

Signed-off-by: Thane Thomson <[email protected]>

* build(deps): Bump github.com/bufbuild/buf from 1.23.1 to 1.24.0 (tendermint#1131)

Bumps [github.com/bufbuild/buf](https://github.com/bufbuild/buf) from 1.23.1 to 1.24.0.
- [Release notes](https://github.com/bufbuild/buf/releases)
- [Changelog](https://github.com/bufbuild/buf/blob/main/CHANGELOG.md)
- [Commits](bufbuild/buf@v1.23.1...v1.24.0)

---
updated-dependencies:
- dependency-name: github.com/bufbuild/buf
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): Bump github.com/vektra/mockery/v2 from 2.31.1 to 2.32.0 (tendermint#1132)

Bumps [github.com/vektra/mockery/v2](https://github.com/vektra/mockery) from 2.31.1 to 2.32.0.
- [Release notes](https://github.com/vektra/mockery/releases)
- [Changelog](https://github.com/vektra/mockery/blob/master/docs/changelog.md)
- [Commits](vektra/mockery@v2.31.1...v2.32.0)

---
updated-dependencies:
- dependency-name: github.com/vektra/mockery/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): Bump docker/setup-buildx-action from 2.9.0 to 2.9.1 (tendermint#1133)

Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 2.9.0 to 2.9.1.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](docker/setup-buildx-action@v2.9.0...v2.9.1)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): Bump bufbuild/buf-setup-action from 1.23.1 to 1.24.0 (tendermint#1134)

Bumps [bufbuild/buf-setup-action](https://github.com/bufbuild/buf-setup-action) from 1.23.1 to 1.24.0.
- [Release notes](https://github.com/bufbuild/buf-setup-action/releases)
- [Commits](bufbuild/buf-setup-action@v1.23.1...v1.24.0)

---
updated-dependencies:
- dependency-name: bufbuild/buf-setup-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* spec: Add mempool specification in English and Quint (tendermint#997)

* add mempool English and Quint specifications

* some changes

* Update spec/mempool/mempool.md

Co-authored-by: Lasaro <[email protected]>

* Update spec/mempool/mempool.md

Co-authored-by: Lasaro <[email protected]>

* small change to the text

* add changelog entry

* some minor fixes

---------

Co-authored-by: Josef Widder <[email protected]>
Co-authored-by: Lasaro <[email protected]>

* Add NewRandomTxs

* Fix TestReactorTxSendersMultiNode

* Fix TestDontExhaustMaxActiveIDs

* Fix unused parameter

* Add changelog

* Update UPGRADING.md

* Remove unused link in doc

---------

Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Thane Thomson <[email protected]>
Co-authored-by: Daniel <[email protected]>
Co-authored-by: Mikhail Zabaluev <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Pierre Sutra <[email protected]>
Co-authored-by: Josef Widder <[email protected]>
Co-authored-by: Lasaro <[email protected]>
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.

6 participants