Skip to content

Conversation

@dharjeezy
Copy link
Contributor

This PR introduces modification to pallet-revive for handling System Log messages as Inherent. It also provides some modification to pallet-revive-eth-rpc for processing SystemLogDispatch extrinsics and extracting ContractEmmitted event from it.

  1. pallet-revive Modifications:

    • Introduced inherent_handlers.rs defining two traits:
      • InherentHandler: Implemented by pallets that can process system messages. It Requires handler_name() and handle_message().
      • InherentHandlers: Implemented for tuples of InherentHandlers (using impl_for_tuples) to provide dispatching logic. Requires is_valid_handler() and dispatch_message().
    • Added SystemLogMessage struct (handler_name, raw_message) to pallet-revive.
    • Added an unsigned extrinsic system_log_dispatch(message: SystemLogMessage) to pallet-revive.
    • Implemented ValidateUnsigned for pallet-revive to validate system_log_dispatch calls by checking T::InherentHandlers::is_valid_handler(&message.handler_name).
    • Added type InherentHandlers to pallet-revive::Config. The runtime configures this with a tuple containing the handler pallets (e.g., (pallet_hyperbridge_verifier::Pallet<Runtime>,)).
  2. pallet-revive-eth-rpc (receipt_extractor.rs) Modifications:

    • Added extract_from_system_log function specifically for SystemLogDispatch extrinsics. This function:
      • Retrieves associated events.
      • Extracts ContractEmitted logs from the events using the same logic as extract_from_extrinsic.
      • Constructs and returns a ReceiptInfo (paired with a default TransactionSigned).
    • Modified extract_from_block to iterate through extrinsics, attempt to decode first as EthTransact (calling extract_from_extrinsic), and if that fails, attempt to decode as SystemLogDispatch (calling extract_from_system_log).
    • Modified extract_from_transaction similarly to handle both extrinsic types based on index.

…rent-handler-in-pallet-revive

# Conflicts:
#	substrate/frame/revive/rpc/src/receipt_extractor.rs
…rent-handler-in-pallet-revive

# Conflicts:
#	substrate/frame/revive/rpc/src/receipt_extractor.rs
fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity {
if let Call::system_log_dispatch { message } = call {
ensure!(T::InherentHandlers::is_valid_handler(&message.handler_name), InvalidTransaction::Call);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are meant to execute the inherent so only valid ones end up in the block

///
/// Pallets implementing this trait register themselves as potential handlers for messages
/// identified by a unique `name`.
pub trait InherentHandler {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, could we find a different naming around InherentHandler?

Just to avoid confusion with existing Inherent concept - extrinsics that are inherently added to each block. (InherentData, InherentIdentifier, ProvideInherent, ...)

@dharjeezy dharjeezy requested a review from Wizdave97 November 4, 2025 12:40
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

Successfully merging this pull request may close these issues.

3 participants