mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 15:47:21 +00:00
tracers/prestate: always remove empty accounts from pre-state (#31427)
The prestateTracer had the intention of excluding accounts that were empty prior to execution from the prestate. This was being done only for created contracts. This PR makes it so all such empty accounts are excluded. This behavior is configurable using the `includeEmpty: true` flag introduced in #31855. --------- Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
This commit is contained in:
parent
8b86ff7979
commit
e2007e513c
8 changed files with 13 additions and 28 deletions
|
|
@ -321,7 +321,7 @@ func TestInternals(t *testing.T) {
|
|||
byte(vm.LOG0),
|
||||
},
|
||||
tracer: mkTracer("prestateTracer", nil),
|
||||
want: fmt.Sprintf(`{"0x0000000000000000000000000000000000000000":{"balance":"0x0"},"0x00000000000000000000000000000000deadbeef":{"balance":"0x0","code":"0x6001600052600164ffffffffff60016000f560ff6000a0"},"%s":{"balance":"0x1c6bf52634000"}}`, originHex),
|
||||
want: fmt.Sprintf(`{"0x00000000000000000000000000000000deadbeef":{"balance":"0x0","code":"0x6001600052600164ffffffffff60016000f560ff6000a0"},"%s":{"balance":"0x1c6bf52634000"}}`, originHex),
|
||||
},
|
||||
{
|
||||
// CREATE2 which requires padding memory by prestate tracer
|
||||
|
|
@ -340,7 +340,7 @@ func TestInternals(t *testing.T) {
|
|||
byte(vm.LOG0),
|
||||
},
|
||||
tracer: mkTracer("prestateTracer", nil),
|
||||
want: fmt.Sprintf(`{"0x0000000000000000000000000000000000000000":{"balance":"0x0"},"0x00000000000000000000000000000000deadbeef":{"balance":"0x0","code":"0x6001600052600160ff60016000f560ff6000a0"},"%s":{"balance":"0x1c6bf52634000"}}`, originHex),
|
||||
want: fmt.Sprintf(`{"0x00000000000000000000000000000000deadbeef":{"balance":"0x0","code":"0x6001600052600160ff60016000f560ff6000a0"},"%s":{"balance":"0x1c6bf52634000"}}`, originHex),
|
||||
},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@
|
|||
},
|
||||
"result": {
|
||||
"0x0024f658a46fbb89d8ac105e98d7ac7cbbaf27c5": {
|
||||
"balance": "0x0",
|
||||
"nonce": 22
|
||||
"balance":"0x0",
|
||||
"nonce":22
|
||||
},
|
||||
"0x3b873a919aa0512d5a0f09e6dcceaa4a6727fafe": {
|
||||
"balance": "0x4d87094125a369d9bd5",
|
||||
|
|
@ -75,9 +75,6 @@
|
|||
"0xb436ba50d378d4bbc8660d312a13df6af6e89dfb": {
|
||||
"balance": "0x1780d77678137ac1b775",
|
||||
"nonce": 29072
|
||||
},
|
||||
"0x1585936b53834b021f68cc13eeefdec2efc8e724": {
|
||||
"balance": "0x0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,9 +70,6 @@
|
|||
"0xb436ba50d378d4bbc8660d312a13df6af6e89dfb": {
|
||||
"balance": "0x1780d77678137ac1b775",
|
||||
"nonce": 29072
|
||||
},
|
||||
"0x1585936b53834b021f68cc13eeefdec2efc8e724": {
|
||||
"balance": "0x0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,9 +70,6 @@
|
|||
"0xb436ba50d378d4bbc8660d312a13df6af6e89dfb": {
|
||||
"balance": "0x1780d77678137ac1b775",
|
||||
"nonce": 29072
|
||||
},
|
||||
"0x1585936b53834b021f68cc13eeefdec2efc8e724": {
|
||||
"balance": "0x0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
"0xb436ba50d378d4bbc8660d312a13df6af6e89dfb": {
|
||||
"balance": "0x1780d77678137ac1b775",
|
||||
"code": "0x",
|
||||
"nonce": "29072",
|
||||
"nonce": 29072,
|
||||
"storage": {}
|
||||
}
|
||||
},
|
||||
|
|
@ -74,9 +74,6 @@
|
|||
"0xb436ba50d378d4bbc8660d312a13df6af6e89dfb": {
|
||||
"balance": "0x1780d77678137ac1b775",
|
||||
"nonce": 29072
|
||||
},
|
||||
"0x1585936b53834b021f68cc13eeefdec2efc8e724": {
|
||||
"balance": "0x0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,9 +64,6 @@
|
|||
"balance": "0x0",
|
||||
"nonce": 22
|
||||
},
|
||||
"0x1585936b53834b021f68cc13eeefdec2efc8e724": {
|
||||
"balance": "0x0"
|
||||
},
|
||||
"0x3b873a919aa0512d5a0f09e6dcceaa4a6727fafe": {
|
||||
"balance": "0x4d87094125a369d9bd5",
|
||||
"nonce": 1,
|
||||
|
|
|
|||
|
|
@ -63,9 +63,6 @@
|
|||
"balance": "0x0",
|
||||
"nonce": 22
|
||||
},
|
||||
"0x1585936b53834b021f68cc13eeefdec2efc8e724": {
|
||||
"balance": "0x0"
|
||||
},
|
||||
"0x3b873a919aa0512d5a0f09e6dcceaa4a6727fafe": {
|
||||
"balance": "0x4d87094125a369d9bd5",
|
||||
"nonce": 1,
|
||||
|
|
|
|||
|
|
@ -184,11 +184,14 @@ func (t *prestateTracer) OnTxEnd(receipt *types.Receipt, err error) {
|
|||
if t.config.DiffMode {
|
||||
t.processDiffState()
|
||||
}
|
||||
// the new created contracts' prestate were empty, so delete them
|
||||
for a := range t.created {
|
||||
// the created contract maybe exists in statedb before the creating tx
|
||||
if s := t.pre[a]; s != nil && s.empty && !t.config.IncludeEmpty {
|
||||
delete(t.pre, a)
|
||||
// Remove accounts that were empty prior to execution. Unless
|
||||
// user requested to include empty accounts.
|
||||
if t.config.IncludeEmpty {
|
||||
return
|
||||
}
|
||||
for addr, s := range t.pre {
|
||||
if s.empty {
|
||||
delete(t.pre, addr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue