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

May need another APIs to get the proofs of Axon's system contracts #1561

Open yangby-cryptape opened 9 months ago

yangby-cryptape commented 9 months ago

Description

If I'm correct, data of system contracts could NOT be accessed or proved.

Application Scenarios

KaoImin commented 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.

yangby-cryptape commented 9 months ago

Besides, the key is a fixed string. So the proof can prove the metadata. ...

Maybe I was Wrong

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.

Let me re-explain my confusion again.

KaoImin commented 9 months ago

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.

yangby-cryptape commented 9 months ago

According to the previous comment, I think there are several new tasks:

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

yangby-cryptape commented 9 months ago

Will there be more APIS or just two?

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.

KaoImin commented 9 months ago
  • [ ] 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.

KaoImin commented 9 months ago
  • [ ] 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.

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.