8000 docs(pbts): forward port of PBTS documentation and fixes by cason · Pull Request #2124 · cometbft/cometbft · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

docs(pbts): forward port of PBTS documentation and fixes #2124

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

Merged
merged 8 commits into from
Jan 31, 2024
17 changes: 10 additions & 7 deletions docs/core/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ The following metrics are available:
| blocksync\_syncing | Gauge | | Either 0 (not block syncing) or 1 (syncing) |
| consensus\_height | Gauge | | Height of the chain |
| consensus\_validators | Gauge | | Number of validators |
| consensus\_validators\_power | Gauge | | Total voting power of all validators |
| consensus\_validator\_power | Gauge | | Voting power of the node if in the validator set |
| consensus\_validator\_last\_signed\_height | Gauge | | Last height the node signed a block, if the node is a validator |
| consensus\_validators\_power | Gauge | validator\_address | Total voting power of all validators |
| consensus\_validator\_power | Gauge | validator\_address | Voting power of the node if in the validator set |
| consensus\_validator\_last\_signed\_height | Gauge | validator\_address | Last height the node signed a block, if the node is a validator |
| consensus\_validator\_missed\_blocks | Gauge | | Total amount of blocks missed for the node, if the node is a validator |
| consensus\_missing\_validators | Gauge | | Number of validators who did not sign |
| consensus\_missing\_validators\_power | Gauge | | Total voting power of the missing validators |
Expand All @@ -39,16 +39,19 @@ The following metrics are available:
| consensus\_block\_parts | Counter | peer\_id | Number of blockparts transmitted by peer |
| consensus\_latest\_block\_height | Gauge | | /status sync\_info number |
| consensus\_block\_size\_bytes | Gauge | | Block size in bytes |
| consensus\_step\_duration | Histogram | step | Histogram of durations for each step in the consensus protocol |
| consensus\_round\_duration | Histogram | | Histogram of durations for all the rounds that have occurred since the process started |
| consensus\_step\_duration\_seconds | Histogram | step | Histogram of durations for each step in the consensus protocol |
| consensus\_round\_duration\_seconds | Histogram | | Histogram of durations for all the rounds that have occurred since the process started |
| consensus\_block\_gossip\_parts\_received | Counter | matches\_current | Number of block parts received by the node |
| consensus\_quorum\_prevote\_delay | Gauge | | Interval in seconds between the proposal timestamp and the timestamp of the earliest prevote that achieved a quorum |
| consensus\_full\_prevote\_delay | Gauge | | Interval in seconds between the proposal timestamp and the timestamp of the latest prevote in a round where all validators voted |
| consensus\_quorum\_prevote\_delay | Gauge | proposer\_address | Interval in seconds between the proposal timestamp and the timestamp of the earliest prevote that achieved a quorum |
| consensus\_full\_prevote\_delay | Gauge | proposer\_address | Interval in seconds between the proposal timestamp and the timestamp of the latest prevote in a round where all validators voted |
| consensus\_vote\_extension\_receive\_count | Counter | status | Number of vote extensions received |
| consensus\_proposal\_receive\_count | Counter | status | Total number of proposals received by the node since process start |
| consensus\_proposal\_create\_count | Counter | | Total number of proposals created by the node since process start |
| consensus\_round\_voting\_power\_percent | Gauge | vote\_type | A value between 0 and 1.0 representing the percentage of the total voting power per vote type received within a round |
| consensus\_late\_votes | Counter | vote\_type | Number of votes received by the node since process start that correspond to earlier heights and rounds than this node is currently in. |
| consensus\_duplicate\_vote | Counter | | Number of times we received a duplicate vote. |
| consensus\_duplicate\_block\_part | Counter | | Number of times we received a duplicate block part. |
| consensus\_proposal\_timestamp\_difference | Histogram | is\_timely | Difference between the timestamp in the proposal message and the local time of the validator at the time it received the message. |
| p2p\_message\_send\_bytes\_total | Counter | message\_type | Number of bytes sent to all peers per message type |
| p2p\_message\_receive\_bytes\_total | Counter | message\_type | Number of bytes received from all peers per message type |
| p2p\_peers | Gauge | | Number of peers node's connected to |
Expand Down
98 changes: 98 additions & 0 deletions docs/core/proposer-based-timestamps.md
8000
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
--- order: 3 ---

# PBTS

