Open yangby-cryptape opened 9 months ago
As the annotation below:
https://github.com/axonweb3/axon/blob/3dbfe5a515c8c46eec434d4584acec13b8d69649/core/executor/src/system_contract/metadata/store.rs#L19-L42
The metadata info stores in a column of RocksDB which is different from the trie. However, the metadata trie root is stored in the storage account with the following key-value pair.
https://github.com/axonweb3/axon/blob/3dbfe5a515c8c46eec434d4584acec13b8d69649/core/executor/src/system_contract/metadata/store.rs#L41-L42
https://github.com/axonweb3/axon/blob/3dbfe5a515c8c46eec434d4584acec13b8d69649/core/executor/src/system_contract/mod.rs#L53
Besides, the key is a fixed string. So the proof can prove the metadata.
Besides, the key is a fixed string. So the proof can prove the metadata. ...
But you have just spoken your words, and didn't answer my question.
We are not that to compare whose words are more here.
- But data of system contracts are stored in another column family.
I already said they were in different column families.
The metadata info stores in a column of RocksDB which is different from the trie. However, the metadata trie root is stored in the storage account with the following key-value pair.
What's different between your words and my words?
I think you just repeated what I said.
If you have clicked the piece of code that I pasted in the issue description, you will see:
As you said above:
The metadata info stores in a column of RocksDB which is different from the trie.
Why state_mpt_tree
and storage_mpt_tree
are loaded from same trie self.trie_db
?
self.trie_db
?As I said in the previous comment, there is no doubt that we can prove the metadata_root
is in the storage trie (through the proof of METADATA_ROOT_KEY
). Now the question is how to prove a metadata contains in the metadata trie.
You're right. It's impossible to get a metadata proof through the eth_getProof
API now. Because the metadata is not directly stored in the account storage trie DB.
In order to do this, Axon need another axon_getMetadataProof
JsonRPC API. With this interface, user can get the proof of a metadata and prove the metadata contains in the metadata trie, and then prove the metadata root is in the storage trie.
According to the previous comment, I think there are several new tasks:
metadata
contract as the example in issue body, but I think how to prove data in ckb_light_client
contract or image_cell
contract is more important.eth_getProof
or eth_getStorgeAt
on incompatible contracts.
Axon could point the correct APIs to users. (ref: the next comment).p.s. I searched the discord channels, public GitHub repositories, and private GitHub repositories, didn't find any content of axon_getMetadataProof
. If developers don't write, how could users know.
ping @Flouse
In order to do this, Axon need another axon_getMetadataProof JsonRPC API. ...
Since axon_getMetadataProof
is only for metadata
contract according to its name, but ckb_light_client
contract and image_cell
contract have same problems.
axon_getMetadataStorageAt
axon_getMetadataProof
axon_getCkbLightClientStorageAt
axon_getCkbLightClientProof
(p.s. I didn't find any API for it.)axon_getImageCellStorageAt
axon_getImageCellProof
(p.s. Since contract address is not the same, account proof will be different. The code could be reused.)
- [ ]
axon_getMetadataStorageAt
- [ ]
axon_getMetadataProof
- [ ]
axon_getCkbLightClientStorageAt
- [ ]
axon_getCkbLightClientProof
(p.s. I didn't find any API for it.)- [ ]
axon_getImageCellStorageAt
- [ ]
axon_getImageCellProof
(p.s. Since contract address is not the same, account proof will be different. The code could be reused.)
I prefer these API, rather than provide two APIs axon_getSystemContractStorageAt
and axon_getSystemContractProof
.
- [ ]
axon_getMetadataStorageAt
- [ ]
axon_getMetadataProof
- [ ]
axon_getCkbLightClientStorageAt
- [ ]
axon_getCkbLightClientProof
(p.s. I didn't find any API for it.)- [ ]
axon_getImageCellStorageAt
- [ ]
axon_getImageCellProof
(p.s. Since contract address is not the same, account proof will be different. The code could be reused.)I prefer these API, rather than provide two APIs
axon_getSystemContractStorageAt
andaxon_getSystemContractProof
.
To be notice that the ckb light client and the image cell use a same column, so these two contracts should provide one pair interface like axon_getHeaderCellStorageAt
and axon_getHeaderCellProof
.
Description
When call
eth_getStorageAt
oreth_getProof
, the storage will be loaded from defaulttrie_db
.eth_getStorageAt
: https://github.com/axonweb3/axon/blob/835cb164fae28f3d200fc2a0eb790bfedd426049/core/api/src/adapter.rs#L239eth_getProof
: https://github.com/axonweb3/axon/blob/835cb164fae28f3d200fc2a0eb790bfedd426049/core/api/src/adapter.rs#L268But data of system contracts are stored in another column family.
https://github.com/axonweb3/axon/blob/835cb164fae28f3d200fc2a0eb790bfedd426049/core/executor/src/system_contract/metadata/store.rs#L31-L33 https://github.com/axonweb3/axon/blob/835cb164fae28f3d200fc2a0eb790bfedd426049/core/executor/src/system_contract/image_cell/store.rs#L29-L31 https://github.com/axonweb3/axon/blob/835cb164fae28f3d200fc2a0eb790bfedd426049/core/executor/src/system_contract/ckb_light_client/store.rs#L22-L24
If I'm correct, data of system contracts could NOT be accessed or proved.
Application Scenarios