8000 consensus: proposer-based timestamps (PBTS) · Issue #1731 · cometbft/cometbft · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

consensus: proposer-based timestamps (PBTS) #1731

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

Closed
30 tasks done
Tracked by #578
melekes opened this issue Dec 4, 2023 · 4 comments
Closed
30 tasks done
Tracked by #578

consensus: proposer-based timestamps (PBTS) #1731

melekes opened this issue Dec 4, 2023 · 4 comments
Labels
consensus enhancement New feature or request major-priority A major, long-running priority for the team pbts tracking A complex issue broken down into sub-problems
Milestone

Comments

@melekes
Copy link
Contributor
melekes commented Dec 4, 2023

Feature Request

Summary

Use proposer-based timestamps instead of calculating the median time of vote timestamps.

Detailed description of previous efforts

Context

This collapsed section describes the previous work on the adoption of proposer-based timestamps (PBTS) for the blocks produced in CometBFT networks and points out relevant aspects to be considered when porting this work to the current code base.

Part of the references included in this section are linked in the PBTS project board in the old Tendermint Core repository: Proposer-Based Timestamps Initial Implementation (view).

Rationale

The adoption of proposer-based timestamps (PBTS) was originally proposed in 2018 (tendermint/tendermint#2840, tendermint/tendermint#1615) to replace the BFT Time algorithm (tendermint/tendermint#2013) that is currently used to compute the timestamp of new blocks. In short, the BFT Time algorithm sets as timestamp of a block (stored in its Time field) the voting-power-weighted median of the Precommit vote messages (stored at the block's LastCommit field) that decided the previous block.

The main problems with BFT Time are the following:

The consensus algorithm adopted by CometBFT needs to be adapted for the use of proposer-based timestamps. Throughout 2021, two proposals of changes in the consensus algorithm were specified (tendermint/spec#261 and tendermint/spec#369). In addition, the architectural changes required for the adoption of PBTS were discussed in ADR 071, originally built from the first proposal (tendermint/tendermint#6799), then adapted for the second proposal (tendermint/tendermint#7764).

Spec

At the moment, the PBTS spec on main refers to the first proposal of changes in the consensus algorithm. The second and latest proposal of changes is currently available on master (tendermint/tendermint#8096).

There is some pending work, especially regarding the formal verification of the spec using TLA+ that needs to be retrieved and added to the spec (maybe ported to Quint?), as described in tendermint/tendermint#8953. In particular, the main/pbts branch referred on that issue is not available anymore. A possible source for this content is PR tendermint/tendermint#8600 and the involved authors.

Implementation

The second and latest version of the PBTS specification was implemented on master. This is the branch from which the release branches v0.35.x and v0.36.x were cut and later retracted. As a result, porting the PBTS implementation to main, which includes all changes introduced for releases v0.37.x and v0.38.x may not be a trivial task.

The tracking issue for the PBTS implementation in master is tendermint/tendermint#6942.

The implementation has some changes to the consensus protocol as prerequisites, not necessarily related to PBTS:

Moreover, the validation of block timestamps on a node in recovery mode is a missing aspect of the implementation:

Block Validation in Full Nodes

A further implementation aspect, not discussed in this previous effort, is the backwards compatibility in full nodes. The PBTS implementation has removed the logic adopted by BFT Time algorithm for producing and validating block timestamps (tendermint/tendermint#7382, tendermint/tendermint#7563). We need to adapt blocksync to accept both mechanisms for producing block timestamps.

Documentation and configuration

The adoption of PBTS requires the configuration of synchronous parameters (clock precision and end-to-end delay for proposal messages) employed to determine whether the timestamp of a block is valid (time-validity). The adoption of too restrictive or tight synchronous parameters may hinder liveness, as blocks produced by honest validators could be systematically rejected, and impact performance. For this reason, the introduction of PBTS should be accompanied by a comprehensive documentation of how to choose the synchronous parameters and how to diagnose and solve PBTS-associated issues:

It is worth mentioning that the time-validity of a proposed block is only verified for a limited number of rounds, currently hard-coded to 10 (tendermint/tendermint#7739). This decision was taken in order to ensure consensus liveness under the adoption of inappropriate synchronous parameters. It is worth considering having this limit configurable.

Another possibility to consider is to allow users or the application to disable at all the time-validity checks of a block. This possibility is mentioned in the original issue proposing PBTS (tendermint/tendermint#2840) but has not been implemented.

Experiments

The implementation was tested using the e2e tests and evaluated in small-scale testnets (tendermint/tendermint#7757). This effort has to be extended using the QA infrastructure to test the solution in more realistic testnets (Digital Ocean).

The experimental efforts included the definition of metrics from which to derive safe and realistic values for the synchronous parameters (tendermint/tendermint#7202), adopted as their default values (tendermint/tendermint#7788). Those experiments should be re-evaluated under the light of the new use cases and features introduced from when they were performed.

Teams interested

  1. DyDx
  2. Osmosis
  3. Hub

Execution steps:

Important: all development related to PBTS will be done on feature branch feature/pbts. Which will be merged back to main (via a merge commit) when the team agrees that:

  • the PBTS implementation is complete
  • its quality is good enough to be part of main

Then, we will need to backport the branch onto branch v1.x. But it should not be difficult, as main and v1.x have diverged very little.

Implementation

Upstream Dependencies

Spec

Verification

Documentation

Experiments

Final Steps

@melekes melekes added enhancement New feature or request needs-triage This issue/PR has not yet been triaged by the team. consensus and removed needs-triage This issue/PR has not yet been triaged by the team. labels Dec 4, 2023
@sergio-mena sergio-mena changed the title consensus: proposer-based timestamps consensus: proposer-based timestamps (PBTS) Dec 6, 2023
@cason
Copy link
Contributor
cason commented Jan 3, 2024

I think the first step here is to migrate the new PBTS spec to main. Unfortunately some people, even some partners, interested on this feature are looking at the outdated version of the spec currently on main. This migration should be easy and I can work on it.

@sergio-mena sergio-mena moved this from Todo to In Progress in CometBFT 2023 Jan 9, 2024
@adizere adizere added this to CometBFT Jan 10, 2024
@github-project-automation github-project-automation bot moved this to Todo in CometBFT Jan 10, 2024
@adizere adizere added this to the 2024-Q1 milestone Jan 10, 2024
@cason
Copy link
Contributor
cason commented Jan 10, 2024
* [ ]  Remove https://github.com/cometbft/cometbft/blob/main/spec/consensus/bft-time.md
  
  * adapt any links to that spec elsewhere

We are not fully deprecating BFT Time, so I think this description must be preserved. Maybe updated, maybe merged with PBTS as the two ways of producing timestamps.

@cason cason added the pbts label Jan 11, 2024
@sergio-mena sergio-mena mentioned this issue Jan 11, 2024
31 tasks
@adizere adizere added the major-priority A major, long-running priority for the team label Jan 12, 2024
@adizere adizere moved this from Todo to In Progress in CometBFT Jan 12, 2024
@melekes melekes mentioned this issue Jan 23, 2024
10 tasks
cason added a commit that referenced this issue Jan 24, 2024
Part of #1731.

The original PR precedes tendermint/tendermint#8488, a PR that adopted
`metricsgen` for metric generation. This PR was forward ported to this
repository as in tendermint/tendermint#9178. Some changes were added to
the forward-ported PR to match the behaviour and description of the
added metric with this follow-up change.

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments

---------

Co-authored-by: William Banfield <4561443+williambanfield@users.noreply.github.com>
Co-authored-by: Sergio Mena <sergio@informal.systems>
cason added a commit that referenced this issue Jan 31, 2024
Part of #1731.

Forward ported changes from PRs:

- tendermint/tendermint#8058
- tendermint/tendermint#8129
- tendermint/tendermint#8454

Plus, updated metrics list on `docs/core/metrics.md`, with PBTS and also
other added metrics.

---

#### PR checklist

- [ ] ~Tests written/updated~
- [ ] ~Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)~
- [x] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [x] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: William Banfield <4561443+williambanfield@users.noreply.github.com>
cason added a commit that referenced this issue Feb 12, 2024
ADR 071, from Tendermint Core repository was renamed to ADR 112 and
updated to match the current implementation of PBTS ( #1731).

Rendered [ADR
112](https://github.com/cometbft/cometbft/blob/cason/pbts-adr/docs/references/architecture/adr-112-proposer-based-timestamps.md).

---

Since the file was copied, renamed, then adapted, Git lost track of the
actual changes, that can be manually checked using:

git diff
cason/pbts-adr:docs/architecture/adr-112-proposer-based-timestamps.md
feature/pbts:docs/architecture/tendermint-core/adr-071-proposer-based-timestamps.md

**Important:** there are missing parts in this ADR, that should be
addressed before merging it. It is open for discussion, as it is
expected for an ADR.

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [x] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [x] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: Sergio Mena <sergio@informal.systems>
Co-authored-by: lasaro <lasaro@informal.systems>
@cason cason added the tracking A complex issue broken down into sub-problems label Feb 29, 2024
cason added a commit that referenced this issue Mar 1, 2024
…2489)

Contributes to #1731

---

#### PR checklist

- [x] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [x] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: lasaro <lasaro@informal.systems>
sergio-mena added a commit that referenced this issue Mar 2, 2024
Contributes to #1731

After some troubleshooting, I realized that, for two `// nolint` added
at the beginning of files in #2494, the `gofumpt` and the
`golangci-lint-full` have contradictory rules. So the first one removes
the space between `//` and `nolint` and the second adds it back 🤯. The
problem has been to _find_ this, as, at the end no files where modified
whereas both linters were saying they were modifying some files.

To work around this problem, I changed the way to fix the original lint
issues.

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [ ] Title follows the [Convent
6D47
ional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec
@cason
Copy link
Contributor
cason commented Mar 28, 2024

There are two action points, but referring to the analysis of the impact of Byzantine nodes in the produced timestamps, that were removed from this tracking issue and will be addressed, on demand, as backlog items:

@cason
Copy link
Contributor
cason commented Mar 28, 2024

The implementation of PBTS is completed.

It has landed on main branch (#2541) and it is part of the v1.x release branch (#2545).

Great work, folks :)

@cason cason closed this as completed Mar 28, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in CometBFT Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus enhancement New feature or request major-priority A major, long-running priority for the team pbts tracking A complex issue broken down into sub-problems
Projects
No open projects
Status: Done
Status: In Progress
Development

No branches or pull requests

3 participants
0