diff options
-rw-r--r-- | core/blockchain_test.go | 10 | ||||
-rw-r--r-- | core/consensus.go | 14 | ||||
-rw-r--r-- | core/consensus_test.go | 2 | ||||
-rw-r--r-- | core/round-based-config.go | 2 | ||||
-rw-r--r-- | core/syncer/consensus.go | 2 | ||||
-rw-r--r-- | core/test/state-change-request.go | 8 | ||||
-rw-r--r-- | core/test/state.go | 6 | ||||
-rw-r--r-- | core/test/state_test.go | 6 | ||||
-rw-r--r-- | core/types/config.go | 10 | ||||
-rw-r--r-- | core/types/config_test.go | 2 | ||||
-rw-r--r-- | core/utils/nodeset-cache.go | 2 | ||||
-rw-r--r-- | core/utils/nodeset-cache_test.go | 2 | ||||
-rw-r--r-- | integration_test/byzantine_test.go | 2 | ||||
-rw-r--r-- | integration_test/consensus_test.go | 16 | ||||
-rw-r--r-- | simulation/config/config.go | 4 | ||||
-rw-r--r-- | simulation/config/utils.go | 4 | ||||
-rw-r--r-- | simulation/node.go | 2 |
17 files changed, 47 insertions, 47 deletions
diff --git a/core/blockchain_test.go b/core/blockchain_test.go index 382ccd7..46cb457 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -128,7 +128,7 @@ func (s *BlockChainTestSuite) newRandomnessFromBlock( } func (s *BlockChainTestSuite) newBlockChain(initB *types.Block, - roundInterval uint64) *blockChain { + roundLength uint64) *blockChain { initRound := uint64(0) if initB != nil { initRound = initB.Position.Round @@ -136,7 +136,7 @@ func (s *BlockChainTestSuite) newBlockChain(initB *types.Block, initConfig := blockChainConfig{} initConfig.fromConfig(initRound, &types.Config{ MinBlockInterval: s.blockInterval, - RoundInterval: roundInterval, + RoundLength: roundLength, }) if initB != nil { initConfig.setRoundBeginHeight(initB.Position.Height) @@ -352,11 +352,11 @@ func (s *BlockChainTestSuite) TestConfirmed() { } func (s *BlockChainTestSuite) TestNextBlockAndTipRound() { - var roundInterval uint64 = 3 - bc := s.newBlockChain(nil, roundInterval) + var roundLength uint64 = 3 + bc := s.newBlockChain(nil, roundLength) s.Require().NoError(bc.appendConfig(1, &types.Config{ MinBlockInterval: s.blockInterval, - RoundInterval: roundInterval, + RoundLength: roundLength, })) blocks := s.newBlocks(3, nil) nextH, nextT := bc.nextBlock() diff --git a/core/consensus.go b/core/consensus.go index b3fd312..25fc16d 100644 --- a/core/consensus.go +++ b/core/consensus.go @@ -613,7 +613,7 @@ func (con *Consensus) prepare( time.Sleep(initConfig.MinBlockInterval * 3) con.cfgModule.registerDKG(initRound, getDKGThreshold(initConfig)) con.event.RegisterHeight( - initConfig.RoundInterval/4, + initConfig.RoundLength/4, func(uint64) { con.runDKG(initRound, initConfig) }) @@ -755,7 +755,7 @@ func (con *Consensus) initialRound( // Initiate CRS routine. if _, exist := curDkgSet[con.ID]; exist { con.event.RegisterHeight( - startHeight+config.RoundInterval/2, + startHeight+config.RoundLength/2, func(uint64) { go func() { con.runCRS(round) @@ -777,7 +777,7 @@ func (con *Consensus) initialRound( } } // Initiate BA modules. - con.event.RegisterHeight(startHeight+config.RoundInterval/2, func(uint64) { + con.event.RegisterHeight(startHeight+config.RoundLength/2, func(uint64) { go func(nextRound uint64) { if !checkWithCancel( con.ctx, 500*time.Millisecond, checkCRS(nextRound)) { @@ -798,7 +798,7 @@ func (con *Consensus) initialRound( }(round + 1) }) // Initiate DKG for this round. - con.event.RegisterHeight(startHeight+config.RoundInterval/2, func(uint64) { + con.event.RegisterHeight(startHeight+config.RoundLength/2, func(uint64) { go func(nextRound uint64) { // Normally, gov.CRS would return non-nil. Use this for in case of // unexpected network fluctuation and ensure the robustness. @@ -820,7 +820,7 @@ func (con *Consensus) initialRound( } con.logger.Info("Selected as DKG set", "round", nextRound) con.cfgModule.registerDKG(nextRound, getDKGThreshold(config)) - con.event.RegisterHeight(startHeight+config.RoundInterval*2/3, + con.event.RegisterHeight(startHeight+config.RoundLength*2/3, func(uint64) { func() { con.dkgReady.L.Lock() @@ -834,13 +834,13 @@ func (con *Consensus) initialRound( }(round + 1) }) // Prepare blockChain module for next round and next "initialRound" routine. - con.event.RegisterHeight(startHeight+config.RoundInterval, func(uint64) { + con.event.RegisterHeight(startHeight+config.RoundLength, func(uint64) { // Change round. // Get configuration for next round. nextRound := round + 1 nextConfig := utils.GetConfigWithPanic(con.gov, nextRound, con.logger) con.initialRound( - startHeight+config.RoundInterval, nextRound, nextConfig) + startHeight+config.RoundLength, nextRound, nextConfig) }) } diff --git a/core/consensus_test.go b/core/consensus_test.go index ca619df..1cad67b 100644 --- a/core/consensus_test.go +++ b/core/consensus_test.go @@ -219,7 +219,7 @@ func (s *ConsensusTestSuite) TestDKGCRS() { gov, err := test.NewGovernance(test.NewState( pubKeys, lambda, &common.NullLogger{}, true), ConfigRoundShift) s.Require().NoError(err) - gov.State().RequestChange(test.StateChangeRoundInterval, uint64(200)) + gov.State().RequestChange(test.StateChangeRoundLength, uint64(200)) cons := map[types.NodeID]*Consensus{} dMoment := time.Now().UTC() for _, key := range prvKeys { diff --git a/core/round-based-config.go b/core/round-based-config.go index f2cfc82..4f3a4cb 100644 --- a/core/round-based-config.go +++ b/core/round-based-config.go @@ -33,7 +33,7 @@ type roundBasedConfig struct { func (config *roundBasedConfig) setupRoundBasedFields( roundID uint64, cfg *types.Config) { config.roundID = roundID - config.roundInterval = cfg.RoundInterval + config.roundInterval = cfg.RoundLength } func (config *roundBasedConfig) setRoundBeginHeight(begin uint64) { diff --git a/core/syncer/consensus.go b/core/syncer/consensus.go index 7399373..566b3f4 100644 --- a/core/syncer/consensus.go +++ b/core/syncer/consensus.go @@ -370,7 +370,7 @@ func (con *Consensus) setupConfigsUntilRound(round uint64) { con.configs = append(con.configs, cfg) con.roundBeginHeights = append( con.roundBeginHeights, - con.roundBeginHeights[r-1]+con.configs[r-1].RoundInterval) + con.roundBeginHeights[r-1]+con.configs[r-1].RoundLength) } } diff --git a/core/test/state-change-request.go b/core/test/state-change-request.go index 5b19859..2aea614 100644 --- a/core/test/state-change-request.go +++ b/core/test/state-change-request.go @@ -43,7 +43,7 @@ const ( // Configuration related. StateChangeLambdaBA StateChangeLambdaDKG - StateChangeRoundInterval + StateChangeRoundLength StateChangeMinBlockInterval StateChangeNotarySetSize StateChangeDKGSetSize @@ -69,8 +69,8 @@ func (t StateChangeType) String() string { return "ChangeLambdaBA" case StateChangeLambdaDKG: return "ChangeLambdaDKG" - case StateChangeRoundInterval: - return "ChangeRoundInterval" + case StateChangeRoundLength: + return "ChangeRoundLength" case StateChangeMinBlockInterval: return "ChangeMinBlockInterval" case StateChangeNotarySetSize: @@ -188,7 +188,7 @@ func (req *StateChangeRequest) String() (ret string) { ret += fmt.Sprintf("%v", time.Duration(req.Payload.(uint64))) case StateChangeLambdaDKG: ret += fmt.Sprintf("%v", time.Duration(req.Payload.(uint64))) - case StateChangeRoundInterval: + case StateChangeRoundLength: ret += fmt.Sprintf("%v", time.Duration(req.Payload.(uint64))) case StateChangeMinBlockInterval: ret += fmt.Sprintf("%v", time.Duration(req.Payload.(uint64))) diff --git a/core/test/state.go b/core/test/state.go index 27ff87a..02ee412 100644 --- a/core/test/state.go +++ b/core/test/state.go @@ -170,7 +170,7 @@ func (s *State) Snapshot() (*types.Config, []crypto.PublicKey) { LambdaDKG: s.lambdaDKG, NotarySetSize: s.notarySetSize, DKGSetSize: s.dkgSetSize, - RoundInterval: s.roundInterval, + RoundLength: s.roundInterval, MinBlockInterval: s.minBlockInterval, } s.logger.Info("Snapshot config", "config", cfg) @@ -208,7 +208,7 @@ func (s *State) unpackPayload( var tmp uint64 err = rlp.DecodeBytes(raw.Payload, &tmp) v = tmp - case StateChangeRoundInterval: + case StateChangeRoundLength: var tmp uint64 err = rlp.DecodeBytes(raw.Payload, &tmp) v = tmp @@ -706,7 +706,7 @@ func (s *State) applyRequest(req *StateChangeRequest) error { s.lambdaBA = time.Duration(req.Payload.(uint64)) case StateChangeLambdaDKG: s.lambdaDKG = time.Duration(req.Payload.(uint64)) - case StateChangeRoundInterval: + case StateChangeRoundLength: s.roundInterval = req.Payload.(uint64) case StateChangeMinBlockInterval: s.minBlockInterval = time.Duration(req.Payload.(uint64)) diff --git a/core/test/state_test.go b/core/test/state_test.go index d92a8c1..9a68930 100644 --- a/core/test/state_test.go +++ b/core/test/state_test.go @@ -137,7 +137,7 @@ func (s *StateTestSuite) makeDKGChanges( func (s *StateTestSuite) makeConfigChanges(st *State) { st.RequestChange(StateChangeLambdaBA, time.Nanosecond) st.RequestChange(StateChangeLambdaDKG, time.Millisecond) - st.RequestChange(StateChangeRoundInterval, uint64(1001)) + st.RequestChange(StateChangeRoundLength, uint64(1001)) st.RequestChange(StateChangeMinBlockInterval, time.Second) st.RequestChange(StateChangeNotarySetSize, uint32(5)) st.RequestChange(StateChangeDKGSetSize, uint32(6)) @@ -147,7 +147,7 @@ func (s *StateTestSuite) checkConfigChanges(config *types.Config) { req := s.Require() req.Equal(config.LambdaBA, time.Nanosecond) req.Equal(config.LambdaDKG, time.Millisecond) - req.Equal(config.RoundInterval, uint64(1001)) + req.Equal(config.RoundLength, uint64(1001)) req.Equal(config.MinBlockInterval, time.Second) req.Equal(config.NotarySetSize, uint32(5)) req.Equal(config.DKGSetSize, uint32(6)) @@ -250,7 +250,7 @@ func (s *StateTestSuite) TestLocalMode() { // Check settings of config1 affected by genesisNodes and lambda. req.Equal(config1.LambdaBA, lambda) req.Equal(config1.LambdaDKG, lambda*10) - req.Equal(config1.RoundInterval, uint64(1000)) + req.Equal(config1.RoundLength, uint64(1000)) req.Equal(config1.NotarySetSize, uint32(len(genesisNodes))) req.Equal(config1.DKGSetSize, uint32(len(genesisNodes))) // Request some changes, every fields for config should be affected. diff --git a/core/types/config.go b/core/types/config.go index 56f0175..eda09f0 100644 --- a/core/types/config.go +++ b/core/types/config.go @@ -33,7 +33,7 @@ type Config struct { DKGSetSize uint32 // Time related. - RoundInterval uint64 + RoundLength uint64 MinBlockInterval time.Duration } @@ -44,7 +44,7 @@ func (c *Config) Clone() *Config { LambdaDKG: c.LambdaDKG, NotarySetSize: c.NotarySetSize, DKGSetSize: c.DKGSetSize, - RoundInterval: c.RoundInterval, + RoundLength: c.RoundLength, MinBlockInterval: c.MinBlockInterval, } } @@ -63,8 +63,8 @@ func (c *Config) Bytes() []byte { binaryDKGSetSize := make([]byte, 4) binary.LittleEndian.PutUint32(binaryDKGSetSize, c.DKGSetSize) - binaryRoundInterval := make([]byte, 8) - binary.LittleEndian.PutUint64(binaryRoundInterval, c.RoundInterval) + binaryRoundLength := make([]byte, 8) + binary.LittleEndian.PutUint64(binaryRoundLength, c.RoundLength) binaryMinBlockInterval := make([]byte, 8) binary.LittleEndian.PutUint64(binaryMinBlockInterval, uint64(c.MinBlockInterval.Nanoseconds())) @@ -74,7 +74,7 @@ func (c *Config) Bytes() []byte { enc = append(enc, binaryLambdaDKG...) enc = append(enc, binaryNotarySetSize...) enc = append(enc, binaryDKGSetSize...) - enc = append(enc, binaryRoundInterval...) + enc = append(enc, binaryRoundLength...) enc = append(enc, binaryMinBlockInterval...) return enc } diff --git a/core/types/config_test.go b/core/types/config_test.go index 6029479..ac9ef5e 100644 --- a/core/types/config_test.go +++ b/core/types/config_test.go @@ -34,7 +34,7 @@ func (s *ConfigTestSuite) TestClone() { LambdaDKG: 2 * time.Hour, NotarySetSize: 5, DKGSetSize: 6, - RoundInterval: 1000, + RoundLength: 1000, MinBlockInterval: 7 * time.Nanosecond, } s.Require().Equal(c, c.Clone()) diff --git a/core/utils/nodeset-cache.go b/core/utils/nodeset-cache.go index 3ff5196..0e616e4 100644 --- a/core/utils/nodeset-cache.go +++ b/core/utils/nodeset-cache.go @@ -228,7 +228,7 @@ func (cache *NodeSetCache) update(round uint64) (nIDs *sets, err error) { notarySet: make(map[types.NodeID]struct{}), dkgSet: nodeSet.GetSubSet( int(cfg.DKGSetSize), types.NewDKGSetTarget(crs)), - leaderNode: make(map[uint64]types.NodeID, cfg.RoundInterval), + leaderNode: make(map[uint64]types.NodeID, cfg.RoundLength), } nIDs.notarySet = nodeSet.GetSubSet( int(cfg.NotarySetSize), types.NewNotarySetTarget(crs)) diff --git a/core/utils/nodeset-cache_test.go b/core/utils/nodeset-cache_test.go index 52036b5..6d29b6e 100644 --- a/core/utils/nodeset-cache_test.go +++ b/core/utils/nodeset-cache_test.go @@ -38,7 +38,7 @@ func (g *nsIntf) Configuration(round uint64) (cfg *types.Config) { return &types.Config{ NotarySetSize: 7, DKGSetSize: 7, - RoundInterval: 60, + RoundLength: 60, LambdaBA: 250 * time.Millisecond, MinBlockInterval: 1 * time.Second, } diff --git a/integration_test/byzantine_test.go b/integration_test/byzantine_test.go index 027b6e7..1e5a2a9 100644 --- a/integration_test/byzantine_test.go +++ b/integration_test/byzantine_test.go @@ -144,7 +144,7 @@ func (s *ByzantineTestSuite) TestOneSlowNodeOneDeadNode() { core.ConfigRoundShift) req.NoError(err) req.NoError(seedGov.State().RequestChange( - test.StateChangeRoundInterval, uint64(60))) + test.StateChangeRoundLength, uint64(60))) slowNodeID := types.NewNodeID(pubKeys[0]) deadNodeID := types.NewNodeID(pubKeys[1]) s.directLatencyModel[slowNodeID] = &test.FixedLatencyModel{ diff --git a/integration_test/consensus_test.go b/integration_test/consensus_test.go index b55ceac..b469859 100644 --- a/integration_test/consensus_test.go +++ b/integration_test/consensus_test.go @@ -215,7 +215,7 @@ func (s *ConsensusTestSuite) TestSimple() { core.ConfigRoundShift) req.NoError(err) req.NoError(seedGov.State().RequestChange( - test.StateChangeRoundInterval, uint64(60))) + test.StateChangeRoundLength, uint64(60))) // A short round interval. nodes := s.setupNodes(dMoment, prvKeys, seedGov) for _, n := range nodes { @@ -259,7 +259,7 @@ func (s *ConsensusTestSuite) TestSetSizeChange() { core.ConfigRoundShift) req.NoError(err) req.NoError(seedGov.State().RequestChange( - test.StateChangeRoundInterval, uint64(60))) + test.StateChangeRoundLength, uint64(60))) req.NoError(seedGov.State().RequestChange( test.StateChangeNotarySetSize, uint32(4))) req.NoError(seedGov.State().RequestChange( @@ -267,7 +267,7 @@ func (s *ConsensusTestSuite) TestSetSizeChange() { seedGov.CatchUpWithRound(0) // Setup configuration for round 0 and round 1. req.NoError(seedGov.State().RequestChange( - test.StateChangeRoundInterval, uint64(85))) + test.StateChangeRoundLength, uint64(85))) req.NoError(seedGov.State().RequestChange( test.StateChangeNotarySetSize, uint32(5))) req.NoError(seedGov.State().RequestChange( @@ -275,7 +275,7 @@ func (s *ConsensusTestSuite) TestSetSizeChange() { seedGov.CatchUpWithRound(1) // Setup configuration for round 2. req.NoError(seedGov.State().RequestChange( - test.StateChangeRoundInterval, uint64(85))) + test.StateChangeRoundLength, uint64(85))) req.NoError(seedGov.State().RequestChange( test.StateChangeNotarySetSize, uint32(6))) req.NoError(seedGov.State().RequestChange( @@ -283,7 +283,7 @@ func (s *ConsensusTestSuite) TestSetSizeChange() { seedGov.CatchUpWithRound(2) // Setup configuration for round 3. req.NoError(seedGov.State().RequestChange( - test.StateChangeRoundInterval, uint64(60))) + test.StateChangeRoundLength, uint64(60))) req.NoError(seedGov.State().RequestChange( test.StateChangeNotarySetSize, uint32(4))) req.NoError(seedGov.State().RequestChange( @@ -298,14 +298,14 @@ func (s *ConsensusTestSuite) TestSetSizeChange() { } // Register configuration changes for round 4. req.NoError(pickedNode.gov.RegisterConfigChange( - 4, test.StateChangeRoundInterval, uint64(80))) + 4, test.StateChangeRoundLength, uint64(80))) req.NoError(pickedNode.gov.RegisterConfigChange( 4, test.StateChangeNotarySetSize, uint32(5))) req.NoError(pickedNode.gov.RegisterConfigChange( 4, test.StateChangeDKGSetSize, uint32(5))) // Register configuration changes for round 5. req.NoError(pickedNode.gov.RegisterConfigChange( - 5, test.StateChangeRoundInterval, uint64(60))) + 5, test.StateChangeRoundLength, uint64(60))) req.NoError(pickedNode.gov.RegisterConfigChange( 5, test.StateChangeNotarySetSize, uint32(4))) req.NoError(pickedNode.gov.RegisterConfigChange( @@ -355,7 +355,7 @@ func (s *ConsensusTestSuite) TestSync() { core.ConfigRoundShift) req.NoError(err) req.NoError(seedGov.State().RequestChange( - test.StateChangeRoundInterval, uint64(60))) + test.StateChangeRoundLength, uint64(60))) seedGov.CatchUpWithRound(0) seedGov.CatchUpWithRound(1) // A short round interval. diff --git a/simulation/config/config.go b/simulation/config/config.go index 0ee2109..d47431a 100644 --- a/simulation/config/config.go +++ b/simulation/config/config.go @@ -32,7 +32,7 @@ type Consensus struct { GenesisCRS string `toml:"genesis_crs"` LambdaBA int `toml:"lambda_ba"` LambdaDKG int `toml:"lambda_dkg"` - RoundInterval int + RoundLength int NotarySetSize uint32 DKGSetSize uint32 `toml:"dkg_set_size"` MinBlockInterval int @@ -114,7 +114,7 @@ func GenerateDefault(path string) error { GenesisCRS: "In DEXON we trust.", LambdaBA: 250, LambdaDKG: 1000, - RoundInterval: 1000, + RoundLength: 1000, NotarySetSize: 7, DKGSetSize: 7, MinBlockInterval: 750, diff --git a/simulation/config/utils.go b/simulation/config/utils.go index f8f1eec..6e9024a 100644 --- a/simulation/config/utils.go +++ b/simulation/config/utils.go @@ -32,7 +32,7 @@ func StateChangeTypeFromString(s string) test.StateChangeType { case "lambda_dkg": return test.StateChangeLambdaDKG case "round_interval": - return test.StateChangeRoundInterval + return test.StateChangeRoundLength case "min_block_interval": return test.StateChangeMinBlockInterval case "notary_set_size": @@ -55,7 +55,7 @@ func StateChangeValueFromString( } return uint32(ret) case test.StateChangeLambdaBA, test.StateChangeLambdaDKG, - test.StateChangeRoundInterval, test.StateChangeMinBlockInterval: + test.StateChangeRoundLength, test.StateChangeMinBlockInterval: ret, err := strconv.ParseInt(v, 10, 32) if err != nil { panic(err) diff --git a/simulation/node.go b/simulation/node.go index 7688c25..758f980 100644 --- a/simulation/node.go +++ b/simulation/node.go @@ -211,7 +211,7 @@ func (n *node) prepareConfigs() { cConfig.LambdaBA)*time.Millisecond) // #nosec G104 n.gov.State().RequestChange(test.StateChangeLambdaDKG, time.Duration( cConfig.LambdaDKG)*time.Millisecond) // #nosec G104 - n.gov.State().RequestChange(test.StateChangeRoundInterval, cConfig.RoundInterval) // #nosec G104 + n.gov.State().RequestChange(test.StateChangeRoundLength, cConfig.RoundLength) // #nosec G104 n.gov.State().RequestChange(test.StateChangeMinBlockInterval, time.Duration( cConfig.MinBlockInterval)*time.Millisecond) // #nosec G104 n.gov.State().ProposeCRS(0, crypto.Keccak256Hash([]byte(cConfig.GenesisCRS))) // #nosec G104 |