diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-11-02 12:43:39 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:27:17 +0800 |
commit | b2e87ed696aed980902308e9210fa33bf9143657 (patch) | |
tree | 1d757233e4cfe74df87e031cef55f8808ee662ec /vendor/github.com/dexon-foundation/dexon-consensus | |
parent | fa4a62c777f38a5f03176405a53c3926fcb90a31 (diff) | |
download | go-tangerine-b2e87ed696aed980902308e9210fa33bf9143657.tar go-tangerine-b2e87ed696aed980902308e9210fa33bf9143657.tar.gz go-tangerine-b2e87ed696aed980902308e9210fa33bf9143657.tar.bz2 go-tangerine-b2e87ed696aed980902308e9210fa33bf9143657.tar.lz go-tangerine-b2e87ed696aed980902308e9210fa33bf9143657.tar.xz go-tangerine-b2e87ed696aed980902308e9210fa33bf9143657.tar.zst go-tangerine-b2e87ed696aed980902308e9210fa33bf9143657.zip |
core: vm: governance: remove maxInterval
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus')
3 files changed, 10 insertions, 21 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go index 7e6934f45..cec3c4f64 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go @@ -367,6 +367,9 @@ func NewConsensus( } validLeader := func(block *types.Block) bool { + if block.Timestamp.After(time.Now()) { + return false + } return lattice.SanityCheck(block) == nil } diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/lattice-data.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/lattice-data.go index 564675730..ca246612d 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/lattice-data.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/lattice-data.go @@ -73,28 +73,24 @@ type latticeDataConfig struct { // Block interval specifies reasonable time difference between // parent/child blocks. minBlockTimeInterval time.Duration - maxBlockTimeInterval time.Duration } // Initiate latticeDataConfig from types.Config. func (config *latticeDataConfig) fromConfig(roundID uint64, cfg *types.Config) { config.numChains = cfg.NumChains config.minBlockTimeInterval = cfg.MinBlockInterval - config.maxBlockTimeInterval = cfg.MaxBlockInterval config.setupRoundBasedFields(roundID, cfg) } // Check if timestamp of a block is valid according to a reference time. func (config *latticeDataConfig) isValidBlockTime( b *types.Block, ref time.Time) bool { - return !(b.Timestamp.Before(ref.Add(config.minBlockTimeInterval)) || - b.Timestamp.After(ref.Add(config.maxBlockTimeInterval))) + return !b.Timestamp.Before(ref.Add(config.minBlockTimeInterval)) } // isValidGenesisBlockTime check if a timestamp is valid for a genesis block. func (config *latticeDataConfig) isValidGenesisBlockTime(b *types.Block) bool { - return !(b.Timestamp.Before(config.roundBeginTime) || b.Timestamp.After( - config.roundBeginTime.Add(config.maxBlockTimeInterval))) + return !b.Timestamp.Before(config.roundBeginTime) } // newGenesisLatticeDataConfig constructs a latticeDataConfig instance. @@ -380,11 +376,11 @@ func (data *latticeData) addFinalizedBlock( // genesis block. func (data *latticeData) prepareBlock(b *types.Block) error { var ( - minTimestamp, maxTimestamp time.Time - config *latticeDataConfig - acks common.Hashes - bindTip bool - chainTip *types.Block + minTimestamp time.Time + config *latticeDataConfig + acks common.Hashes + bindTip bool + chainTip *types.Block ) if config = data.getConfig(b.Position.Round); config == nil { return ErrUnknownRoundID @@ -425,7 +421,6 @@ func (data *latticeData) prepareBlock(b *types.Block) error { // parent block and bound config. if bindTip { minTimestamp = chainTip.Timestamp.Add(config.minBlockTimeInterval) - maxTimestamp = chainTip.Timestamp.Add(config.maxBlockTimeInterval) // When a chain is removed and added back, the reference block // of previous round can't be used as parent block. b.ParentHash = chainTip.Hash @@ -434,13 +429,10 @@ func (data *latticeData) prepareBlock(b *types.Block) error { // Discontinuous round ID detected, another fresh start of // new round. minTimestamp = config.roundBeginTime - maxTimestamp = config.roundBeginTime.Add(config.maxBlockTimeInterval) } // Fix timestamp if the given one is invalid. if b.Timestamp.Before(minTimestamp) { b.Timestamp = minTimestamp - } else if b.Timestamp.After(maxTimestamp) { - b.Timestamp = maxTimestamp } // Setup acks fields. for _, status := range data.chains { diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/types/config.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/types/config.go index 975eec9cb..c9d31f8c4 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/types/config.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/types/config.go @@ -43,7 +43,6 @@ type Config struct { // Time related. RoundInterval time.Duration MinBlockInterval time.Duration - MaxBlockInterval time.Duration } // Clone return a copied configuration. @@ -58,7 +57,6 @@ func (c *Config) Clone() *Config { DKGSetSize: c.DKGSetSize, RoundInterval: c.RoundInterval, MinBlockInterval: c.MinBlockInterval, - MaxBlockInterval: c.MaxBlockInterval, } } @@ -90,9 +88,6 @@ func (c *Config) Bytes() []byte { binaryMinBlockInterval := make([]byte, 8) binary.LittleEndian.PutUint64(binaryMinBlockInterval, uint64(c.MinBlockInterval.Nanoseconds())) - binaryMaxBlockInterval := make([]byte, 8) - binary.LittleEndian.PutUint64(binaryMaxBlockInterval, - uint64(c.MaxBlockInterval.Nanoseconds())) enc := make([]byte, 0, 40) enc = append(enc, binaryNumChains...) @@ -104,6 +99,5 @@ func (c *Config) Bytes() []byte { enc = append(enc, binaryDKGSetSize...) enc = append(enc, binaryRoundInterval...) enc = append(enc, binaryMinBlockInterval...) - enc = append(enc, binaryMaxBlockInterval...) return enc } |