Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid BASIC_DATA branch edit for free in existent accounts #513

Merged
merged 1 commit into from
Oct 17, 2024

Conversation

jsign
Copy link
Collaborator

@jsign jsign commented Oct 17, 2024

Fixing a problem I found when filling the test now, I'll explain in comments.

cc @tanishqjasoria

// Note that we do a write-event in CodeHash without distinguishing if the tx target account
// exists or not. Pre-7702, there's no situation in which an existing codeHash can be mutated, thus
// doing a write-event shouldn't cause an observable difference in gas usage.
// TODO(7702): re-check this in the spec and implementation to be sure is a correct solution after
// EIP-7702 is implemented.
aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, utils.CodeHashLeafKey, true, nil)
aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, utils.CodeHashLeafKey, false, nil)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverting this to the way it was pre-yesterday PR. (Still keeping the renaming since it was a useful change).

Comment on lines 399 to +402
st.evm.Accesses.TouchTxTarget(targetAddr.Bytes(), msg.Value.Sign() != 0)
if !st.state.Exist(*targetAddr) {
st.evm.Accesses.TouchCodeHash(targetAddr.Bytes(), true, nil, false)
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out that the logic I made yesterday reg CODEHASH being immutable (before 7702) was fine. But this free CODEHASH write we did before is also giving for free a BRANCH_EDIT unconditionally.

This means that for existing addresses, the unconditional free write-event on CODEHASH made writes in BASIC_DATA cheaper (since CODEHASH got that for free, which attempted to be a simplification but is wrong).

@jsign jsign requested a review from gballet October 17, 2024 11:39
@jsign jsign marked this pull request as ready for review October 17, 2024 11:40
@jsign jsign changed the title avoid BASIC_DATA branch edit for free avoid BASIC_DATA branch edit for free in existent accounts Oct 17, 2024
Copy link
Owner

@gballet gballet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jsign jsign merged commit 59426d9 into jsign-witness-fix Oct 17, 2024
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants