Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Remove redundant address (#49)
Browse files Browse the repository at this point in the history
* Fix compile error

* Load PricingParameters from control

* Load InboundDeliveryCost from EthereumInboundQueue

* Allow utility calls

* Fix integration tests

* Remove createAssetExecutionFee

* Fix breaking test

* fix benchmark weights

---------

Co-authored-by: Vincent Geddes <[email protected]>
  • Loading branch information
2 people authored and claravanstaden committed Dec 4, 2023
1 parent 468a2a1 commit 87e28a2
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ const TREASURY_ACCOUNT: [u8; 32] =
hex!("6d6f646c70792f74727372790000000000000000000000000000000000000000");
const WETH: [u8; 20] = hex!("87d1f7fdfEe7f651FaBc8bFCB6E086C278b77A7d");
const ETHEREUM_DESTINATION_ADDRESS: [u8; 20] = hex!("44a57ee2f2FCcb85FDa2B0B18EBD0D8D2333700e");
const XCM_FEE: u128 = 4_000_000_000;

#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
pub enum ControlCall {
#[codec(index = 2)]
CreateAgent,
#[codec(index = 3)]
CreateChannel { mode: OperatingMode, outbound_fee: u128 },
CreateAgent,
#[codec(index = 4)]
CreateChannel { mode: OperatingMode },
}

#[allow(clippy::large_enum_variant)]
Expand Down Expand Up @@ -133,10 +134,8 @@ fn create_channel() {
},
]));

let create_channel_call = SnowbridgeControl::Control(ControlCall::CreateChannel {
mode: OperatingMode::Normal,
outbound_fee: 1,
});
let create_channel_call =
SnowbridgeControl::Control(ControlCall::CreateChannel { mode: OperatingMode::Normal });

let create_channel_xcm = VersionedXcm::from(Xcm(vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
Expand Down Expand Up @@ -205,7 +204,7 @@ fn register_token() {
<BridgeHubRococo as BridgeHubRococoPallet>::EthereumInboundQueue;
let message = VersionedMessage::V1(MessageV1 {
chain_id: CHAIN_ID,
command: Command::RegisterToken { token: WETH.into() },
command: Command::RegisterToken { token: WETH.into(), fee: XCM_FEE },
});
let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap();
let _ = EthereumInboundQueue::send_xcm(xcm, ASSETHUB_PARA_ID.into()).unwrap();
Expand Down Expand Up @@ -294,8 +293,10 @@ fn send_token_to_penpal() {
destination: Destination::ForeignAccountId32 {
para_id: 2000,
id: PenpalAReceiver::get().into(),
fee: XCM_FEE,
},
amount: 1_000_000_000,
fee: XCM_FEE,
},
});
let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap();
Expand Down Expand Up @@ -354,7 +355,7 @@ fn send_token() {
<BridgeHubRococo as BridgeHubRococoPallet>::EthereumInboundQueue;
let message = VersionedMessage::V1(MessageV1 {
chain_id: CHAIN_ID,
command: Command::RegisterToken { token: WETH.into() },
command: Command::RegisterToken { token: WETH.into(), fee: XCM_FEE },
});
let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap();
let _ = EthereumInboundQueue::send_xcm(xcm, ASSETHUB_PARA_ID.into()).unwrap();
Expand All @@ -364,6 +365,7 @@ fn send_token() {
token: WETH.into(),
destination: Destination::AccountId32 { id: AssetHubRococoReceiver::get().into() },
amount: 1_000_000_000,
fee: XCM_FEE,
},
});
let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap();
Expand Down Expand Up @@ -409,7 +411,7 @@ fn reserve_transfer_token() {
<BridgeHubRococo as BridgeHubRococoPallet>::EthereumInboundQueue;
let message = VersionedMessage::V1(MessageV1 {
chain_id: CHAIN_ID,
command: Command::RegisterToken { token: WETH.into() },
command: Command::RegisterToken { token: WETH.into(), fee: XCM_FEE },
});
let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap();
let _ = EthereumInboundQueue::send_xcm(xcm, ASSETHUB_PARA_ID.into()).unwrap();
Expand All @@ -419,6 +421,7 @@ fn reserve_transfer_token() {
token: WETH.into(),
destination: Destination::AccountId32 { id: AssetHubRococoReceiver::get().into() },
amount: WETH_AMOUNT,
fee: XCM_FEE,
},
});
let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@ pub mod xcm_config;

use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use snowbridge_beacon_primitives::{Fork, ForkVersions};
use snowbridge_core::{outbound::Message, AgentId, AllowSiblingsOnly};
use snowbridge_core::{
gwei, meth, outbound::Message, AgentId, AllowSiblingsOnly, PricingParameters, Rewards,
};
use snowbridge_router_primitives::inbound::MessageToXcm;
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H160};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, Keccak256},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult,
ApplyExtrinsicResult, FixedU128,
};

