Browse Source

abci: add AppVersion to ConsensusParams (#106)

pull/7804/head
Anton Kaliaev 5 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.
- `Evidence (EvidenceParams)`: Parameters limiting the validity of
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
@ -631,6 +632,11 @@ via light client.
- `PubKeyTypes ([]string)`: List of accepted pubkey types. Uses same
naming as `PubKey.Type`.
### VersionParams
- **Fields**:
- `AppVersion (uint64)`: The ABCI application version.
### Proof
- **Fields**:


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

@ -67,16 +67,16 @@ Further details on each of these fields is described below.
## Version
The `Version` contains the protocol version for the blockchain and the
application as two `uint64` values:
```go
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
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
```
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
@ -551,18 +551,24 @@ and `ABCIApp` is an ABCI application that can return results and changes to the
set (TODO). Execute is defined as:
```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
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
```go
@ -90,36 +109,41 @@ type ConsensusParams struct {
Block
Evidence
Validator
Version
}
type hashedParams struct {
BlockMaxBytes int64
BlockMaxGas int64
BlockMaxBytes int64
BlockMaxGas int64
}
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 {
MaxBytes int64
MaxGas int64
TimeIotaMs int64
MaxBytes int64
MaxGas int64
TimeIotaMs int64
}
type EvidenceParams struct {
MaxAgeNumBlocks int64
MaxAgeDuration time.Duration
MaxNum uint32
ProofTrialPeriod int64
MaxAgeNumBlocks int64
MaxAgeDuration time.Duration
MaxNum uint32
ProofTrialPeriod int64
}
type ValidatorParams struct {
PubKeyTypes []string
}
type VersionParams struct {
AppVersion uint64
}
```
#### Block


Loading…
Cancel
Save