From 69c03b7191a0a9b17c3bf07f7aed5e717c1e1d06 Mon Sep 17 00:00:00 2001 From: dustinxie Date: Fri, 25 Oct 2019 15:18:25 -0700 Subject: [PATCH] rename Hudson to Dardanelles (#1571) --- action/protocol/rolldpos/epoch.go | 38 ++++++++++---------- blockchain/blockchain.go | 12 +++---- blockchain/genesis/genesis.go | 46 ++++++++++++------------- chainservice/chainservice.go | 2 +- config/config.go | 18 +++++----- config/heightupgrade.go | 22 ++++++------ consensus/consensusfsm/consensus_ttl.go | 32 ++++++++--------- 7 files changed, 85 insertions(+), 85 deletions(-) diff --git a/action/protocol/rolldpos/epoch.go b/action/protocol/rolldpos/epoch.go index 2d3fecf1fd..edd27718e7 100644 --- a/action/protocol/rolldpos/epoch.go +++ b/action/protocol/rolldpos/epoch.go @@ -19,23 +19,23 @@ const ProtocolID = "rolldpos" // Protocol defines an epoch protocol type Protocol struct { - numCandidateDelegates uint64 - numDelegates uint64 - numSubEpochs uint64 - numSubEpochsHudson uint64 - hudsonHeight uint64 - hudsonOn bool + numCandidateDelegates uint64 + numDelegates uint64 + numSubEpochs uint64 + numSubEpochsDardanelles uint64 + dardanellesHeight uint64 + dardanellesOn bool } // Option is optional setting for epoch protocol type Option func(*Protocol) error -// EnableHudsonSubEpoch will set give numSubEpochs at give height. -func EnableHudsonSubEpoch(height, numSubEpochs uint64) Option { +// EnableDardanellesSubEpoch will set give numSubEpochs at give height. +func EnableDardanellesSubEpoch(height, numSubEpochs uint64) Option { return func(p *Protocol) error { - p.hudsonOn = true - p.numSubEpochsHudson = numSubEpochs - p.hudsonHeight = height + p.dardanellesOn = true + p.numSubEpochsDardanelles = numSubEpochs + p.dardanellesHeight = height return nil } } @@ -88,12 +88,12 @@ func (p *Protocol) GetEpochNum(height uint64) uint64 { if height == 0 { return 0 } - if !p.hudsonOn || height <= p.hudsonHeight { + if !p.dardanellesOn || height <= p.dardanellesHeight { return (height-1)/p.numDelegates/p.numSubEpochs + 1 } - hudsonEpoch := p.GetEpochNum(p.hudsonHeight) - hudsonEpochHeight := p.GetEpochHeight(hudsonEpoch) - return hudsonEpoch + (height-hudsonEpochHeight)/p.numDelegates/p.numSubEpochsHudson + dardanellesEpoch := p.GetEpochNum(p.dardanellesHeight) + dardanellesEpochHeight := p.GetEpochHeight(dardanellesEpoch) + return dardanellesEpoch + (height-dardanellesEpochHeight)/p.numDelegates/p.numSubEpochsDardanelles } // GetEpochHeight returns the start height of an epoch @@ -101,12 +101,12 @@ func (p *Protocol) GetEpochHeight(epochNum uint64) uint64 { if epochNum == 0 { return 0 } - hudsonEpoch := p.GetEpochNum(p.hudsonHeight) - if !p.hudsonOn || epochNum <= hudsonEpoch { + dardanellesEpoch := p.GetEpochNum(p.dardanellesHeight) + if !p.dardanellesOn || epochNum <= dardanellesEpoch { return (epochNum-1)*p.numDelegates*p.numSubEpochs + 1 } - hudsonEpochHeight := p.GetEpochHeight(hudsonEpoch) - return hudsonEpochHeight + (epochNum-hudsonEpoch)*p.numDelegates*p.numSubEpochsHudson + dardanellesEpochHeight := p.GetEpochHeight(dardanellesEpoch) + return dardanellesEpochHeight + (epochNum-dardanellesEpoch)*p.numDelegates*p.numSubEpochsDardanelles } // GetEpochLastBlockHeight returns the last height of an epoch diff --git a/blockchain/blockchain.go b/blockchain/blockchain.go index 51442f95af..a257231bbf 100644 --- a/blockchain/blockchain.go +++ b/blockchain/blockchain.go @@ -634,8 +634,8 @@ func (bc *blockchain) MintNewBlock( } } - if newblockHeight == bc.config.Genesis.HudsonBlockHeight { - if err := bc.updateHudsonBlockRewardAmount(ctx, ws); err != nil { + if newblockHeight == bc.config.Genesis.DardanellesBlockHeight { + if err := bc.updateDardanellesBlockRewardAmount(ctx, ws); err != nil { return nil, err } } @@ -1093,8 +1093,8 @@ func (bc *blockchain) runActions( } } - if acts.BlockHeight() == bc.config.Genesis.HudsonBlockHeight { - if err := bc.updateHudsonBlockRewardAmount(ctx, ws); err != nil { + if acts.BlockHeight() == bc.config.Genesis.DardanellesBlockHeight { + if err := bc.updateDardanellesBlockRewardAmount(ctx, ws); err != nil { return nil, err } } @@ -1493,7 +1493,7 @@ func (bc *blockchain) updateAleutianEpochRewardAmount(ctx context.Context, ws fa return rp.SetReward(ctx, ws, bc.config.Genesis.AleutianEpochReward(), false) } -func (bc *blockchain) updateHudsonBlockRewardAmount(ctx context.Context, ws factory.WorkingSet) error { +func (bc *blockchain) updateDardanellesBlockRewardAmount(ctx context.Context, ws factory.WorkingSet) error { p, ok := bc.registry.Find(rewarding.ProtocolID) if !ok { return nil @@ -1502,7 +1502,7 @@ func (bc *blockchain) updateHudsonBlockRewardAmount(ctx context.Context, ws fact if !ok { return errors.Errorf("error when casting protocol") } - return rp.SetReward(ctx, ws, bc.config.Genesis.HudsonBlockReward(), true) + return rp.SetReward(ctx, ws, bc.config.Genesis.DardanellesBlockReward(), true) } func calculateReceiptRoot(receipts []*action.Receipt) hash.Hash256 { diff --git a/blockchain/genesis/genesis.go b/blockchain/genesis/genesis.go index 9b67c3ab36..61bfa50be8 100644 --- a/blockchain/genesis/genesis.go +++ b/blockchain/genesis/genesis.go @@ -39,19 +39,19 @@ func init() { func defaultConfig() Genesis { return Genesis{ Blockchain: Blockchain{ - Timestamp: 1546329600, - BlockGasLimit: 20000000, - ActionGasLimit: 5000000, - BlockInterval: 10 * time.Second, - NumSubEpochs: 2, - NumDelegates: 24, - NumCandidateDelegates: 36, - TimeBasedRotation: false, - PacificBlockHeight: 432001, - AleutianBlockHeight: 864001, - BeringBlockHeight: 1512001, - CookBlockHeight: 1641601, - HudsonBlockHeight: 1855201, + Timestamp: 1546329600, + BlockGasLimit: 20000000, + ActionGasLimit: 5000000, + BlockInterval: 10 * time.Second, + NumSubEpochs: 2, + NumDelegates: 24, + NumCandidateDelegates: 36, + TimeBasedRotation: false, + PacificBlockHeight: 432001, + AleutianBlockHeight: 864001, + BeringBlockHeight: 1512001, + CookBlockHeight: 1641601, + DardanellesBlockHeight: 1855201, }, Account: Account{ InitBalanceMap: make(map[string]string), @@ -62,7 +62,7 @@ func defaultConfig() Genesis { Rewarding: Rewarding{ InitBalanceStr: unit.ConvertIotxToRau(200000000).String(), BlockRewardStr: unit.ConvertIotxToRau(16).String(), - HudsonBlockRewardStr: unit.ConvertIotxToRau(8).String(), + DardanellesBlockRewardStr: unit.ConvertIotxToRau(8).String(), EpochRewardStr: unit.ConvertIotxToRau(12500).String(), AleutianEpochRewardStr: unit.ConvertIotxToRau(18750).String(), NumDelegatesForEpochReward: 100, @@ -112,8 +112,8 @@ type ( BlockInterval time.Duration `yaml:"blockInterval"` // NumSubEpochs is the number of sub epochs in one epoch of block production NumSubEpochs uint64 `yaml:"numSubEpochs"` - // HudsonNumSubEpochs is the number of sub epochs starts from hudson height in one epoch of block production - HudsonNumSubEpochs uint64 `yaml:"hudsonNumSubEpochs"` + // DardanellesNumSubEpochs is the number of sub epochs starts from dardanelles height in one epoch of block production + DardanellesNumSubEpochs uint64 `yaml:"dardanellesNumSubEpochs"` // NumDelegates is the number of delegates that participate into one epoch of block production NumDelegates uint64 `yaml:"numDelegates"` // NumCandidateDelegates is the number of candidate delegates, who may be selected as a delegate via roll dpos @@ -129,8 +129,8 @@ type ( BeringBlockHeight uint64 `yaml:"beringHeight"` // CookBlockHeight is the start height of native staking CookBlockHeight uint64 `yaml:"cookHeight"` - // HudsonBlockHeight is the start height of 5s block internal - HudsonBlockHeight uint64 `yaml:"hudsonHeight"` + // DardanellesBlockHeight is the start height of 5s block internal + DardanellesBlockHeight uint64 `yaml:"dardanellesHeight"` } // Account contains the configs for account protocol Account struct { @@ -177,8 +177,8 @@ type ( InitBalanceStr string `yaml:"initBalance"` // BlockReward is the block reward amount in decimal string format BlockRewardStr string `yaml:"blockReward"` - // HudsonBlockReward is the block reward amount starts from hudson height in decimal string format - HudsonBlockRewardStr string `yaml:"hudsonBlockReward"` + // DardanellesBlockReward is the block reward amount starts from dardanelles height in decimal string format + DardanellesBlockRewardStr string `yaml:"dardanellesBlockReward"` // EpochReward is the epoch reward amount in decimal string format EpochRewardStr string `yaml:"epochReward"` // AleutianEpochRewardStr is the epoch reward amount in decimal string format after aleutian fork @@ -384,9 +384,9 @@ func (r *Rewarding) AleutianEpochReward() *big.Int { return val } -// HudsonBlockReward returns the block reward amount after hudson fork -func (r *Rewarding) HudsonBlockReward() *big.Int { - val, ok := big.NewInt(0).SetString(r.HudsonBlockRewardStr, 10) +// DardanellesBlockReward returns the block reward amount after dardanelles fork +func (r *Rewarding) DardanellesBlockReward() *big.Int { + val, ok := big.NewInt(0).SetString(r.DardanellesBlockRewardStr, 10) if !ok { log.S().Panicf("Error when casting block reward string %s into big int", r.EpochRewardStr) } diff --git a/chainservice/chainservice.go b/chainservice/chainservice.go index 407251cd4c..9620ac2345 100644 --- a/chainservice/chainservice.go +++ b/chainservice/chainservice.go @@ -156,7 +156,7 @@ func New( cfg.Genesis.NumCandidateDelegates, cfg.Genesis.NumDelegates, cfg.Genesis.NumSubEpochs, - rolldpos.EnableHudsonSubEpoch(cfg.Genesis.HudsonBlockHeight, cfg.Genesis.HudsonNumSubEpochs), + rolldpos.EnableDardanellesSubEpoch(cfg.Genesis.DardanellesBlockHeight, cfg.Genesis.DardanellesNumSubEpochs), ) copts := []consensus.Option{ consensus.WithBroadcast(func(msg proto.Message) error { diff --git a/config/config.go b/config/config.go index 7d2d622e6d..50b0611754 100644 --- a/config/config.go +++ b/config/config.go @@ -72,16 +72,16 @@ func (ss *strs) Set(str string) error { return nil } -// Hudson consensus config +// Dardanelles consensus config const ( - HudsonUnmatchedEventTTL = 2 * time.Second - HudsonUnmatchedEventInterval = 100 * time.Millisecond - HudsonAcceptBlockTTL = 2 * time.Second - HudsonAcceptProposalEndorsementTTL = time.Second - HudsonAcceptLockEndorsementTTL = time.Second - HudsonCommitTTL = time.Second - HudsonBlockInterval = 5 * time.Second - HudsonDelay = 2 * time.Second + DardanellesUnmatchedEventTTL = 2 * time.Second + DardanellesUnmatchedEventInterval = 100 * time.Millisecond + DardanellesAcceptBlockTTL = 2 * time.Second + DardanellesAcceptProposalEndorsementTTL = time.Second + DardanellesAcceptLockEndorsementTTL = time.Second + DardanellesCommitTTL = time.Second + DardanellesBlockInterval = 5 * time.Second + DardanellesDelay = 2 * time.Second ) var ( diff --git a/config/heightupgrade.go b/config/heightupgrade.go index ed336cdfa2..eeca7cca7d 100644 --- a/config/heightupgrade.go +++ b/config/heightupgrade.go @@ -16,7 +16,7 @@ const ( Aleutian Bering Cook - Hudson + Dardanelles ) type ( @@ -25,11 +25,11 @@ type ( // HeightUpgrade lists heights at which certain fixes take effect HeightUpgrade struct { - pacificHeight uint64 - aleutianHeight uint64 - beringHeight uint64 - cookHeight uint64 - hudsonHeight uint64 + pacificHeight uint64 + aleutianHeight uint64 + beringHeight uint64 + cookHeight uint64 + dardanellesHeight uint64 } ) @@ -40,7 +40,7 @@ func NewHeightUpgrade(cfg Config) HeightUpgrade { cfg.Genesis.AleutianBlockHeight, cfg.Genesis.BeringBlockHeight, cfg.Genesis.CookBlockHeight, - cfg.Genesis.HudsonBlockHeight, + cfg.Genesis.DardanellesBlockHeight, } } @@ -56,8 +56,8 @@ func (hu *HeightUpgrade) IsPost(name HeightName, height uint64) bool { h = hu.beringHeight case Cook: h = hu.cookHeight - case Hudson: - h = hu.hudsonHeight + case Dardanelles: + h = hu.dardanellesHeight default: log.Panic("invalid height name!") } @@ -81,5 +81,5 @@ func (hu *HeightUpgrade) BeringBlockHeight() uint64 { return hu.beringHeight } // CookBlockHeight returns the cook height func (hu *HeightUpgrade) CookBlockHeight() uint64 { return hu.cookHeight } -// HudsonBlockHeight returns the hudson height -func (hu *HeightUpgrade) HudsonBlockHeight() uint64 { return hu.hudsonHeight } +// DardanellesBlockHeight returns the dardanelles height +func (hu *HeightUpgrade) DardanellesBlockHeight() uint64 { return hu.dardanellesHeight } diff --git a/consensus/consensusfsm/consensus_ttl.go b/consensus/consensusfsm/consensus_ttl.go index 2a8c19da39..3e28e1ca33 100644 --- a/consensus/consensusfsm/consensus_ttl.go +++ b/consensus/consensusfsm/consensus_ttl.go @@ -50,57 +50,57 @@ func (c *consensusCfg) EventChanSize() uint { } func (c *consensusCfg) UnmatchedEventTTL(height uint64) time.Duration { - if c.hu.IsPost(config.Hudson, height) { - return config.HudsonUnmatchedEventTTL + if c.hu.IsPost(config.Dardanelles, height) { + return config.DardanellesUnmatchedEventTTL } return c.cfg.UnmatchedEventTTL } func (c *consensusCfg) UnmatchedEventInterval(height uint64) time.Duration { - if c.hu.IsPost(config.Hudson, height) { - return config.HudsonUnmatchedEventInterval + if c.hu.IsPost(config.Dardanelles, height) { + return config.DardanellesUnmatchedEventInterval } return c.cfg.UnmatchedEventInterval } func (c *consensusCfg) AcceptBlockTTL(height uint64) time.Duration { - if c.hu.IsPost(config.Hudson, height) { - return config.HudsonAcceptBlockTTL + if c.hu.IsPost(config.Dardanelles, height) { + return config.DardanellesAcceptBlockTTL } return c.cfg.AcceptBlockTTL } func (c *consensusCfg) AcceptProposalEndorsementTTL(height uint64) time.Duration { - if c.hu.IsPost(config.Hudson, height) { - return config.HudsonAcceptProposalEndorsementTTL + if c.hu.IsPost(config.Dardanelles, height) { + return config.DardanellesAcceptProposalEndorsementTTL } return c.cfg.AcceptProposalEndorsementTTL } func (c *consensusCfg) AcceptLockEndorsementTTL(height uint64) time.Duration { - if c.hu.IsPost(config.Hudson, height) { - return config.HudsonAcceptLockEndorsementTTL + if c.hu.IsPost(config.Dardanelles, height) { + return config.DardanellesAcceptLockEndorsementTTL } return c.cfg.AcceptLockEndorsementTTL } func (c *consensusCfg) CommitTTL(height uint64) time.Duration { - if c.hu.IsPost(config.Hudson, height) { - return config.HudsonCommitTTL + if c.hu.IsPost(config.Dardanelles, height) { + return config.DardanellesCommitTTL } return c.cfg.CommitTTL } func (c *consensusCfg) BlockInterval(height uint64) time.Duration { - if c.hu.IsPost(config.Hudson, height) { - return config.HudsonBlockInterval + if c.hu.IsPost(config.Dardanelles, height) { + return config.DardanellesBlockInterval } return c.blockInterval } func (c *consensusCfg) Delay(height uint64) time.Duration { - if c.hu.IsPost(config.Hudson, height) { - return config.HudsonDelay + if c.hu.IsPost(config.Dardanelles, height) { + return config.DardanellesDelay } return c.delay }