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

Commit

Permalink
Merge pull request #27 from Snowfork/channel-id
Browse files Browse the repository at this point in the history
Companion for ChannelID PR
  • Loading branch information
vgeddes authored Nov 14, 2023
2 parents 5fec1d3 + 42c1258 commit ee6c5e4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 31 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::*;
use codec::Encode;
use hex_literal::hex;
use integration_tests_common::{AssetHubRococoPallet, BridgeHubRococoPallet};
use snowbridge_control;
use snowbridge_router_primitives::inbound::{Command, Destination, MessageV1, VersionedMessage};
use sp_core::H256;

use snowbridge_core::outbound::OperatingMode;

const INITIAL_FUND: u128 = 5_000_000_000 * ROCOCO_ED;
const CHAIN_ID: u64 = 15;
const DEST_PARA_ID: u32 = 1000;
Expand All @@ -31,10 +34,12 @@ const ETHEREUM_DESTINATION_ADDRESS: [u8; 20] = hex!("44a57ee2f2FCcb85FDa2B0B18EB

#[test]
fn create_agent() {
let origin_para: u32 = 1001;

BridgeHubRococo::fund_accounts(vec![(
BridgeHubRococo::sovereign_account_id_of(MultiLocation {
parents: 1,
interior: X1(Parachain(DEST_PARA_ID)),
interior: X1(Parachain(origin_para)),
}),
INITIAL_FUND,
)]);
Expand All @@ -44,11 +49,11 @@ fn create_agent() {

let remote_xcm = VersionedXcm::from(Xcm(vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
DescendOrigin(X1(Parachain(DEST_PARA_ID))),
DescendOrigin(X1(Parachain(origin_para))),
Transact {
require_weight_at_most: 3000000000.into(),
origin_kind: OriginKind::Xcm,
call: vec![51, 1].into(),
call: vec![51, 2].into(),
},
]));

Expand Down Expand Up @@ -91,7 +96,9 @@ fn create_agent() {

#[test]
fn create_channel() {
let source_location = MultiLocation { parents: 1, interior: X1(Parachain(DEST_PARA_ID)) };
let origin_para: u32 = 1001;

let source_location = MultiLocation { parents: 1, interior: X1(Parachain(origin_para)) };

BridgeHubRococo::fund_accounts(vec![(
BridgeHubRococo::sovereign_account_id_of(source_location),
Expand All @@ -104,21 +111,21 @@ fn create_channel() {

let create_agent_xcm = VersionedXcm::from(Xcm(vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
DescendOrigin(X1(Parachain(DEST_PARA_ID))),
DescendOrigin(X1(Parachain(origin_para))),
Transact {
require_weight_at_most: 3000000000.into(),
origin_kind: OriginKind::Xcm,
call: vec![51, 1].into(),
call: vec![51, 2].into(),
},
]));

let create_channel_xcm = VersionedXcm::from(Xcm(vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
DescendOrigin(X1(Parachain(DEST_PARA_ID))),
DescendOrigin(X1(Parachain(origin_para))),
Transact {
require_weight_at_most: 3000000000.into(),
origin_kind: OriginKind::Xcm,
call: vec![51, 2].into(),
call: ([51u8, 3u8], OperatingMode::Normal, 1u128).encode().into(),
},
]));

Expand Down Expand Up @@ -378,21 +385,25 @@ fn reserve_transfer_token() {
);
let events = BridgeHubRococo::events();
assert!(
events.iter().find(|&event| matches!(
event,
RuntimeEvent::Balances(pallet_balances::Event::Deposit{ who, amount })
if *who == TREASURY_ACCOUNT.into() && *amount == 16903333
))
.is_some(),
events
.iter()
.find(|&event| matches!(
event,
RuntimeEvent::Balances(pallet_balances::Event::Deposit{ who, amount })
if *who == TREASURY_ACCOUNT.into() && *amount == 16903333
))
.is_some(),
"Snowbridge sovereign takes local fee."
);
assert!(
events.iter().find(|&event| matches!(
event,
RuntimeEvent::Balances(pallet_balances::Event::Deposit{ who, amount })
if *who == ASSETHUB_SOVEREIGN.into() && *amount == 2200000000000
))
.is_some(),
events
.iter()
.find(|&event| matches!(
event,
RuntimeEvent::Balances(pallet_balances::Event::Deposit{ who, amount })
if *who == ASSETHUB_SOVEREIGN.into() && *amount == 2200000000000
))
.is_some(),
"Assethub sovereign takes remote fee."
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ impl pallet_message_queue::Config for Runtime {
type ServiceWeight = MessageQueueServiceWeight;
type MessageProcessor = EthereumOutboundQueue;
type QueueChangeHandler = ();
type QueuePausedQuery = EthereumOutboundQueue;
type QueuePausedQuery = ();
type WeightInfo = ();
}

Expand Down Expand Up @@ -523,6 +523,7 @@ impl snowbridge_inbound_queue::Config for Runtime {
#[cfg(feature = "runtime-benchmarks")]
type XcmSender = DoNothingRouter;
type WeightInfo = weights::snowbridge_inbound_queue::WeightInfo<Runtime>;
type ChannelLookup = EthereumControl;
type GatewayAddress = GatewayAddress;
#[cfg(feature = "runtime-benchmarks")]
type Helper = Runtime;
Expand All @@ -544,7 +545,6 @@ impl snowbridge_outbound_queue::Config for Runtime {
type Decimals = ConstU8<12>;
type MaxMessagePayloadSize = ConstU32<2048>;
type MaxMessagesPerBlock = ConstU32<32>;
type OwnParaId = ParachainInfo;
type GasMeter = snowbridge_core::outbound::ConstantGasMeter;
type Balance = Balance;
type WeightToFee = WeightToFee;
Expand Down Expand Up @@ -604,12 +604,6 @@ impl snowbridge_ethereum_beacon_client::Config for Runtime {
type WeightInfo = weights::snowbridge_ethereum_beacon_client::WeightInfo<Runtime>;
}

parameter_types! {
// TODO: placeholder value - choose a real one
pub const MaxUpgradeDataSize: u32 = 1024;
pub const RelayNetwork: NetworkId = Rococo;
}

#[cfg(feature = "runtime-benchmarks")]
impl snowbridge_control::BenchmarkHelper<RuntimeOrigin> for () {
fn make_xcm_origin(location: xcm::latest::MultiLocation) -> RuntimeOrigin {
Expand All @@ -619,9 +613,7 @@ impl snowbridge_control::BenchmarkHelper<RuntimeOrigin> for () {

impl snowbridge_control::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OwnParaId = ParachainInfo;
type OutboundQueue = EthereumOutboundQueue;
type MessageHasher = BlakeTwo256;
type SiblingOrigin = EnsureXcm<AllowSiblingsOnly>;
type AgentIdOf = xcm_config::AgentIdOf;
type TreasuryAccount = TreasuryAccount;
Expand Down Expand Up @@ -683,7 +675,7 @@ construct_runtime!(
EthereumInboundQueue: snowbridge_inbound_queue::{Pallet, Call, Storage, Event<T>} = 48,
EthereumOutboundQueue: snowbridge_outbound_queue::{Pallet, Call, Storage, Event<T>} = 49,
EthereumBeaconClient: snowbridge_ethereum_beacon_client::{Pallet, Call, Storage, Event<T>} = 50,
EthereumControl: snowbridge_control::{Pallet, Call, Storage, Event<T>} = 51,
EthereumControl: snowbridge_control::{Pallet, Call, Storage, Config<T>, Event<T>} = 51,

// Message Queue. Registered after EthereumOutboundQueue so that their `on_initialize` handlers
// run in the desired order.
Expand Down
5 changes: 5 additions & 0 deletions cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ pub mod rococo {
owner: bridges_pallet_owner,
..Default::default()
},
ethereum_control: bridge_hub_rococo_runtime::EthereumControlConfig {
para_id: id,
asset_hub_para_id: 1000.into(),
..Default::default()
},
}
}
}
Expand Down

0 comments on commit ee6c5e4

Please sign in to comment.