eth/tracers: fix prestateTracer for EIP-6780 SELFDESTRUCT (#33050)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run

fix https://github.com/ethereum/go-ethereum/issues/33049
This commit is contained in:
hero5512 2025-10-31 13:14:52 -04:00 committed by GitHub
parent 243407a3aa
commit e6d34c1fee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 110 additions and 1 deletions

View file

@ -0,0 +1,101 @@
{
"context": {
"difficulty": "0",
"gasLimit": "8000000",
"miner": "0x0000000000000000000000000000000000000000",
"number": "1",
"timestamp": "1000",
"baseFeePerGas": "7"
},
"genesis": {
"alloc": {
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance": "0x10000000000000000",
"nonce": "0",
"code": "0x",
"storage": {}
},
"0x1111111111111111111111111111111111111111": {
"balance": "0x0",
"nonce": "0",
"code": "0x",
"storage": {}
},
"0x2222222222222222222222222222222222222222": {
"balance": "0xde0b6b3a7640000",
"nonce": "1",
"code": "0x6099600155731111111111111111111111111111111111111111ff",
"storage": {
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x000000000000000000000000000000000000000000000000000000000000abcd",
"0x0000000000000000000000000000000000000000000000000000000000000002": "0x0000000000000000000000000000000000000000000000000000000000001234"
}
}
},
"config": {
"chainId": 1,
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"mergeNetsplitBlock": 0,
"shanghaiTime": 0,
"cancunTime": 0,
"terminalTotalDifficulty": 0,
"terminalTotalDifficultyPassed": true
},
"difficulty": "0",
"extraData": "0x",
"gasLimit": "8000000",
"hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"miner": "0x0000000000000000000000000000000000000000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000000",
"number": "0",
"stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp": "0"
},
"input": "0xf860800a830186a094222222222222222222222222222222222222222280801ba0c4829400221936e8016721406f84b4710ead5608f15c785a3cedc20a7aebaab2a033e8e6e12cc432098b5ce8a409691f977867249073a3fc7804e8676c4d159475",
"tracerConfig": {
"diffMode": true
},
"result": {
"pre": {
"0x2222222222222222222222222222222222222222": {
"balance": "0xde0b6b3a7640000",
"nonce": 1,
"code": "0x6099600155731111111111111111111111111111111111111111ff",
"codeHash": "0x701bdb1d43777a9304905a100f758955d130e09c8e86d97e3f6becccdc001048",
"storage": {
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x000000000000000000000000000000000000000000000000000000000000abcd"
}
},
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance": "0x10000000000000000"
}
},
"post": {
"0x0000000000000000000000000000000000000000": {
"balance": "0x2aed3"
},
"0x1111111111111111111111111111111111111111": {
"balance": "0xde0b6b3a7640000"
},
"0x2222222222222222222222222222222222222222": {
"balance": "0x0",
"storage": {
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000099"
}
},
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance": "0xfffffffffff70e96",
"nonce": 1
}
}
}
}

View file

@ -131,7 +131,15 @@ func (t *prestateTracer) OnOpcode(pc uint64, opcode byte, gas, cost uint64, scop
addr := common.Address(stackData[stackLen-1].Bytes20())
t.lookupAccount(addr)
if op == vm.SELFDESTRUCT {
t.deleted[caller] = true
if t.chainConfig.IsCancun(t.env.BlockNumber, t.env.Time) {
// EIP-6780: only delete if created in same transaction
if t.created[caller] {
t.deleted[caller] = true
}
} else {
// Pre-EIP-6780: always delete
t.deleted[caller] = true
}
}
case stackLen >= 5 && (op == vm.DELEGATECALL || op == vm.CALL || op == vm.STATICCALL || op == vm.CALLCODE):
addr := common.Address(stackData[stackLen-2].Bytes20())