Skip to content

Commit

Permalink
Set operating mode (#72)
Browse files Browse the repository at this point in the history
* Add calculate_fee runtime api

* update runtime config
  • Loading branch information
vgeddes authored Oct 27, 2023
1 parent 179da41 commit c175fe1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
10 changes: 7 additions & 3 deletions parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ pub use sp_runtime::{MultiAddress, Perbill, Permill};
use xcm::VersionedMultiLocation;
use xcm_config::{EthereumGatewayAddress, XcmConfig, XcmOriginToTransactDispatchOrigin};

use crate::xcm_config::RelayLocation;
use bp_parachains::SingleParaStoredHeaderDataBuilder;
use bp_runtime::HeaderId;

Expand Down Expand Up @@ -106,7 +105,7 @@ use parachains_common::{
AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION,
};
use snowbridge_beacon_primitives::{Fork, ForkVersions};
use snowbridge_core::AgentId;
use snowbridge_core::{outbound::Message, AgentId};
use snowbridge_router_primitives::inbound::MessageToXcm;
use xcm_executor::XcmExecutor;

Expand Down Expand Up @@ -634,6 +633,7 @@ impl snowbridge_outbound_queue::Config for Runtime {
type DeliveryFeePerGas = DeliveryFeePerGas;
type DeliveryRefundPerGas = DeliveryRefundPerGas;
type DeliveryReward = DeliveryReward;
type WeightToFee = WeightToFee;
type WeightInfo = weights::snowbridge_outbound_queue::WeightInfo<Runtime>;
}

Expand Down Expand Up @@ -1055,10 +1055,14 @@ impl_runtime_apis! {
}
}

impl snowbridge_outbound_queue_runtime_api::OutboundQueueApi<Block> for Runtime {
impl snowbridge_outbound_queue_runtime_api::OutboundQueueApi<Block, Balance> for Runtime {
fn prove_message(leaf_index: u64) -> Option<snowbridge_outbound_queue::MerkleProof> {
snowbridge_outbound_queue::api::prove_message::<Runtime>(leaf_index)
}

fn calculate_fee(message: Message) -> Option<Balance> {
snowbridge_outbound_queue::api::calculate_fee::<Runtime>(message)
}
}

impl snowbridge_control_runtime_api::ControlApi<Block> for Runtime {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,32 @@ impl<T: frame_system::Config> snowbridge_outbound_queue::WeightInfo for WeightIn
// Proof Size summary in bytes:
// Measured: `42`
// Estimated: `3485`
// Minimum execution time: 38_000_000 picoseconds.
Weight::from_parts(38_000_000, 0)
.saturating_add(Weight::from_parts(0, 3485))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(4))
// Minimum execution time: 39_000_000 picoseconds.
Weight::from_parts(39_000_000, 3485)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(4_u64))
}
/// Storage: EthereumOutboundQueue MessageLeaves (r:1 w:0)
/// Proof Skipped: EthereumOutboundQueue MessageLeaves (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: System Digest (r:1 w:1)
/// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured)
fn on_finalize() -> Weight {
fn commit_messages() -> Weight {
// Proof Size summary in bytes:
// Measured: `1094`
// Estimated: `2579`
// Minimum execution time: 28_000_000 picoseconds.
Weight::from_parts(28_000_000, 0)
.saturating_add(Weight::from_parts(0, 2579))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
Weight::from_parts(28_000_000, 2579)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}

fn commit_one_message() -> Weight {
// Proof Size summary in bytes:
// Measured: `1094`
// Estimated: `2579`
// Minimum execution time: 9_000_000 picoseconds.
Weight::from_parts(9_000_000, 1586)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,9 @@ impl Contains<RuntimeCall> for SafeCallFilter {
>::initialize { .. }) |
RuntimeCall::EthereumBeaconClient(
snowbridge_ethereum_beacon_client::Call::force_checkpoint { .. } |
snowbridge_ethereum_beacon_client::Call::set_owner { .. } |
snowbridge_ethereum_beacon_client::Call::set_operating_mode { .. },
) | RuntimeCall::EthereumInboundQueue(
snowbridge_inbound_queue::Call::set_owner { .. } |
snowbridge_inbound_queue::Call::set_operating_mode { .. },
snowbridge_inbound_queue::Call::set_operating_mode { .. },
) | RuntimeCall::EthereumOutboundQueue(..) |
RuntimeCall::EthereumControl(..)
)
Expand Down

0 comments on commit c175fe1

Please sign in to comment.