fn on_initialize(_: T::BlockNumber) -> Weight {
            let mut weight = T::SystemWeightInfo::kill_storage(1);

            // If the digest contain an existing ethereum block(encoded as PreLog), If contains,
            // execute the imported block firstly and disable transact dispatch function.
            if let Ok(log) = fp_consensus::find_pre_log(&frame_system::Pallet::<T>::digest()) {
                let PreLog::Block(block) = log;

                for transaction in block.transactions {
                    let source = Self::recover_signer(&transaction).expect(
                        "pre-block transaction signature invalid; the block cannot be built",

                    Self::validate_transaction_in_block(source, &transaction).expect(
                        "pre-block transaction verification failed; the block cannot be built",
                    let r = Self::apply_validated_transaction(source, transaction)
                        .expect("pre-block apply transaction failed; the block cannot be built");

                    weight = weight.saturating_add(r.actual_weight.unwrap_or_default());

This hook is part of the ethereum pallet defined in Frontier. I understand that in the wrapped block model, communication between the runtime and the node can be achieved through digest. It's used by the on_finalize hook to pass data about the inner block, in so the client can keep a mapping of inner to outer block up to date.

The code I quoted seems to check that the provided block is valid and then execute the transactions it contains. My problem is that I don't understand under which conditions exactly a block would be provided to the runtime by a PreRuntime DigestItem.

Also the logging of the block in the Digest in the on_finalize hook is disabled when a PreRuntime block had been found. But I cannot see how having a PreRuntime block prevent from more transactions to be added to the block through regular extrinsic execution.

Aslo, it seems to go against the 1-1 equivalence between wrapped and wrapper blocks.

1 Answer 1


The PreLog digest is not actually used in the frontier runtime by now. It's only reserved for some reasons.

  • How do you speed up the syncing while using this? I mean, you don't want to wait the full block time each time you are importing a new block. You want to run the on_initialize and then immediately the on_finalize, without waiting for any transaction to come Commented May 30, 2023 at 17:38

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.