From 2519798cd4b3429aea083290bc17545c754bf455 Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Wed, 2 Oct 2024 14:34:51 +0100 Subject: [PATCH 01/19] feat: added initial PoV handling config variable for frontier template --- container-chains/runtime-templates/frontier/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/container-chains/runtime-templates/frontier/src/lib.rs b/container-chains/runtime-templates/frontier/src/lib.rs index b9c3aeac4..bac733f59 100644 --- a/container-chains/runtime-templates/frontier/src/lib.rs +++ b/container-chains/runtime-templates/frontier/src/lib.rs @@ -843,6 +843,7 @@ parameter_types! { pub PrecompilesValue: TemplatePrecompiles = TemplatePrecompiles::<_>::new(); pub WeightPerGas: Weight = Weight::from_parts(WEIGHT_PER_GAS, 0); pub SuicideQuickClearLimit: u32 = 0; + pub GasLimitPovSizeRatio: u32 = 16; } impl_on_charge_evm_transaction!(); @@ -870,8 +871,7 @@ impl pallet_evm::Config for Runtime { type OnChargeTransaction = OnChargeEVMTransaction<()>; type OnCreate = (); type FindAuthor = FindAuthorAdapter; - // TODO: update in the future - type GasLimitPovSizeRatio = (); + type GasLimitPovSizeRatio = GasLimitPovSizeRatio; type SuicideQuickClearLimit = SuicideQuickClearLimit; type Timestamp = Timestamp; type WeightInfo = (); From 9ea5ad3330a70015df8e7a7e6dd00abde067b1f9 Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Mon, 7 Oct 2024 14:21:58 +0100 Subject: [PATCH 02/19] feat: updated fp_rpc::EthereumRuntimeRPCApi call function implementation --- .../runtime-templates/frontier/src/lib.rs | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/container-chains/runtime-templates/frontier/src/lib.rs b/container-chains/runtime-templates/frontier/src/lib.rs index bac733f59..aeb4aee69 100644 --- a/container-chains/runtime-templates/frontier/src/lib.rs +++ b/container-chains/runtime-templates/frontier/src/lib.rs @@ -1519,20 +1519,54 @@ impl_runtime_apis! { ) -> Result { let is_transactional = false; let validate = true; + + // Estimated encoded transaction size must be based on the heaviest transaction + // type (EIP1559Transaction) to be compatible with all transaction types. + let mut estimated_transaction_len = data.len() + + // pallet ethereum index: 1 + // transact call index: 1 + // Transaction enum variant: 1 + // chain_id 8 bytes + // nonce: 32 + // max_priority_fee_per_gas: 32 + // max_fee_per_gas: 32 + // gas_limit: 32 + // action: 21 (enum varianrt + call address) + // value: 32 + // access_list: 1 (empty vec size) + // 65 bytes signature + 258; + + if access_list.is_some() { + estimated_transaction_len += access_list.encoded_size(); + } + let gas_limit = gas_limit.min(u64::MAX.into()).low_u64(); + let without_base_extrinsic_weight = true; + let (weight_limit, proof_size_base_cost) = + match ::GasWeightMapping::gas_to_weight( + gas_limit, + without_base_extrinsic_weight + ) { + weight_limit if weight_limit.proof_size() > 0 => { + (Some(weight_limit), Some(estimated_transaction_len as u64)) + } + _ => (None, None), + }; + ::Runner::call( from, to, data, value, - gas_limit.min(u64::MAX.into()).low_u64(), + gas_limit, max_fee_per_gas, max_priority_fee_per_gas, nonce, access_list.unwrap_or_default(), is_transactional, validate, - None, - None, + weight_limit, + proof_size_base_cost, ::config(), ).map_err(|err| err.error.into()) } From 7bce549f4c26f1223d6665f75d8145922a65fd03 Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Mon, 7 Oct 2024 17:25:22 +0100 Subject: [PATCH 03/19] test: added PoV testing setup and initial PoV tests for frontier-template --- test/contracts/solidity/CallForwarder.sol | 26 +++++ test/helpers/contracts.ts | 64 +++++++++++ test/helpers/index.ts | 1 + .../test-pov/test-evm-over-pov.ts | 108 ++++++++++++++++++ .../test-pov/test-evm-over-pov2.ts | 82 +++++++++++++ 5 files changed, 281 insertions(+) create mode 100644 test/contracts/solidity/CallForwarder.sol create mode 100644 test/helpers/contracts.ts create mode 100644 test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts create mode 100644 test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts diff --git a/test/contracts/solidity/CallForwarder.sol b/test/contracts/solidity/CallForwarder.sol new file mode 100644 index 000000000..34c1b1b0c --- /dev/null +++ b/test/contracts/solidity/CallForwarder.sol @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-3.0-only +pragma solidity >=0.8.3; + +contract CallForwarder { + function call( + address target, + bytes memory data + ) public returns (bool, bytes memory) { + return target.call(data); + } + + function callRange(address first, address last) public { + require(first < last, "invalid range"); + while (first < last) { + first.call(""); + first = address(uint160(first) + 1); + } + } + + function delegateCall( + address target, + bytes memory data + ) public returns (bool, bytes memory) { + return target.delegatecall(data); + } +} \ No newline at end of file diff --git a/test/helpers/contracts.ts b/test/helpers/contracts.ts new file mode 100644 index 000000000..56c98f8f2 --- /dev/null +++ b/test/helpers/contracts.ts @@ -0,0 +1,64 @@ +import { DevModeContext } from "@moonwall/cli"; +import { ALITH_ADDRESS, alith } from "@moonwall/util"; + +export interface HeavyContract { + deployed: boolean; + account: string; + key: string; +} + +/** + * @description Deploy multiple contracts to test the EVM storage limit. + * @param context Context of the test + * @param count Number of contracts to deploy + * @returns + */ +export const deployHeavyContracts = async (context: DevModeContext, first = 6000, last = 6999) => { + // Generate the contract addresses + const contracts = await Promise.all( + new Array(last - first + 1).fill(0).map(async (_, i) => { + const account = `0x${(i + first).toString(16).padStart(40, "0")}`; + return { + deployed: false, + account, + key: context.polkadotJs().query.evm.accountCodes.key(account), + }; + }) + ); + + // Check which contracts are already deployed + for (const contract of contracts) { + contract.deployed = (await context.polkadotJs().rpc.state.getStorage(contract.key))!.toString().length > 10; + } + + // Create the contract code (24kb of zeros) + const evmCode = `60006000fd${"0".repeat(24_000 * 2)}`; + const storageData = `${context + .polkadotJs() + .registry.createType("Compact", `0x${BigInt((evmCode.length + 1) * 2).toString(16)}`) + .toHex(true)}${evmCode}`; + + // Create the batchs of contracts to deploy + const batchs = contracts + .reduce( + (acc, value) => { + if (acc[acc.length - 1].length >= 30) acc.push([]); + if (!value.deployed) acc[acc.length - 1].push([value.key, storageData]); + return acc; + }, + [[]] as [string, string][][] + ) + .filter((batch) => batch.length > 0); + + // Set the storage of the contracts + let nonce = await context.viem().getTransactionCount({ address: ALITH_ADDRESS }); + for (let i = 0; i < batchs.length; i++) { + const batch = batchs[i]; + await context.createBlock([ + context.polkadotJs().tx.sudo.sudo(context.polkadotJs().tx.system.setStorage(batch)).signAsync(alith, { + nonce: nonce++, + }), + ]); + } + return contracts as HeavyContract[]; +}; diff --git a/test/helpers/index.ts b/test/helpers/index.ts index 3c98932f8..834f82305 100644 --- a/test/helpers/index.ts +++ b/test/helpers/index.ts @@ -1,2 +1,3 @@ export * from "./eth-transactions"; export * from "./xcm"; +export * from "./contracts"; diff --git a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts new file mode 100644 index 000000000..6ad7cfbd1 --- /dev/null +++ b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts @@ -0,0 +1,108 @@ +import "@moonbeam-network/api-augment"; +import { beforeAll, deployCreateCompiledContract, describeSuite, expect } from "@moonwall/cli"; +import { ALITH_ADDRESS, createEthersTransaction } from "@moonwall/util"; +import { Abi, encodeFunctionData } from "viem"; +import { expectEVMResult, HeavyContract, deployHeavyContracts } from "../../../helpers"; + +describeSuite({ + id: "DF1301", + title: "PoV controlled by gasLimit", + foundationMethods: "dev", + testCases: ({ context, it, log }) => { + let proxyAddress: `0x${string}`; + let proxyAbi: Abi; + let contracts: HeavyContract[]; + let callData: `0x${string}`; + const MAX_CONTRACTS = 20; + const EXPECTED_POV_ROUGH = 40_000; // bytes + + beforeAll(async () => { + const { contractAddress, abi } = await deployCreateCompiledContract(context, "CallForwarder"); + proxyAddress = contractAddress; + proxyAbi = abi; + + // Deploy heavy contracts (test won't use more than what is needed for reaching max pov) + contracts = await deployHeavyContracts(context, 6000, 6000 + MAX_CONTRACTS); + + callData = encodeFunctionData({ + abi: proxyAbi, + functionName: "callRange", + args: [contracts[0].account, contracts[MAX_CONTRACTS].account], + }); + }); + + it({ + id: "T01", + title: "should allow to include transaction with estimate gas to cover PoV", + test: async function () { + const gasEstimate = await context.viem().estimateGas({ + account: ALITH_ADDRESS, + to: proxyAddress, + value: 0n, + data: callData, + }); + + const rawSigned = await createEthersTransaction(context, { + to: proxyAddress, + data: callData, + txnType: "eip1559", + gasLimit: gasEstimate, + }); + + const { result, block } = await context.createBlock(rawSigned); + + log(`block.proofSize: ${block.proofSize} (successful: ${result?.successful})`); + console.log(block); + expect(block.proofSize).toBeGreaterThanOrEqual(EXPECTED_POV_ROUGH / 2.0); + expect(block.proofSize).toBeLessThanOrEqual(EXPECTED_POV_ROUGH * 1.1); + expect(result?.successful).to.equal(true); + }, + }); + + it({ + id: "T02", + title: "should allow to include transaction with enough gas limit to cover PoV", + test: async function () { + const rawSigned = await createEthersTransaction(context, { + to: proxyAddress, + data: callData, + txnType: "eip1559", + gasLimit: 3_000_000, + }); + + const { result, block } = await context.createBlock(rawSigned); + + log(`block.proof_size: ${block.proofSize} (successful: ${result?.successful})`); + expect(block.proofSize).to.be.at.least(EXPECTED_POV_ROUGH / 2.0); + expect(block.proofSize).to.be.at.most(EXPECTED_POV_ROUGH * 1.1); + expect(result?.successful).to.equal(true); + }, + }); + + it({ + id: "T03", + title: "should fail to include transaction without enough gas limit to cover PoV", + test: async function () { + // This execution uses only < 100k Gas in cpu execute but require 2M Gas for PoV. + // We are providing only 1M Gas, so it should fail. + const rawSigned = await createEthersTransaction(context, { + to: proxyAddress, + data: callData, + txnType: "eip1559", + gasLimit: 1_000_000, + }); + + const { result, block } = await context.createBlock(rawSigned); + + log(`block.proof_size: ${block.proofSize} (successful: ${result?.successful})`); + // The block still contain the failed (out of gas) transaction so the PoV is still included + // in the block. + // 1M Gas allows ~250k of PoV, so we verify we are within range. + expect(block.proofSize).to.be.at.least(23_000); + expect(block.proofSize).to.be.at.most(50_000); + expect(result?.successful).to.equal(true); + expectEVMResult(result!.events, "Error", "OutOfGas"); + }, + }); + }, +}); diff --git a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts new file mode 100644 index 000000000..b4b8f3ed8 --- /dev/null +++ b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts @@ -0,0 +1,82 @@ +import "@moonbeam-network/api-augment"; +import { beforeAll, deployCreateCompiledContract, describeSuite, expect } from "@moonwall/cli"; +import { MAX_ETH_POV_PER_TX, createEthersTransaction } from "@moonwall/util"; +import { Abi, encodeFunctionData } from "viem"; +import { HeavyContract, deployHeavyContracts } from "../../../helpers"; + +describeSuite({ + id: "DF1302", + title: "PoV Limit (3.5Mb in Dev)", + foundationMethods: "dev", + testCases: ({ context, it, log }) => { + let proxyAddress: `0x${string}`; + let proxyAbi: Abi; + let contracts: HeavyContract[]; + const max_eth_pov_per_tx = MAX_ETH_POV_PER_TX / 100n; + + beforeAll(async () => { + const { contractAddress, abi } = await deployCreateCompiledContract(context, "CallForwarder"); + proxyAddress = contractAddress; + proxyAbi = abi; + + // Deploy heavy contracts (test won't use more than what is needed for reaching max pov) + contracts = await deployHeavyContracts(context, 6000, Number(6000n + max_eth_pov_per_tx / 24_000n + 1n)); + }); + + it({ + id: "T01", + title: "should allow to produce block just under the PoV Limit", + test: async function () { + const calculatedMax = max_eth_pov_per_tx / 24_000n - 1n; + + const callData = encodeFunctionData({ + abi: proxyAbi, + functionName: "callRange", + args: [contracts[0].account, contracts[Number(calculatedMax)].account], + }); + + const rawSigned = await createEthersTransaction(context, { + to: proxyAddress, + data: callData, + gasLimit: 13_000_000, + txnType: "eip1559", + }); + + const { result, block } = await context.createBlock(rawSigned); + + log(`block.proofSize: ${block.proofSize} (successful: ${result?.successful})`); + expect(block.proofSize).toBeGreaterThanOrEqual(max_eth_pov_per_tx - 30_000n); + expect(block.proofSize).toBeLessThanOrEqual(max_eth_pov_per_tx - 1n); + expect(result?.successful).to.equal(true); + }, + }); + + it({ + id: "T02", + title: "should prevent a transaction reaching just over the PoV", + test: async function () { + const calculatedMax = max_eth_pov_per_tx / 24_000n; + + const callData = encodeFunctionData({ + abi: proxyAbi, + functionName: "callRange", + args: [contracts[0].account, contracts[Number(calculatedMax) + 1].account], + }); + + const rawSigned = await createEthersTransaction(context, { + to: proxyAddress, + data: callData, + gasLimit: 15_000_000, + txnType: "eip1559", + }); + + const { result, block } = await context.createBlock(rawSigned); + + log(`block.proofSize: ${block.proofSize} (successful: ${result?.successful})`); + // Empty blocks usually do not exceed 10kb, picking 50kb as a safe limit + expect(block.proofSize).to.be.at.most(50_000); + expect(result?.successful).to.equal(false); + }, + }); + }, +}); From a227faf1764cd62cdf864c95d4affb763c4c39ae Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Tue, 8 Oct 2024 18:26:54 +0100 Subject: [PATCH 04/19] test: updated PoV tests to match updated moonbeam PoV setup --- .../test-pov/test-evm-over-pov.ts | 21 ++++++------- .../test-pov/test-evm-over-pov2.ts | 31 +++++++++++++------ 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts index 6ad7cfbd1..4fd4d1b5c 100644 --- a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts +++ b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts @@ -14,7 +14,7 @@ describeSuite({ let contracts: HeavyContract[]; let callData: `0x${string}`; const MAX_CONTRACTS = 20; - const EXPECTED_POV_ROUGH = 40_000; // bytes + const EXPECTED_POV_ROUGH = 16_000; // bytes beforeAll(async () => { const { contractAddress, abi } = await deployCreateCompiledContract(context, "CallForwarder"); @@ -52,9 +52,8 @@ describeSuite({ const { result, block } = await context.createBlock(rawSigned); log(`block.proofSize: ${block.proofSize} (successful: ${result?.successful})`); - console.log(block); - expect(block.proofSize).toBeGreaterThanOrEqual(EXPECTED_POV_ROUGH / 2.0); - expect(block.proofSize).toBeLessThanOrEqual(EXPECTED_POV_ROUGH * 1.1); + expect(block.proofSize).toBeGreaterThanOrEqual(EXPECTED_POV_ROUGH / 1.2); + expect(block.proofSize).toBeLessThanOrEqual(EXPECTED_POV_ROUGH * 1.2); expect(result?.successful).to.equal(true); }, }); @@ -67,14 +66,14 @@ describeSuite({ to: proxyAddress, data: callData, txnType: "eip1559", - gasLimit: 3_000_000, + gasLimit: 12_000_000, }); const { result, block } = await context.createBlock(rawSigned); log(`block.proof_size: ${block.proofSize} (successful: ${result?.successful})`); - expect(block.proofSize).to.be.at.least(EXPECTED_POV_ROUGH / 2.0); - expect(block.proofSize).to.be.at.most(EXPECTED_POV_ROUGH * 1.1); + expect(block.proofSize).to.be.at.least(EXPECTED_POV_ROUGH / 1.2); + expect(block.proofSize).to.be.at.most(EXPECTED_POV_ROUGH * 1.2); expect(result?.successful).to.equal(true); }, }); @@ -89,7 +88,7 @@ describeSuite({ to: proxyAddress, data: callData, txnType: "eip1559", - gasLimit: 1_000_000, + gasLimit: 100_000, }); const { result, block } = await context.createBlock(rawSigned); @@ -97,9 +96,9 @@ describeSuite({ log(`block.proof_size: ${block.proofSize} (successful: ${result?.successful})`); // The block still contain the failed (out of gas) transaction so the PoV is still included // in the block. - // 1M Gas allows ~250k of PoV, so we verify we are within range. - expect(block.proofSize).to.be.at.least(23_000); - expect(block.proofSize).to.be.at.most(50_000); + // 1M Gas allows ~38k of PoV, so we verify we are within range. + expect(block.proofSize).to.be.at.least(15_000); + expect(block.proofSize).to.be.at.most(25_000); expect(result?.successful).to.equal(true); expectEVMResult(result!.events, "Error", "OutOfGas"); }, diff --git a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts index b4b8f3ed8..e0dbdb06c 100644 --- a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts +++ b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts @@ -12,22 +12,35 @@ describeSuite({ let proxyAddress: `0x${string}`; let proxyAbi: Abi; let contracts: HeavyContract[]; - const max_eth_pov_per_tx = MAX_ETH_POV_PER_TX / 100n; + let callData: `0x${string}`; + let emptyBlockProofSize: bigint; + const MAX_CONTRACTS = 20; beforeAll(async () => { + // Create an empty block to estimate empty block proof size + const { block } = await context.createBlock(); + // Empty blocks usually do not exceed 50kb + emptyBlockProofSize = BigInt(block.proofSize || 50_000); + const { contractAddress, abi } = await deployCreateCompiledContract(context, "CallForwarder"); proxyAddress = contractAddress; proxyAbi = abi; // Deploy heavy contracts (test won't use more than what is needed for reaching max pov) - contracts = await deployHeavyContracts(context, 6000, Number(6000n + max_eth_pov_per_tx / 24_000n + 1n)); + contracts = await deployHeavyContracts(context, 6000, Number(6000n + MAX_ETH_POV_PER_TX / 24_000n + 1n)); + + callData = encodeFunctionData({ + abi: proxyAbi, + functionName: "callRange", + args: [contracts[0].account, contracts[MAX_CONTRACTS].account], + }); }); it({ id: "T01", title: "should allow to produce block just under the PoV Limit", test: async function () { - const calculatedMax = max_eth_pov_per_tx / 24_000n - 1n; + const calculatedMax = MAX_ETH_POV_PER_TX / 24_000n - 1n; const callData = encodeFunctionData({ abi: proxyAbi, @@ -38,15 +51,15 @@ describeSuite({ const rawSigned = await createEthersTransaction(context, { to: proxyAddress, data: callData, - gasLimit: 13_000_000, + gasLimit: 52_000_000, txnType: "eip1559", }); const { result, block } = await context.createBlock(rawSigned); log(`block.proofSize: ${block.proofSize} (successful: ${result?.successful})`); - expect(block.proofSize).toBeGreaterThanOrEqual(max_eth_pov_per_tx - 30_000n); - expect(block.proofSize).toBeLessThanOrEqual(max_eth_pov_per_tx - 1n); + expect(block.proofSize).toBeGreaterThanOrEqual(15_000); + expect(block.proofSize).toBeLessThanOrEqual(25_000n + emptyBlockProofSize); expect(result?.successful).to.equal(true); }, }); @@ -55,7 +68,7 @@ describeSuite({ id: "T02", title: "should prevent a transaction reaching just over the PoV", test: async function () { - const calculatedMax = max_eth_pov_per_tx / 24_000n; + const calculatedMax = MAX_ETH_POV_PER_TX / 24_000n; const callData = encodeFunctionData({ abi: proxyAbi, @@ -66,7 +79,7 @@ describeSuite({ const rawSigned = await createEthersTransaction(context, { to: proxyAddress, data: callData, - gasLimit: 15_000_000, + gasLimit: 60_000_000, txnType: "eip1559", }); @@ -74,7 +87,7 @@ describeSuite({ log(`block.proofSize: ${block.proofSize} (successful: ${result?.successful})`); // Empty blocks usually do not exceed 10kb, picking 50kb as a safe limit - expect(block.proofSize).to.be.at.most(50_000); + expect(block.proofSize).to.be.at.most(25_000); expect(result?.successful).to.equal(false); }, }); From f98f5c18b7e19ec13518e4ffdb399e2afe0f225c Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Wed, 9 Oct 2024 13:59:24 +0100 Subject: [PATCH 05/19] fix: adjusted GasLimitPovRatio and increased gasLimit for test-precompile-pallet-xcm to fix non-PoV test errors --- container-chains/runtime-templates/frontier/src/lib.rs | 2 +- .../test-precompiles/test-precompile-pallet-xcm.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/container-chains/runtime-templates/frontier/src/lib.rs b/container-chains/runtime-templates/frontier/src/lib.rs index aeb4aee69..669f58c43 100644 --- a/container-chains/runtime-templates/frontier/src/lib.rs +++ b/container-chains/runtime-templates/frontier/src/lib.rs @@ -843,7 +843,7 @@ parameter_types! { pub PrecompilesValue: TemplatePrecompiles = TemplatePrecompiles::<_>::new(); pub WeightPerGas: Weight = Weight::from_parts(WEIGHT_PER_GAS, 0); pub SuicideQuickClearLimit: u32 = 0; - pub GasLimitPovSizeRatio: u32 = 16; + pub GasLimitPovSizeRatio: u32 = 4; } impl_on_charge_evm_transaction!(); diff --git a/test/suites/dev-frontier-template/test-precompiles/test-precompile-pallet-xcm.ts b/test/suites/dev-frontier-template/test-precompiles/test-precompile-pallet-xcm.ts index a2336af9f..2cb7a052f 100644 --- a/test/suites/dev-frontier-template/test-precompiles/test-precompile-pallet-xcm.ts +++ b/test/suites/dev-frontier-template/test-precompiles/test-precompile-pallet-xcm.ts @@ -69,7 +69,7 @@ describeSuite({ args: [dest, beneficiary, assetLocationInfo, 0, weight], functionName: "transferAssetsLocation", }), - gasLimit: 500_000n, + gasLimit: 5_000_000n, }); const result = await context.createBlock(rawTxn); @@ -105,7 +105,7 @@ describeSuite({ args: [paraId, BALTATHAR_ADDRESS, assetAddressInfo, 0, weight], functionName: "transferAssetsToPara20", }), - gasLimit: 500_000n, + gasLimit: 5_000_000n, }); const result = await context.createBlock(rawTxn); @@ -142,7 +142,7 @@ describeSuite({ args: [paraId, beneficiaryAddress, assetAddressInfo, 0, weight], functionName: "transferAssetsToPara32", }), - gasLimit: 500_000n, + gasLimit: 5_000_000n, }); const result = await context.createBlock(rawTxn); @@ -178,7 +178,7 @@ describeSuite({ args: [beneficiaryAddress, assetAddressInfo, 0, weight], functionName: "transferAssetsToRelay", }), - gasLimit: 500_000n, + gasLimit: 5_000_000n, }); const result = await context.createBlock(rawTxn); From fc68c83ed95499184dc25585b32f25d31effbc89 Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Wed, 9 Oct 2024 14:28:05 +0100 Subject: [PATCH 06/19] style: removed unused code in test-evm-over-pov2 --- .../dev-frontier-template/test-pov/test-evm-over-pov2.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts index e0dbdb06c..9277bb944 100644 --- a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts +++ b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts @@ -12,9 +12,7 @@ describeSuite({ let proxyAddress: `0x${string}`; let proxyAbi: Abi; let contracts: HeavyContract[]; - let callData: `0x${string}`; let emptyBlockProofSize: bigint; - const MAX_CONTRACTS = 20; beforeAll(async () => { // Create an empty block to estimate empty block proof size @@ -28,12 +26,6 @@ describeSuite({ // Deploy heavy contracts (test won't use more than what is needed for reaching max pov) contracts = await deployHeavyContracts(context, 6000, Number(6000n + MAX_ETH_POV_PER_TX / 24_000n + 1n)); - - callData = encodeFunctionData({ - abi: proxyAbi, - functionName: "callRange", - args: [contracts[0].account, contracts[MAX_CONTRACTS].account], - }); }); it({ From aa8feb31a74de96e11a900e5adb7a4715d64679b Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Fri, 11 Oct 2024 09:58:43 +0100 Subject: [PATCH 07/19] fix: added missing StorageProof configuartion to node-common service and manual_seal so blocks proofSize is displayed correctly --- client/consensus/src/manual_seal.rs | 3 ++- client/node-common/src/service.rs | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/client/consensus/src/manual_seal.rs b/client/consensus/src/manual_seal.rs index 969a472a1..56267bb99 100644 --- a/client/consensus/src/manual_seal.rs +++ b/client/consensus/src/manual_seal.rs @@ -16,6 +16,7 @@ //! The Manual Seal implementation for the OrchestratorAuraConsensus +use sp_api::StorageProof; use { cumulus_primitives_core::ParaId, dp_consensus::TanssiAuthorityAssignmentApi, @@ -175,7 +176,7 @@ impl ConsensusDataProvider for ContainerManualSealAuraConsensusDataProvide where B: BlockT, { - type Proof = (); + type Proof = StorageProof; fn create_digest( &self, diff --git a/client/node-common/src/service.rs b/client/node-common/src/service.rs index 5da92f7f1..9af59dc46 100644 --- a/client/node-common/src/service.rs +++ b/client/node-common/src/service.rs @@ -64,6 +64,7 @@ use { #[allow(deprecated)] use sc_executor::NativeElseWasmExecutor; +use sp_api::StorageProof; /// Trait to configure the main types the builder rely on, bundled in a single /// type to reduce verbosity and the amount of type parameters. @@ -625,7 +626,7 @@ where let prometheus_registry = self.prometheus_registry.clone(); - let mut env = sc_basic_authorship::ProposerFactory::new( + let mut env = sc_basic_authorship::ProposerFactory::with_proof_recording( self.task_manager.spawn_handle(), self.client.clone(), self.transaction_pool.clone(), @@ -953,6 +954,6 @@ pub struct ManualSealConfiguration { pub block_import: BI, pub soft_deadline: Option, pub select_chain: SC, - pub consensus_data_provider: Option>>, + pub consensus_data_provider: Option>>, pub create_inherent_data_providers: CIDP, } From bd99d46078931bd8761d03d31f451344003b59a3 Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Fri, 11 Oct 2024 10:26:29 +0100 Subject: [PATCH 08/19] fix: revert GasLimitPovRatio value to 16 --- container-chains/runtime-templates/frontier/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/container-chains/runtime-templates/frontier/src/lib.rs b/container-chains/runtime-templates/frontier/src/lib.rs index 669f58c43..aeb4aee69 100644 --- a/container-chains/runtime-templates/frontier/src/lib.rs +++ b/container-chains/runtime-templates/frontier/src/lib.rs @@ -843,7 +843,7 @@ parameter_types! { pub PrecompilesValue: TemplatePrecompiles = TemplatePrecompiles::<_>::new(); pub WeightPerGas: Weight = Weight::from_parts(WEIGHT_PER_GAS, 0); pub SuicideQuickClearLimit: u32 = 0; - pub GasLimitPovSizeRatio: u32 = 4; + pub GasLimitPovSizeRatio: u32 = 16; } impl_on_charge_evm_transaction!(); From 3ae331b3f904efc00a3b674b6e293b29fe831b78 Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Fri, 11 Oct 2024 10:28:01 +0100 Subject: [PATCH 09/19] test: increase proof size estimates for PoV tests --- .../dev-frontier-template/test-pov/test-evm-over-pov.ts | 4 ++-- .../dev-frontier-template/test-pov/test-evm-over-pov2.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts index 4fd4d1b5c..69ab9f7cf 100644 --- a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts +++ b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts @@ -14,7 +14,7 @@ describeSuite({ let contracts: HeavyContract[]; let callData: `0x${string}`; const MAX_CONTRACTS = 20; - const EXPECTED_POV_ROUGH = 16_000; // bytes + const EXPECTED_POV_ROUGH = 38_000; // bytes beforeAll(async () => { const { contractAddress, abi } = await deployCreateCompiledContract(context, "CallForwarder"); @@ -98,7 +98,7 @@ describeSuite({ // in the block. // 1M Gas allows ~38k of PoV, so we verify we are within range. expect(block.proofSize).to.be.at.least(15_000); - expect(block.proofSize).to.be.at.most(25_000); + expect(block.proofSize).to.be.at.most(38_000 * 1.2); expect(result?.successful).to.equal(true); expectEVMResult(result!.events, "Error", "OutOfGas"); }, diff --git a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts index 9277bb944..08114fa46 100644 --- a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts +++ b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts @@ -79,7 +79,7 @@ describeSuite({ log(`block.proofSize: ${block.proofSize} (successful: ${result?.successful})`); // Empty blocks usually do not exceed 10kb, picking 50kb as a safe limit - expect(block.proofSize).to.be.at.most(25_000); + expect(block.proofSize).to.be.at.most(50_000); expect(result?.successful).to.equal(false); }, }); From 3a91fb3b86a737e22d7506a34ce9b70c73c650ce Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Fri, 11 Oct 2024 10:35:57 +0100 Subject: [PATCH 10/19] test: increased gas limit for test-precompile-pallet-xcm --- .../test-precompiles/test-precompile-pallet-xcm.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/suites/dev-frontier-template/test-precompiles/test-precompile-pallet-xcm.ts b/test/suites/dev-frontier-template/test-precompiles/test-precompile-pallet-xcm.ts index 2cb7a052f..32e51a0ae 100644 --- a/test/suites/dev-frontier-template/test-precompiles/test-precompile-pallet-xcm.ts +++ b/test/suites/dev-frontier-template/test-precompiles/test-precompile-pallet-xcm.ts @@ -69,7 +69,7 @@ describeSuite({ args: [dest, beneficiary, assetLocationInfo, 0, weight], functionName: "transferAssetsLocation", }), - gasLimit: 5_000_000n, + gasLimit: 20_000_000n, }); const result = await context.createBlock(rawTxn); @@ -105,7 +105,7 @@ describeSuite({ args: [paraId, BALTATHAR_ADDRESS, assetAddressInfo, 0, weight], functionName: "transferAssetsToPara20", }), - gasLimit: 5_000_000n, + gasLimit: 20_000_000n, }); const result = await context.createBlock(rawTxn); @@ -142,7 +142,7 @@ describeSuite({ args: [paraId, beneficiaryAddress, assetAddressInfo, 0, weight], functionName: "transferAssetsToPara32", }), - gasLimit: 5_000_000n, + gasLimit: 20_000_000n, }); const result = await context.createBlock(rawTxn); @@ -178,7 +178,7 @@ describeSuite({ args: [beneficiaryAddress, assetAddressInfo, 0, weight], functionName: "transferAssetsToRelay", }), - gasLimit: 5_000_000n, + gasLimit: 20_000_000n, }); const result = await context.createBlock(rawTxn); From db17a6714696d1c27cf9f6b1beb2bbfd4c331b71 Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Fri, 11 Oct 2024 10:46:40 +0100 Subject: [PATCH 11/19] test: adjusted test-precompile-proxy expected gasUsed to account for PoV --- .../test-precompiles/test-precompile-proxy.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/suites/dev-frontier-template/test-precompiles/test-precompile-proxy.ts b/test/suites/dev-frontier-template/test-precompiles/test-precompile-proxy.ts index f225a1fa2..286f5501e 100644 --- a/test/suites/dev-frontier-template/test-precompiles/test-precompile-proxy.ts +++ b/test/suites/dev-frontier-template/test-precompiles/test-precompile-proxy.ts @@ -565,8 +565,8 @@ describeSuite({ .getTransactionReceipt({ hash: result2!.hash as `0x${string}` }); // Allow 10% variance - expect(gasUsed <= (35_015n * 110n) / 100n).to.be.true; - expect(gasUsed >= (35_015n * 90n) / 100n).to.be.true; + expect(gasUsed).toBeLessThanOrEqual((87_538n * 110n) / 100n); + expect(gasUsed).toBeGreaterThanOrEqual((87_538n * 90n) / 100n); expect(await context.viem().getBalance({ address: randomAccount })).toBe(parseEther("5")); const balAfter = await context.viem().getBalance({ address: DOROTHY_ADDRESS }); From 66c56afe8d27c585d83a5c8ded1c7dab99898a4d Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Fri, 11 Oct 2024 10:50:23 +0100 Subject: [PATCH 12/19] test: adjusted test-evm-over-pov2.ts expected max block proofSize --- .../dev-frontier-template/test-pov/test-evm-over-pov2.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts index 08114fa46..ddb29ee29 100644 --- a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts +++ b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts @@ -50,8 +50,8 @@ describeSuite({ const { result, block } = await context.createBlock(rawSigned); log(`block.proofSize: ${block.proofSize} (successful: ${result?.successful})`); - expect(block.proofSize).toBeGreaterThanOrEqual(15_000); - expect(block.proofSize).toBeLessThanOrEqual(25_000n + emptyBlockProofSize); + expect(block.proofSize).toBeGreaterThanOrEqual(30_000); + expect(block.proofSize).toBeLessThanOrEqual(50_000n + emptyBlockProofSize); expect(result?.successful).to.equal(true); }, }); @@ -79,7 +79,7 @@ describeSuite({ log(`block.proofSize: ${block.proofSize} (successful: ${result?.successful})`); // Empty blocks usually do not exceed 10kb, picking 50kb as a safe limit - expect(block.proofSize).to.be.at.most(50_000); + expect(block.proofSize).to.be.at.most(25_000); expect(result?.successful).to.equal(false); }, }); From 15d8f0815f0c02d8b21d9230f7f92f168db343b6 Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Fri, 11 Oct 2024 12:03:33 +0100 Subject: [PATCH 13/19] test: added precompile PoV tests --- .../test-pov/test-evm-over-pov.ts | 2 +- .../test-pov/test-evm-over-pov2.ts | 2 +- .../test-pov/test-precompile-over-pov.ts | 117 ++++++++++++++++++ .../test-pov/test-precompile-over-pov2.ts | 106 ++++++++++++++++ 4 files changed, 225 insertions(+), 2 deletions(-) create mode 100644 test/suites/dev-frontier-template/test-pov/test-precompile-over-pov.ts create mode 100644 test/suites/dev-frontier-template/test-pov/test-precompile-over-pov2.ts diff --git a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts index 69ab9f7cf..e600e8df1 100644 --- a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts +++ b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts @@ -1,4 +1,4 @@ -import "@moonbeam-network/api-augment"; +import "@tanssi/api-augment"; import { beforeAll, deployCreateCompiledContract, describeSuite, expect } from "@moonwall/cli"; import { ALITH_ADDRESS, createEthersTransaction } from "@moonwall/util"; import { Abi, encodeFunctionData } from "viem"; diff --git a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts index ddb29ee29..9be614a09 100644 --- a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts +++ b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts @@ -1,4 +1,4 @@ -import "@moonbeam-network/api-augment"; +import "@tanssi/api-augment"; import { beforeAll, deployCreateCompiledContract, describeSuite, expect } from "@moonwall/cli"; import { MAX_ETH_POV_PER_TX, createEthersTransaction } from "@moonwall/util"; import { Abi, encodeFunctionData } from "viem"; diff --git a/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov.ts b/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov.ts new file mode 100644 index 000000000..9f37f6b76 --- /dev/null +++ b/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov.ts @@ -0,0 +1,117 @@ +import "@tanssi/api-augment"; +import { describeSuite, expect, beforeAll, deployCreateCompiledContract, fetchCompiledContract } from "@moonwall/cli"; +import { HeavyContract, deployHeavyContracts, expectEVMResult } from "../../../helpers"; + +import { Abi, encodeFunctionData } from "viem"; +import { ALITH_ADDRESS, PRECOMPILE_BATCH_ADDRESS, createEthersTransaction } from "@moonwall/util"; + +describeSuite({ + id: "D012704", + title: "PoV precompile test - gasLimit", + foundationMethods: "dev", + testCases: ({ context, it }) => { + let contracts: HeavyContract[]; + const MAX_CONTRACTS = 50; + const EXPECTED_POV_ROUGH = 8_000; // bytes + let batchAbi: Abi; + let proxyAbi: Abi; + let proxyAddress: `0x${string}`; + let callData: `0x${string}`; + + beforeAll(async function () { + const { contractAddress: contractAdd1, abi } = await deployCreateCompiledContract(context, "CallForwarder"); + proxyAddress = contractAdd1; + proxyAbi = abi; + contracts = await deployHeavyContracts(context, 6000, 6000 + MAX_CONTRACTS); + + // Get the interface for Batch precompile + batchAbi = fetchCompiledContract("Batch").abi; + + callData = encodeFunctionData({ + abi: batchAbi, + functionName: "batchAll", + args: [ + [proxyAddress], + [], + [ + encodeFunctionData({ + abi: proxyAbi, + functionName: "callRange", + args: [contracts[0].account, contracts[MAX_CONTRACTS].account], + }), + ], + [], + ], + }); + }); + + it({ + id: "T01", + title: "gas cost should have increased with POV", + test: async function () { + // Previously this tx cost was ~500K gas -> now it is about 5M due to POV. + // We pass 1M, so it should fail. + const rawSigned = await createEthersTransaction(context, { + to: PRECOMPILE_BATCH_ADDRESS, + data: callData, + gasLimit: 100_000, + txnType: "eip1559", + }); + + const { result, block } = await context.createBlock(rawSigned); + + // With 1M gas we are allowed to use ~62kb of POV, so verify the range. + // The tx is still included in the block because it contains the failed tx, + // so POV is included in the block as well. + expect(block.proofSize).to.be.at.least(6_000); + expect(block.proofSize).to.be.at.most(10_000); + expect(result?.successful).to.equal(true); + expectEVMResult(result!.events, "Error", "OutOfGas"); + }, + }); + + it({ + id: "T02", + title: "should be able to create a block using the estimated amount of gas", + test: async function () { + const gasEstimate = await context.viem().estimateGas({ + account: ALITH_ADDRESS, + to: PRECOMPILE_BATCH_ADDRESS, + data: callData, + }); + + const rawSigned = await createEthersTransaction(context, { + to: PRECOMPILE_BATCH_ADDRESS, + data: callData, + gasLimit: gasEstimate, + txnType: "eip1559", + }); + + const { result, block } = await context.createBlock(rawSigned); + expect(block.proofSize).to.be.at.least(EXPECTED_POV_ROUGH / 1.3); + expect(block.proofSize).to.be.at.most(EXPECTED_POV_ROUGH * 1.3); + expect(result?.successful).to.equal(true); + expectEVMResult(result!.events, "Succeed"); + }, + }); + + it({ + id: "T03", + title: "should allow to call a precompile tx with enough gas limit to cover PoV", + test: async function () { + const rawSigned = await createEthersTransaction(context, { + to: PRECOMPILE_BATCH_ADDRESS, + data: callData, + gasLimit: 24_000_000, + txnType: "eip1559", + }); + + const { result, block } = await context.createBlock(rawSigned); + expect(block.proofSize).to.be.at.least(EXPECTED_POV_ROUGH / 1.3); + expect(block.proofSize).to.be.at.most(EXPECTED_POV_ROUGH * 1.3); + expect(result?.successful).to.equal(true); + expectEVMResult(result!.events, "Succeed"); + }, + }); + }, +}); diff --git a/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov2.ts b/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov2.ts new file mode 100644 index 000000000..b86789804 --- /dev/null +++ b/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov2.ts @@ -0,0 +1,106 @@ +import "@tanssi/api-augment"; +import { beforeAll, deployCreateCompiledContract, describeSuite, expect, fetchCompiledContract } from "@moonwall/cli"; +import { MAX_ETH_POV_PER_TX, PRECOMPILE_BATCH_ADDRESS, createEthersTransaction } from "@moonwall/util"; +import { Abi, encodeFunctionData } from "viem"; +import { HeavyContract, deployHeavyContracts } from "../../../helpers"; + +describeSuite({ + id: "D012705", + title: "PoV precompile test - PoV Limit (3.5Mb in Dev)", + foundationMethods: "dev", + testCases: ({ context, it }) => { + let contracts: HeavyContract[]; + let batchAbi: Abi; + let proxyAbi: Abi; + let proxyAddress: `0x${string}`; + let emptyBlockProofSize: bigint; + + beforeAll(async function () { + // Create an empty block to estimate empty block proof size + const { block } = await context.createBlock(); + // Empty blocks usually do not exceed 50kb + emptyBlockProofSize = BigInt(block.proofSize || 50_000); + + const { contractAddress: contractAdd1, abi } = await deployCreateCompiledContract(context, "CallForwarder"); + proxyAddress = contractAdd1; + proxyAbi = abi; + contracts = await deployHeavyContracts(context, 6000, Number(6000n + MAX_ETH_POV_PER_TX / 24_000n + 1n)); + + // Get the interface for Batch precompile + batchAbi = fetchCompiledContract("Batch").abi; + }); + + it({ + id: "T01", + title: "should allow to produce block under the PoV Limit with precompile tx", + test: async function () { + const maxContracts = MAX_ETH_POV_PER_TX / 24_000n - 1n; + + const callData = encodeFunctionData({ + abi: batchAbi, + functionName: "batchAll", + args: [ + [proxyAddress], + [], + [ + encodeFunctionData({ + abi: proxyAbi, + functionName: "callRange", + args: [contracts[0].account, contracts[Number(maxContracts)].account], + }), + ], + [], + ], + }); + + const rawSigned = await createEthersTransaction(context, { + to: PRECOMPILE_BATCH_ADDRESS, + data: callData, + gasLimit: 52_000_000, + }); + + const { result, block } = await context.createBlock(rawSigned); + expect(block.proofSize).to.be.at.least(Number(6_000)); + expect(block.proofSize).to.be.at.most(Number(10_000n + emptyBlockProofSize)); + expect(result?.successful).to.equal(true); + }, + }); + + it({ + id: "T0", + title: "should prevent a tx reaching just over the PoV with a precompile tx", + test: async function () { + const maxContracts = MAX_ETH_POV_PER_TX / 24_000n; + + const callData = encodeFunctionData({ + abi: batchAbi, + functionName: "batchAll", + args: [ + [proxyAddress], + [], + [ + encodeFunctionData({ + abi: proxyAbi, + functionName: "callRange", + args: [contracts[0].account, contracts[Number(maxContracts)].account], + }), + ], + [], + ], + }); + + const rawSigned = await createEthersTransaction(context, { + to: PRECOMPILE_BATCH_ADDRESS, + data: callData, + gasLimit: 60_000_000, + }); + + const { result, block } = await context.createBlock(rawSigned); + + // Empty blocks usually do not exceed 10kb, picking 50kb as a safe limit + expect(block.proofSize).to.be.at.most(50_000); + expect(result?.successful).to.equal(false); + }, + }); + }, +}); From d9621114bfaa750913899dba22186110924be1bb Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Fri, 11 Oct 2024 12:11:45 +0100 Subject: [PATCH 14/19] refactor: better explanation for test-precompile-proxy.ts T15 expected gasUsed --- .../test-precompiles/test-precompile-proxy.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/suites/dev-frontier-template/test-precompiles/test-precompile-proxy.ts b/test/suites/dev-frontier-template/test-precompiles/test-precompile-proxy.ts index 286f5501e..53ca681aa 100644 --- a/test/suites/dev-frontier-template/test-precompiles/test-precompile-proxy.ts +++ b/test/suites/dev-frontier-template/test-precompiles/test-precompile-proxy.ts @@ -564,9 +564,15 @@ describeSuite({ .viem() .getTransactionReceipt({ hash: result2!.hash as `0x${string}` }); + // The tx can create an account, so record 148 bytes of storage growth + // Storage growth ratio is 366 (Not defined in frontier template) + // storage_gas = 148 * 366 = 54168 + // pov_gas = 5693 * 16 = 91088 + const expectedGas = 91_088n; + // Allow 10% variance - expect(gasUsed).toBeLessThanOrEqual((87_538n * 110n) / 100n); - expect(gasUsed).toBeGreaterThanOrEqual((87_538n * 90n) / 100n); + expect(gasUsed).toBeLessThanOrEqual((expectedGas * 110n) / 100n); + expect(gasUsed).toBeGreaterThanOrEqual((expectedGas * 90n) / 100n); expect(await context.viem().getBalance({ address: randomAccount })).toBe(parseEther("5")); const balAfter = await context.viem().getBalance({ address: DOROTHY_ADDRESS }); From 58db5bd6992983f6a2df28a7ee03b2569cc69a90 Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Fri, 11 Oct 2024 12:24:15 +0100 Subject: [PATCH 15/19] test: revert PoV tests to their original expected proofSize value ranges --- .../test-pov/test-evm-over-pov.ts | 4 ++-- .../test-pov/test-evm-over-pov2.ts | 4 ++-- .../test-pov/test-precompile-over-pov.ts | 10 +++++----- .../test-pov/test-precompile-over-pov2.ts | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts index e600e8df1..207f8cb5c 100644 --- a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts +++ b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts @@ -14,7 +14,7 @@ describeSuite({ let contracts: HeavyContract[]; let callData: `0x${string}`; const MAX_CONTRACTS = 20; - const EXPECTED_POV_ROUGH = 38_000; // bytes + const EXPECTED_POV_ROUGH = 16_000; // bytes beforeAll(async () => { const { contractAddress, abi } = await deployCreateCompiledContract(context, "CallForwarder"); @@ -98,7 +98,7 @@ describeSuite({ // in the block. // 1M Gas allows ~38k of PoV, so we verify we are within range. expect(block.proofSize).to.be.at.least(15_000); - expect(block.proofSize).to.be.at.most(38_000 * 1.2); + expect(block.proofSize).to.be.at.most(25_000); expect(result?.successful).to.equal(true); expectEVMResult(result!.events, "Error", "OutOfGas"); }, diff --git a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts index 9be614a09..f02aec8bf 100644 --- a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts +++ b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts @@ -50,8 +50,8 @@ describeSuite({ const { result, block } = await context.createBlock(rawSigned); log(`block.proofSize: ${block.proofSize} (successful: ${result?.successful})`); - expect(block.proofSize).toBeGreaterThanOrEqual(30_000); - expect(block.proofSize).toBeLessThanOrEqual(50_000n + emptyBlockProofSize); + expect(block.proofSize).toBeGreaterThanOrEqual(15_000); + expect(block.proofSize).toBeLessThanOrEqual(25_000n + emptyBlockProofSize); expect(result?.successful).to.equal(true); }, }); diff --git a/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov.ts b/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov.ts index 9f37f6b76..659ef5652 100644 --- a/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov.ts +++ b/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov.ts @@ -12,7 +12,7 @@ describeSuite({ testCases: ({ context, it }) => { let contracts: HeavyContract[]; const MAX_CONTRACTS = 50; - const EXPECTED_POV_ROUGH = 8_000; // bytes + const EXPECTED_POV_ROUGH = 20_000; // bytes let batchAbi: Abi; let proxyAbi: Abi; let proxyAddress: `0x${string}`; @@ -63,8 +63,8 @@ describeSuite({ // With 1M gas we are allowed to use ~62kb of POV, so verify the range. // The tx is still included in the block because it contains the failed tx, // so POV is included in the block as well. - expect(block.proofSize).to.be.at.least(6_000); - expect(block.proofSize).to.be.at.most(10_000); + expect(block.proofSize).to.be.at.least(15_000); + expect(block.proofSize).to.be.at.most(30_000); expect(result?.successful).to.equal(true); expectEVMResult(result!.events, "Error", "OutOfGas"); }, @@ -91,7 +91,7 @@ describeSuite({ expect(block.proofSize).to.be.at.least(EXPECTED_POV_ROUGH / 1.3); expect(block.proofSize).to.be.at.most(EXPECTED_POV_ROUGH * 1.3); expect(result?.successful).to.equal(true); - expectEVMResult(result!.events, "Succeed"); + expectEVMResult(result!.events, "Succeed", "Reserved"); }, }); @@ -110,7 +110,7 @@ describeSuite({ expect(block.proofSize).to.be.at.least(EXPECTED_POV_ROUGH / 1.3); expect(block.proofSize).to.be.at.most(EXPECTED_POV_ROUGH * 1.3); expect(result?.successful).to.equal(true); - expectEVMResult(result!.events, "Succeed"); + expectEVMResult(result!.events, "Succeed", "Returned"); }, }); }, diff --git a/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov2.ts b/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov2.ts index b86789804..09aab66e5 100644 --- a/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov2.ts +++ b/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov2.ts @@ -60,8 +60,8 @@ describeSuite({ }); const { result, block } = await context.createBlock(rawSigned); - expect(block.proofSize).to.be.at.least(Number(6_000)); - expect(block.proofSize).to.be.at.most(Number(10_000n + emptyBlockProofSize)); + expect(block.proofSize).to.be.at.least(Number(15_000)); + expect(block.proofSize).to.be.at.most(Number(30_000n + emptyBlockProofSize)); expect(result?.successful).to.equal(true); }, }); From fb26af9214ba8fb2f337e00a64b85e5b06fbc801 Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Fri, 11 Oct 2024 14:49:02 +0100 Subject: [PATCH 16/19] feat: added proofSize calculation config tanssi-relay-service --- solo-chains/node/tanssi-relay-service/src/dev_service.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solo-chains/node/tanssi-relay-service/src/dev_service.rs b/solo-chains/node/tanssi-relay-service/src/dev_service.rs index b04249f8d..220107434 100644 --- a/solo-chains/node/tanssi-relay-service/src/dev_service.rs +++ b/solo-chains/node/tanssi-relay-service/src/dev_service.rs @@ -361,7 +361,7 @@ fn new_full< let mut command_sink = None; if role.is_authority() { - let proposer = sc_basic_authorship::ProposerFactory::new( + let proposer = sc_basic_authorship::ProposerFactory::with_proof_recording( task_manager.spawn_handle(), client.clone(), transaction_pool.clone(), From fba39a20436d68c13a42fa7788a687d1d170d1c3 Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Fri, 11 Oct 2024 18:03:17 +0100 Subject: [PATCH 17/19] chore: updated Cargo.lock --- Cargo.lock | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 44a949d00..fbdcd167c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4278,7 +4278,7 @@ dependencies = [ [[package]] name = "fc-api" version = "1.0.0-dev" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "async-trait", "fp-storage", @@ -4290,7 +4290,7 @@ dependencies = [ [[package]] name = "fc-cli" version = "1.0.0-dev" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "clap 4.5.4", "ethereum-types", @@ -4308,7 +4308,7 @@ dependencies = [ [[package]] name = "fc-consensus" version = "2.0.0-dev" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "async-trait", "fp-consensus", @@ -4324,7 +4324,7 @@ dependencies = [ [[package]] name = "fc-db" version = "2.0.0-dev" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "async-trait", "ethereum", @@ -4354,7 +4354,7 @@ dependencies = [ [[package]] name = "fc-mapping-sync" version = "2.0.0-dev" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "fc-db", "fc-storage", @@ -4377,7 +4377,7 @@ dependencies = [ [[package]] name = "fc-rpc" version = "2.0.0-dev" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "ethereum", "ethereum-types", @@ -4431,7 +4431,7 @@ dependencies = [ [[package]] name = "fc-rpc-core" version = "1.1.0-dev" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "ethereum", "ethereum-types", @@ -4446,7 +4446,7 @@ dependencies = [ [[package]] name = "fc-storage" version = "1.0.0-dev" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "ethereum", "ethereum-types", @@ -4745,7 +4745,7 @@ dependencies = [ [[package]] name = "fp-account" version = "1.0.0-dev" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "hex", "impl-serde", @@ -4764,7 +4764,7 @@ dependencies = [ [[package]] name = "fp-consensus" version = "2.0.0-dev" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "ethereum", "parity-scale-codec", @@ -4775,7 +4775,7 @@ dependencies = [ [[package]] name = "fp-ethereum" version = "1.0.0-dev" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "ethereum", "ethereum-types", @@ -4787,7 +4787,7 @@ dependencies = [ [[package]] name = "fp-evm" version = "3.0.0-dev" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "evm", "frame-support", @@ -4802,7 +4802,7 @@ dependencies = [ [[package]] name = "fp-rpc" version = "3.0.0-dev" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "ethereum", "ethereum-types", @@ -4818,7 +4818,7 @@ dependencies = [ [[package]] name = "fp-self-contained" version = "1.0.0-dev" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "frame-support", "parity-scale-codec", @@ -4830,7 +4830,7 @@ dependencies = [ [[package]] name = "fp-storage" version = "2.0.0" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "parity-scale-codec", "serde", @@ -8668,7 +8668,7 @@ dependencies = [ [[package]] name = "pallet-base-fee" version = "1.0.0" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "fp-evm", "frame-support", @@ -9104,7 +9104,7 @@ dependencies = [ [[package]] name = "pallet-ethereum" version = "4.0.0-dev" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "ethereum", "ethereum-types", @@ -9126,7 +9126,7 @@ dependencies = [ [[package]] name = "pallet-evm" version = "6.0.0-dev" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "environmental", "evm", @@ -9149,7 +9149,7 @@ dependencies = [ [[package]] name = "pallet-evm-chain-id" version = "1.0.0-dev" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "frame-support", "frame-system", @@ -9227,7 +9227,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-modexp" version = "2.0.0-dev" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "fp-evm", "num", @@ -9257,7 +9257,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-sha3fips" version = "2.0.0-dev" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "fp-evm", "tiny-keccak", @@ -9266,7 +9266,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-simple" version = "2.0.0-dev" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "fp-evm", "ripemd", @@ -12269,7 +12269,7 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "precompile-utils" version = "0.1.0" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "environmental", "evm", @@ -12293,7 +12293,7 @@ dependencies = [ [[package]] name = "precompile-utils-macro" version = "0.1.0" -source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#002ef30b38b427bc38f8ee9965472cc7ede46276" +source = "git+https://github.com/moondance-labs/frontier?branch=tanssi-polkadot-stable2407#103242c06bde7e0c9713de1e2d1d3a2d51a39040" dependencies = [ "case", "num_enum", From e8dfc8d9c0c3b23570326143b38b5d72e3b2a742 Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Fri, 11 Oct 2024 18:48:56 +0100 Subject: [PATCH 18/19] test: using correct PoV test gasLimit and proofSize values before the Moonbeam's Frontier update --- .../dev-frontier-template/test-pov/test-evm-over-pov.ts | 8 ++++---- .../dev-frontier-template/test-pov/test-evm-over-pov2.ts | 6 +++--- .../test-pov/test-precompile-over-pov.ts | 8 ++++---- .../test-pov/test-precompile-over-pov2.ts | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts index 207f8cb5c..ad37f4b35 100644 --- a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts +++ b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov.ts @@ -14,7 +14,7 @@ describeSuite({ let contracts: HeavyContract[]; let callData: `0x${string}`; const MAX_CONTRACTS = 20; - const EXPECTED_POV_ROUGH = 16_000; // bytes + const EXPECTED_POV_ROUGH = 40_000; // bytes beforeAll(async () => { const { contractAddress, abi } = await deployCreateCompiledContract(context, "CallForwarder"); @@ -88,7 +88,7 @@ describeSuite({ to: proxyAddress, data: callData, txnType: "eip1559", - gasLimit: 100_000, + gasLimit: 1_000_000, }); const { result, block } = await context.createBlock(rawSigned); @@ -97,8 +97,8 @@ describeSuite({ // The block still contain the failed (out of gas) transaction so the PoV is still included // in the block. // 1M Gas allows ~38k of PoV, so we verify we are within range. - expect(block.proofSize).to.be.at.least(15_000); - expect(block.proofSize).to.be.at.most(25_000); + expect(block.proofSize).to.be.at.least(30_000); + expect(block.proofSize).to.be.at.most(50_000); expect(result?.successful).to.equal(true); expectEVMResult(result!.events, "Error", "OutOfGas"); }, diff --git a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts index f02aec8bf..9e0b3dae7 100644 --- a/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts +++ b/test/suites/dev-frontier-template/test-pov/test-evm-over-pov2.ts @@ -50,8 +50,8 @@ describeSuite({ const { result, block } = await context.createBlock(rawSigned); log(`block.proofSize: ${block.proofSize} (successful: ${result?.successful})`); - expect(block.proofSize).toBeGreaterThanOrEqual(15_000); - expect(block.proofSize).toBeLessThanOrEqual(25_000n + emptyBlockProofSize); + expect(block.proofSize).toBeGreaterThanOrEqual(30_000); + expect(block.proofSize).toBeLessThanOrEqual(50_000n + emptyBlockProofSize); expect(result?.successful).to.equal(true); }, }); @@ -79,7 +79,7 @@ describeSuite({ log(`block.proofSize: ${block.proofSize} (successful: ${result?.successful})`); // Empty blocks usually do not exceed 10kb, picking 50kb as a safe limit - expect(block.proofSize).to.be.at.most(25_000); + expect(block.proofSize).to.be.at.most(50_000); expect(result?.successful).to.equal(false); }, }); diff --git a/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov.ts b/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov.ts index 659ef5652..33c0e82b1 100644 --- a/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov.ts +++ b/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov.ts @@ -12,7 +12,7 @@ describeSuite({ testCases: ({ context, it }) => { let contracts: HeavyContract[]; const MAX_CONTRACTS = 50; - const EXPECTED_POV_ROUGH = 20_000; // bytes + const EXPECTED_POV_ROUGH = 55_000; // bytes let batchAbi: Abi; let proxyAbi: Abi; let proxyAddress: `0x${string}`; @@ -54,7 +54,7 @@ describeSuite({ const rawSigned = await createEthersTransaction(context, { to: PRECOMPILE_BATCH_ADDRESS, data: callData, - gasLimit: 100_000, + gasLimit: 1_000_000, txnType: "eip1559", }); @@ -63,8 +63,8 @@ describeSuite({ // With 1M gas we are allowed to use ~62kb of POV, so verify the range. // The tx is still included in the block because it contains the failed tx, // so POV is included in the block as well. - expect(block.proofSize).to.be.at.least(15_000); - expect(block.proofSize).to.be.at.most(30_000); + expect(block.proofSize).to.be.at.least(35_000); + expect(block.proofSize).to.be.at.most(70_000); expect(result?.successful).to.equal(true); expectEVMResult(result!.events, "Error", "OutOfGas"); }, diff --git a/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov2.ts b/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov2.ts index 09aab66e5..42e1dc502 100644 --- a/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov2.ts +++ b/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov2.ts @@ -60,8 +60,8 @@ describeSuite({ }); const { result, block } = await context.createBlock(rawSigned); - expect(block.proofSize).to.be.at.least(Number(15_000)); - expect(block.proofSize).to.be.at.most(Number(30_000n + emptyBlockProofSize)); + expect(block.proofSize).to.be.at.least(Number(30_000)); + expect(block.proofSize).to.be.at.most(Number(50_000n + emptyBlockProofSize)); expect(result?.successful).to.equal(true); }, }); From 71661de113d34163a1f75288f0b00798a906a5a8 Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Fri, 11 Oct 2024 18:53:02 +0100 Subject: [PATCH 19/19] style: updated test-precompile-over-pov test IDs --- .../dev-frontier-template/test-pov/test-precompile-over-pov.ts | 2 +- .../dev-frontier-template/test-pov/test-precompile-over-pov2.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov.ts b/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov.ts index 33c0e82b1..c16657c60 100644 --- a/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov.ts +++ b/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov.ts @@ -6,7 +6,7 @@ import { Abi, encodeFunctionData } from "viem"; import { ALITH_ADDRESS, PRECOMPILE_BATCH_ADDRESS, createEthersTransaction } from "@moonwall/util"; describeSuite({ - id: "D012704", + id: "DF1303", title: "PoV precompile test - gasLimit", foundationMethods: "dev", testCases: ({ context, it }) => { diff --git a/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov2.ts b/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov2.ts index 42e1dc502..ded9528b5 100644 --- a/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov2.ts +++ b/test/suites/dev-frontier-template/test-pov/test-precompile-over-pov2.ts @@ -5,7 +5,7 @@ import { Abi, encodeFunctionData } from "viem"; import { HeavyContract, deployHeavyContracts } from "../../../helpers"; describeSuite({ - id: "D012705", + id: "DF1304", title: "PoV precompile test - PoV Limit (3.5Mb in Dev)", foundationMethods: "dev", testCases: ({ context, it }) => {