mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-08 07:58:40 +00:00
core: misc fixes (claude)
This commit is contained in:
parent
42a87ae77a
commit
f59ec20794
2 changed files with 28 additions and 2 deletions
|
|
@ -771,6 +771,24 @@ func (s *StateDB) CloseSnapshot(revid int) {
|
|||
s.journal.closeSnapshot(revid)
|
||||
}
|
||||
|
||||
// SnapshotReadList returns a deep copy of the current EIP-7928 state-read list.
|
||||
// Pair with RestoreReadList: callers that may discard a transaction attempt
|
||||
// (e.g. the miner reverting a failed tx via RevertToSnapshot) should restore
|
||||
// the read list as well, since reads are not journaled and would otherwise
|
||||
// leak into the next BAL emission via engine.Finalize.
|
||||
func (s *StateDB) SnapshotReadList() *bal.StateAccessList {
|
||||
if s.stateReadList == nil {
|
||||
return nil
|
||||
}
|
||||
return s.stateReadList.Copy()
|
||||
}
|
||||
|
||||
// RestoreReadList replaces the current EIP-7928 state-read list with the given
|
||||
// snapshot. See SnapshotReadList for the motivation.
|
||||
func (s *StateDB) RestoreReadList(snap *bal.StateAccessList) {
|
||||
s.stateReadList = snap
|
||||
}
|
||||
|
||||
// GetRefund returns the current value of the refund counter.
|
||||
func (s *StateDB) GetRefund() uint64 {
|
||||
return s.refund
|
||||
|
|
|
|||
|
|
@ -444,13 +444,21 @@ func (miner *Miner) commitBlobTransaction(env *environment, tx *types.Transactio
|
|||
// applyTransaction runs the transaction. If execution fails, state and gas pool are reverted.
|
||||
func (miner *Miner) applyTransaction(env *environment, tx *types.Transaction) (*types.Receipt, error) {
|
||||
var (
|
||||
snap = env.state.Snapshot()
|
||||
gp = env.gasPool.Snapshot()
|
||||
snap = env.state.Snapshot()
|
||||
gp = env.gasPool.Snapshot()
|
||||
readSnap = env.state.SnapshotReadList()
|
||||
)
|
||||
txAccesses, txMutations, receipt, err := core.ApplyTransaction(env.evm, env.gasPool, env.state, env.header, tx)
|
||||
if err != nil {
|
||||
env.state.RevertToSnapshot(snap)
|
||||
env.gasPool.Set(gp)
|
||||
// EIP-7928 BAL: reads accumulated during a failed-Go-error tx
|
||||
// (e.g. preCheck reads sender's nonce/balance/code before Prepare resets the
|
||||
// per-tx read list) are not journaled and survive RevertToSnapshot. If left
|
||||
// in place they leak into the live state-read list and ultimately into the
|
||||
// BAL via engine.Finalize, producing a hash mismatch with validators that
|
||||
// only re-execute the txs sealed in the block.
|
||||
env.state.RestoreReadList(readSnap)
|
||||
return nil, err
|
||||
}
|
||||
if env.accessList != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue