Skip to content

Commit

Permalink
chore(spec): specify which fields must be deterministic (cometbft#1804)
Browse files Browse the repository at this point in the history
* spec: specify which fields must be deterministic

Closes cometbft#1622

* proto: add comment to `events` field

* spec: align spec for CheckTx Response with implementation

* change No to N/A in methods not involved in SMR

* change No to N/A in Info method as well

* same for snapshot
  • Loading branch information
melekes authored Dec 13, 2023
1 parent c2af320 commit 7c6951f
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 151 deletions.
4 changes: 2 additions & 2 deletions proto/cometbft/abci/v1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ message CheckTxResponse {
repeated Event events = 7 [
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "events,omitempty"
];
]; // nondeterministic
string codespace = 8;

// These reserved fields were used till v0.37 by the priority mempool (now
Expand Down Expand Up @@ -424,7 +424,7 @@ message FinalizeBlockResponse {
repeated Event events = 1 [
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "events,omitempty"
];
]; // nondeterministic
// the result of executing each transaction including the events
// the particular transaction emitted. This should match the order
// of the transactions delivered in the block itself
Expand Down
23 changes: 14 additions & 9 deletions spec/abci/abci++_basic_concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ The state changes caused by processing those
proposed blocks must never replace the previous state until `FinalizeBlock` confirms
that the proposed block was decided and `Commit` is invoked for it.

The same is true to Applications that quickly accept blocks and execute the blocks optimistically in parallel with the remaining consensus steps to save time during `FinalizeBlock`; they must only apply state changes in `Commit`.
The same is true to Applications that quickly accept blocks and execute the
blocks optimistically in parallel with the remaining consensus steps to save
time during `FinalizeBlock`; they must only apply state changes in `Commit`.

Additionally, vote extensions or the validation thereof (via `ExtendVote` or
`VerifyVoteExtension`) must *never* have side effects on the current state.
Expand Down Expand Up @@ -274,11 +276,12 @@ Sources of non-determinism in applications may include:

See [#56](https://github.com/tendermint/abci/issues/56) for the original discussion.

Note that some methods (`Query`, `FinalizeBlock`) return non-deterministic data in the form
of `Info` and `Log` fields. The `Log` is intended for the literal output from the Application's
logger, while the `Info` is any additional info that should be returned. These are the only fields
that are not included in block header computations, so we don't need agreement
on them. All other fields in the `*Response` must be strictly deterministic.
Note that some methods (e.g., `Query` and `FinalizeBlock`) may return
non-deterministic data in the form of `Info`, `Log` and/or `Events` fields. The
`Log` is intended for the literal output from the Application's logger, while
the `Info` is any additional info that should be returned. These fields are not
included in block header computations, so we don't need agreement on them. See
each field's description on whether it must be deterministic or not.

## Events

Expand Down Expand Up @@ -311,9 +314,11 @@ message Event {
}
```

The attributes of an `Event` consist of a `key`, a `value`, and an `index` flag. The
index flag notifies the CometBFT indexer to index the attribute. The value of
the `index` flag is non-deterministic and may vary across different nodes in the network.
The attributes of an `Event` consist of a `key`, a `value`, and an `index`
flag. The index flag notifies the CometBFT indexer to index the attribute.

The `type` and `attributes` fields are non-deterministic and may vary across
different nodes in the network.

```protobuf
message EventAttribute {
Expand Down
Loading

0 comments on commit 7c6951f

Please sign in to comment.