Skip to content
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

Need method to fetch deployment info of metadata cell on CKB #1501

Closed
ashuralyk opened this issue Oct 26, 2023 · 18 comments · Fixed by #1576 or #1640
Closed

Need method to fetch deployment info of metadata cell on CKB #1501

ashuralyk opened this issue Oct 26, 2023 · 18 comments · Fixed by #1576 or #1640

Comments

@ashuralyk
Copy link
Contributor

ashuralyk commented Oct 26, 2023

context: https://discord.com/channels/674518700518408213/1173534867296895006/1173534872044843039

@KaoImin
Copy link
Contributor

KaoImin commented Nov 1, 2023

The deployment info of metadata cell is stored in metadata system contract. Firstly, it should be set by a transaction, and then you can call the axon_getCkbRelatedInfo rpc method to get them.

@wenyuanhust
Copy link
Contributor

wenyuanhust commented Nov 6, 2023

I refers to metadata contract as the one which are responsible for managing the metadata cell on ckb of Axon-based chain.
So,for metadata cell:

  • the code hash is type id of metadata contract
  • the hash type should be type
  • the args is metadata_type_id of CkbRelatedInfo which can be got from axon_getCkbRelatedInfo
    For ckb testnet, the type id of metadata contract can be got from axon-contracts-testnet-address-info under section metadata.

@Flouse
Copy link
Contributor

Flouse commented Nov 13, 2023

  • the args is metadata_type_id of CkbRelatedInfo which can be got from axon_getCkbRelatedInfo

Test CkbRelatedInfo on axon-alphanet

curl --location --request POST 'https://rpc-alphanet-axon.ckbapp.dev/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "axon_getCkbRelatedInfo",
    "params": []
}'

Result: None CKB related info

{"jsonrpc":"2.0","error":{"code":-49999,
"message":"Internal error",
"data":"[ProtocolError] Kind: Executor, Error: None CKB related info"},
"id":42}%             

@Flouse

This comment was marked as resolved.

@blckngm

This comment was marked as off-topic.

@wenyuanhust
Copy link
Contributor

wenyuanhust commented Nov 17, 2023

steps:

  1. Create an unique metadata cell.
    As ckb-cli can not calculate type id, ckb-sdk-rust can only calculate type id for TYPE_ID.
    So I calculate type_id of metadata cell manually in axon-contract repo.

tx-hash: 0xa2a2d631aa974ceb48db92fed774ca73f2a976c12d50f1beb64a516025f3cb6f
index: 0
cell type_script:
"code_hash": 0x2c8f63ac17c1e5e660dddbf49e88994cd1c49d4d6e99e7a7fd3f8879700d3cd1
"hash_type": type
"args": 0xdb0782aba62896c2a7c279f3de8dbbd7fd06729cc8b7b499df93f5c450f61839

  1. Send a tx to set CkbRelatedInfo for system contract METADATA_CONTRACT_ADDRESS.
    I'm using hardhat to do this job, I now can send tx to alpha net, but the tx failed.
    This is the infos in axon explorer:

Transaction Hash 0xdba17b9d8ae445327a6b479ecc6527bb048651edcae13eeb8271dec1cd10e1c7
Result Error: (Awaiting internal transactions for reason)
Status Confirmed

@ashuralyk
Copy link
Contributor Author

@wenyuanhust I just want metadata cell's type script info, including its code_hash and args, I need to write them into config file of forcerelay to search on-chain metadata cell for light client verification use

@wenyuanhust
Copy link
Contributor

wenyuanhust commented Nov 20, 2023

steps:

  1. Create an unique metadata cell.
    As ckb-cli can not calculate type id, ckb-sdk-rust can only calculate type id for TYPE_ID.
    So I calculate type_id of metadata cell manually in axon-contract repo.

tx-hash: 0xa2a2d631aa974ceb48db92fed774ca73f2a976c12d50f1beb64a516025f3cb6f
index: 0
cell type_script:
"code_hash": 0x2c8f63ac17c1e5e660dddbf49e88994cd1c49d4d6e99e7a7fd3f8879700d3cd1
"hash_type": type
"args": 0xdb0782aba62896c2a7c279f3de8dbbd7fd06729cc8b7b499df93f5c450f61839

  1. Send a tx to set CkbRelatedInfo for system contract METADATA_CONTRACT_ADDRESS.
    I'm using hardhat to do this job, I now can send tx to alpha net, but the tx failed.
    This is the infos in axon explorer:

