From ed08fe5c5adba18d2275946d2eaf2b5c5abe2126 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 bcb0562c6..a350e383a 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -28,7 +28,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" "github.com/holiman/uint256" @@ -361,12 +360,6 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types. amount = amount.Mul(amount, uint256.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 c2936fd4b..070937ca5 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -31,6 +31,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" "github.com/holiman/uint256" @@ -502,6 +503,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) }