Skip to content

Commit

Permalink
rename Hudson to Dardanelles (#1571)
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinxie authored and Yutong Pei committed Oct 25, 2019
1 parent 1da4e75 commit 69c03b7
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 85 deletions.
38 changes: 19 additions & 19 deletions action/protocol/rolldpos/epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -88,25 +88,25 @@ 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
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
Expand Down
12 changes: 6 additions & 6 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down
46 changes: 23 additions & 23 deletions blockchain/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion chainservice/chainservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
18 changes: 9 additions & 9 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
22 changes: 11 additions & 11 deletions config/heightupgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
Aleutian
Bering
Cook
Hudson
Dardanelles
)

type (
Expand All @@ -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
}
)

Expand All @@ -40,7 +40,7 @@ func NewHeightUpgrade(cfg Config) HeightUpgrade {
cfg.Genesis.AleutianBlockHeight,
cfg.Genesis.BeringBlockHeight,
cfg.Genesis.CookBlockHeight,
cfg.Genesis.HudsonBlockHeight,
cfg.Genesis.DardanellesBlockHeight,
}
}

Expand All @@ -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!")
}
Expand All @@ -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 }
32 changes: 16 additions & 16 deletions consensus/consensusfsm/consensus_ttl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 69c03b7

Please sign in to comment.