Transaction Hash 0xdba17b9d8ae445327a6b479ecc6527bb048651edcae13eeb8271dec1cd10e1c7
Result Error: (Awaiting internal transactions for reason)
Status Confirmed

@ashuralyk this is the infos about a sample metadata cell. The meatadata only contains 1 validator, with bls_key ( [0u8; 48] ).
I will modify it to the bls_keys of axon-alphanet if necessary.

@KaoImin
Copy link
Contributor

KaoImin commented Nov 23, 2023

The issue is fixed in #1576

@Flouse

This comment was marked as outdated.

@blckngm
Copy link
Contributor

blckngm commented Dec 18, 2023

Forcerelay doesn't need to get metadata cell info from axon system contract. Ibc ckb contracts would have no way to verify that the metadata cell is the same as in axon system contract. It only needs to know the type script of the metadata cell. The validity of the metadata cell must be verified by end users offchain.

For forcerelay, it's also not necessary that the metadata cell uses the metadata contract (as type script). The metadata cell could be a normal type-id cell, locked by e.g. multisig.

@blckngm
Copy link
Contributor

blckngm commented Dec 18, 2023

What's the specific documentation work needed here? Deploying metadata cell or setting/fetching deployment info of metadata cell?

@Flouse Flouse linked a pull request Dec 18, 2023 that will close this issue
3 tasks
@Flouse
Copy link
Contributor

Flouse commented Dec 18, 2023

Forcerelay doesn't need to get metadata cell info from axon system contract. Ibc ckb contracts would have no way to verify that the metadata cell is the same as in axon system contract. It only needs to know the type script of the metadata cell. The validity of the metadata cell must be verified by end users offchain.

If the Axon election feature is not activated, I think you are right. Forcerelay doesn't need axon-contract/metadata contract

forcerelay-ckb-contracts only need to know the type script of the metadata cell. The validity of the metadata cell must be verified by end users offchain.

But how? I think we need to leave a simple guide docs telling the end users how to verify it.

Related Code

@Flouse
Copy link
Contributor

Flouse commented Dec 18, 2023

What's the specific documentation work needed here? Deploying metadata cell or setting/fetching deployment info of metadata cell?

I think all we need now is the docs explaining how to create an Axon metadata cell.
The metadata cell will be used by Forcerealy.
And maybe adding a simple guide explaining how to verify it offline would be better.

@blckngm
Copy link
Contributor

blckngm commented Dec 18, 2023

But how? I think we need to leave a simple guide docs telling the end users how to verify it.

Assuming the metadata cell is a normal type-id cell (that doesn't use metadata contract), the user would need to verify two things:

  • the validators in the metadata cell is the same as the axon chain.

    The metadata cli can provide a parse-data sub-command that displays validators in a metadata cell data. (The reverse of get-data)

  • the cell is locked by a party that he trusts, so the validators wouldn't be changed to someone else.

@Flouse
Copy link
Contributor

Flouse commented Dec 18, 2023

  • the validators in the metadata cell is the same as the axon chain.
    The metadata cli can provide a parse-data sub-command that displays validators in a metadata cell data. (The reverse of get-data)
  • the cell is locked by a party that he trusts, so the validators wouldn't be changed to someone else.

LGTM, one more thing, tell the Forcerealy maintainer about the axon_metadata_type_script config?
Or add comments for axon_metadata_type_script config, leave a link pointing to the metadata deployment docs.

@ashuralyk
Copy link
Contributor Author

no need to fetch metadata cell from an official rpc method, but we really need the type script of it as the config value for forcerelay, so the question is how to get this type script

@wenyuanhust
Copy link
Contributor

wenyuanhust commented Dec 18, 2023

Forcerelay doesn't need to get metadata cell info from axon system contract. Ibc ckb contracts would have no way to verify that the metadata cell is the same as in axon system contract. It only needs to know the type script of the metadata cell. The validity of the metadata cell must be verified by end users offchain.

If the Axon election feature is not activated, I think you are right. Forcerelay doesn't need axon-contract/metadata contract

forcerelay-ckb-contracts only need to know the type script of the metadata cell. The validity of the metadata cell must be verified by end users offchain.

But how? I think we need to leave a simple guide docs telling the end users how to verify it.

Related Code

If you fetch metadata type id by axon_getCkbRelatedInfo, it means you trust the axon node. There will be no need to verify the data in the corresponding metadata cell. You get the validators by parsing metadata cell data.
Of course, if you get validators by following GuanHao's suggestion, it is ok with forcerelay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment