Browse Source

add description of arbitrary initial height (#135)

pull/7804/head
Erik Grinaker 4 years ago
committed by GitHub
parent
commit
f3207cee52
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 9 deletions
  1. +3
    -3
      spec/abci/abci.md
  2. +8
    -4
      spec/core/data_structures.md
  3. +8
    -2
      spec/core/state.md

+ 3
- 3
spec/abci/abci.md View File

@ -239,6 +239,7 @@ via light client.
- `ConsensusParams (ConsensusParams)`: Initial consensus-critical parameters. - `ConsensusParams (ConsensusParams)`: Initial consensus-critical parameters.
- `Validators ([]ValidatorUpdate)`: Initial genesis validators, sorted by voting power. - `Validators ([]ValidatorUpdate)`: Initial genesis validators, sorted by voting power.
- `AppStateBytes ([]byte)`: Serialized initial application state. Amino-encoded JSON bytes. - `AppStateBytes ([]byte)`: Serialized initial application state. Amino-encoded JSON bytes.
- `InitialHeight (int64)`: Height of the initial block (typically `1`).
- **Response**: - **Response**:
- `ConsensusParams (ConsensusParams)`: Initial - `ConsensusParams (ConsensusParams)`: Initial
consensus-critical parameters (optional). consensus-critical parameters (optional).
@ -498,9 +499,8 @@ via light client.
- `ChainID (string)`: ID of the blockchain - `ChainID (string)`: ID of the blockchain
- `Height (int64)`: Height of the block in the chain - `Height (int64)`: Height of the block in the chain
- `Time (google.protobuf.Timestamp)`: Time of the previous block. - `Time (google.protobuf.Timestamp)`: Time of the previous block.
For heights > 1, it's the weighted median of the timestamps of the valid
votes in the block.LastCommit.
For height == 1, it's genesis time.
For most blocks it's the weighted median of the timestamps of the valid votes in the
block.LastCommit, except for the initial height where it's the genesis time.
- `LastBlockID (BlockID)`: Hash of the previous (parent) block - `LastBlockID (BlockID)`: Hash of the previous (parent) block
- `LastCommitHash ([]byte)`: Hash of the previous block's commit - `LastCommitHash ([]byte)`: Hash of the previous block's commit
- `ValidatorsHash ([]byte)`: Hash of the validator set for this block - `ValidatorsHash ([]byte)`: Hash of the validator set for this block


+ 8
- 4
spec/core/data_structures.md View File

@ -349,10 +349,11 @@ ChainID must be less than 50 bytes.
```go ```go
block.Header.Height > 0 block.Header.Height > 0
block.Header.Height >= state.InitialHeight
block.Header.Height == prevBlock.Header.Height + 1 block.Header.Height == prevBlock.Header.Height + 1
``` ```
The height is an incrementing integer. The first block has `block.Header.Height == 1`.
The height is an incrementing integer. The first block has `block.Header.Height == state.InitialHeight`, derived from the genesis file.
### Time ### Time
@ -371,7 +372,7 @@ The timestamp of the first block must be equal to the genesis time (since
there's no votes to compute the median). there's no votes to compute the median).
``` ```
if block.Header.Height == 1 {
if block.Header.Height == state.InitialHeight {
block.Header.Timestamp == genesisTime block.Header.Timestamp == genesisTime
} }
``` ```
@ -494,7 +495,7 @@ Arbitrary length array of arbitrary length byte-arrays.
The first height is an exception - it requires the `LastCommit` to be empty: The first height is an exception - it requires the `LastCommit` to be empty:
```go ```go
if block.Header.Height == 1 {
if block.Header.Height == state.InitialHeight {
len(b.LastCommit) == 0 len(b.LastCommit) == 0
} }
``` ```
@ -563,7 +564,7 @@ Once a block is validated, it can be executed against the state.
The state follows this recursive equation: The state follows this recursive equation:
```go ```go
state(1) = InitialState
state(initialHeight) = InitialState
state(h+1) <- Execute(state(h), ABCIApp, block(h)) state(h+1) <- Execute(state(h), ABCIApp, block(h))
``` ```
@ -579,8 +580,11 @@ func Execute(s State, app ABCIApp, block Block) State {
nextConsensusParams := UpdateConsensusParams(state.ConsensusParams, ConsensusParamChanges) nextConsensusParams := UpdateConsensusParams(state.ConsensusParams, ConsensusParamChanges)
return State{ return State{
ChainID: state.ChainID,
InitialHeight: state.InitialHeight,
LastResults: abciResponses.DeliverTxResults, LastResults: abciResponses.DeliverTxResults,
AppHash: AppHash, AppHash: AppHash,
InitialHeight: state.InitialHeight,
LastValidators: state.Validators, LastValidators: state.Validators,
Validators: state.NextValidators, Validators: state.NextValidators,
NextValidators: UpdateValidators(state.NextValidators, ValidatorChanges), NextValidators: UpdateValidators(state.NextValidators, ValidatorChanges),


+ 8
- 2
spec/core/state.md View File

@ -15,18 +15,24 @@ validation.
```go ```go
type State struct { type State struct {
ChainID string
InitialHeight int64
Version Version Version Version
LastResults []Result LastResults []Result
AppHash []byte
AppHash []byte
LastValidators []Validator LastValidators []Validator
Validators []Validator
Validators []Validator
NextValidators []Validator NextValidators []Validator
ConsensusParams ConsensusParams ConsensusParams ConsensusParams
} }
``` ```
The chain ID and initial height are taken from the genesis file, and not changed again. The
initial height will be `1` in the typical case, `0` is an invalid value.
Note there is a hard-coded limit of 10000 validators. This is inherited from the Note there is a hard-coded limit of 10000 validators. This is inherited from the
limit on the number of votes in a commit. limit on the number of votes in a commit.


Loading…
Cancel
Save