The storage isn't cleared after the destruction of the contract #95
Labels
No Label
bug
critical
documentation
duplicate
enhancement
Epic
good first issue
help wanted
Integration tests
invalid
question
v5
wontfix
Copied from Github
Kind/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cerc-io/ipld-eth-server#95
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi Ilnure we need more details around this bug, and also what are you working on that you ran into this? Please provide more info, in Russian if need be I can have it translated, thank you
I needed to add a check for function
RetrieveStorageAtByAddressAndStorageSlotAndBlockHash
in the case when storage is empty. In the integration tests for theGLDToken
contract, I added a destroy function for the contract. After that i started comparing storage data before destoying and after.Geth:
before:
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 54 53 201 173 197 222 160 0 0]
after:
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
ipld-eth-server:
before:
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 54 53 201 173 197 222 160 0 0]
after:
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 54 53 201 173 197 222 160 0 0]
i think, ipld-eth-server should return zero values after contract destoying
We are a little in the weeds for me, but isn't there a flag we're using someplace else to address this? Or put another way, I suspect that the current release of the stack marks that data correctly it's just the mark isn't making it all the way to whatever you're accessing.
When a state or storage node is destroyed post EIP-158 an entry at that path/leaf_key is made in the database that is flagged with the "Removed" node type to signify as such.
This issue I think makes an assumption that this is not occurring, but we do not know that the issue is at this level yet and in fact the unit test coverage of statediffing geth suggests this is not where the issue lies.
What is most likely occurring is that "Removed" node entries are in the database but are not being properly considered when querying the database.
Please see:
https://github.com/vulcanize/ipld-eth-server/pull/94#discussion_r699574336
and
https://github.com/vulcanize/ipld-eth-server/pull/94#discussion_r703038391
@ramilexe can you please translate Ian's message above and make sure it is conveyed to Ilnur?
Copying over from slack:
So the issue is probably with these stored functions https://github.com/vulcanize/ipld-eth-server/blob/master/db/migrations/00014_create_stored_functions.sql#L4 and https://github.com/vulcanize/ipld-eth-server/blob/master/db/migrations/00014_create_stored_functions.sql#L22
Or in how they are being used here and the other related pg queries below it https://github.com/vulcanize/ipld-eth-server/blob/master/pkg/eth/ipld_retriever.go#L118
If its not at the ipld-eth-server level it is at the indexer level, but not the builder level. There are unit tests for these edge cases for the statediff builder but I cant recall if there are for the indexer (although it isn't really an edge case at that level, since it's the same db model being indexed in the same capacity/fashion).
I tried running sql scripts (for block 54 in my environment):
Query:
Result:
Query:
Result:
I think both scripts are working not correctly. Function
was_storage_removed
return not correct result. Second sql withLIMIT 1
also return bad result in functionwas_state_removed
I used two versions of docker:
Thanks @n0cte, I think @arijitAD has fixed the state query issue in #99 but it's not clear what the issue is for storage.
I should have noticed this sooner, but the reason we needed to use these
was_x_removed
functions was because, prior to https://github.com/vulcanize/go-ethereum/pull/58, we did not have the leaf key present for "Removed" nodes and so we would not find them using the basic query against leaf_key. Now that we have leaf_key present, these functions are unnecessary (and indeed broken in this new context).E.g. instead of
We can just do
This will return the latest node entry for a specific leaf key, including "Removed" types. We can check if the
node_type
returned is "Removed" and if it is handle the zero value appropriately. Alternatively, if we want to get the latest state of a node at a leaf_key (last value before it was "Removed"), we just need to add a condition to the query to exclude "Removed" node_types.I.e.
Fixed this in https://github.com/vulcanize/ipld-eth-server/pull/98