Expand description
Pezpallet for committing outbound messages for delivery to Ethereum
§Overview
Messages come either from sibling teyrchains via XCM, or BridgeHub itself
via the pezsnowbridge-pezpallet-system:
pezsnowbridge_outbound_queue_primitives::v1::EthereumBlobExporter::deliverpezsnowbridge_pezpallet_system::Pezpallet::send
The message submission pipeline works like this:
- The message is first validated via the implementation for
pezsnowbridge_outbound_queue_primitives::v1::SendMessage::validate - The message is then enqueued for later processing via the implementation for
pezsnowbridge_outbound_queue_primitives::v1::SendMessage::deliver - The underlying message queue is implemented by
Config::MessageQueue - The message queue delivers messages back to this pezpallet via the implementation for
pezframe_support::traits::ProcessMessage::process_message - The message is processed in
Pezpallet::do_process_message: a. Assigned a nonce b. ABI-encoded, hashed, and stored in theMessageLeavesvector - At the end of the block, a merkle root is constructed from all the leaves in
MessageLeaves. - This merkle root is inserted into the teyrchain header as a digest item
- Offchain relayers are able to relay the message to Ethereum after: a. Generating a merkle
proof for the committed message using the
prove_messageruntime API b. Reading the actual message content from theMessagesvector in storage
On the Ethereum side, the message root is ultimately the thing being verified by the Pezkuwi light client.
§Message Priorities
The processing of governance commands can never be halted. This effectively allows us to pause processing of normal user messages while still allowing governance commands to be sent to Ethereum.
§Fees
An upfront fee must be paid for delivering a message. This fee covers several components:
- The weight of processing the message locally
- The gas refund paid out to relayers for message submission
- An additional reward paid out to relayers for message submission
Messages are weighed to determine the maximum amount of gas they could consume on Ethereum. Using this upper bound, a final fee can be calculated.
The fee calculation also requires the following parameters:
- Average ETH/HEZ exchange rate over some period
- Max fee per unit of gas that bridge is willing to refund relayers for
By design, it is expected that governance should manually update these
parameters every few weeks using the set_pricing_parameters extrinsic in the
system pezpallet.
This is an interim measure. Once ETH/HEZ liquidity pools are available in the Pezkuwi network, we’ll use them as a source of pricing info, subject to certain safeguards.
§Fee Computation Function
LocalFee(Message) = WeightToFee(ProcessMessageWeight(Message))
RemoteFee(Message) = MaxGasRequired(Message) * Params.MaxFeePerGas + Params.Reward
RemoteFeeAdjusted(Message) = Params.Multiplier * (RemoteFee(Message) / Params.Ratio("ETH/HEZ"))
Fee(Message) = LocalFee(Message) + RemoteFeeAdjusted(Message)By design, the computed fee includes a safety factor (the Multiplier) to cover
unfavourable fluctuations in the ETH/HEZ exchange rate.
§Fee Settlement
On the remote side, in the gateway contract, the relayer accrues
Min(GasPrice, Message.MaxFeePerGas) * GasUsed() + Message.RewardOr in plain english, relayers are refunded for gas consumption, using a
price that is a minimum of the actual gas price, or Message.MaxFeePerGas.
§Extrinsics
Call::set_operating_mode: Set the operating mode
§Runtime API
prove_message: Generate a merkle proof for a committed messagecalculate_fee: Calculate the delivery fee for a message
Re-exports§
pub use types::CommittedMessage;pub use types::ProcessMessageOriginOf;pub use weights::WeightInfo;pub use pezpallet::*;
Modules§
- api
- Helpers for implementing runtime api
- pezpallet
- The
pezpalletmodule in each FRAME pezpallet hosts the most important items needed to construct this pezpallet. - process_
message_ impl - Implementation for
pezframe_support::traits::ProcessMessage - send_
message_ impl - Implementation for
pezsnowbridge_outbound_queue_primitives::v1::SendMessage - types
- weights
- Autogenerated weights for
pezsnowbridge-pezpallet-outbound-queue