Skip to content

Conversation

gballet
Copy link
Member

@gballet gballet commented Jul 22, 2024

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.

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[:]))
Copy link
Member Author

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.

Copy link
Member Author

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)
Copy link
Member Author

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))
Copy link
Member Author

@gballet gballet Jul 29, 2024

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

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 one should be fixed by just charging the empty code hash as well from here

@fjl fjl added the verkle label Mar 5, 2025
@fjl fjl mentioned this pull request Mar 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants