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

failed call mmr_generateProof on rococo testnet #829

Closed
DaviRain-Su opened this issue Feb 18, 2023 · 6 comments
Closed

failed call mmr_generateProof on rococo testnet #829

DaviRain-Su opened this issue Feb 18, 2023 · 6 comments

Comments

@DaviRain-Su
Copy link

DaviRain-Su commented Feb 18, 2023

I use this command can get data.

echo '{"id":1,"jsonrpc":"2.0","method":"mmr_generateProof","params":[[4007966,4007967,4007968]]}' |  websocat -n1 -B 99999999 wss://rococo-rpc.polkadot.io | jq
{
  "jsonrpc": "2.0",
  "result": {
    "blockHash": "0x0da92932a52bd659ca02d601d77b184e65158f6689291a07a228a9eb8195d56a",
    "leaves": "0x0cc501001d283d00d6bfb177ba2da1ddc85cdb59fbf217823936d72f7ddc7cf9f1d7925fb5c482c4c01a00000000000067000000404ee469d464d2b306ccf0fcc5434b72128438573f3dbd60b2a858dfdc604c23ba2e764cbb91d00a30652680c87efdc9d62b923e327f2d26665d1fbfae6c996fc501001e283d00275d28e6255613f363c16276b9943cb747d68ca51fc6517955207a177a927926c01a00000000000067000000404ee469d464d2b306ccf0fcc5434b72128438573f3dbd60b2a858dfdc604c23da02014a22a002f0a227a47f5e327ff21ac3481212afbb9a5ed4ee322434f096c501001f283d009f9b54764977f597386488b8f594ac982f6384b1a54adeb9bb71c24f144dfaa8c01a00000000000067000000404ee469d464d2b306ccf0fcc5434b72128438573f3dbd60b2a858dfdc604c23a34f4fda00d2f66be85029eac144b1a05803d0444de017d4bb72c9e9299441cc",
    "proof": "0x0ca11c030000000000a21c030000000000a31c030000000000cc71050000000000487f3a5ea357c6d089112c54127d615b823af96ffafd68f00576668224b0ad48de7199b692b2e8457dfe91f1c16eaa5d4bccc79b1a4165d5885aefd6b8b70a4635d0ae76860d343d83ef1f63e99d9c4ec7d2c9351b3078ca1a7e7144944cdeda58dd9f17a6875a290895bb6604cc05e5b716df5e86f7430d61d6711475aa41f61502f1ccedb8e6ecaf36c390d88e43f621629a46c8ba44526614e256125c53dfdb5612b9e4ca1bea503c207a6b0492c6697799c33db8388335f07b46ef81a2a930b5eb70a6f5f4ec07a90a36e4bc743940dd6c2be3bfd56a1297dd7b2c113039ce2a3ce70484603cfcd04110b9beb5f2ffa3ee1d4fb88b8b1181913414a4e32b8884d836ab77259bbc1b5d14d6cb8daeb0464646363a3912d11787b4a75360fb5c6cbb7bb344df9a81989dd3aef6d8dbdfdc198239786b3b9498ebcbc3b985700a63e72001c09b668338e705e1e65d0cac8f98bee6b96f77c3f57ab127fe1f7aea272aab0fd0c3847705699e5a9da1ed7c54a4300c9428c84880bf10a5aaaca0bf9d0dbc1df2c0139a4fff51948f7f37c49ae8313cb7627c071ecb88380eb76f388b969c95941c6d64b2cf0922380ee233eaae8b2790ddb4c6aeba937c462870a5e40879beb0403bc6d57c86d16f3948224eae04c974570394c6c483764c92f5a158a301c4957e0833406cffbb1d0e7eb5ccf53c652986784a0c22b042c5eaafd729b9496fec4860eef71c045efd02b81a4ee82c48a82dd58a89bb922f4aca1bda5cbea00dff840c2e69d47f46f9b1058d0e992f9cd95f59ddd9e3aa682789eb6d"
  },
  "id": 1
}

but I used subxt, I cannot get successful response. here, is example call code.

 // test mmr_generateProof
    let method = "mmr_generateProof";
    // let block_numner: Vec<BlockNumber> = vec![0u32.into(),1u32.into(), 2u32.into()];
    let block_numner: Vec<BlockNumber> = vec![4007966u32.into(),4007967u32.into(),4007968u32.into()];
    // let block_numner: Vec<BlockNumber> = vec![30u64.into()];
    let best_known_block_number = Option::<BlockNumber>::None;
    let at = Option::<sp_core::H256>::None;
    let params = rpc_params![block_numner, best_known_block_number, at];
    let result: LeavesProof<sp_core::H256> = api.rpc().request(method, params).await?;
    println!("mmr_generateProof is {:?}", result);

