mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 18:01:03 +00:00
Account proof size in weight formula (#679)
* fix broken message lane benchmarks * proof-size related benchmarks * impl Size for proof parameters * include proof weight into weight formula * left TODO * fixed proof size * WeightInfoExt::receive_messages_proof_weight * charge for extra message bytes delivery in send_message * removed default impl of WeightsInfoExt * moved weight formulas to WeightInfoExt * receive_messages_proof_outbound_lane_state_overhead is included twice in weight * typo * typo * fixed TODO * more asserts * started wotk on message-lane documentation * expected_extra_storage_proof_size() is actually expected in delivery confirmation tx * update README.md * ensure_able_to_receive_confirmation * test rialto message lane weights * removed TODO * removed unnecessary trait requirements * fixed arguments * fix compilation * decreased basic delivery tx weight * fmt * clippy * Update modules/message-lane/src/benchmarking.rs Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com> * structs * Update primitives/millau/src/lib.rs Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com> * removed readme.md * removed obsolete trait bounds * Revert "removed readme.md" This reverts commit 50b7376a41687a94c27bf77565434be153f87ca1. * Update bin/runtime-common/src/messages.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Update bin/runtime-common/src/messages.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Update bin/runtime-common/src/messages.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Update bin/runtime-common/src/messages.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Update bin/runtime-common/src/messages.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Update bin/runtime-common/src/messages.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Update bin/runtime-common/src/messages.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * PreComputedSize Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com> Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
This commit is contained in:
committed by
Bastian Köcher
parent
fb7c191234
commit
2f457775bb
@@ -74,11 +74,10 @@ pub type FromMillauMessageDispatch = messages::target::FromBridgedChainMessageDi
|
||||
>;
|
||||
|
||||
/// Messages proof for Millau -> Rialto messages.
|
||||
pub type FromMillauMessagesProof = messages::target::FromBridgedChainMessagesProof<WithMillauMessageBridge>;
|
||||
pub type FromMillauMessagesProof = messages::target::FromBridgedChainMessagesProof<bp_millau::Hash>;
|
||||
|
||||
/// Messages delivery proof for Rialto -> Millau messages.
|
||||
pub type FromMillauMessagesDeliveryProof =
|
||||
messages::source::FromBridgedChainMessagesDeliveryProof<WithMillauMessageBridge>;
|
||||
pub type ToMillauMessagesDeliveryProof = messages::source::FromBridgedChainMessagesDeliveryProof<bp_millau::Hash>;
|
||||
|
||||
/// Millau <-> Rialto message bridge.
|
||||
#[derive(RuntimeDebug, Clone, Copy)]
|
||||
@@ -98,7 +97,7 @@ impl MessageBridge for WithMillauMessageBridge {
|
||||
|
||||
fn weight_limits_of_message_on_bridged_chain(message_payload: &[u8]) -> RangeInclusive<Weight> {
|
||||
// we don't want to relay too large messages + keep reserve for future upgrades
|
||||
let upper_limit = bp_millau::max_extrinsic_weight() / 2;
|
||||
let upper_limit = messages::target::maximal_incoming_message_dispatch_weight(bp_millau::max_extrinsic_weight());
|
||||
|
||||
// given Millau chain parameters (`TransactionByteFee`, `WeightToFee`, `FeeMultiplierUpdate`),
|
||||
// the minimal weight of the message may be computed as message.length()
|
||||
@@ -110,13 +109,17 @@ impl MessageBridge for WithMillauMessageBridge {
|
||||
}
|
||||
|
||||
fn weight_of_delivery_transaction(message_payload: &[u8]) -> Weight {
|
||||
let message_payload_len = u32::try_from(message_payload.len())
|
||||
.map(Into::into)
|
||||
.unwrap_or(Weight::MAX);
|
||||
let extra_bytes_in_payload =
|
||||
message_payload_len.saturating_sub(pallet_message_lane::EXPECTED_DEFAULT_MESSAGE_LENGTH.into());
|
||||
messages::transaction_weight_without_multiplier(
|
||||
bp_millau::BlockWeights::get().get(DispatchClass::Normal).base_extrinsic,
|
||||
u32::try_from(message_payload.len())
|
||||
.map(Into::into)
|
||||
.unwrap_or(Weight::MAX)
|
||||
.saturating_add(bp_rialto::EXTRA_STORAGE_PROOF_SIZE as _),
|
||||
bp_millau::MAX_SINGLE_MESSAGE_DELIVERY_TX_WEIGHT,
|
||||
message_payload_len.saturating_add(bp_rialto::EXTRA_STORAGE_PROOF_SIZE as _),
|
||||
extra_bytes_in_payload
|
||||
.saturating_mul(bp_millau::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT)
|
||||
.saturating_add(bp_millau::MAX_SINGLE_MESSAGE_DELIVERY_TX_WEIGHT),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -186,7 +189,7 @@ impl TargetHeaderChain<ToMillauMessagePayload, bp_millau::AccountId> for Millau
|
||||
// - hash of the header this proof has been created with;
|
||||
// - the storage proof of one or several keys;
|
||||
// - id of the lane we prove state of.
|
||||
type MessagesDeliveryProof = FromMillauMessagesDeliveryProof;
|
||||
type MessagesDeliveryProof = ToMillauMessagesDeliveryProof;
|
||||
|
||||
fn verify_message(payload: &ToMillauMessagePayload) -> Result<(), Self::Error> {
|
||||
messages::source::verify_chain_message::<WithMillauMessageBridge>(payload)
|
||||
|
||||
Reference in New Issue
Block a user