From 3197e1ec1dcf0c79c130c335c25f2d751e129de6 Mon Sep 17 00:00:00 2001 From: Wei-Ning Huang Date: Fri, 2 Nov 2018 12:43:39 +0800 Subject: core: vm: governance: remove maxInterval --- .../dexon-consensus/core/consensus.go | 3 ++ .../dexon-consensus/core/lattice-data.go | 22 +++++-------- .../dexon-consensus/core/types/config.go | 6 ---- vendor/vendor.json | 36 +++++++++++----------- 4 files changed, 28 insertions(+), 39 deletions(-) (limited to 'vendor') 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 } diff --git a/vendor/vendor.json b/vendor/vendor.json index 53a5ed354..ba2ff3d10 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -105,50 +105,50 @@ { "checksumSHA1": "ev84RyegNbt2Pr/sK26LK9LoQNI=", "path": "github.com/dexon-foundation/dexon-consensus/common", - "revision": "f521279b0d3d33e072d0dc439288fa16cbbf34d3", - "revisionTime": "2018-11-02T03:41:28Z" + "revision": "117e7b00aeb314e5201a6e82b606385370a86ee4", + "revisionTime": "2018-11-02T05:42:54Z" }, { - "checksumSHA1": "O/LHWlFbdYp+dJDcuUHjIiBGyK4=", + "checksumSHA1": "0r8fTQxyg8QYnU7bvwuRvy1Vme8=", "path": "github.com/dexon-foundation/dexon-consensus/core", - "revision": "f521279b0d3d33e072d0dc439288fa16cbbf34d3", - "revisionTime": "2018-11-02T03:41:28Z" + "revision": "117e7b00aeb314e5201a6e82b606385370a86ee4", + "revisionTime": "2018-11-02T05:42:54Z" }, { "checksumSHA1": "vNsaBvsrXJF+W6K5DCLpgy1rUZY=", "path": "github.com/dexon-foundation/dexon-consensus/core/blockdb", - "revision": "f521279b0d3d33e072d0dc439288fa16cbbf34d3", - "revisionTime": "2018-11-02T03:41:28Z" + "revision": "117e7b00aeb314e5201a6e82b606385370a86ee4", + "revisionTime": "2018-11-02T05:42:54Z" }, { "checksumSHA1": "tQSbYCu5P00lUhKsx3IbBZCuSLY=", "path": "github.com/dexon-foundation/dexon-consensus/core/crypto", - "revision": "f521279b0d3d33e072d0dc439288fa16cbbf34d3", - "revisionTime": "2018-11-02T03:41:28Z" + "revision": "117e7b00aeb314e5201a6e82b606385370a86ee4", + "revisionTime": "2018-11-02T05:42:54Z" }, { "checksumSHA1": "p2jOAulavUU2xyj018pYPHlj8XA=", "path": "github.com/dexon-foundation/dexon-consensus/core/crypto/dkg", - "revision": "f521279b0d3d33e072d0dc439288fa16cbbf34d3", - "revisionTime": "2018-11-02T03:41:28Z" + "revision": "117e7b00aeb314e5201a6e82b606385370a86ee4", + "revisionTime": "2018-11-02T05:42:54Z" }, { "checksumSHA1": "6Pf6caC8LTNCI7IflFmglKYnxYo=", "path": "github.com/dexon-foundation/dexon-consensus/core/crypto/ecdsa", - "revision": "f521279b0d3d33e072d0dc439288fa16cbbf34d3", - "revisionTime": "2018-11-02T03:41:28Z" + "revision": "117e7b00aeb314e5201a6e82b606385370a86ee4", + "revisionTime": "2018-11-02T05:42:54Z" }, { - "checksumSHA1": "h7dAzmB5HttApz3pSlgzNP82TqE=", + "checksumSHA1": "Zxp6rFW4SLz4ZSITYbyrm/5jHDg=", "path": "github.com/dexon-foundation/dexon-consensus/core/types", - "revision": "f521279b0d3d33e072d0dc439288fa16cbbf34d3", - "revisionTime": "2018-11-02T03:41:28Z" + "revision": "117e7b00aeb314e5201a6e82b606385370a86ee4", + "revisionTime": "2018-11-02T05:42:54Z" }, { "checksumSHA1": "ovChyW9OfDGnk/7CDAR+A5vJymc=", "path": "github.com/dexon-foundation/dexon-consensus/core/types/dkg", - "revision": "f521279b0d3d33e072d0dc439288fa16cbbf34d3", - "revisionTime": "2018-11-02T03:41:28Z" + "revision": "117e7b00aeb314e5201a6e82b606385370a86ee4", + "revisionTime": "2018-11-02T05:42:54Z" }, { "checksumSHA1": "TAkwduKZqLyimyTPPWIllZWYFuE=", -- cgit v1.2.3