aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-11-02 12:43:39 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:17 +0800
commitb2e87ed696aed980902308e9210fa33bf9143657 (patch)
tree1d757233e4cfe74df87e031cef55f8808ee662ec
parentfa4a62c777f38a5f03176405a53c3926fcb90a31 (diff)
downloadgo-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
-rw-r--r--core/vm/governance.go32
-rw-r--r--dex/governance.go1
-rw-r--r--params/config.go6
-rw-r--r--params/gen_dexcon_config.go6
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go3
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/lattice-data.go22
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/types/config.go6
-rw-r--r--vendor/vendor.json36
8 files changed, 29 insertions, 83 deletions
diff --git a/core/vm/governance.go b/core/vm/governance.go
index e2948c25b..f940efd14 100644
--- a/core/vm/governance.go
+++ b/core/vm/governance.go
@@ -364,20 +364,6 @@ const abiJSON = `
},
{
"constant": true,
- "inputs": [],
- "name": "maxBlockInterval",
- "outputs": [
- {
- "name": "",
- "type": "uint256"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": true,
"inputs": [
{
"name": "",
@@ -478,10 +464,6 @@ const abiJSON = `
{
"name": "MinBlockInterval",
"type": "uint256"
- },
- {
- "name": "MaxBlockInterval",
- "type": "uint256"
}
],
"name": "updateConfiguration",
@@ -844,12 +826,6 @@ func RunGovernanceContract(evm *EVM, input []byte, contract *Contract) (
return nil, errExecutionReverted
}
return res, nil
- case "maxBlockInterval":
- res, err := method.Outputs.Pack(g.state.MaxBlockInterval())
- if err != nil {
- return nil, errExecutionReverted
- }
- return res, nil
case "minBlockInterval":
res, err := method.Outputs.Pack(g.state.MinBlockInterval())
if err != nil {
@@ -943,7 +919,6 @@ const (
dkgSetSizeLoc
roundIntervalLoc
minBlockIntervalLoc
- maxBlockIntervalLoc
)
// State manipulation helper fro the governance contract.
@@ -1322,11 +1297,6 @@ func (s *GovernanceStateHelper) MinBlockInterval() *big.Int {
return s.getStateBigInt(big.NewInt(minBlockIntervalLoc))
}
-// uint256 public maxBlockInterval;
-func (s *GovernanceStateHelper) MaxBlockInterval() *big.Int {
- return s.getStateBigInt(big.NewInt(maxBlockIntervalLoc))
-}
-
// Stake is a helper function for creating genesis state.
func (s *GovernanceStateHelper) Stake(addr common.Address, publicKey []byte, staked *big.Int) {
offset := s.NodesLength()
@@ -1352,7 +1322,6 @@ func (s *GovernanceStateHelper) Configuration() *params.DexconConfig {
DKGSetSize: uint32(s.getStateBigInt(big.NewInt(dkgSetSizeLoc)).Uint64()),
RoundInterval: s.getStateBigInt(big.NewInt(roundIntervalLoc)).Uint64(),
MinBlockInterval: s.getStateBigInt(big.NewInt(minBlockIntervalLoc)).Uint64(),
- MaxBlockInterval: s.getStateBigInt(big.NewInt(maxBlockIntervalLoc)).Uint64(),
}
}
@@ -1369,7 +1338,6 @@ func (s *GovernanceStateHelper) UpdateConfiguration(cfg *params.DexconConfig) {
s.setStateBigInt(big.NewInt(dkgSetSizeLoc), big.NewInt(int64(cfg.DKGSetSize)))
s.setStateBigInt(big.NewInt(roundIntervalLoc), big.NewInt(int64(cfg.RoundInterval)))
s.setStateBigInt(big.NewInt(minBlockIntervalLoc), big.NewInt(int64(cfg.MinBlockInterval)))
- s.setStateBigInt(big.NewInt(maxBlockIntervalLoc), big.NewInt(int64(cfg.MaxBlockInterval)))
}
// event ConfigurationChanged();
diff --git a/dex/governance.go b/dex/governance.go
index 61dddf0e6..766920a62 100644
--- a/dex/governance.go
+++ b/dex/governance.go
@@ -100,7 +100,6 @@ func (d *DexconGovernance) Configuration(round uint64) *coreTypes.Config {
DKGSetSize: c.DKGSetSize,
RoundInterval: time.Duration(c.RoundInterval) * time.Millisecond,
MinBlockInterval: time.Duration(c.MinBlockInterval) * time.Millisecond,
- MaxBlockInterval: time.Duration(c.MaxBlockInterval) * time.Millisecond,
}
}
diff --git a/params/config.go b/params/config.go
index 11d25f9ef..744be496b 100644
--- a/params/config.go
+++ b/params/config.go
@@ -65,7 +65,6 @@ var (
DKGSetSize: 4,
RoundInterval: 99999999999,
MinBlockInterval: 900,
- MaxBlockInterval: 1100,
},
}
@@ -104,7 +103,6 @@ var (
DKGSetSize: 4,
RoundInterval: 99999999999,
MinBlockInterval: 900,
- MaxBlockInterval: 1100,
},
}
@@ -214,7 +212,6 @@ type DexconConfig struct {
DKGSetSize uint32 `json:"dkgSetSize"`
RoundInterval uint64 `json:"roundInterval"`
MinBlockInterval uint64 `json:"minBlockInterval"`
- MaxBlockInterval uint64 `json:"maxBlockInterval"`
}
type dexconConfigSpecMarshaling struct {
@@ -223,7 +220,7 @@ type dexconConfigSpecMarshaling struct {
// String implements the stringer interface, returning the consensus engine details.
func (d *DexconConfig) String() string {
- return fmt.Sprintf("{GenesisCRSText: %v Owner: %v BlockReward: %v BlockGasLimit: %v NumChains: %v LambdaBA: %v LambdaDKG: %v K: %v PhiRatio: %v NotarySetSize: %v DKGSetSize: %v RoundInterval: %v MinBlockInterval: %v MaxBlockInterval: %v BlockReward: %v",
+ return fmt.Sprintf("{GenesisCRSText: %v Owner: %v BlockReward: %v BlockGasLimit: %v NumChains: %v LambdaBA: %v LambdaDKG: %v K: %v PhiRatio: %v NotarySetSize: %v DKGSetSize: %v RoundInterval: %v MinBlockInterval: %v",
d.GenesisCRSText,
d.Owner,
d.BlockReward,
@@ -237,7 +234,6 @@ func (d *DexconConfig) String() string {
d.DKGSetSize,
d.RoundInterval,
d.MinBlockInterval,
- d.MaxBlockInterval,
)
}
diff --git a/params/gen_dexcon_config.go b/params/gen_dexcon_config.go
index f378b4588..e1be574c0 100644
--- a/params/gen_dexcon_config.go
+++ b/params/gen_dexcon_config.go
@@ -28,7 +28,6 @@ func (d DexconConfig) MarshalJSON() ([]byte, error) {
DKGSetSize uint32 `json:"dkgSetSize"`
RoundInterval uint64 `json:"roundInterval"`
MinBlockInterval uint64 `json:"minBlockInterval"`
- MaxBlockInterval uint64 `json:"maxBlockInterval"`
}
var enc DexconConfig
enc.GenesisCRSText = d.GenesisCRSText
@@ -44,7 +43,6 @@ func (d DexconConfig) MarshalJSON() ([]byte, error) {
enc.DKGSetSize = d.DKGSetSize
enc.RoundInterval = d.RoundInterval
enc.MinBlockInterval = d.MinBlockInterval
- enc.MaxBlockInterval = d.MaxBlockInterval
return json.Marshal(&enc)
}
@@ -64,7 +62,6 @@ func (d *DexconConfig) UnmarshalJSON(input []byte) error {
DKGSetSize *uint32 `json:"dkgSetSize"`
RoundInterval *uint64 `json:"roundInterval"`
MinBlockInterval *uint64 `json:"minBlockInterval"`
- MaxBlockInterval *uint64 `json:"maxBlockInterval"`
}
var dec DexconConfig
if err := json.Unmarshal(input, &dec); err != nil {
@@ -109,8 +106,5 @@ func (d *DexconConfig) UnmarshalJSON(input []byte) error {
if dec.MinBlockInterval != nil {
d.MinBlockInterval = *dec.MinBlockInterval
}
- if dec.MaxBlockInterval != nil {
- d.MaxBlockInterval = *dec.MaxBlockInterval
- }
return nil
}
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 a5b6e6a60..7eec125ec 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=",