core/state: track the block-level accessList#34803
Conversation
283c062 to
83b995b
Compare
| // code and storage is guaranteed to be empty, leaving nothing to | ||
| // clean up here. | ||
| balance := uint256.NewInt(0) | ||
| if state.balanceSet && balance.Cmp(state.balance) != 0 { |
There was a problem hiding this comment.
It correctly catches the edge-case of a selfdestructing initcode in a prefunded account: a balance subtraction happens at the time the selfdestruct opcode is invoked.
| s.stateAccessList.NonceChange(addr, s.blockAccessIndex, nonce) | ||
| } | ||
| if state.codeSet { | ||
| if code := obj.Code(); !bytes.Equal(code, state.code) { |
There was a problem hiding this comment.
Might be worth it to compare by hash here. I'm not sure how much performance difference it makes in practice.
There was a problem hiding this comment.
It's a good point.
In practice, the code change can be categorized as:
- nil -> contract code
- nil -> delegation
- delegation -> nil
- delegation a -> delegation b
for all these cases, the byte comparison is not expensive.
|
Did a first pass through this. tentatively LGTM but would be good to get more eyes on it. |
20a778d to
bb032bb
Compare
|
Can you remind me what the plan was to track storage mutations? |
bb032bb to
e6977f2
Compare
// Aggregate storage writes into the block-level access list.
// All slots in the dirtyStorage set must have post-transaction
// values that differ from their pre-transaction values.
if s.db.stateAccessList != nil {
s.db.stateAccessList.StorageWrite(s.db.blockAccessIndex, s.address, key, value)
} |
This PR extends the journal to track the pre-transaction values of mutated balances, nonces, and code.
At the end of the transaction, these values are used to filter out no-op changes, such as balance transitions from a-> b->a. These changes are excluded from the block-level access list.
Additionally, there is a dedicated
bal.ConstructionBlockAccessListobjects for gathering the state reads and writes within the current transaction. These state writes will be keyed by the block accessList index.