Skip to content

Commit

Permalink
go/consensus/genesis: Make max evidence age block and time based
Browse files Browse the repository at this point in the history
 * Rename `max_evidence_age` -> `max_evidence_age_blocks`
 * Add `max_evidence_age_time` (default 48h)

This is obviously breaking.
  • Loading branch information
Yawning committed Apr 13, 2020
1 parent fd72a0b commit 1b03f06
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 22 deletions.
6 changes: 6 additions & 0 deletions .changelog/2834.breaking.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
go/consensus/genesis: Make max evidence age block and time based

* Rename `max_evidence_age` -> `max_evidence_age_blocks`
* Add `max_evidence_age_time` (default 48h)

This is obviously breaking.
9 changes: 5 additions & 4 deletions go/consensus/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ type Parameters struct {
SkipTimeoutCommit bool `json:"skip_timeout_commit"`
EmptyBlockInterval time.Duration `json:"empty_block_interval"`

MaxTxSize uint64 `json:"max_tx_size"`
MaxBlockSize uint64 `json:"max_block_size"`
MaxBlockGas transaction.Gas `json:"max_block_gas"`
MaxEvidenceAge uint64 `json:"max_evidence_age"`
MaxTxSize uint64 `json:"max_tx_size"`
MaxBlockSize uint64 `json:"max_block_size"`
MaxBlockGas transaction.Gas `json:"max_block_gas"`
MaxEvidenceAgeBlocks uint64 `json:"max_evidence_age_blocks"`
MaxEvidenceAgeTime time.Duration `json:"max_evidence_age_time"`

// GasCosts are the base transaction gas costs.
GasCosts transaction.Costs `json:"gas_costs,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions go/consensus/tendermint/tendermint.go
Original file line number Diff line number Diff line change
Expand Up @@ -1073,8 +1073,8 @@ func genesisToTendermint(d *genesisAPI.Document) (*tmtypes.GenesisDoc, error) {
TimeIotaMs: 1000,
},
Evidence: tmtypes.EvidenceParams{
MaxAgeNumBlocks: int64(d.Consensus.Parameters.MaxEvidenceAge),
MaxAgeDuration: 48 * time.Hour, // XXX: Change the tm default?
MaxAgeNumBlocks: int64(d.Consensus.Parameters.MaxEvidenceAgeBlocks),
MaxAgeDuration: d.Consensus.Parameters.MaxEvidenceAgeTime,
},
Validator: tmtypes.ValidatorParams{
PubKeyTypes: []string{tmtypes.ABCIPubKeyTypeEd25519},
Expand Down
35 changes: 19 additions & 16 deletions go/oasis-node/cmd/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ const (
cfgRoothashDebugBypassStake = "roothash.debug.bypass_stake" // nolint: gosec

// Tendermint config flags.
cfgConsensusTimeoutCommit = "consensus.tendermint.timeout_commit"
cfgConsensusSkipTimeoutCommit = "consensus.tendermint.skip_timeout_commit"
cfgConsensusEmptyBlockInterval = "consensus.tendermint.empty_block_interval"
cfgConsensusMaxTxSizeBytes = "consensus.tendermint.max_tx_size"
cfgConsensusMaxBlockSizeBytes = "consensus.tendermint.max_block_size"
cfgConsensusMaxBlockGas = "consensus.tendermint.max_block_gas"
cfgConsensusMaxEvidenceAge = "consensus.tendermint.max_evidence_age"
CfgConsensusGasCostsTxByte = "consensus.gas_costs.tx_byte"
cfgConsensusTimeoutCommit = "consensus.tendermint.timeout_commit"
cfgConsensusSkipTimeoutCommit = "consensus.tendermint.skip_timeout_commit"
cfgConsensusEmptyBlockInterval = "consensus.tendermint.empty_block_interval"
cfgConsensusMaxTxSizeBytes = "consensus.tendermint.max_tx_size"
cfgConsensusMaxBlockSizeBytes = "consensus.tendermint.max_block_size"
cfgConsensusMaxBlockGas = "consensus.tendermint.max_block_gas"
cfgConsensusMaxEvidenceAgeBlocks = "consensus.tendermint.max_evidence_age_blocks"
cfgConsensusMaxEvidenceAgeTime = "consensus.tendermint.max_evidence_age_time"
CfgConsensusGasCostsTxByte = "consensus.gas_costs.tx_byte"

// Consensus backend config flag.
cfgConsensusBackend = "consensus.backend"
Expand Down Expand Up @@ -217,13 +218,14 @@ func doInitGenesis(cmd *cobra.Command, args []string) {
doc.Consensus = consensusGenesis.Genesis{
Backend: viper.GetString(cfgConsensusBackend),
Parameters: consensusGenesis.Parameters{
TimeoutCommit: viper.GetDuration(cfgConsensusTimeoutCommit),
SkipTimeoutCommit: viper.GetBool(cfgConsensusSkipTimeoutCommit),
EmptyBlockInterval: viper.GetDuration(cfgConsensusEmptyBlockInterval),
MaxTxSize: uint64(viper.GetSizeInBytes(cfgConsensusMaxTxSizeBytes)),
MaxBlockSize: uint64(viper.GetSizeInBytes(cfgConsensusMaxBlockSizeBytes)),
MaxBlockGas: transaction.Gas(viper.GetUint64(cfgConsensusMaxBlockGas)),
MaxEvidenceAge: viper.GetUint64(cfgConsensusMaxEvidenceAge),
TimeoutCommit: viper.GetDuration(cfgConsensusTimeoutCommit),
SkipTimeoutCommit: viper.GetBool(cfgConsensusSkipTimeoutCommit),
EmptyBlockInterval: viper.GetDuration(cfgConsensusEmptyBlockInterval),
MaxTxSize: uint64(viper.GetSizeInBytes(cfgConsensusMaxTxSizeBytes)),
MaxBlockSize: uint64(viper.GetSizeInBytes(cfgConsensusMaxBlockSizeBytes)),
MaxBlockGas: transaction.Gas(viper.GetUint64(cfgConsensusMaxBlockGas)),
MaxEvidenceAgeBlocks: viper.GetUint64(cfgConsensusMaxEvidenceAgeBlocks),
MaxEvidenceAgeTime: viper.GetDuration(cfgConsensusMaxEvidenceAgeTime),
GasCosts: transaction.Costs{
consensusGenesis.GasOpTxByte: transaction.Gas(viper.GetUint64(CfgConsensusGasCostsTxByte)),
},
Expand Down Expand Up @@ -723,7 +725,8 @@ func init() {
initGenesisFlags.String(cfgConsensusMaxTxSizeBytes, "32kb", "tendermint maximum transaction size (in bytes)")
initGenesisFlags.String(cfgConsensusMaxBlockSizeBytes, "21mb", "tendermint maximum block size (in bytes)")
initGenesisFlags.Uint64(cfgConsensusMaxBlockGas, 0, "tendermint max gas used per block")
initGenesisFlags.Uint64(cfgConsensusMaxEvidenceAge, 100000, "tendermint max evidence age (in blocks)")
initGenesisFlags.Uint64(cfgConsensusMaxEvidenceAgeBlocks, 100000, "tendermint max evidence age (in blocks)")
initGenesisFlags.Duration(cfgConsensusMaxEvidenceAgeTime, 48*time.Hour, "tendermint max evidence age (in time)")
initGenesisFlags.Uint64(CfgConsensusGasCostsTxByte, 1, "consensus gas costs: each transaction byte")

// Consensus backend flag.
Expand Down

0 comments on commit 1b03f06

Please sign in to comment.