axonweb3 / axon

Axon is a Layer 2 framework of CKB with native cross-chain and interoperability.
https://axonweb3.io
MIT License
65 stars 39 forks source link

What's the position of `Metadata.CKB_RELATED_INFO_KEY`? #1565

Closed yangby-cryptape closed 11 months ago

yangby-cryptape commented 11 months ago

Question

I want to get the proof of Metadata.CKB_RELATED_INFO_KEY through eth_getProof.

What's the position (or storage keys) of it?

https://github.com/axonweb3/axon/blob/3dbfe5a515c8c46eec434d4584acec13b8d69649/core/executor/src/system_contract/metadata/store.rs#L24

https://github.com/axonweb3/axon/blob/835cb164fae28f3d200fc2a0eb790bfedd426049/core/api/README.md?plain=1#L1081-L1087 https://github.com/axonweb3/axon/blob/835cb164fae28f3d200fc2a0eb790bfedd426049/core/api/README.md?plain=1#L1910-L1917

In Further

If I'm incorrect, please point out.

I have only read some documents from the internet.

In my understand, the positions are defined as following:

contract Demo {
    uint     a = 1;
    uint128  b = 2;
    uint32   c = 3;

    /* ... omit ... */
}
storage(position = 0) is 0x0000000000000000000000000000000000000000000000000000000000000001
                                                                                          ^
storage(position = 1) is 0x0000000000000000000000000000000300000000000000000000000000000002
                                                          ^                               ^

Also, the position will be the key in the storage.

Since Axon system contracts use self-defined keys for all state variables, how could users to get those keys?

If one data has more than 256 bits, it will have more than 1 position. If data type is array or map, it's more complex. But each data for Axon system contracts has only one key, how to process these situations?

References

yangby-cryptape commented 11 months ago

Have been answered in https://github.com/axonweb3/axon/issues/1561#issuecomment-1814060202.

KaoImin commented 11 months ago

Duplicated with #1561