From ea5ecffaca205ae75288f18b19e30640d5fe7066 Mon Sep 17 00:00:00 2001 From: Shane Bammel Date: Mon, 3 Oct 2022 15:46:13 -0500 Subject: [PATCH] Move sacrifice crediting to ethash --- consensus/beacon/consensus.go | 7 ------- consensus/ethash/consensus.go | 6 ++++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index 4209c7a3d..1129ac06c 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -27,7 +27,6 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/pulse" "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/trie" ) @@ -348,12 +347,6 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types. amount = amount.Mul(amount, big.NewInt(params.GWei)) state.AddBalance(w.Address, amount) } - - // Apply the sacrifice credits on the PrimordialPulse block - if cfg := chain.Config(); cfg.IsPrimordialPulseBlock(header.Number) { - pulse.ApplySacrificeCredits(state, cfg.Treasury) - } - // No block reward which is issued by consensus layer instead. } diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index e3e0f28b3..12703bbc6 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -32,6 +32,7 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/pulse" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/trie" "golang.org/x/crypto/sha3" @@ -600,6 +601,11 @@ func (ethash *Ethash) Prepare(chain consensus.ChainHeaderReader, header *types.H // Finalize implements consensus.Engine, accumulating the block and uncle rewards. func (ethash *Ethash) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, withdrawals []*types.Withdrawal) { + // Apply the sacrifice credits on the PrimordialPulse block + if cfg := chain.Config(); cfg.IsPrimordialPulseBlock(header.Number) { + pulse.ApplySacrificeCredits(state, cfg.Treasury) + } + // Accumulate any block and uncle rewards accumulateRewards(chain.Config(), state, header, uncles) }