mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-08 07:58:40 +00:00
miner: fix miner bug again
This commit is contained in:
parent
fc0e03c667
commit
6dddd29936
2 changed files with 22 additions and 2 deletions
|
|
@ -792,6 +792,24 @@ func (s *StateDB) RevertToSnapshot(revid int) {
|
||||||
s.journal.revertToSnapshot(revid, s)
|
s.journal.revertToSnapshot(revid, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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.
|
// GetRefund returns the current value of the refund counter.
|
||||||
func (s *StateDB) GetRefund() uint64 {
|
func (s *StateDB) GetRefund() uint64 {
|
||||||
return s.refund
|
return s.refund
|
||||||
|
|
|
||||||
|
|
@ -444,13 +444,15 @@ func (miner *Miner) commitBlobTransaction(env *environment, tx *types.Transactio
|
||||||
// applyTransaction runs the transaction. If execution fails, state and gas pool are reverted.
|
// 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) {
|
func (miner *Miner) applyTransaction(env *environment, tx *types.Transaction) (*types.Receipt, error) {
|
||||||
var (
|
var (
|
||||||
snap = env.state.Snapshot()
|
snap = env.state.Snapshot()
|
||||||
gp = env.gasPool.Snapshot()
|
gp = env.gasPool.Snapshot()
|
||||||
|
readSnap = env.state.SnapshotReadList()
|
||||||
)
|
)
|
||||||
txAccesses, txMutations, receipt, err := core.ApplyTransaction(env.evm, env.gasPool, env.state, env.header, tx)
|
txAccesses, txMutations, receipt, err := core.ApplyTransaction(env.evm, env.gasPool, env.state, env.header, tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.state.RevertToSnapshot(snap)
|
env.state.RevertToSnapshot(snap)
|
||||||
env.gasPool.Set(gp)
|
env.gasPool.Set(gp)
|
||||||
|
env.state.RestoreReadList(readSnap)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if env.accessList != nil {
|
if env.accessList != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue