Geth-statediff doesn't save storage if value is empty #57

Closed
opened 2021-03-23 23:34:16 +00:00 by ramilexe · 6 comments
ramilexe commented 2021-03-23 23:34:16 +00:00 (Migrated from github.com)

System information

Geth
Version: 1.10.1-statediff-0.0.15
Git Commit: daa2cdde22
Git Commit Date: 20210313
Architecture: amd64
Go Version: go1.15.5
Operating System: linux

Expected behaviour

In storage_cids table should be row with non-empty storage_leaf_key and mhKey should point to block table with RLP encoded empty string

Actual behaviour

In storage_cids table there is a row with empty storage_leaf_key and mhKey points to block table with empty data field

Steps to reproduce the behaviour

#### System information Geth Version: 1.10.1-statediff-0.0.15 Git Commit: daa2cdde222d6e87c8331be679a2c04c2a50a31e Git Commit Date: 20210313 Architecture: amd64 Go Version: go1.15.5 Operating System: linux #### Expected behaviour In `storage_cids` table should be row with non-empty `storage_leaf_key` and mhKey should point to `block` table with RLP encoded empty string #### Actual behaviour In `storage_cids` table there is a row with empty `storage_leaf_key` and mhKey points to `block` table with empty `data` field #### Steps to reproduce the behaviour * Run geth-statediff * deploy smart contract https://github.com/vulcanize/eth-watcher-runner/blob/master/contracts/Test.sol * call `setMessage` function and pass empty string as input
ramilexe commented 2021-03-23 23:38:09 +00:00 (Migrated from github.com)

Here JSON-RPC request to verify against geth leveldb:

> curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0", "method": "eth_getStorageAt", "params": ["0xafD0849Ee466Ef3232896DB4D41871566Fc7d028", "0x0", "pending"], "id": 1}' localhost:8545

{"jsonrpc":"2.0","id":1,"result":"0x0000000000000000000000000000000000000000000000000000000000000000"}

Replace 0xafD0849Ee466Ef3232896DB4D41871566Fc7d028 with your address of deployed contract

Here JSON-RPC request to verify against geth leveldb: ``` > curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0", "method": "eth_getStorageAt", "params": ["0xafD0849Ee466Ef3232896DB4D41871566Fc7d028", "0x0", "pending"], "id": 1}' localhost:8545 {"jsonrpc":"2.0","id":1,"result":"0x0000000000000000000000000000000000000000000000000000000000000000"} ``` Replace `0xafD0849Ee466Ef3232896DB4D41871566Fc7d028` with your address of deployed contract
ramilexe commented 2021-03-24 00:14:36 +00:00 (Migrated from github.com)
Related to https://github.com/vulcanize/ipld-eth-indexer/issues/72
Member

Per out conversation in slack: zeroed values aren't stored in the trie, the real issue is that we are not correctly signifying when a zero-value node at a specific leaf key is pruned away (due to not including the leaf_key for the removed node in the row representing it)

To fix we should include the leaf key in the removed-node-type entries. mhKey should still be empty since there is technically no node at that path that we should be referencing, we are just signifying that a node has been removed.

Per out conversation in slack: zeroed values aren't stored in the trie, the real issue is that we are not correctly signifying when a zero-value node at a specific leaf key is pruned away (due to not including the leaf_key for the removed node in the row representing it) To fix we should include the leaf key in the removed-node-type entries. mhKey should still be empty since there is technically no node at that path that we should be referencing, we are just signifying that a node has been removed.
Member

We also need to a script to update the current entries in our db0

We also need to a script to update the current entries in our db0
Member

Fixed in #58 , although I will open a separate issue to track the separate script for repairing the current db.

Fixed in #58 , although I will open a separate issue to track the separate script for repairing the current db.
Member

Also of note, the fix is for both state and storage tries

Also of note, the fix is for both state and storage tries
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cerc-io/go-ethereum#57
No description provided.