ethereum / portal-network-specs

Official repository for specifications for the Portal Network
313 stars 85 forks source link

Update state network to use address_hash instead of address #329

Closed KolbyML closed 3 months ago

KolbyML commented 3 months ago

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.

How to fix this?

Instead of using the address for storage_key and contract_key use the address_hash

One 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

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

KolbyML commented 3 months ago

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?

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.

KolbyML commented 3 months ago

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

KolbyML commented 3 months ago

Ok I have PR's for ethereum/trin and ethereum/portal-spec-tests so when we are ready 2 merge this PR things are in place to update Trin to match the spec

bhartnett commented 3 months ago

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.