-
Notifications
You must be signed in to change notification settings - Fork 1.1k
introduce inherent handler in pallet revive #10140
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
base: master
Are you sure you want to change the base?
introduce inherent handler in pallet revive #10140
Conversation
…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); | ||
|
|
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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, ...)
This PR introduces modification to
pallet-revivefor handling System Log messages as Inherent. It also provides some modification topallet-revive-eth-rpcfor processingSystemLogDispatchextrinsics and extractingContractEmmittedevent from it.pallet-reviveModifications:inherent_handlers.rsdefining two traits:InherentHandler: Implemented by pallets that can process system messages. It Requireshandler_name()andhandle_message().InherentHandlers: Implemented for tuples ofInherentHandlers (usingimpl_for_tuples) to provide dispatching logic. Requiresis_valid_handler()anddispatch_message().SystemLogMessagestruct (handler_name,raw_message) topallet-revive.system_log_dispatch(message: SystemLogMessage)topallet-revive.ValidateUnsignedforpallet-reviveto validatesystem_log_dispatchcalls by checkingT::InherentHandlers::is_valid_handler(&message.handler_name).type InherentHandlerstopallet-revive::Config. The runtime configures this with a tuple containing the handler pallets (e.g.,(pallet_hyperbridge_verifier::Pallet<Runtime>,)).pallet-revive-eth-rpc(receipt_extractor.rs) Modifications:extract_from_system_logfunction specifically forSystemLogDispatchextrinsics. This function:ContractEmittedlogs from the events using the same logic asextract_from_extrinsic.ReceiptInfo(paired with a defaultTransactionSigned).extract_from_blockto iterate through extrinsics, attempt to decode first asEthTransact(callingextract_from_extrinsic), and if that fails, attempt to decode asSystemLogDispatch(callingextract_from_system_log).extract_from_transactionsimilarly to handle both extrinsic types based on index.