|
|
@ -86,18 +86,50 @@ Otherwise it should never be modified. |
|
|
|
|
|
|
|
## Transaction Results |
|
|
|
|
|
|
|
`ResponseCheckTx` and `ResponseDeliverTx` contain the same fields, though they |
|
|
|
have slightly different effects. |
|
|
|
`ResponseCheckTx` and `ResponseDeliverTx` contain the same fields. |
|
|
|
|
|
|
|
In both cases, `Info` and `Log` are non-deterministic values for debugging/convenience purposes |
|
|
|
The `Info` and `Log` fields are non-deterministic values for debugging/convenience purposes |
|
|
|
that are otherwise ignored. |
|
|
|
|
|
|
|
In both cases, `GasWanted` and `GasUsed` parameters are currently ignored, |
|
|
|
though see issues |
|
|
|
[#1861](https://github.com/tendermint/tendermint/issues/1861), |
|
|
|
[#2299](https://github.com/tendermint/tendermint/issues/2299) and |
|
|
|
[#2310](https://github.com/tendermint/tendermint/issues/2310) for how this may |
|
|
|
soon change. |
|
|
|
The `Data` field must be strictly deterministic, but can be arbitrary data. |
|
|
|
|
|
|
|
### Gas |
|
|
|
|
|
|
|
Ethereum introduced the notion of `gas` as an absract representation of the |
|
|
|
cost of resources used by nodes when processing transactions. Every operation in the |
|
|
|
Ethereum Virtual Machine uses some amount of gas, and gas can be accepted at a market-variable price. |
|
|
|
Users propose a maximum amount of gas for their transaction; if the tx uses less, they get |
|
|
|
the difference credited back. Tendermint adopts a similar abstraction, |
|
|
|
though uses it only optionally and weakly, allowing applications to define |
|
|
|
their own sense of the cost of execution. |
|
|
|
|
|
|
|
In Tendermint, the `ConsensusParams.BlockSize.MaxGas` limits the amount of `gas` that can be used in a block. |
|
|
|
The default value is `-1`, meaning no limit, or that the concept of gas is |
|
|
|
meaningless. |
|
|
|
|
|
|
|
Responses contain a `GasWanted` and `GasUsed` field. The former is the maximum |
|
|
|
amount of gas the sender of a tx is willing to use, and the later is how much it actually |
|
|
|
used. Applications should enforce that `GasUsed <= GasWanted` - ie. tx execution |
|
|
|
should halt before it can use more resources than it requested. |
|
|
|
|
|
|
|
When `MaxGas > -1`, Tendermint enforces the following rules: |
|
|
|
|
|
|
|
- `GasWanted <= MaxGas` for all txs in the mempool |
|
|
|
- `(sum of GasWanted in a block) <= MaxGas` when proposing a block |
|
|
|
|
|
|
|
If `MaxGas == -1`, no rules about gas are enforced. |
|
|
|
|
|
|
|
Note that Tendermint does not currently enforce anything about Gas in the consensus, only the mempool. |
|
|
|
This means it does not guarantee that committed blocks satisfy these rules! |
|
|
|
It is the application's responsibility to return non-zero response codes when gas limits are exceeded. |
|
|
|
|
|
|
|
The `GasUsed` field is ignored compltely by Tendermint. That said, applications should enforce: |
|
|
|
- `GasUsed <= GasWanted` for any given transaction |
|
|
|
- `(sum of GasUsed in a block) <= MaxGas` for every block |
|
|
|
|
|
|
|
In the future, we intend to add a `Priority` field to the responses that can be |
|
|
|
used to explicitly prioritize txs in the mempool for inclusion in a block |
|
|
|
proposal. See [#1861](https://github.com/tendermint/tendermint/issues/1861). |
|
|
|
|
|
|
|
### CheckTx |
|
|
|
|
|
|
@ -142,9 +174,6 @@ If the list is not empty, Tendermint will use it for the validator set. |
|
|
|
This way the application can determine the initial validator set for the |
|
|
|
blockchain. |
|
|
|
|
|
|
|
ResponseInitChain also includes ConsensusParams, but these are presently |
|
|
|
ignored. |
|
|
|
|
|
|
|
### EndBlock |
|
|
|
|
|
|
|
Updates to the Tendermint validator set can be made by returning |
|
|
@ -179,14 +208,74 @@ following rules: |
|
|
|
|
|
|
|
Note the updates returned in block `H` will only take effect at block `H+2`. |
|
|
|
|
|
|
|
## Consensus Parameters |
|
|
|
|
|
|
|
ConsensusParams enforce certain limits in the blockchain, like the maximum size |
|
|
|
of blocks, amount of gas used in a block, and the maximum acceptable age of |
|
|
|
evidence. They can be set in InitChain and updated in EndBlock. |
|
|
|
|
|
|
|
### BlockSize.MaxBytes |
|
|
|
|
|
|
|
The maximum size of a complete Amino encoded block. |
|
|
|
This is enforced by Tendermint consensus. |
|
|
|
|
|
|
|
This implies a maximum tx size that is this MaxBytes, less the expected size of |
|
|
|
the header, the validator set, and any included evidence in the block. |
|
|
|
|
|
|
|
Must have `0 < MaxBytes < 100 MB`. |
|
|
|
|
|
|
|
### BlockSize.MaxGas |
|
|
|
|
|
|
|
The maximum of the sum of `GasWanted` in a proposed block. |
|
|
|
This is *not* enforced by Tendermint consensus. |
|
|
|
It is left to the app to enforce (ie. if txs are included past the |
|
|
|
limit, they should return non-zero codes). It is used by Tendermint to limit the |
|
|
|
txs included in a proposed block. |
|
|
|
|
|
|
|
Must have `MaxGas >= -1`. |
|
|
|
If `MaxGas == -1`, no limit is enforced. |
|
|
|
|
|
|
|
### EvidenceParams.MaxAge |
|
|
|
|
|
|
|
This is the maximum age of evidence. |
|
|
|
This is enforced by Tendermint consensus. |
|
|
|
If a block includes evidence older than this, the block will be rejected |
|
|
|
(validators won't vote for it). |
|
|
|
|
|
|
|
Must have `0 < MaxAge`. |
|
|
|
|
|
|
|
### Updates |
|
|
|
|
|
|
|
The application may set the consensus params during InitChain, and update them during |
|
|
|
EndBlock. |
|
|
|
|
|
|
|
#### InitChain |
|
|
|
|
|
|
|
ResponseInitChain includes a ConsensusParams. |
|
|
|
If its nil, Tendermint will use the params loaded in the genesis |
|
|
|
file. If it's not nil, Tendermint will use it. |
|
|
|
This way the application can determine the initial consensus params for the |
|
|
|
blockchain. |
|
|
|
|
|
|
|
#### EndBlock |
|
|
|
|
|
|
|
ResponseEndBlock includes a ConsensusParams. |
|
|
|
If its nil, Tendermint will do nothing. |
|
|
|
If it's not nil, Tendermint will use it. |
|
|
|
This way the application can update the consensus params over time. |
|
|
|
|
|
|
|
Note the updates returned in block `H` will take effect right away for block |
|
|
|
`H+1`. |
|
|
|
|
|
|
|
## Query |
|
|
|
|
|
|
|
Query is a generic method with lots of flexibility to enable diverse sets |
|
|
|
of queries on application state. Tendermint makes use of Query to filter new peers |
|
|
|
based on ID and IP, and exposes Query to the user over RPC. |
|
|
|
|
|
|
|
Note that calls to Query are not replicated across nodes, but rather query the |
|
|
|
local node's state - hence they may provide stale reads. For reads that require |
|
|
|
consensus, a transaction is required. |
|
|
|
local node's state - hence they may return stale reads. For reads that require |
|
|
|
consensus, use a transaction. |
|
|
|
|
|
|
|
The most important use of Query is to return Merkle proofs of the application state at some height |
|
|
|
that can be used for efficient application-specific lite-clients. |
|
|
@ -235,6 +324,15 @@ using the following paths, with no additional data: |
|
|
|
If either of these queries return a non-zero ABCI code, Tendermint will refuse |
|
|
|
to connect to the peer. |
|
|
|
|
|
|
|
### Paths |
|
|
|
|
|
|
|
Queries are directed at paths, and may optionally include additional data. |
|
|
|
|
|
|
|
The expectation is for there to be some number of high level paths |
|
|
|
differentiating concerns, like `/p2p`, `/store`, and `/app`. Currently, |
|
|
|
Tendermint only uses `/p2p`, for filtering peers. For more advanced use, see the |
|
|
|
implementation of |
|
|
|
[Query in the Cosmos-SDK](https://github.com/cosmos/cosmos-sdk/blob/v0.23.1/baseapp/baseapp.go#L333). |
|
|
|
|
|
|
|
## Crash Recovery |
|
|
|
|
|
|
|