From 1a6658926de9d27441cf1e25e22cc39b805f9e67 Mon Sep 17 00:00:00 2001 From: Rodrigo Quelhas <22591718+RomarQ@users.noreply.github.com> Date: Thu, 18 Apr 2024 23:00:46 +0100 Subject: [PATCH] Multiply Erc20TransferGasLimit constant by 4 for moonbase (#2768) * multiply Erc20TransferGasLimit constant by 4 in moonbase * fix test-xcm-erc20-v3-filter and test-xcm-erc20-fees-and-trap tests * fix test test-xcm-erc20-transfer * fix test test-xcm-erc20-v3 * fix test-xcm-erc20-excess-gas.ts * fix comment in test * fix tracing test --------- Co-authored-by: Agusrodri --- runtime/moonbase/src/lib.rs | 1 + runtime/moonbase/src/xcm_config.rs | 2 +- runtime/moonbeam/src/lib.rs | 1 + runtime/moonriver/src/lib.rs | 1 + test/contracts/src/ERC20ExcessGas.sol | 2 +- .../dev/moonbase/test-xcm-v3/test-xcm-erc20-excess-gas.ts | 8 ++++---- .../moonbase/test-xcm-v3/test-xcm-erc20-fees-and-trap.ts | 2 +- .../dev/moonbase/test-xcm-v3/test-xcm-erc20-v3-filter.ts | 2 +- test/suites/dev/moonbase/test-xcm-v3/test-xcm-erc20-v3.ts | 2 +- .../dev/moonbase/test-xcm-v4/test-xcm-erc20-transfer.ts | 4 ++-- test/suites/tracing-tests/test-trace-erc20-xcm.ts | 2 +- 11 files changed, 15 insertions(+), 12 deletions(-) diff --git a/runtime/moonbase/src/lib.rs b/runtime/moonbase/src/lib.rs index f68748d2ed..61b721929a 100644 --- a/runtime/moonbase/src/lib.rs +++ b/runtime/moonbase/src/lib.rs @@ -426,6 +426,7 @@ parameter_types! { /// ceil( /// (max_extrinsic.ref_time() / max_extrinsic.proof_size()) / WEIGHT_PER_GAS /// ) + /// We should re-check `xcm_config::Erc20XcmBridgeTransferGasLimit` when changing this value pub const GasLimitPovSizeRatio: u64 = 16; /// The amount of gas per storage (in bytes): BLOCK_GAS_LIMIT / BLOCK_STORAGE_LIMIT /// (60_000_000 / 160 kb) diff --git a/runtime/moonbase/src/xcm_config.rs b/runtime/moonbase/src/xcm_config.rs index bd05759a21..17c2ccc65c 100644 --- a/runtime/moonbase/src/xcm_config.rs +++ b/runtime/moonbase/src/xcm_config.rs @@ -691,7 +691,7 @@ parameter_types! { // To be able to support almost all erc20 implementations, // we provide a sufficiently hight gas limit. - pub Erc20XcmBridgeTransferGasLimit: u64 = 200_000; + pub Erc20XcmBridgeTransferGasLimit: u64 = 800_000; } impl pallet_erc20_xcm_bridge::Config for Runtime { diff --git a/runtime/moonbeam/src/lib.rs b/runtime/moonbeam/src/lib.rs index 4c7109e892..8dabb586ed 100644 --- a/runtime/moonbeam/src/lib.rs +++ b/runtime/moonbeam/src/lib.rs @@ -410,6 +410,7 @@ parameter_types! { /// ceil( /// (max_extrinsic.ref_time() / max_extrinsic.proof_size()) / WEIGHT_PER_GAS /// ) + /// We should re-check `xcm_config::Erc20XcmBridgeTransferGasLimit` when changing this value pub const GasLimitPovSizeRatio: u64 = 4; /// The amount of gas per storage (in bytes): BLOCK_GAS_LIMIT / BLOCK_STORAGE_LIMIT /// The current definition of BLOCK_STORAGE_LIMIT is 40 KB, resulting in a value of 366. diff --git a/runtime/moonriver/src/lib.rs b/runtime/moonriver/src/lib.rs index 186aef2b16..4dab7ad485 100644 --- a/runtime/moonriver/src/lib.rs +++ b/runtime/moonriver/src/lib.rs @@ -411,6 +411,7 @@ parameter_types! { /// ceil( /// (max_extrinsic.ref_time() / max_extrinsic.proof_size()) / WEIGHT_PER_GAS /// ) + /// We should re-check `xcm_config::Erc20XcmBridgeTransferGasLimit` when changing this value pub const GasLimitPovSizeRatio: u64 = 4; /// The amount of gas per storage (in bytes): BLOCK_GAS_LIMIT / BLOCK_STORAGE_LIMIT /// The current definition of BLOCK_STORAGE_LIMIT is 40 KB, resulting in a value of 366. diff --git a/test/contracts/src/ERC20ExcessGas.sol b/test/contracts/src/ERC20ExcessGas.sol index f8cd5aa74a..73a5d0e8bb 100644 --- a/test/contracts/src/ERC20ExcessGas.sol +++ b/test/contracts/src/ERC20ExcessGas.sol @@ -18,7 +18,7 @@ contract ERC20ExcessGas is ERC20WithInitialSupply { uint256 amount ) public override returns (bool) { // Consume gas to over Erc20XcmBridgeTransferGasLimit - for (uint i = 0; i < 500; i++) { + for (uint i = 0; i < 2000; i++) { _gasHog += i; } diff --git a/test/suites/dev/moonbase/test-xcm-v3/test-xcm-erc20-excess-gas.ts b/test/suites/dev/moonbase/test-xcm-v3/test-xcm-erc20-excess-gas.ts index 3c95fc41c3..4d5eb2f09c 100644 --- a/test/suites/dev/moonbase/test-xcm-v3/test-xcm-erc20-excess-gas.ts +++ b/test/suites/dev/moonbase/test-xcm-v3/test-xcm-erc20-excess-gas.ts @@ -63,7 +63,7 @@ describeSuite({ // weight 4_000_000n, ], - gas: 300_000n, + gas: 900_000n, rawTxOnly: true, }); @@ -235,12 +235,12 @@ describeSuite({ }, }, // Override default gas limit with optional GeneralKey. - // b'gas_limit:' + 300000(little endian) + zeros padding + // b'gas_limit:' + 900000(little endian) + zeros padding { GeneralKey: { data: [ - 103, 97, 115, 95, 108, 105, 109, 105, 116, 58, 224, 147, 4, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 103, 97, 115, 95, 108, 105, 109, 105, 116, 58, 160, 187, 13, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ], length: 32, }, diff --git a/test/suites/dev/moonbase/test-xcm-v3/test-xcm-erc20-fees-and-trap.ts b/test/suites/dev/moonbase/test-xcm-v3/test-xcm-erc20-fees-and-trap.ts index 1057caa492..0e87e1e611 100644 --- a/test/suites/dev/moonbase/test-xcm-v3/test-xcm-erc20-fees-and-trap.ts +++ b/test/suites/dev/moonbase/test-xcm-v3/test-xcm-erc20-fees-and-trap.ts @@ -175,7 +175,7 @@ describeSuite({ }) ).equals(amountTransferred); - const feeAssetAmount = 1_000_000_000_000_000n; + const feeAssetAmount = 1_100_000_000_000_000n; // Create xcm message to send ERC20 tokens to Charleth const config: XcmFragmentConfig = { diff --git a/test/suites/dev/moonbase/test-xcm-v3/test-xcm-erc20-v3-filter.ts b/test/suites/dev/moonbase/test-xcm-v3/test-xcm-erc20-v3-filter.ts index 676b466338..1e7875f263 100644 --- a/test/suites/dev/moonbase/test-xcm-v3/test-xcm-erc20-v3-filter.ts +++ b/test/suites/dev/moonbase/test-xcm-v3/test-xcm-erc20-v3-filter.ts @@ -83,7 +83,7 @@ describeSuite({ X1: { PalletInstance: Number(balancesPalletIndex) }, }, }, - fungible: 1_000_000_000_000_000n, + fungible: 1_700_000_000_000_000n, }, { multilocation: { diff --git a/test/suites/dev/moonbase/test-xcm-v3/test-xcm-erc20-v3.ts b/test/suites/dev/moonbase/test-xcm-v3/test-xcm-erc20-v3.ts index f35905ce6c..2628603c20 100644 --- a/test/suites/dev/moonbase/test-xcm-v3/test-xcm-erc20-v3.ts +++ b/test/suites/dev/moonbase/test-xcm-v3/test-xcm-erc20-v3.ts @@ -83,7 +83,7 @@ describeSuite({ X1: { PalletInstance: Number(balancesPalletIndex) }, }, }, - fungible: 1_000_000_000_000_000n, + fungible: 1_100_000_000_000_000n, }, { multilocation: { diff --git a/test/suites/dev/moonbase/test-xcm-v4/test-xcm-erc20-transfer.ts b/test/suites/dev/moonbase/test-xcm-v4/test-xcm-erc20-transfer.ts index 015c192642..01eacd6993 100644 --- a/test/suites/dev/moonbase/test-xcm-v4/test-xcm-erc20-transfer.ts +++ b/test/suites/dev/moonbase/test-xcm-v4/test-xcm-erc20-transfer.ts @@ -61,9 +61,9 @@ describeSuite({ // Destination as multilocation destination, // weight - 500_000n, + 900_000n, ], - gas: 500_000n, + gas: 900_000n, rawTxOnly: true, }); diff --git a/test/suites/tracing-tests/test-trace-erc20-xcm.ts b/test/suites/tracing-tests/test-trace-erc20-xcm.ts index 777baca63e..2125434ec4 100644 --- a/test/suites/tracing-tests/test-trace-erc20-xcm.ts +++ b/test/suites/tracing-tests/test-trace-erc20-xcm.ts @@ -74,7 +74,7 @@ describeSuite({ X1: { PalletInstance: Number(balancesPalletIndex) }, }, }, - fungible: 1_000_000_000_000_000n, + fungible: 1_700_000_000_000_000n, }, { multilocation: {