Skip to content

Commit

Permalink
Snowbridge - Extract Ethereum Chain ID (#3501)
Browse files Browse the repository at this point in the history
While adding runtime tests to
polkadot-fellows/runtimes#130, I noticed the
Ethereum chain ID was hardcoded. For Kusama + Polkadot, the Ethereum
chain ID should 1 (Mainnet), whereas on Rococo it is 11155111 (Sepolia).

This PR also updates the Snowbridge crates versions to the current
versions on crates.io.

---------

Co-authored-by: claravanstaden <Cats 4 life!>
  • Loading branch information
claravanstaden authored Feb 28, 2024
1 parent 4261366 commit 576681b
Show file tree
Hide file tree
Showing 18 changed files with 45 additions and 30 deletions.
28 changes: 14 additions & 14 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion bridges/snowbridge/pallets/ethereum-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "snowbridge-pallet-ethereum-client"
description = "Snowbridge Ethereum Client Pallet"
version = "0.0.0"
version = "0.2.0"
authors = ["Snowfork <contact@snowfork.com>"]
edition.workspace = true
repository.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/pallets/inbound-queue/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "snowbridge-pallet-inbound-queue"
description = "Snowbridge Inbound Queue Pallet"
version = "0.0.0"
version = "0.2.0"
authors = ["Snowfork <contact@snowfork.com>"]
edition.workspace = true
repository.workspace = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "snowbridge-pallet-inbound-queue-fixtures"
description = "Snowbridge Inbound Queue Test Fixtures"
version = "0.9.0"
version = "0.10.0"
authors = ["Snowfork <contact@snowfork.com>"]
edition.workspace = true
repository.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/pallets/outbound-queue/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "snowbridge-pallet-outbound-queue"
description = "Snowbridge Outbound Queue Pallet"
version = "0.0.0"
version = "0.2.0"
authors = ["Snowfork <contact@snowfork.com>"]
edition.workspace = true
repository.workspace = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "snowbridge-outbound-queue-merkle-tree"
description = "Snowbridge Outbound Queue Merkle Tree"
version = "0.1.1"
version = "0.3.0"
authors = ["Snowfork <contact@snowfork.com>"]
edition.workspace = true
repository.workspace = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "snowbridge-outbound-queue-runtime-api"
description = "Snowbridge Outbound Queue Runtime API"
version = "0.0.0"
version = "0.2.0"
authors = ["Snowfork <contact@snowfork.com>"]
edition.workspace = true
repository.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/pallets/system/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "snowbridge-pallet-system"
description = "Snowbridge System Pallet"
version = "0.0.0"
version = "0.2.0"
authors = ["Snowfork <contact@snowfork.com>"]
edition.workspace = true
repository.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/pallets/system/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "snowbridge-system-runtime-api"
description = "Snowbridge System Runtime API"
version = "0.0.0"
version = "0.2.0"
authors = ["Snowfork <contact@snowfork.com>"]
edition.workspace = true
repository.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/primitives/beacon/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "snowbridge-beacon-primitives"
description = "Snowbridge Beacon Primitives"
version = "0.0.0"
version = "0.2.0"
authors = ["Snowfork <contact@snowfork.com>"]
edition.workspace = true
repository.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/primitives/core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "snowbridge-core"
description = "Snowbridge Core"
version = "0.0.0"
version = "0.2.0"
authors = ["Snowfork <contact@snowfork.com>"]
edition.workspace = true
repository.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/primitives/ethereum/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "snowbridge-ethereum"
description = "Snowbridge Ethereum"
version = "0.1.0"
version = "0.3.0"
authors = ["Snowfork <contact@snowfork.com>"]
edition.workspace = true
repository.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/primitives/router/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "snowbridge-router-primitives"
description = "Snowbridge Router Primitives"
version = "0.0.0"
version = "0.9.0"
authors = ["Snowfork <contact@snowfork.com>"]
edition.workspace = true
repository.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/runtime/runtime-common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "snowbridge-runtime-common"
description = "Snowbridge Runtime Common"
version = "0.0.0"
version = "0.2.0"
authors = ["Snowfork <contact@snowfork.com>"]
edition.workspace = true
repository.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/runtime/test-common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "snowbridge-runtime-test-common"
description = "Snowbridge Runtime Tests"
version = "0.0.0"
version = "0.2.0"
authors = ["Snowfork <contact@snowfork.com>"]
edition = "2021"
license = "Apache-2.0"
Expand Down
12 changes: 10 additions & 2 deletions bridges/snowbridge/runtime/test-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ where
}

pub fn send_transfer_token_message<Runtime, XcmConfig>(
ethereum_chain_id: u64,
assethub_parachain_id: u32,
weth_contract_address: H160,
destination_address: H160,
Expand Down Expand Up @@ -89,7 +90,7 @@ where
WithdrawAsset(Assets::from(vec![fee.clone()])),
BuyExecution { fees: fee, weight_limit: Unlimited },
ExportMessage {
network: Ethereum { chain_id: 11155111 },
network: Ethereum { chain_id: ethereum_chain_id },
destination: Here,
xcm: inner_xcm,
},
Expand All @@ -107,6 +108,7 @@ where
}