and example git repo: https://github.com/DaviRain-Su/example-subxt

rococo should report this error:

panicked at 'Bad input data provided to generate_proof: Codec error', /Users/lisagunn/polkadot/runtime/rococo/src/lib.rs:963:1
2023-02-18 16:46:08 💤 Idle (1 peers), best: #419 (0xab71…a534), finalized #416 (0xad19…b62a), ⬇ 0.5kiB/s ⬆ 0.3kiB/s
@niklasad1
Copy link
Member

Hey,

Can you run the example with RUST_LOG="jsonrpsee=trace"?
Also to have identical JSON-RPC omit best_known_block_number and at from RPC call i.e,

let params = rpc_params![block_numner];

but yeah not sure what's happening here

@DaviRain-Su
Copy link
Author

DaviRain-Su commented Feb 18, 2023

Hey,

Can you run the example with RUST_LOG="jsonrpsee=trace"? Also to have identical JSON-RPC omit best_known_block_number and at from RPC call i.e,

let params = rpc_params![block_numner];

but yeah not sure what's happening here

have been try, also have problem.

2023-02-18T15:45:37.246320Z TRACE method_call{method="mmr_generateProof"}: jsonrpsee_core::tracing: send="{\"jsonrpc\":\"2.0\",\"id\":10,\"method\":\"mmr_generateProof\",\"params\":[[0,1,2]]}"
2023-02-18T15:45:37.246363Z TRACE jsonrpsee_client_transport::ws: send: {"jsonrpc":"2.0","id":10,"method":"mmr_generateProof","params":[[0,1,2]]}
2023-02-18T15:45:37.248076Z DEBUG jsonrpsee_core::client::async_client: [backend]: Client dropped
Error: Rpc(ClientError(Call(Custom(ErrorObject { code: ServerError(8000), message: "Runtime trapped", data: Some(RawValue("Application(Execution(AbortedDueToTrap(MessageWithBacktrace { message: \"wasm trap: wasm `unreachable` instruction executed\", backtrace: Some(Backtrace { backtrace_string: \"\\n    0: 0x3297a0 - <unknown>!rust_begin_unwind\\n    1: 0x5659 - <unknown>!core::panicking::panic_fmt::hd6942e22a1490f82\\n    2: 0x1f3c08 - <unknown>!MmrApi_generate_proof\\n\" }) })))")) }))))

on rococo test occur this

2023-02-18 23:45:37 Accepting new connection 1/100
2023-02-18 23:45:37 panicked at 'Bad input data provided to generate_proof: Codec error', /Users/lisagunn/polkadot/runtime/rococo/src/lib.rs:963:1
2023-02-18 23:45:37 💤 Idle (1 peers), best: #15 (0xe748…9584), finalized #12 (0xb835…68c5), ⬇ 0.6kiB/s ⬆ 0.3kiB/s

@niklasad1
Copy link
Member

niklasad1 commented Feb 19, 2023

This is really just an incorrect use of the runtime API/MMR RPC in substrate and not a subxt issue.

Sorry if I lead down a incorrect path. It looks like you are using it wrong, for historical state you have to provide a best block according to https://github.com/paritytech/substrate/blob/master/primitives/merkle-mountain-range/src/lib.rs#L432-#L438.

Try this instead:

let block_nums: Vec<BlockNumber> = vec![0u32.into(),1u32.into(), 2u32.into()];
let best_block = Some(3);
let params = rpc_params![block_nums, best_block];

If ☝️ doesn't work then I would regard it as substrate/rococo issue and please move/open a new issue in substrate.

@DaviRain-Su
Copy link
Author

If ☝️ doesn't work then I would regard it as substrate/rococo issue and please move/open a new issue in substrate.

Yet, It also don't work.

@jsdw
Copy link
Collaborator

jsdw commented Feb 20, 2023

Offhand this sounds like a Substrate issue/thing then and not a Subxt one, so any objections if I close this?

@niklasad1
Copy link
Member

Let's close this, apparently it has been around for a while paritytech/substrate#12864

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants