Browse Source

abci: add AppVersion to ConsensusParams (#106)

pull/7804/head
Anton Kaliaev 4 years ago
committed by GitHub
parent
commit
89922df775
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 71 additions and 35 deletions
  1. +7
    -1
      spec/abci/abci.md
  2. +27
    -21
      spec/blockchain/blockchain.md
  3. +37
    -13
      spec/blockchain/state.md

+ 7
- 1
spec/abci/abci.md View File

@ -596,7 +596,8 @@ via light client.
- `Block (BlockParams)`: Parameters limiting the size of a block and time between consecutive blocks. - `Block (BlockParams)`: Parameters limiting the size of a block and time between consecutive blocks.
- `Evidence (EvidenceParams)`: Parameters limiting the validity of - `Evidence (EvidenceParams)`: Parameters limiting the validity of
evidence of byzantine behaviour. evidence of byzantine behaviour.
- `Validator (ValidatorParams)`: Parameters limitng the types of pubkeys validators can use.
- `Validator (ValidatorParams)`: Parameters limiting the types of pubkeys validators can use.
- `Version (VersionParams)`: The ABCI application version.
### BlockParams ### BlockParams
@ -631,6 +632,11 @@ via light client.
- `PubKeyTypes ([]string)`: List of accepted pubkey types. Uses same - `PubKeyTypes ([]string)`: List of accepted pubkey types. Uses same
naming as `PubKey.Type`. naming as `PubKey.Type`.
### VersionParams
- **Fields**:
- `AppVersion (uint64)`: The ABCI application version.
### Proof ### Proof
- **Fields**: - **Fields**:


+ 27
- 21
spec/blockchain/blockchain.md View File

@ -67,16 +67,16 @@ Further details on each of these fields is described below.
## Version ## Version
The `Version` contains the protocol version for the blockchain and the
application as two `uint64` values:
```go ```go
type Version struct { type Version struct {
Block uint64
App uint64
Block uint64
App uint64
} }
``` ```
The `Version` contains the protocol version for the blockchain and the
application as two `uint64` values.
## BlockID ## BlockID
The `BlockID` contains two distinct Merkle roots of the block. The `BlockID` contains two distinct Merkle roots of the block.
@ -296,11 +296,11 @@ A Header is valid if its corresponding fields are valid.
### Version ### Version
``` ```
block.Version.Block == state.Version.Block
block.Version.App == state.Version.App
block.Version.Block == state.Version.Consensus.Block
block.Version.App == state.Version.Consensus.App
``` ```
The block version must match the state version.
The block version must match consensus version from the state.
### ChainID ### ChainID
@ -551,18 +551,24 @@ and `ABCIApp` is an ABCI application that can return results and changes to the
set (TODO). Execute is defined as: set (TODO). Execute is defined as:
```go ```go
Execute(s State, app ABCIApp, block Block) State {
// Fuction ApplyBlock executes block of transactions against the app and returns the new root hash of the app state,
// modifications to the validator set and the changes of the consensus parameters.
AppHash, ValidatorChanges, ConsensusParamChanges := app.ApplyBlock(block)
return State{
LastResults: abciResponses.DeliverTxResults,
AppHash: AppHash,
LastValidators: state.Validators,
Validators: state.NextValidators,
NextValidators: UpdateValidators(state.NextValidators, ValidatorChanges),
ConsensusParams: UpdateConsensusParams(state.ConsensusParams, ConsensusParamChanges),
}
func Execute(s State, app ABCIApp, block Block) State {
// Fuction ApplyBlock executes block of transactions against the app and returns the new root hash of the app state,
// modifications to the validator set and the changes of the consensus parameters.
AppHash, ValidatorChanges, ConsensusParamChanges := app.ApplyBlock(block)
nextConsensusParams := UpdateConsensusParams(state.ConsensusParams, ConsensusParamChanges)
return State{
LastResults: abciResponses.DeliverTxResults,
AppHash: AppHash,
LastValidators: state.Validators,
Validators: state.NextValidators,
NextValidators: UpdateValidators(state.NextValidators, ValidatorChanges),
ConsensusParams: nextConsensusParams,
Version: {
Consensus: {
AppVersion: nextConsensusParams.Version.AppVersion,
},
},
}
} }
``` ```

+ 37
- 13
spec/blockchain/state.md View File

@ -30,6 +30,25 @@ type State struct {
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.
### Version
```go
type Version struct {
consensus Consensus
software string
}
```
The `Consensus` contains the protocol version for the blockchain and the
application as two `uint64` values:
```go
type Consensus struct {
Block uint64
App uint64
}
```
### Result ### Result
```go ```go
@ -90,36 +109,41 @@ type ConsensusParams struct {
Block Block
Evidence Evidence
Validator Validator
Version
} }
type hashedParams struct { type hashedParams struct {
BlockMaxBytes int64
BlockMaxGas int64
BlockMaxBytes int64
BlockMaxGas int64
} }
func (params ConsensusParams) Hash() []byte { func (params ConsensusParams) Hash() []byte {
SHA256(hashedParams{
BlockMaxBytes: params.Block.MaxBytes,
BlockMaxGas: params.Block.MaxGas,
})
SHA256(hashedParams{
BlockMaxBytes: params.Block.MaxBytes,
BlockMaxGas: params.Block.MaxGas,
})
} }
type BlockParams struct { type BlockParams struct {
MaxBytes int64
MaxGas int64
TimeIotaMs int64
MaxBytes int64
MaxGas int64
TimeIotaMs int64
} }
type EvidenceParams struct { type EvidenceParams struct {
MaxAgeNumBlocks int64
MaxAgeDuration time.Duration
MaxNum uint32
ProofTrialPeriod int64
MaxAgeNumBlocks int64
MaxAgeDuration time.Duration
MaxNum uint32
ProofTrialPeriod int64
} }
type ValidatorParams struct { type ValidatorParams struct {
PubKeyTypes []string PubKeyTypes []string
} }
type VersionParams struct {
AppVersion uint64
}
``` ```
#### Block #### Block


Loading…
Cancel
Save