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

core/{state,vm}: FILL_COSTS using StateExists #30390

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

gballet
Copy link
Member

@gballet gballet commented Sep 4, 2024

This is a reimplementation of the FILL_COST PR rebased on Gary's StateExists PR (rjl493456442@732cb64#diff-c3757dc9e9d868f63bc84a0cc67159c1d5c22cc5d8c9468757098f0492e0658c).

Comment on lines +145 to +146
ae.touchAddressAndChargeGas(originAddr, zeroTreeIndex, utils.BasicDataLeafKey, true, false)
ae.touchAddressAndChargeGas(originAddr, zeroTreeIndex, utils.CodeHashLeafKey, false, false)
Copy link
Member Author

Choose a reason for hiding this comment

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

We need to test what happens if we try to send a tx from an account that isn't in the state (i.e. someone generates a public key, and sends a tx from it before they even created the account in the state)

// the intrinsic tx gas if needed. If the destination is written to during
// the contract execution, before the state db layer has saved it to disk,
// the fill cost will already have been covered by the intrinsic gas.
ae.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.BasicDataLeafKey, sendsValue, true)
Copy link
Member Author

Choose a reason for hiding this comment

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

This sendsValue here is potentially incorrect, because if we create an account while not sending funds, but it does create the account (which isn't possible now but might be the case in 7702). So I think we should change sendsValue to true.

return gas
}

// ContractCreateInitGas returns the access gas costs for the initialization of
// a contract creation.
func (ae *AccessEvents) ContractCreateInitGas(addr common.Address, createSendsValue bool) uint64 {
var gas uint64
gas += ae.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.BasicDataLeafKey, true)
gas += ae.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.BasicDataLeafKey, true, true)
Copy link
Member Author

Choose a reason for hiding this comment

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

this is ok for now, but this isn't going to when we implement fill_cost: we need to find out if the contract exists as there might be a collision. There is some argument that needs to be debated here but if we can't use the collision check to determine that it's a fill, then we need to add a parameter here.

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