2

In the try-runtime documentation, there is note of a follow-chain subcommand which follows the given chain’s finalized blocks and apply all of its extrinsics.

There are also some examples here.

I would like a step-by-step instruction of how to use try-runtime's follow-chain subcommand.

1 Answer 1

3

Clone repo:

git clone https://github.com/paritytech/substrate
cd substrate

Run a dev chain locally. This is the chain that I want to "follow":

cargo b -r
cp target/release/node-template .
./node-template --dev

Compile with try-runtime:

cargo b -r --features=try-runtime
cp target/release/node-template node-template-try-runtime
cp target/release/wbuild/node-template-runtime/node_template_runtime.wasm runtime-try-runtime.wasm

Run the follow-chain subcommand:

./node-template-try-runtime \
    try-runtime \
    --runtime runtime-try-runtime.wasm \ 
    -lruntime=debug \
    follow-chain \
    --uri ws://localhost:9944

You will get beautiful output like the following:

./node-template-try-runtime try-runtime --runtime runtime-try-runtime.wasm -lruntime=debug follow-chain --uri ws://localhost:9944
2023-04-07 10:15:39.620  INFO main try-runtime::cli: subscribing to "chain_subscribeFinalizedHeads" / "chain_unsubscribeFinalizedHeads"    
2023-04-07 10:15:39.633  INFO main remote-ext: since no prefix is filtered, the data for all pallets will be downloaded    
2023-04-07 10:15:39.635  INFO main remote-ext: scraping key-pairs from remote at block height 0xb651c240a9b85a0ba7fb7fa297f55c954606264cc4733ebd34249aa3c2a2b95c    
2023-04-07 10:15:39.636  INFO main remote-ext: adding data for hashed prefix: 3a6368696c645f73746f726167653a64656661756c743a, took 0s    
2023-04-07 10:15:39.636  INFO main remote-ext: Querying a total of 42 keys from prefix , splitting among 10 threads, 5 keys per thread    
2023-04-07 10:15:39.642  INFO main remote-ext: adding data for hashed prefix: , took 0s    
2023-04-07 10:15:39.642  INFO main remote-ext: adding data for hashed key: 3a636f6465    
2023-04-07 10:15:39.645  INFO main remote-ext: adding data for hashed key: 26aa394eea5630e07c48ae0c9558cef7f9cce9c888469bb1a0dceaa129672ef8    
2023-04-07 10:15:39.645  INFO main remote-ext: adding data for hashed key: 26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac    
2023-04-07 10:15:39.645  INFO main remote-ext: initialized state externalities with storage root 0x7687476066905904caba95c9cfb119793ef4d9d36f36bd7d317ee603b3e76186 and state_version V1    
2023-04-07 10:15:39.659  INFO main try-runtime::cli: original spec: RuntimeString::Owned("node-template")-100, code hash: 9fd0a02fb6e725221ae379fc4d13929c26b90efb4d817d46d7fd64274dd7bb7d    
2023-04-07 10:15:39.666  INFO main try-runtime::cli: new spec: RuntimeString::Owned("node-template")-100, code hash: 4516ccbbd02187bd17a18098c644e3723741d7f30cb75faef2974f389356f6dc    
2023-04-07 10:15:39.782  INFO main runtime::executive: try-runtime: executing block #11 / state root check: false / signature check: true / try-state-select: All    
2023-04-07 10:15:39.783 DEBUG main runtime::frame-support: 🩺 try-state pallet "System"    
2023-04-07 10:15:39.783 DEBUG main runtime::frame-support: 🩺 try-state pallet "Timestamp"    
2023-04-07 10:15:39.783 DEBUG main runtime::frame-support: 🩺 try-state pallet "Aura"    
2023-04-07 10:15:39.783 DEBUG main runtime::frame-support: 🩺 try-state pallet "Grandpa"    
2023-04-07 10:15:39.783 DEBUG main runtime::frame-support: 🩺 try-state pallet "Balances"    
2023-04-07 10:15:39.783 DEBUG main runtime::frame-support: 🩺 try-state pallet "TransactionPayment"    
2023-04-07 10:15:39.783 DEBUG main runtime::frame-support: 🩺 try-state pallet "Sudo"    
2023-04-07 10:15:39.783 DEBUG main runtime::frame-support: 🩺 try-state pallet "TemplateModule"    
2023-04-07 10:15:39.783 DEBUG main runtime::system: [11] 0 extrinsics, length: 11 (normal 0%, op: 0%, mandatory 0%) / normal weight:Weight(ref_time: 0, proof_size: 0) (0%) op weight Weight(ref_time: 0, proof_size: 0) (0%) / mandatory weight Weight(ref_time: 839311000, proof_size: 2986) (0%)    
2023-04-07 10:15:39.785  INFO main try-runtime::cli: executed block 11, consumed weight Weight(ref_time: 839311000, proof_size: 2986), new storage root 0x0dc5e9cebb0cc37a19c9a9285e3102a2977509566c5d96dddbf4dee0e48fef23    
2023-04-07 10:15:44.019  INFO main runtime::executive: try-runtime: executing block #12 / state root check: false / signature check: true / try-state-select: All    
2023-04-07 10:15:44.020 DEBUG main runtime::frame-support: 🩺 try-state pallet "System"    
2023-04-07 10:15:44.020 DEBUG main runtime::frame-support: 🩺 try-state pallet "Timestamp"    
2023-04-07 10:15:44.020 DEBUG main runtime::frame-support: 🩺 try-state pallet "Aura"    
2023-04-07 10:15:44.020 DEBUG main runtime::frame-support: 🩺 try-state pallet "Grandpa"    
2023-04-07 10:15:44.020 DEBUG main runtime::frame-support: 🩺 try-state pallet "Balances"    
2023-04-07 10:15:44.020 DEBUG main runtime::frame-support: 🩺 try-state pallet "TransactionPayment"    
2023-04-07 10:15:44.020 DEBUG main runtime::frame-support: 🩺 try-state pallet "Sudo"    
2023-04-07 10:15:44.020 DEBUG main runtime::frame-support: 🩺 try-state pallet "TemplateModule"    
2023-04-07 10:15:44.020 DEBUG main runtime::system: [12] 0 extrinsics, length: 11 (normal 0%, op: 0%, mandatory 0%) / normal weight:Weight(ref_time: 0, proof_size: 0) (0%) op weight Weight(ref_time: 0, proof_size: 0) (0%) / mandatory weight Weight(ref_time: 839311000, proof_size: 2986) (0%)    
2023-04-07 10:15:44.021  INFO main try-runtime::cli: executed block 12, consumed weight Weight(ref_time: 839311000, proof_size: 2986), new storage root 0x7f335319d53bae574dbebff262b28c02825b9c945f2e40eac472e9980758c656    

And you can see that this will continuously follow the chain!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.