diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index 070937ca5..6815cc83d 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -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 { next := new(big.Int).Add(parent.Number, big1) switch { + case config.IsPrimordialPulseBlock(next): + return params.PulseChainTTDOffset case config.IsGrayGlacier(next): return calcDifficultyEip5133(time, parent) case config.IsArrowGlacier(next): diff --git a/params/pulse.go b/params/pulse.go index c32502435..fc99cfc4e 100644 --- a/params/pulse.go +++ b/params/pulse.go @@ -12,6 +12,14 @@ type Treasury struct { 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 ( PulseChainConfig = &ChainConfig{ ChainID: big.NewInt(369), @@ -30,7 +38,7 @@ var ( LondonBlock: big.NewInt(12_965_000), ArrowGlacierBlock: big.NewInt(13_773_000), GrayGlacierBlock: big.NewInt(15_050_000), - TerminalTotalDifficulty: MainnetTerminalTotalDifficulty, // 58_750_000_000_000_000_000_000 + TerminalTotalDifficulty: PulseChainTerminalTotalDifficulty, TerminalTotalDifficultyPassed: true, Ethash: new(EthashConfig), PrimordialPulseBlock: big.NewInt(15_700_000), // TODO: UPDATE FORK BLOCK @@ -53,7 +61,7 @@ var ( LondonBlock: big.NewInt(12_965_000), ArrowGlacierBlock: big.NewInt(13_773_000), GrayGlacierBlock: big.NewInt(15_050_000), - TerminalTotalDifficulty: MainnetTerminalTotalDifficulty, // 58_750_000_000_000_000_000_000 + TerminalTotalDifficulty: PulseChainTerminalTotalDifficulty, TerminalTotalDifficultyPassed: true, Ethash: new(EthashConfig), PrimordialPulseBlock: big.NewInt(15_700_000), // TODO: UPDATE FORK BLOCK