1

Currently, I am trying to test how frame-executive is working in this repo

I add some logs in executive interface impl_runtime_apis! : https://github.com/paritytech/substrate/blob/master/bin/node/runtime/src/lib.rs#L1811

Code:

impl sp_api::Core<Block> for Runtime {
    ...

    fn execute_block(block: Block) {
        log::info!("RUNTIME : GO IN EXECUTE BLOCK");
        Executive::execute_block(block);
    }

    fn initialize_block(header: &<Block as BlockT>::Header) {
        log::info!("RUNTIME : GO IN INITIALIZE BLOCK");
        Executive::initialize_block(header)
    }
}

  ...

impl sp_block_builder::BlockBuilder<Block> for Runtime {
    fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
        log::info!("RUNTIME : GO IN APPLY EXTRINSIC");
        Executive::apply_extrinsic(extrinsic)
    }

    fn finalize_block() -> <Block as BlockT>::Header {
        log::info!("RUNTIME : GO IN FINALIZE BLOCK");
        Executive::finalize_block()
    }

Result:

enter image description here

Problem:

Executive::execute_block(block); API doesn't trigger and display in the terminal (although I executed a simple transfer extrinsic)

How should I understand? How do I trigger this execute_block() API?

1 Answer 1

1

I assume you are running a one-validator network. execute_block is only called when importing blocks from the network. Blocks that the node builds itself are directly imported into the database and will not use execute_block. This should explain what you see.

When you start a second node that syncs from your first node, you should see your log message.

1
  • Yes, I am running a one-validator, it's working when I am running 2 validators. Thanks
    – CocDap
    Nov 18, 2022 at 2:47

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.