-
Notifications
You must be signed in to change notification settings - Fork 21.4k
[wip] implement FILL_COST #30201
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
base: master
Are you sure you want to change the base?
[wip] implement FILL_COST #30201
Conversation
func (s *StateDB) IsSlotFilled(addr common.Address, slot common.Hash) bool { | ||
// The snapshot can not be used, because it uses the old encoding where | ||
// no difference is made between 0 and no data. | ||
_, err := s.db.DiskDB().Get(utils.StorageSlotKeyWithEvaluatedAddress(s.accessList.pointCache.GetTreeKeyHeader(addr[:]), slot[:])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should go through the reader abstaction, because it might have been written in a previous block but not in the db / also we want to use the layers to build the witness if we can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rjl493456442 s.reader.StorageExist(addr, slot)
ae.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.CodeSizeLeafKey, false) | ||
func (ae *AccessEvents) AddTxDestination(addr common.Address, sendsValue, isFill bool) { | ||
ae.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.VersionLeafKey, false, false) | ||
ae.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.BalanceLeafKey, sendsValue, isFill) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsign correctly points out that if isFill
is true, then the whole account will be created.
statelessGas += evm.AccessEvents.BalanceGas(contractAddr, true, false) | ||
if contractAddr != beneficiaryAddr { | ||
statelessGas += evm.AccessEvents.BalanceGas(beneficiaryAddr, true) | ||
statelessGas += evm.AccessEvents.BalanceGas(beneficiaryAddr, true, !evm.StateDB.Exist(beneficiaryAddr)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same point by @jsign : the account will need to be created so the fill might be more than just the balance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one should be fixed by just charging the empty code hash as well from here
FILL_COST
is currently missing from every verkle testnet owing to the difficulty of knowing that a slot already existed. This is the implementation of the feature, trying to get the information from context as much as possible instead of recovering it from the database.