From 0fb74172a83c95f89d2a7a2f2f605d2859daf3e2 Mon Sep 17 00:00:00 2001 From: Andrew Ashikhmin <34320705+yperbasis@users.noreply.github.com> Date: Tue, 18 Oct 2022 10:44:56 +0200 Subject: [PATCH] FinalizeTx after engine.Initialize (#5783) AuRa storage changes made by `onEpochBegin` should be finalized. Otherwise, `SSTORE` cost might be incorrect in block transactions when [EIP-2200](https://eips.ethereum.org/EIPS/eip-2200) is active. https://gnosisscan.io/tx/0xa6d45d903c977ad237165737ebc4e34fb7756675719d112a199af858bb1275e0 is an example of a transaction on Gnosis Chain whose gas used was previously calculated incorrectly. --- core/blockchain.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/blockchain.go b/core/blockchain.go index a1960fd11..1f0a8088e 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -572,5 +572,7 @@ func InitializeBlockExecution(engine consensus.Engine, chain consensus.ChainHead engine.Initialize(cc, chain, epochReader, header, txs, uncles, func(contract common.Address, data []byte) ([]byte, error) { return SysCallContract(contract, data, *cc, ibs, header, engine) }) + noop := state.NewNoopWriter() + ibs.FinalizeTx(cc.Rules(header.Number.Uint64()), noop) return nil }