diff options
Diffstat (limited to 'core')
-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 |
12 files changed, 33 insertions, 33 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, } |