Skip to content

Commit

Permalink
Multiply Erc20TransferGasLimit constant by 4 for moonbase (#2768)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
2 people authored and noandrea committed Apr 18, 2024
1 parent fec46d5 commit 1a66589
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions runtime/moonbase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion runtime/moonbase/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions runtime/moonbeam/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions runtime/moonriver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/src/ERC20ExcessGas.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describeSuite({
// weight
4_000_000n,
],
gas: 300_000n,
gas: 900_000n,
rawTxOnly: true,
});

Expand Down Expand Up @@ -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,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describeSuite({
X1: { PalletInstance: Number(balancesPalletIndex) },
},
},
fungible: 1_000_000_000_000_000n,
fungible: 1_700_000_000_000_000n,
},
{
multilocation: {
Expand Down
2 changes: 1 addition & 1 deletion test/suites/dev/moonbase/test-xcm-v3/test-xcm-erc20-v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describeSuite({
X1: { PalletInstance: Number(balancesPalletIndex) },
},
},
fungible: 1_000_000_000_000_000n,
fungible: 1_100_000_000_000_000n,
},
{
multilocation: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ describeSuite({
// Destination as multilocation
destination,
// weight
500_000n,
900_000n,
],
gas: 500_000n,
gas: 900_000n,
rawTxOnly: true,
});

Expand Down
2 changes: 1 addition & 1 deletion test/suites/tracing-tests/test-trace-erc20-xcm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describeSuite({
X1: { PalletInstance: Number(balancesPalletIndex) },
},
},
fungible: 1_000_000_000_000_000n,
fungible: 1_700_000_000_000_000n,
},
{
multilocation: {
Expand Down

0 comments on commit 1a66589

Please sign in to comment.