-
Notifications
You must be signed in to change notification settings - Fork 81
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
Update state network to use address_hash instead of address #329
Conversation
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.
No objections that jump out to me.
Are there any areas or use cases that you've identified where using address_hash
has a downside or where we'd end up needing the pre-image map?
(I think this should get more than my approval before merge)
One thing I will bring up is currently there is no mechanism to obtain a pre-image map from any of the Portal Networks. So I don't think this change adds a downside as the pre-images weren't obtainable in the first place. |
If we were to provide pre-image mappings I think that should be its own Portal network, like the transaction index network The Portal Address mapping network or something |
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.
I support this change. The address is currently used only as part of the content-key, and can't be obtained if one doesn't have it. So using address_hash doesn't seem to have any downsides (except making keys 12 bytes longer, which is negligible) while it has benefits.
This PR should also fix the test vectors in state-network-test-vectors.md.
Once merged, we should also update files in portal-spec-tests
repo.
state/state-network.md
Outdated
@@ -209,7 +209,7 @@ content_for_retrieval := Container(node: TrieNode) | |||
These data types represent a node from an individual contract storage trie. | |||
|
|||
``` | |||
storage_trie_node_key := Container(address: Address, path: Nibbles, node_hash: Bytes32) | |||
storage_trie_node_key := Container(address_hash: keccak(Address), path: Nibbles, node_hash: Bytes32) |
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.
nit: In my opinion, this should be: address_hash: AddressHash
and in the "Helper Data Types" section above, you would define AddressHash := Bytes32
with brief explanation.
state/state-network.md
Outdated
@@ -129,6 +129,14 @@ Examples: | |||
[1, 2, a, b, c] -> [0x11, 0x2a, 0xbc] | |||
``` | |||
|
|||
##### Address Hash | |||
|
|||
An address hash is a sha256 of an Ethereum Address |
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.
Is it not keccak?
Ok I have PR's for |
I have no objections to this change. When implementing the Fluffy state bridge I found the need to store the account preimages so that I could get the address for a given addressHash in order to build contract trie and contract code offers. With this change we can likely save space by avoid the requirement to store preimages. Looks good to me. |
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.
Approved 👍
Issue
Currently you can't walk or download a whole state snapshot from the State Portal network. There is no way to get an address well walking the account trie. Which means it isn't possible to walk storage tries or get contracts as currently they require an address, which isn't a native concept in the execution layer.
address_hash
toaddress
mappings)How to fix this?
Instead of using the address for
storage_key
andcontract_key
use the address_hashOne of the main reasons for this is the address_hash is retrivalible from walking the account trie as the address_hash can be recovered from the path of the account.
Doing this allows us to
block + 1
of the snapshot.In short this makes the Portal State Network much more usable and more aligned with how Ethereum's state actually looks like from an Ethereum perspective