pub fn send_transfer_token_message_success<Runtime, XcmConfig>(
ethereum_chain_id: u64,
collator_session_key: CollatorSessionKeys<Runtime>,
runtime_para_id: u32,
assethub_parachain_id: u32,
Expand Down Expand Up @@ -149,6 +151,7 @@ pub fn send_transfer_token_message_success<Runtime, XcmConfig>(
initial_fund::<Runtime>(assethub_parachain_id, 5_000_000_000_000);

let outcome = send_transfer_token_message::<Runtime, XcmConfig>(
ethereum_chain_id,
assethub_parachain_id,
weth_contract_address,
destination_address,
Expand Down Expand Up @@ -205,6 +208,7 @@ pub fn ethereum_outbound_queue_processes_messages_before_message_queue_works<
XcmConfig,
AllPalletsWithoutSystem,
>(
ethereum_chain_id: u64,
collator_session_key: CollatorSessionKeys<Runtime>,
runtime_para_id: u32,
assethub_parachain_id: u32,
Expand Down Expand Up @@ -249,6 +253,7 @@ pub fn ethereum_outbound_queue_processes_messages_before_message_queue_works<
initial_fund::<Runtime>(assethub_parachain_id, 5_000_000_000_000);

let outcome = send_transfer_token_message::<Runtime, XcmConfig>(
ethereum_chain_id,
assethub_parachain_id,
weth_contract_address,
destination_address,
Expand Down Expand Up @@ -290,6 +295,7 @@ pub fn ethereum_outbound_queue_processes_messages_before_message_queue_works<
}

pub fn send_unpaid_transfer_token_message<Runtime, XcmConfig>(
ethereum_chain_id: u64,
collator_session_key: CollatorSessionKeys<Runtime>,
runtime_para_id: u32,
assethub_parachain_id: u32,
Expand Down Expand Up @@ -353,7 +359,7 @@ pub fn send_unpaid_transfer_token_message<Runtime, XcmConfig>(
let xcm = Xcm(vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
ExportMessage {
network: Ethereum { chain_id: 11155111 },
network: Ethereum { chain_id: ethereum_chain_id },
destination: Here,
xcm: inner_xcm,
},
Expand All @@ -375,6 +381,7 @@ pub fn send_unpaid_transfer_token_message<Runtime, XcmConfig>(

#[allow(clippy::too_many_arguments)]
pub fn send_transfer_token_message_failure<Runtime, XcmConfig>(
ethereum_chain_id: u64,
collator_session_key: CollatorSessionKeys<Runtime>,
runtime_para_id: u32,
assethub_parachain_id: u32,
Expand Down Expand Up @@ -414,6 +421,7 @@ pub fn send_transfer_token_message_failure<Runtime, XcmConfig>(
initial_fund::<Runtime>(assethub_parachain_id, initial_amount);

let outcome = send_transfer_token_message::<Runtime, XcmConfig>(
ethereum_chain_id,
assethub_parachain_id,
weth_contract_address,
destination_address,
Expand Down
2 changes: 2 additions & 0 deletions bridges/snowbridge/scripts/contribute-upstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ git checkout "$branch_name"

# remove everything we think is not required for our needs
rm -rf rust-toolchain.toml
rm -rf codecov.yml
rm -rf $SNOWBRIDGE_FOLDER/.cargo
rm -rf $SNOWBRIDGE_FOLDER/.github
rm -rf $SNOWBRIDGE_FOLDER/SECURITY.md
rm -rf $SNOWBRIDGE_FOLDER/.gitignore
rm -rf $SNOWBRIDGE_FOLDER/rustfmt.toml
rm -rf $SNOWBRIDGE_FOLDER/templates
rm -rf $SNOWBRIDGE_FOLDER/pallets/ethereum-client/fuzz

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ fn collator_session_keys() -> bridge_hub_test_utils::CollatorSessionKeys<Runtime
#[test]
pub fn transfer_token_to_ethereum_works() {
snowbridge_runtime_test_common::send_transfer_token_message_success::<Runtime, XcmConfig>(
11155111,
collator_session_keys(),
1013,
1000,
Expand All @@ -69,6 +70,7 @@ pub fn transfer_token_to_ethereum_works() {
#[test]
pub fn unpaid_transfer_token_to_ethereum_fails_with_barrier() {
snowbridge_runtime_test_common::send_unpaid_transfer_token_message::<Runtime, XcmConfig>(
11155111,
collator_session_keys(),
1013,
1000,
Expand All @@ -80,6 +82,7 @@ pub fn unpaid_transfer_token_to_ethereum_fails_with_barrier() {
#[test]
pub fn transfer_token_to_ethereum_fee_not_enough() {
snowbridge_runtime_test_common::send_transfer_token_message_failure::<Runtime, XcmConfig>(
11155111,
collator_session_keys(),
1013,
1000,
Expand All @@ -95,6 +98,7 @@ pub fn transfer_token_to_ethereum_fee_not_enough() {
#[test]
pub fn transfer_token_to_ethereum_insufficient_fund() {
snowbridge_runtime_test_common::send_transfer_token_message_failure::<Runtime, XcmConfig>(
11155111,
collator_session_keys(),
1013,
1000,
Expand Down Expand Up @@ -146,6 +150,7 @@ pub fn ethereum_outbound_queue_processes_messages_before_message_queue_works() {
XcmConfig,
AllPalletsWithoutSystem,
>(
11155111,
collator_session_keys(),
1013,
1000,
Expand Down

0 comments on commit 576681b

Please sign in to comment.