From bfa8b5984ac1ddc224dd5fe134e2b5ce8de37552 Mon Sep 17 00:00:00 2001 From: ron Date: Fri, 12 Apr 2024 19:46:19 +0800 Subject: [PATCH 1/7] Fix emulated test sending token to penpal --- relayer/cmd/generate_beacon_data.go | 7 +- smoketest/Cargo.lock | 119 +++++++++++++----- smoketest/src/constants.rs | 4 + smoketest/tests/send_token_to_penpal.rs | 14 ++- .../test/scripts/configure-substrate.sh | 11 ++ web/packages/test/scripts/set-env.sh | 2 + 6 files changed, 118 insertions(+), 39 deletions(-) diff --git a/relayer/cmd/generate_beacon_data.go b/relayer/cmd/generate_beacon_data.go index c2300df2ae..27eec465d5 100644 --- a/relayer/cmd/generate_beacon_data.go +++ b/relayer/cmd/generate_beacon_data.go @@ -83,6 +83,7 @@ func generateInboundFixtureCmd() *cobra.Command { cmd.Flags().String("url", "http://127.0.0.1:9596", "Beacon URL") cmd.Flags().Uint32("nonce", 1, "Nonce of the inbound message") cmd.Flags().String("test_case", "register_token", "Inbound test case") + cmd.Flags().String("execution_relay_config", "/tmp/snowbridge/execution-relay-asset-hub.json", "Config file of execution relayer") return cmd } @@ -675,7 +676,11 @@ func generateInboundFixture(cmd *cobra.Command, _ []string) error { client := api.NewBeaconClient(endpoint, conf.Source.Beacon.Spec.SlotsInEpoch) s := syncer.New(client, conf.Source.Beacon.Spec, &store) - viper.SetConfigFile("/tmp/snowbridge/execution-relay-asset-hub.json") + executionRelayConfig, err := cmd.Flags().GetString("execution_relay_config") + if err != nil { + return err + } + viper.SetConfigFile(executionRelayConfig) if err = viper.ReadInConfig(); err != nil { return err diff --git a/smoketest/Cargo.lock b/smoketest/Cargo.lock index b8d924c190..47cb426d7b 100644 --- a/smoketest/Cargo.lock +++ b/smoketest/Cargo.lock @@ -457,7 +457,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -491,7 +491,7 @@ checksum = "823b8bb275161044e2ac7a25879cb3e2480cb403e3943022c7c769c599b756aa" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -896,6 +896,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "common-path" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2382f75942f4b3be3690fe4f86365e9c853c1587d6ee58212cebf6e2a9ccd101" + [[package]] name = "concurrent-queue" version = "2.4.0" @@ -1124,7 +1130,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -1172,7 +1178,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -1194,7 +1200,7 @@ checksum = "1d1545d67a2149e1d93b7e5c7752dce5a7426eb5d1357ddcfd89336b94444f77" dependencies = [ "darling_core 0.20.5", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -1233,6 +1239,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive-syn-parse" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d65d7ce8132b7c0e54497a4d9a55a1c2a0912a0d786cf894472ba818fba45762" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -1276,6 +1293,33 @@ dependencies = [ "subtle", ] +[[package]] +name = "docify" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a2f138ad521dc4a2ced1a4576148a6a610b4c5923933b062a263130a6802ce" +dependencies = [ + "docify_macros", +] + +[[package]] +name = "docify_macros" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a081e51fb188742f5a7a1164ad752121abcb22874b21e2c3b0dd040c515fdad" +dependencies = [ + "common-path", + "derive-syn-parse", + "once_cell", + "proc-macro2", + "quote", + "regex", + "syn 2.0.58", + "termcolor", + "toml", + "walkdir", +] + [[package]] name = "downcast-rs" version = "1.2.0" @@ -1584,7 +1628,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.52", + "syn 2.0.58", "toml", "walkdir", ] @@ -1601,7 +1645,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -1626,7 +1670,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.52", + "syn 2.0.58", "tempfile", "thiserror", "tiny-keccak", @@ -1955,7 +1999,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -2717,9 +2761,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "lru" @@ -2952,7 +2996,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -3157,7 +3201,7 @@ checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -3259,7 +3303,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ "proc-macro2", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -3483,7 +3527,7 @@ checksum = "5fddb4f8d99b0a2ebafc65a87a69a7b9875e4b1ae1f00db265d300ef7f28bccc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -4115,7 +4159,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -4477,6 +4521,7 @@ dependencies = [ name = "sp-arithmetic" version = "23.0.0" dependencies = [ + "docify", "integer-sqrt", "num-traits", "parity-scale-codec", @@ -4556,7 +4601,7 @@ checksum = "50535e1a5708d3ba5c1195b59ebefac61cc8679c2c24716b87a86e8b7ed2e4a1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -4565,7 +4610,7 @@ version = "14.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -4681,7 +4726,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -4809,7 +4854,6 @@ dependencies = [ "smallvec", "sp-arithmetic 23.0.0", "sp-debug-derive 14.0.0", - "sp-std 14.0.0", ] [[package]] @@ -4903,7 +4947,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -4973,7 +5017,7 @@ dependencies = [ "quote", "scale-info", "subxt-metadata", - "syn 2.0.52", + "syn 2.0.58", "thiserror", "tokio", ] @@ -5003,7 +5047,7 @@ dependencies = [ "parity-scale-codec", "proc-macro-error", "subxt-codegen", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -5052,9 +5096,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", @@ -5112,6 +5156,15 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + [[package]] name = "thiserror" version = "1.0.56" @@ -5129,7 +5182,7 @@ checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -5222,7 +5275,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -5387,7 +5440,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -5706,7 +5759,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", "wasm-bindgen-shared", ] @@ -5740,7 +5793,7 @@ checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6247,7 +6300,7 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -6273,7 +6326,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -6293,5 +6346,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] diff --git a/smoketest/src/constants.rs b/smoketest/src/constants.rs index f72404a595..8fe89d0a58 100644 --- a/smoketest/src/constants.rs +++ b/smoketest/src/constants.rs @@ -53,6 +53,10 @@ lazy_static! { .expect("cannot create keypair"); pub static ref BOB_PUBLIC: [u8; 32] = (*BOB).public().into(); + pub static ref NOEXIST: Pair = Pair::from_string("//NoExist", None) + .expect("cannot create keypair"); + pub static ref NOEXIST_PUBLIC: [u8; 32] = (*NOEXIST).public().into(); + pub static ref REGISTER_TOKEN_FEE: u64 = env::var("REGISTER_TOKEN_FEE") .unwrap_or("200000000000000000".to_string()) .parse() diff --git a/smoketest/tests/send_token_to_penpal.rs b/smoketest/tests/send_token_to_penpal.rs index a09dbaf4d6..889f0e51b4 100644 --- a/smoketest/tests/send_token_to_penpal.rs +++ b/smoketest/tests/send_token_to_penpal.rs @@ -61,7 +61,7 @@ async fn send_token_to_penpal() { .unwrap(); assert_eq!(receipt.status.unwrap().as_u64(), 1u64); - let destination_fee = 4_000_000_000; + let destination_fee = 40_000_000_000; let fee = gateway .quote_send_token_fee(weth.address(), PENPAL_PARA_ID, destination_fee) .call() @@ -74,8 +74,8 @@ async fn send_token_to_penpal() { .send_token( weth.address(), PENPAL_PARA_ID, - i_gateway::MultiAddress { kind: 1, data: (*FERDIE_PUBLIC).into() }, - 4_000_000_000, + i_gateway::MultiAddress { kind: 1, data: (*NOEXIST_PUBLIC).into() }, + destination_fee, amount, ) .value(fee) @@ -86,7 +86,11 @@ async fn send_token_to_penpal() { .unwrap() .unwrap(); - println!("receipt: {:#?}", receipt); + println!( + "receipt transaction hash: {:#?}, transaction block: {:#?}", + hex::encode(receipt.transaction_hash), + receipt.block_number + ); assert_eq!(receipt.status.unwrap().as_u64(), 1u64); @@ -133,7 +137,7 @@ async fn send_token_to_penpal() { .expect("block subscription") .take(wait_for_blocks); - let penpal_expected_owner: AccountId32 = (*FERDIE_PUBLIC).into(); + let penpal_expected_owner: AccountId32 = (*NOEXIST_PUBLIC).into(); issued_event_found = false; while let Some(Ok(block)) = penpal_blocks.next().await { diff --git a/web/packages/test/scripts/configure-substrate.sh b/web/packages/test/scripts/configure-substrate.sh index c5a625d2ce..b4f911b70c 100755 --- a/web/packages/test/scripts/configure-substrate.sh +++ b/web/packages/test/scripts/configure-substrate.sh @@ -85,6 +85,16 @@ config_xcm_version() { send_governance_transact_from_relaychain $ASSET_HUB_PARAID "$call" } +config_penpal() { + # System::set_storage(CustomizableAssetFromSystemAssetHub,Ethereum) + local call=0x00040440770800eb78be69c327d8334d0927607220020109079edaa802 + send_governance_transact_from_relaychain $PENPAL_PARAID "$call" + + # foreignAssets::force_create(WETH) + local call=0x3301020209079edaa802030087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d00d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d0004 + send_governance_transact_from_relaychain $PENPAL_PARAID "$call" +} + configure_substrate() { set_gateway fund_accounts @@ -92,6 +102,7 @@ configure_substrate() { config_beacon_checkpoint open_hrmp_channels config_xcm_version + config_penpal } if [ -z "${from_start_services:-}" ]; then diff --git a/web/packages/test/scripts/set-env.sh b/web/packages/test/scripts/set-env.sh index 85481110e2..640ec8ee5e 100755 --- a/web/packages/test/scripts/set-env.sh +++ b/web/packages/test/scripts/set-env.sh @@ -53,6 +53,8 @@ export PENPAL_CHANNEL_ID="0xa69fbbae90bb6096d59b1930bbcfc8a3ef23959d226b1861deb7 export PRIMARY_GOVERNANCE_CHANNEL_ID="0x0000000000000000000000000000000000000000000000000000000000000001" export SECONDARY_GOVERNANCE_CHANNEL_ID="0x0000000000000000000000000000000000000000000000000000000000000002" +export PENPAL_PARAID="${PENPAL_PARAID:-2000}" + # Token decimal of the relaychain(KSM|ROC:12,DOT:10) export FOREIGN_TOKEN_DECIMALS=12 From 202bc9523f2364b6ce05111181ffd801455a2861 Mon Sep 17 00:00:00 2001 From: ron Date: Fri, 12 Apr 2024 21:53:02 +0800 Subject: [PATCH 2/7] Comments --- relayer/cmd/generate_beacon_data.go | 7 +------ smoketest/tests/send_token_to_penpal.rs | 2 ++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/relayer/cmd/generate_beacon_data.go b/relayer/cmd/generate_beacon_data.go index 27eec465d5..c2300df2ae 100644 --- a/relayer/cmd/generate_beacon_data.go +++ b/relayer/cmd/generate_beacon_data.go @@ -83,7 +83,6 @@ func generateInboundFixtureCmd() *cobra.Command { cmd.Flags().String("url", "http://127.0.0.1:9596", "Beacon URL") cmd.Flags().Uint32("nonce", 1, "Nonce of the inbound message") cmd.Flags().String("test_case", "register_token", "Inbound test case") - cmd.Flags().String("execution_relay_config", "/tmp/snowbridge/execution-relay-asset-hub.json", "Config file of execution relayer") return cmd } @@ -676,11 +675,7 @@ func generateInboundFixture(cmd *cobra.Command, _ []string) error { client := api.NewBeaconClient(endpoint, conf.Source.Beacon.Spec.SlotsInEpoch) s := syncer.New(client, conf.Source.Beacon.Spec, &store) - executionRelayConfig, err := cmd.Flags().GetString("execution_relay_config") - if err != nil { - return err - } - viper.SetConfigFile(executionRelayConfig) + viper.SetConfigFile("/tmp/snowbridge/execution-relay-asset-hub.json") if err = viper.ReadInConfig(); err != nil { return err diff --git a/smoketest/tests/send_token_to_penpal.rs b/smoketest/tests/send_token_to_penpal.rs index 889f0e51b4..2490527191 100644 --- a/smoketest/tests/send_token_to_penpal.rs +++ b/smoketest/tests/send_token_to_penpal.rs @@ -61,6 +61,8 @@ async fn send_token_to_penpal() { .unwrap(); assert_eq!(receipt.status.unwrap().as_u64(), 1u64); + // Sending to an account non-existent so the destination_fee here should cover the ED on penpal + // https://github.com/Snowfork/polkadot-sdk/blob/68ab248801fdadef7ef4923c21d6b9d55a5f15b4/cumulus/parachains/runtimes/testing/penpal/src/lib.rs#L265 let destination_fee = 40_000_000_000; let fee = gateway .quote_send_token_fee(weth.address(), PENPAL_PARA_ID, destination_fee) From 1cbb4fa34e408c447f12d1dfed4bbb8b822ecf99 Mon Sep 17 00:00:00 2001 From: ron Date: Sat, 13 Apr 2024 09:33:00 +0800 Subject: [PATCH 3/7] Print the beneficiary --- smoketest/tests/send_token.rs | 6 ++++-- web/packages/test/scripts/configure-substrate.sh | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/smoketest/tests/send_token.rs b/smoketest/tests/send_token.rs index e0063d9391..3733c7b98c 100644 --- a/smoketest/tests/send_token.rs +++ b/smoketest/tests/send_token.rs @@ -57,13 +57,15 @@ async fn send_token() { .await .unwrap(); + println!("beneficiary: {:#?}", hex::encode::>((*NOEXIST_PUBLIC).into())); + // Lock tokens into vault let amount: u128 = U256::from(value).low_u128(); let receipt = gateway .send_token( weth.address(), ASSET_HUB_PARA_ID, - i_gateway::MultiAddress { kind: 1, data: (*BOB_PUBLIC).into() }, + i_gateway::MultiAddress { kind: 1, data: (*NOEXIST_PUBLIC).into() }, destination_fee, amount, ) @@ -104,7 +106,7 @@ async fn send_token() { AccountKey20 { network: None, key: WETH_CONTRACT.into() }, ), }; - let expected_owner: AccountId32 = (*BOB_PUBLIC).into(); + let expected_owner: AccountId32 = (*NOEXIST_PUBLIC).into(); let mut issued_event_found = false; while let Some(Ok(block)) = blocks.next().await { diff --git a/web/packages/test/scripts/configure-substrate.sh b/web/packages/test/scripts/configure-substrate.sh index b4f911b70c..80b851a8e6 100755 --- a/web/packages/test/scripts/configure-substrate.sh +++ b/web/packages/test/scripts/configure-substrate.sh @@ -91,7 +91,7 @@ config_penpal() { send_governance_transact_from_relaychain $PENPAL_PARAID "$call" # foreignAssets::force_create(WETH) - local call=0x3301020209079edaa802030087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d00d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d0004 + local call=0x3301020209079edaa802030087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d00d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d0104 send_governance_transact_from_relaychain $PENPAL_PARAID "$call" } From e1d4c1495f8b336183ebe330aeedaa9c9ccbd29a Mon Sep 17 00:00:00 2001 From: ron Date: Tue, 16 Apr 2024 10:23:27 +0800 Subject: [PATCH 4/7] Remove changes unnecessary --- smoketest/tests/send_token_to_penpal.rs | 16 +++++----------- web/packages/test/scripts/configure-substrate.sh | 1 - 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/smoketest/tests/send_token_to_penpal.rs b/smoketest/tests/send_token_to_penpal.rs index 2490527191..a09dbaf4d6 100644 --- a/smoketest/tests/send_token_to_penpal.rs +++ b/smoketest/tests/send_token_to_penpal.rs @@ -61,9 +61,7 @@ async fn send_token_to_penpal() { .unwrap(); assert_eq!(receipt.status.unwrap().as_u64(), 1u64); - // Sending to an account non-existent so the destination_fee here should cover the ED on penpal - // https://github.com/Snowfork/polkadot-sdk/blob/68ab248801fdadef7ef4923c21d6b9d55a5f15b4/cumulus/parachains/runtimes/testing/penpal/src/lib.rs#L265 - let destination_fee = 40_000_000_000; + let destination_fee = 4_000_000_000; let fee = gateway .quote_send_token_fee(weth.address(), PENPAL_PARA_ID, destination_fee) .call() @@ -76,8 +74,8 @@ async fn send_token_to_penpal() { .send_token( weth.address(), PENPAL_PARA_ID, - i_gateway::MultiAddress { kind: 1, data: (*NOEXIST_PUBLIC).into() }, - destination_fee, + i_gateway::MultiAddress { kind: 1, data: (*FERDIE_PUBLIC).into() }, + 4_000_000_000, amount, ) .value(fee) @@ -88,11 +86,7 @@ async fn send_token_to_penpal() { .unwrap() .unwrap(); - println!( - "receipt transaction hash: {:#?}, transaction block: {:#?}", - hex::encode(receipt.transaction_hash), - receipt.block_number - ); + println!("receipt: {:#?}", receipt); assert_eq!(receipt.status.unwrap().as_u64(), 1u64); @@ -139,7 +133,7 @@ async fn send_token_to_penpal() { .expect("block subscription") .take(wait_for_blocks); - let penpal_expected_owner: AccountId32 = (*NOEXIST_PUBLIC).into(); + let penpal_expected_owner: AccountId32 = (*FERDIE_PUBLIC).into(); issued_event_found = false; while let Some(Ok(block)) = penpal_blocks.next().await { diff --git a/web/packages/test/scripts/configure-substrate.sh b/web/packages/test/scripts/configure-substrate.sh index 80b851a8e6..0c5a2880c0 100755 --- a/web/packages/test/scripts/configure-substrate.sh +++ b/web/packages/test/scripts/configure-substrate.sh @@ -102,7 +102,6 @@ configure_substrate() { config_beacon_checkpoint open_hrmp_channels config_xcm_version - config_penpal } if [ -z "${from_start_services:-}" ]; then From 02ab816ba99bc009362b1836ba828a20826ae2c1 Mon Sep 17 00:00:00 2001 From: ron Date: Tue, 16 Apr 2024 10:42:34 +0800 Subject: [PATCH 5/7] Adding rfc --- rfc/Deposit fee to beneficiary.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 rfc/Deposit fee to beneficiary.md diff --git a/rfc/Deposit fee to beneficiary.md b/rfc/Deposit fee to beneficiary.md new file mode 100644 index 0000000000..da5e64dbce --- /dev/null +++ b/rfc/Deposit fee to beneficiary.md @@ -0,0 +1,29 @@ +# RFC: Deposit fee to beneficiary + + +## Summary + +This RFC proposes a change to make the remaining DOT trapped in pallet-xcm on AssetHub deposited to the beneficiary + +## Motivation + +- To make the remaining DOT trapped in pallet-xcm on AssetHub deposited to the beneficiary +- Another benefit is when fees left more than ED could be used to create the beneficiary account in case it does not exist. + +## Stakeholders + +## Explanation + +Currently the xcm only [deposit asset to the beneficiary](https://github.com/Snowfork/polkadot-sdk/blob/3f495e56ed01f24a29d341d8928c19cc2fd8f17e/bridges/snowbridge/primitives/router/src/inbound/mod.rs#L292-L293) and +will change to ```DepositAsset { assets: Wild(All), beneficiary }``` which includes both the asset and fees. + +## Drawbacks + +This now places a burden on the destination parachain to store excess DOT in one of their pallets, if it is not configured to than the deposit will fail and assets will be trapped. It should be fine for AssetHub because relay token(i.e. DOT) is configured as a fungible asset as https://github.com/Snowfork/polkadot-sdk/blob/3f495e56ed01f24a29d341d8928c19cc2fd8f17e/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs#L119 but may not be true for other parachains as usually no Parachain treats the system asset as the local currency. + +So we applies this change only on asset hub and not do this on the destination chain portion. + +## Testing, Security, and Privacy + +In https://github.com/Snowfork/snowbridge/pull/1174 we change the smoke test `send_token` to send weth to an non-existence account on asset hub, the test still works as expected. + From 78489ffe7098a3441f1939ca25ea8774786f417e Mon Sep 17 00:00:00 2001 From: ron Date: Tue, 16 Apr 2024 11:01:55 +0800 Subject: [PATCH 6/7] Add logs for demonstration --- rfc/Deposit fee to beneficiary.md | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/rfc/Deposit fee to beneficiary.md b/rfc/Deposit fee to beneficiary.md index da5e64dbce..a16a3b4f5f 100644 --- a/rfc/Deposit fee to beneficiary.md +++ b/rfc/Deposit fee to beneficiary.md @@ -27,3 +27,39 @@ So we applies this change only on asset hub and not do this on the destination c In https://github.com/Snowfork/snowbridge/pull/1174 we change the smoke test `send_token` to send weth to an non-existence account on asset hub, the test still works as expected. +From the xcm log we can see that both the asset and the fee deposited to the beneficiary. + +``` +2024-04-16T02:50:18.942245Z TRACE xcm::barriers: AllowTopLevelPaidExecutionFrom origin: Location { parents: 1, interior: X1([Parachain(1013)]) }, instructions: [ReceiveTeleportedAsset(Assets([Asset { id: AssetId(Location { parents: 1, interior: Here }), fun: Fungible(10000000000) }])), BuyExecution { fees: Asset { id: AssetId(Location { parents: 1, interior: Here }), fun: Fungible(10000000000) }, weight_limit: Unlimited }, DescendOrigin(X1([PalletInstance(80)])), UniversalOrigin(GlobalConsensus(Ethereum { chain_id: 11155111 })), ReserveAssetDeposited(Assets([Asset { id: AssetId(Location { parents: 2, interior: X2([GlobalConsensus(Ethereum { chain_id: 11155111 }), AccountKey20 { network: None, key: [135, 209, 247, 253, 254, 231, 246, 81, 250, 188, 139, 252, 182, 224, 134, 194, 120, 183, 122, 125] }]) }), fun: Fungible(1000000000000000000) }])), ClearOrigin, DepositAsset { assets: Wild(All), beneficiary: Location { parents: 0, interior: X1([AccountId32 { network: None, id: [40, 72, 212, 220, 228, 167, 56, 124, 15, 56, 249, 50, 168, 47, 27, 78, 215, 131, 99, 62, 18, 255, 115, 240, 65, 108, 201, 130, 181, 216, 41, 48] }]) } }], max_weight: Weight { ref_time: 14541642000, proof_size: 362278 }, properties: Properties { weight_credit: Weight { ref_time: 0, proof_size: 0 }, message_id: Some([200, 234, 242, 47, 44, 176, 123, 172, 70, 121, 223, 10, 102, 14, 113, 21, 237, 135, 252, 253, 78, 50, 172, 38, 159, 101, 64, 38, 91, 187, 210, 111]) } +2024-04-16T02:50:18.942266Z TRACE xcm::process: origin: Some(Location { parents: 1, interior: X1([Parachain(1013)]) }), total_surplus/refunded: Weight { ref_time: 0, proof_size: 0 }/Weight { ref_time: 0, proof_size: 0 }, error_handler_weight: Weight { ref_time: 0, proof_size: 0 } +2024-04-16T02:50:18.942320Z TRACE xcm::process_instruction: === ReceiveTeleportedAsset(Assets([Asset { id: AssetId(Location { parents: 1, interior: Here }), fun: Fungible(10000000000) }])) +2024-04-16T02:50:18.942327Z TRACE xcm::ensure_can_subsume_assets: worst_case_holding_len: 1, holding_limit: 64 +2024-04-16T02:50:18.942338Z TRACE xcm::contains: ConcreteAssetFromSystem asset: Asset { id: AssetId(Location { parents: 1, interior: Here }), fun: Fungible(10000000000) }, origin: Location { parents: 1, interior: X1([Parachain(1013)]) } +2024-04-16T02:50:18.942344Z TRACE xcm::fungible_adapter: can_check_in origin: Location { parents: 1, interior: X1([Parachain(1013)]) }, what: Asset { id: AssetId(Location { parents: 1, interior: Here }), fun: Fungible(10000000000) } +2024-04-16T02:50:18.942349Z TRACE xcm::fungible_adapter: check_in origin: Location { parents: 1, interior: X1([Parachain(1013)]) }, what: Asset { id: AssetId(Location { parents: 1, interior: Here }), fun: Fungible(10000000000) } +2024-04-16T02:50:18.942355Z TRACE xcm::fungibles_adapter: check_in origin: Location { parents: 1, interior: X1([Parachain(1013)]) }, what: Asset { id: AssetId(Location { parents: 1, interior: Here }), fun: Fungible(10000000000) } +2024-04-16T02:50:18.942361Z TRACE xcm::fungibles_adapter: check_in origin: Location { parents: 1, interior: X1([Parachain(1013)]) }, what: Asset { id: AssetId(Location { parents: 1, interior: Here }), fun: Fungible(10000000000) } +2024-04-16T02:50:18.942406Z TRACE xcm::fungibles_adapter: check_in origin: Location { parents: 1, interior: X1([Parachain(1013)]) }, what: Asset { id: AssetId(Location { parents: 1, interior: Here }), fun: Fungible(10000000000) } +2024-04-16T02:50:18.942414Z TRACE xcm::nonfungibles_adapter: check_in origin: Location { parents: 1, interior: X1([Parachain(1013)]) }, what: Asset { id: AssetId(Location { parents: 1, interior: Here }), fun: Fungible(10000000000) }, context: XcmContext { origin: Some(Location { parents: 1, interior: X1([Parachain(1013)]) }), message_id: [200, 234, 242, 47, 44, 176, 123, 172, 70, 121, 223, 10, 102, 14, 113, 21, 237, 135, 252, 253, 78, 50, 172, 38, 159, 101, 64, 38, 91, 187, 210, 111], topic: None } +2024-04-16T02:50:18.942431Z TRACE xcm::process_instruction: === BuyExecution { fees: Asset { id: AssetId(Location { parents: 1, interior: Here }), fun: Fungible(10000000000) }, weight_limit: Limited(Weight { ref_time: 14541642000, proof_size: 362278 }) } +2024-04-16T02:50:18.942441Z TRACE xcm::weight: UsingComponents::buy_weight weight: Weight { ref_time: 14541642000, proof_size: 362278 }, payment: AssetsInHolding { fungible: {AssetId(Location { parents: 1, interior: Here }): 10000000000}, non_fungible: {} }, context: XcmContext { origin: Some(Location { parents: 1, interior: X1([Parachain(1013)]) }), message_id: [200, 234, 242, 47, 44, 176, 123, 172, 70, 121, 223, 10, 102, 14, 113, 21, 237, 135, 252, 253, 78, 50, 172, 38, 159, 101, 64, 38, 91, 187, 210, 111], topic: None } +2024-04-16T02:50:18.942454Z TRACE xcm::process_instruction: === DescendOrigin(X1([PalletInstance(80)])) +2024-04-16T02:50:18.942460Z TRACE xcm::process_instruction: === UniversalOrigin(GlobalConsensus(Ethereum { chain_id: 11155111 })) +2024-04-16T02:50:18.942479Z TRACE xcm::process_instruction: === ReserveAssetDeposited(Assets([Asset { id: AssetId(Location { parents: 2, interior: X2([GlobalConsensus(Ethereum { chain_id: 11155111 }), AccountKey20 { network: None, key: [135, 209, 247, 253, 254, 231, 246, 81, 250, 188, 139, 252, 182, 224, 134, 194, 120, 183, 122, 125] }]) }), fun: Fungible(1000000000000000000) }])) +2024-04-16T02:50:18.942487Z TRACE xcm::ensure_can_subsume_assets: worst_case_holding_len: 2, holding_limit: 64 +2024-04-16T02:50:18.942499Z TRACE xcm::contains: IsTrustedBridgedReserveLocationForConcreteAsset asset: Asset { id: AssetId(Location { parents: 2, interior: X2([GlobalConsensus(Ethereum { chain_id: 11155111 }), AccountKey20 { network: None, key: [135, 209, 247, 253, 254, 231, 246, 81, 250, 188, 139, 252, 182, 224, 134, 194, 120, 183, 122, 125] }]) }), fun: Fungible(1000000000000000000) }, origin: Location { parents: 2, interior: X1([GlobalConsensus(Ethereum { chain_id: 11155111 })]) }, universal_source: X2([GlobalConsensus(Rococo), Parachain(1000)]) +2024-04-16T02:50:18.942508Z TRACE xcm::contains: Case asset: Asset { id: AssetId(Location { parents: 2, interior: X2([GlobalConsensus(Ethereum { chain_id: 11155111 }), AccountKey20 { network: None, key: [135, 209, 247, 253, 254, 231, 246, 81, 250, 188, 139, 252, 182, 224, 134, 194, 120, 183, 122, 125] }]) }), fun: Fungible(1000000000000000000) }, origin: Location { parents: 2, interior: X1([GlobalConsensus(Ethereum { chain_id: 11155111 })]) } +2024-04-16T02:50:18.942549Z TRACE xcm::contains: IsForeignConcreteAsset asset: Asset { id: AssetId(Location { parents: 2, interior: X2([GlobalConsensus(Ethereum { chain_id: 11155111 }), AccountKey20 { network: None, key: [135, 209, 247, 253, 254, 231, 246, 81, 250, 188, 139, 252, 182, 224, 134, 194, 120, 183, 122, 125] }]) }), fun: Fungible(1000000000000000000) }, origin: Location { parents: 2, interior: X1([GlobalConsensus(Ethereum { chain_id: 11155111 })]) } +2024-04-16T02:50:18.942576Z TRACE xcm::process_instruction: === ClearOrigin +2024-04-16T02:50:18.942582Z TRACE xcm::process_instruction: === DepositAsset { assets: Wild(All), beneficiary: Location { parents: 0, interior: X1([AccountId32 { network: None, id: [40, 72, 212, 220, 228, 167, 56, 124, 15, 56, 249, 50, 168, 47, 27, 78, 215, 131, 99, 62, 18, 255, 115, 240, 65, 108, 201, 130, 181, 216, 41, 48] }]) } } +2024-04-16T02:50:18.942595Z TRACE xcm::fungible_adapter: deposit_asset what: Asset { id: AssetId(Location { parents: 1, interior: Here }), fun: Fungible(8792406679) }, who: Location { parents: 0, interior: X1([AccountId32 { network: None, id: [40, 72, 212, 220, 228, 167, 56, 124, 15, 56, 249, 50, 168, 47, 27, 78, 215, 131, 99, 62, 18, 255, 115, 240, 65, 108, 201, 130, 181, 216, 41, 48] }]) } +2024-04-16T02:50:18.942713Z TRACE xcm::fungible_adapter: deposit_asset what: Asset { id: AssetId(Location { parents: 2, interior: X2([GlobalConsensus(Ethereum { chain_id: 11155111 }), AccountKey20 { network: None, key: [135, 209, 247, 253, 254, 231, 246, 81, 250, 188, 139, 252, 182, 224, 134, 194, 120, 183, 122, 125] }]) }), fun: Fungible(1000000000000000000) }, who: Location { parents: 0, interior: X1([AccountId32 { network: None, id: [40, 72, 212, 220, 228, 167, 56, 124, 15, 56, 249, 50, 168, 47, 27, 78, 215, 131, 99, 62, 18, 255, 115, 240, 65, 108, 201, 130, 181, 216, 41, 48] }]) } +2024-04-16T02:50:18.942723Z TRACE xcm::fungibles_adapter: deposit_asset what: Asset { id: AssetId(Location { parents: 2, interior: X2([GlobalConsensus(Ethereum { chain_id: 11155111 }), AccountKey20 { network: None, key: [135, 209, 247, 253, 254, 231, 246, 81, 250, 188, 139, 252, 182, 224, 134, 194, 120, 183, 122, 125] }]) }), fun: Fungible(1000000000000000000) }, who: Location { parents: 0, interior: X1([AccountId32 { network: None, id: [40, 72, 212, 220, 228, 167, 56, 124, 15, 56, 249, 50, 168, 47, 27, 78, 215, 131, 99, 62, 18, 255, 115, 240, 65, 108, 201, 130, 181, 216, 41, 48] }]) } +2024-04-16T02:50:18.942758Z TRACE xcm::fungibles_adapter: deposit_asset what: Asset { id: AssetId(Location { parents: 2, interior: X2([GlobalConsensus(Ethereum { chain_id: 11155111 }), AccountKey20 { network: None, key: [135, 209, 247, 253, 254, 231, 246, 81, 250, 188, 139, 252, 182, 224, 134, 194, 120, 183, 122, 125] }]) }), fun: Fungible(1000000000000000000) }, who: Location { parents: 0, interior: X1([AccountId32 { network: None, id: [40, 72, 212, 220, 228, 167, 56, 124, 15, 56, 249, 50, 168, 47, 27, 78, 215, 131, 99, 62, 18, 255, 115, 240, 65, 108, 201, 130, 181, 216, 41, 48] }]) } +2024-04-16T02:50:18.942951Z TRACE xcm::process_instruction: === SetTopic([200, 234, 242, 47, 44, 176, 123, 172, 70, 121, 223, 10, 102, 14, 113, 21, 237, 135, 252, 253, 78, 50, 172, 38, 159, 101, 64, 38, 91, 187, 210, 111]) +2024-04-16T02:50:18.942963Z TRACE xcm::execute: result: Ok(()) +2024-04-16T02:50:18.942967Z TRACE xcm::refund_surplus: total_surplus: Weight { ref_time: 0, proof_size: 0 }, total_refunded: Weight { ref_time: 0, proof_size: 0 }, current_surplus: Weight { ref_time: 0, proof_size: 0 } +2024-04-16T02:50:18.942972Z TRACE xcm::refund_surplus: total_refunded: Weight { ref_time: 0, proof_size: 0 } +2024-04-16T02:50:18.943024Z TRACE xcm::process-message: XCM message execution complete, used weight: Weight(ref_time: 14541642000, proof_size: 362278) +``` + From f7aa9614014d89109390b6dd85ab4e3e4093085f Mon Sep 17 00:00:00 2001 From: ron Date: Tue, 23 Apr 2024 10:14:15 +0800 Subject: [PATCH 7/7] Polish the rfc --- rfc/Deposit fee to beneficiary.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/rfc/Deposit fee to beneficiary.md b/rfc/Deposit fee to beneficiary.md index a16a3b4f5f..4a4dd09fa7 100644 --- a/rfc/Deposit fee to beneficiary.md +++ b/rfc/Deposit fee to beneficiary.md @@ -15,11 +15,28 @@ This RFC proposes a change to make the remaining DOT trapped in pallet-xcm on As ## Explanation Currently the xcm only [deposit asset to the beneficiary](https://github.com/Snowfork/polkadot-sdk/blob/3f495e56ed01f24a29d341d8928c19cc2fd8f17e/bridges/snowbridge/primitives/router/src/inbound/mod.rs#L292-L293) and -will change to ```DepositAsset { assets: Wild(All), beneficiary }``` which includes both the asset and fees. +will change to ```DepositAsset { assets: Wild(AllCounted(2)), beneficiary }``` which includes both the asset and fees. + +So the xcm instructions forwarded as follows: + +``` +origin: Location { parents: 1, interior: X1([Parachain(1013)]) }, +instructions: [ + ReceiveTeleportedAsset( Assets([Asset { id: AssetId(Location { parents: 1, interior: Here }), fun: Fungible(10000000000) }]) ), + BuyExecution { fees: Asset { id: AssetId(Location { parents: 1, interior: Here }), fun: Fungible(10000000000) }, weight_limit: Unlimited }, + DescendOrigin(X1([PalletInstance(80)])), + UniversalOrigin(GlobalConsensus(Ethereum { chain_id: 11155111 })), + ReserveAssetDeposited(Assets([Asset { id: AssetId(Location { parents: 2, interior: X2([GlobalConsensus(Ethereum { chain_id: 11155111 }), AccountKey20 { network: None, key: [135, 209, 247, 253, 254, 231, 246, 81, 250, 188, 139, 252, 182, 224, 134, 194, 120, 183, 122, 125] }]) }), fun: Fungible(1000000000000000000) }])), + ClearOrigin, + DepositAsset { assets: Wild(AllCounted(2)), beneficiary: Location { parents: 0, interior: X1([AccountId32 { network: None, id: [40, 72, 212, 220, 228, 167, 56, 124, 15, 56, 249, 50, 168, 47, 27, 78, 215, 131, 99, 62, 18, 255, 115, 240, 65, 108, 201, 130, 181, 216, 41, 48] }]) } } +] +``` ## Drawbacks -This now places a burden on the destination parachain to store excess DOT in one of their pallets, if it is not configured to than the deposit will fail and assets will be trapped. It should be fine for AssetHub because relay token(i.e. DOT) is configured as a fungible asset as https://github.com/Snowfork/polkadot-sdk/blob/3f495e56ed01f24a29d341d8928c19cc2fd8f17e/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs#L119 but may not be true for other parachains as usually no Parachain treats the system asset as the local currency. +This now places a burden on the destination parachain to store excess DOT in one of their pallets, if it is not configured then the deposit will fail and assets will be trapped. + +It should be fine for AssetHub because relay token(i.e. DOT) is configured as a [fungible asset](https://github.com/Snowfork/polkadot-sdk/blob/3f495e56ed01f24a29d341d8928c19cc2fd8f17e/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs#L119) but may not be true for other parachains. Usually no Parachain treats the system asset as the local currency. So we applies this change only on asset hub and not do this on the destination chain portion.