This document provides an overview of the Proposer-Based Timestamp (PBTS)
algorithm introduced in CometBFT in the v1.0 release. It outlines the core
functionality as well as the parameters and constraints of the this algorithm.

## Algorithm Overview

The PBTS algorithm defines a way for a blockchain to create block
timestamps that are within a reasonable bound of the clocks of the validators on
the network. This replaces the original BFT Time algorithm for timestamp
assignment that computed a timestamp using the timestamps included in precommit
messages.

## Algorithm Parameters

The functionality of the PBTS algorithm is governed by two parameters.
These two parameters are [consensus parameters][consensus-parameters],
meaning they are configured by the ABCI application and are therefore the
same across all nodes on the network.

### `SynchronyParams.Precision`

The `Precision` parameter configures the acceptable upper-bound of clock drift
among all of the nodes on the network. Any two nodes on the
network are expected to have clocks that differ by at most `Precision`
milliseconds any given instant.

### `SynchronyParams.MessageDelay`

The `MessageDelay` parameter configures the acceptable upper-bound for
transmitting a `Proposal` message from the proposer to _all_ of the validators
on the network.

Networks should choose as small a value for `MessageDelay` as is practical,
provided it is large enough that messages can reach all participants with high
probability given the number of participants and latency of their connections.

## Algorithm Concepts

### Block timestamps

Each block produced by the CometBFT consensus engine contains a timestamp.
The timestamp produced in each block is a meaningful representation of time that is
useful for the protocols and applications built on top of CometBFT.

The following protocols and application features require a reliable source of time:

* Light Clients [rely on correspondence between their known time][light-client-verification] and the block time for block verification.
* Evidence expiration is determined [either in terms of heights or in terms of time][evidence-verification].
* Unbonding of staked assets in the Cosmos Hub [occurs after a period of 21
days](https://github.com/cosmos/governance/blob/master/params-change/Staking.md#unbondingtime).
* IBC packets can use either a [timestamp or a height to timeout packet
delivery](https://ibc.cosmos.network/v8/ibc/light-clients/updates-and-misbehaviour?_highlight=time#checkformisbehaviour).

### Proposer Selects a Block Timestamp

When the proposer node creates a new block proposal, the node reads the time
from its local clock and uses this reading as the timestamp for the proposed
block.

### Timeliness

When each validator on the network receives a proposed block, it
performs a series of checks to ensure that the block can be considered valid as
a candidate to be the next block in the chain.

The PBTS algorithm performs a validity check on the timestamp of proposed
blocks. When a validator receives a proposal it ensures that the timestamp in
the proposal is within a bound of the validator's local clock. Specifically, the
algorithm checks that the timestamp is no more than `Precision` greater than the
node's local clock and no less than `Precision + MessageDelay` behind than the
node's local clock. This creates range of acceptable timestamps around the
node's local time. If the timestamp is within this range, the PBTS algorithm
considers the block **timely**. If a block is not **timely**, the node will
issue a `nil` prevote for this block, signaling to the rest of the network
that the node does not consider the block to be valid.

### Clock Synchronization

The PBTS algorithm requires the clocks of the validators on the network
are within `Precision` of each other. In practice, this means that validators
should periodically synchronize to a reliable NTP server. Validators that drift
too far away from the rest of the network will no longer propose blocks with
valid timestamps. Additionally, they will not view the timestamps of blocks
proposed by their peers to be valid either.
Copy link
Contributor 8000

Choose a reason for hiding this comment

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

With current specification, should add that the network will halt if the drift affects >2/3 nodes, but don't know if we should add it here (for correctness of this document) or just wait for the updates to the spec.


## See Also

* [The PBTS specification][pbts-spec]
contains all of the details of the algorithm.

[pbts-spec]: https://github.com/cometbft/cometbft/blob/main/spec/consensus/proposer-based-timestamp/README.md
[consensus-parameters]: https://github.com/cometbft/cometbft/blob/main/spec/abci/abci%2B%2B_app_requirements.md#consensus-parameters
[light-client-verification]: https://github.com/cometbft/cometbft/blob/main/spec/light-client/verification/README.md#failure-model
[evidence-verification]: https://github.com/cometbft/cometbft/blob/main/spec/consensus/evidence.md#verification
Comment on lines +95 to +98
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we set these with relative paths? This way we don't have to be changing the .../main/... part of the URL at every release.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, because they are on spec/. See: cometbft/cometbft-docs#79

Loading
0