use sp_std::prelude::*;
Expand Down Expand Up @@ -505,9 +507,12 @@ parameter_types! {
pub const Reward: u128 = 10;
pub const GatewayAddress: H160 = H160(hex_literal::hex!("EDa338E4dC46038493b885327842fD3E301CaB39"));
pub const CreateAssetCall: [u8;2] = [53, 0];
pub const CreateAssetExecutionFee: u128 = 2_000_000_000;
pub const CreateAssetDeposit: u128 = (UNITS / 10) + EXISTENTIAL_DEPOSIT;
pub const SendTokenExecutionFee: u128 = 4_000_000_000;
pub Parameters: PricingParameters<u128> = PricingParameters {
exchange_rate: FixedU128::from_rational(1, 400),
fee_per_gas: gwei(20),
rewards: Rewards { local: 1 * UNITS, remote: meth(1) }
};
}

#[cfg(feature = "runtime-benchmarks")]
Expand All @@ -521,7 +526,6 @@ impl snowbridge_inbound_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Verifier = snowbridge_ethereum_beacon_client::Pallet<Runtime>;
type Token = Balances;
type Reward = Reward;
#[cfg(not(feature = "runtime-benchmarks"))]
type XcmSender = XcmRouter;
#[cfg(feature = "runtime-benchmarks")]
Expand All @@ -530,16 +534,10 @@ impl snowbridge_inbound_queue::Config for Runtime {
type GatewayAddress = GatewayAddress;
#[cfg(feature = "runtime-benchmarks")]
type Helper = Runtime;
type MessageConverter = MessageToXcm<
CreateAssetCall,
CreateAssetExecutionFee,
CreateAssetDeposit,
SendTokenExecutionFee,
AccountId,
Balance,
>;
type MessageConverter = MessageToXcm<CreateAssetCall, CreateAssetDeposit, AccountId, Balance>;
type WeightToFee = WeightToFee;
type WeightInfo = weights::snowbridge_inbound_queue::WeightInfo<Runtime>;
type PricingParameters = EthereumControl;
}

impl snowbridge_outbound_queue::Config for Runtime {
Expand All @@ -553,6 +551,7 @@ impl snowbridge_outbound_queue::Config for Runtime {
type Balance = Balance;
type WeightToFee = WeightToFee;
type WeightInfo = weights::snowbridge_outbound_queue::WeightInfo<Runtime>;
type PricingParameters = EthereumControl;
}

#[cfg(not(feature = "beacon-spec-mainnet"))]
Expand Down Expand Up @@ -625,6 +624,8 @@ impl snowbridge_system::Config for Runtime {
type WeightInfo = weights::snowbridge_system::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type Helper = ();
type DefaultPricingParameters = Parameters;
type InboundDeliveryCost = EthereumInboundQueue;
}

// Create the runtime by composing the FRAME pallets that were previously configured.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,24 @@ impl<T: frame_system::Config> snowbridge_system::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}

/// Storage: ParachainInfo ParachainId (r:1 w:0)
/// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
/// Storage: EthereumOutboundQueue PalletOperatingMode (r:1 w:0)
/// Proof: EthereumOutboundQueue PalletOperatingMode (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen)
/// Storage: MessageQueue BookStateFor (r:1 w:1)
/// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen)
/// Storage: MessageQueue ServiceHead (r:1 w:1)
/// Proof: MessageQueue ServiceHead (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen)
/// Storage: MessageQueue Pages (r:0 w:1)
/// Proof: MessageQueue Pages (max_values: None, max_size: Some(65585), added: 68060, mode: MaxEncodedLen)
fn set_pricing_parameters() -> Weight {
// Proof Size summary in bytes:
// Measured: `80`
// Estimated: `3517`
// Minimum execution time: 31_000_000 picoseconds.
Weight::from_parts(42_000_000, 3517)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ impl Contains<RuntimeCall> for SafeCallFilter {
frame_system::Call::set_code_without_checks { .. } |
frame_system::Call::kill_prefix { .. },
) | RuntimeCall::ParachainSystem(..) |
RuntimeCall::Utility(..) |
RuntimeCall::Timestamp(..) |
RuntimeCall::Balances(..) |
RuntimeCall::CollatorSelection(
Expand Down
2 changes: 1 addition & 1 deletion cumulus/parachains/runtimes/testing/penpal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
type AssetAccountDeposit = ForeignAssetsAssetAccountDeposit;
type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = xcm_config::XcmBenchmarkHelper;
type BenchmarkHelper = ();
}

parameter_types! {
Expand Down

0 comments on commit 87e28a2

Please sign in to comment.