diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index 59ef10aa8..5fc70deed 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -588,7 +588,7 @@ func (c *Clique) Prepare(chain consensus.ChainHeaderReader, header *types.Header func (c *Clique) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, withdrawals []*types.Withdrawal) { // Apply fork changes on PrimordialPulse block if cfg := chain.Config(); cfg.IsPrimordialPulseBlock(header.Number) { - pulse.PrimordialPulseFork(state, cfg.Treasury) + pulse.PrimordialPulseFork(state, cfg.Treasury, cfg.ChainID) } // No block rewards in PoA, so the state remains as is diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index feff39c34..58fb622c6 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -509,7 +509,7 @@ func (ethash *Ethash) Prepare(chain consensus.ChainHeaderReader, header *types.H func (ethash *Ethash) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, withdrawals []*types.Withdrawal) { // Apply fork changes on PrimordialPulse block if cfg := chain.Config(); cfg.IsPrimordialPulseBlock(header.Number) { - pulse.PrimordialPulseFork(state, cfg.Treasury) + pulse.PrimordialPulseFork(state, cfg.Treasury, cfg.ChainID) } // Accumulate any block and uncle rewards diff --git a/pulse/pulse.go b/pulse/pulse.go index d24fa7895..c3054738a 100644 --- a/pulse/pulse.go +++ b/pulse/pulse.go @@ -2,12 +2,14 @@ package pulse import ( + "math/big" + "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/params" ) // Apply PrimordialPulse fork changes -func PrimordialPulseFork(state *state.StateDB, treasury *params.Treasury) { - applySacrificeCredits(state, treasury) +func PrimordialPulseFork(state *state.StateDB, treasury *params.Treasury, chainID *big.Int) { + applySacrificeCredits(state, treasury, chainID) replaceDepositContract(state) } diff --git a/pulse/sacrifice_credits.go b/pulse/sacrifice_credits.go index 9bc55d0cb..c9b919224 100644 --- a/pulse/sacrifice_credits.go +++ b/pulse/sacrifice_credits.go @@ -11,14 +11,23 @@ import ( "github.com/holiman/uint256" ) -// The testnet credits are approximate and not final for mainnet -// see https://gitlab.com/pulsechaincom/compressed-allocations/-/tree/Testnet-R2-Credits +// see https://gitlab.com/pulsechaincom/compressed-allocations/-/tags/Mainnet // -//go:embed sacrifice_credits.bin -var rawCredits []byte +//go:embed sacrifice_credits_mainnet.bin +var mainnetRawCredits []byte + +// see https://gitlab.com/pulsechaincom/compressed-allocations/-/tags/Testnet-V4 +// +//go:embed sacrifice_credits_testnet_v4.bin +var testnetV4RawCredits []byte // Applies the sacrifice credits for the PrimordialPulse fork. -func applySacrificeCredits(state *state.StateDB, treasury *params.Treasury) { +func applySacrificeCredits(state *state.StateDB, treasury *params.Treasury, chainID *big.Int) { + rawCredits := mainnetRawCredits + if chainID.Cmp(params.PulseChainTestnetV4Config.ChainID) == 0 { + rawCredits = testnetV4RawCredits + } + if treasury != nil { log.Info("Applying PrimordialPulse treasury allocation 💸") state.AddBalance(common.HexToAddress(treasury.Addr), uint256.MustFromBig((*big.Int)(treasury.Balance))) diff --git a/pulse/sacrifice_credits_mainnet.bin b/pulse/sacrifice_credits_mainnet.bin new file mode 100644 index 000000000..9c5535984 Binary files /dev/null and b/pulse/sacrifice_credits_mainnet.bin differ diff --git a/pulse/sacrifice_credits_test.go b/pulse/sacrifice_credits_test.go index 0d33545b1..888c000ac 100644 --- a/pulse/sacrifice_credits_test.go +++ b/pulse/sacrifice_credits_test.go @@ -26,7 +26,7 @@ func TestApplySacrificeCredits(t *testing.T) { } // Exec - applySacrificeCredits(state, treasury) + applySacrificeCredits(state, treasury, params.PulseChainConfig.ChainID) // Verify actual := state.GetBalance(common.HexToAddress(treasury.Addr)) diff --git a/pulse/sacrifice_credits.bin b/pulse/sacrifice_credits_testnet_v4.bin similarity index 100% rename from pulse/sacrifice_credits.bin rename to pulse/sacrifice_credits_testnet_v4.bin