Configure the PulseChain TTD

This commit is contained in:
Shane Bammel 2022-10-03 17:05:27 -05:00
parent ed08fe5c5a
commit f8bf51978e
2 changed files with 12 additions and 2 deletions

View File

@ -311,6 +311,8 @@ func (ethash *Ethash) CalcDifficulty(chain consensus.ChainHeaderReader, time uin
func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Header) *big.Int { func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Header) *big.Int {
next := new(big.Int).Add(parent.Number, big1) next := new(big.Int).Add(parent.Number, big1)
switch { switch {
case config.IsPrimordialPulseBlock(next):
return params.PulseChainTTDOffset
case config.IsGrayGlacier(next): case config.IsGrayGlacier(next):
return calcDifficultyEip5133(time, parent) return calcDifficultyEip5133(time, parent)
case config.IsArrowGlacier(next): case config.IsArrowGlacier(next):

View File

@ -12,6 +12,14 @@ type Treasury struct {
Balance *math.HexOrDecimal256 `json:"balance"` Balance *math.HexOrDecimal256 `json:"balance"`
} }
// A trivially small amount of work to add to the Ethereum Mainnet TTD
// to allow for un-merging and merging with the PulseChain beacon chain
var PulseChainTTDOffset = big.NewInt(131_072)
// This value is defined as LAST_ACTUAL_MAINNET_TTD + PulseChainTTDOffset
// where LAST_ACTUAL_MAINNET_TTD = 58_750_003_716_598_352_816_469
var PulseChainTerminalTotalDifficulty, _ = new(big.Int).SetString("58_750_003_716_598_352_947_541", 0)
var ( var (
PulseChainConfig = &ChainConfig{ PulseChainConfig = &ChainConfig{
ChainID: big.NewInt(369), ChainID: big.NewInt(369),
@ -30,7 +38,7 @@ var (
LondonBlock: big.NewInt(12_965_000), LondonBlock: big.NewInt(12_965_000),
ArrowGlacierBlock: big.NewInt(13_773_000), ArrowGlacierBlock: big.NewInt(13_773_000),
GrayGlacierBlock: big.NewInt(15_050_000), GrayGlacierBlock: big.NewInt(15_050_000),
TerminalTotalDifficulty: MainnetTerminalTotalDifficulty, // 58_750_000_000_000_000_000_000 TerminalTotalDifficulty: PulseChainTerminalTotalDifficulty,
TerminalTotalDifficultyPassed: true, TerminalTotalDifficultyPassed: true,
Ethash: new(EthashConfig), Ethash: new(EthashConfig),
PrimordialPulseBlock: big.NewInt(15_700_000), // TODO: UPDATE FORK BLOCK PrimordialPulseBlock: big.NewInt(15_700_000), // TODO: UPDATE FORK BLOCK
@ -53,7 +61,7 @@ var (
LondonBlock: big.NewInt(12_965_000), LondonBlock: big.NewInt(12_965_000),
ArrowGlacierBlock: big.NewInt(13_773_000), ArrowGlacierBlock: big.NewInt(13_773_000),
GrayGlacierBlock: big.NewInt(15_050_000), GrayGlacierBlock: big.NewInt(15_050_000),
TerminalTotalDifficulty: MainnetTerminalTotalDifficulty, // 58_750_000_000_000_000_000_000 TerminalTotalDifficulty: PulseChainTerminalTotalDifficulty,
TerminalTotalDifficultyPassed: true, TerminalTotalDifficultyPassed: true,
Ethash: new(EthashConfig), Ethash: new(EthashConfig),
PrimordialPulseBlock: big.NewInt(15_700_000), // TODO: UPDATE FORK BLOCK PrimordialPulseBlock: big.NewInt(15_700_000), // TODO: UPDATE FORK BLOCK