diff --git a/Cargo.lock b/Cargo.lock index 5ccb81593e9..f4e83dc6f10 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4164,7 +4164,7 @@ dependencies = [ [[package]] name = "fc-api" version = "1.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "async-trait", "fp-storage", @@ -4176,7 +4176,7 @@ dependencies = [ [[package]] name = "fc-consensus" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "async-trait", "fp-consensus", @@ -4192,7 +4192,7 @@ dependencies = [ [[package]] name = "fc-db" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "async-trait", "ethereum", @@ -4222,7 +4222,7 @@ dependencies = [ [[package]] name = "fc-mapping-sync" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "fc-db", "fc-storage", @@ -4245,7 +4245,7 @@ dependencies = [ [[package]] name = "fc-rpc" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "ethereum", "ethereum-types", @@ -4299,7 +4299,7 @@ dependencies = [ [[package]] name = "fc-rpc-core" version = "1.1.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "ethereum", "ethereum-types", @@ -4315,7 +4315,7 @@ dependencies = [ [[package]] name = "fc-rpc-v2-api" version = "0.1.0" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "ethereum-types", "fc-rpc-v2-types", @@ -4325,7 +4325,7 @@ dependencies = [ [[package]] name = "fc-rpc-v2-types" version = "0.1.0" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "const-hex", "ethereum-types", @@ -4336,7 +4336,7 @@ dependencies = [ [[package]] name = "fc-storage" version = "1.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "ethereum", "ethereum-types", @@ -4529,7 +4529,7 @@ dependencies = [ [[package]] name = "fp-account" version = "1.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "hex", "impl-serde", @@ -4547,7 +4547,7 @@ dependencies = [ [[package]] name = "fp-consensus" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "ethereum", "parity-scale-codec", @@ -4558,7 +4558,7 @@ dependencies = [ [[package]] name = "fp-ethereum" version = "1.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "ethereum", "ethereum-types", @@ -4570,7 +4570,7 @@ dependencies = [ [[package]] name = "fp-evm" version = "3.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "environmental", "evm", @@ -4586,7 +4586,7 @@ dependencies = [ [[package]] name = "fp-rpc" version = "3.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "ethereum", "ethereum-types", @@ -4602,7 +4602,7 @@ dependencies = [ [[package]] name = "fp-self-contained" version = "1.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "frame-support", "parity-scale-codec", @@ -4614,7 +4614,7 @@ dependencies = [ [[package]] name = "fp-storage" version = "2.0.0" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "parity-scale-codec", "serde", @@ -9867,7 +9867,7 @@ dependencies = [ [[package]] name = "pallet-ethereum" version = "4.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "environmental", "ethereum", @@ -9922,7 +9922,7 @@ dependencies = [ [[package]] name = "pallet-evm" version = "6.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "cumulus-primitives-storage-weight-reclaim", "environmental", @@ -9947,7 +9947,7 @@ dependencies = [ [[package]] name = "pallet-evm-chain-id" version = "1.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "frame-support", "frame-system", @@ -10025,7 +10025,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-blake2" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "fp-evm", ] @@ -10033,7 +10033,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-bls12381" version = "1.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "ark-bls12-381 0.4.0", "ark-ec 0.4.2", @@ -10045,7 +10045,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-bn128" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "fp-evm", "sp-core", @@ -10201,7 +10201,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-modexp" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "fp-evm", "num", @@ -10403,7 +10403,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-sha3fips" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "fp-evm", "frame-support", @@ -10414,7 +10414,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-simple" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "fp-evm", "ripemd", @@ -13345,7 +13345,7 @@ dependencies = [ [[package]] name = "precompile-utils" version = "0.1.0" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "derive_more 1.0.0", "environmental", @@ -13374,7 +13374,7 @@ dependencies = [ [[package]] name = "precompile-utils-macro" version = "0.1.0" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#3f9fe44ab75571856d0735142620ae42dacb17d8" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2506#fc04876e7a35a8a0cecf101906f5c1650c231107" dependencies = [ "case", "num_enum 0.7.3", diff --git a/node/service/src/rpc.rs b/node/service/src/rpc.rs index 1332d97e037..e4631f92c96 100644 --- a/node/service/src/rpc.rs +++ b/node/service/src/rpc.rs @@ -297,6 +297,7 @@ where fee_history_cache, fee_history_limit, 10, + true, forced_parent_hashes, pending_create_inherent_data_providers, Some(pending_consenus_data_provider), diff --git a/pallets/ethereum-xcm/src/lib.rs b/pallets/ethereum-xcm/src/lib.rs index 56f1bf39096..d052dfdac33 100644 --- a/pallets/ethereum-xcm/src/lib.rs +++ b/pallets/ethereum-xcm/src/lib.rs @@ -365,6 +365,7 @@ impl Pallet { base_fee: U256::zero(), chain_id: 0u64, is_transactional: true, + allow_unprotected_txs: false, }, transaction_data.into(), weight_limit, diff --git a/pallets/ethereum-xcm/src/mock.rs b/pallets/ethereum-xcm/src/mock.rs index adc38231af4..06f42084c7b 100644 --- a/pallets/ethereum-xcm/src/mock.rs +++ b/pallets/ethereum-xcm/src/mock.rs @@ -205,12 +205,14 @@ impl pallet_evm::Config for Test { parameter_types! { pub const PostBlockAndTxnHashes: PostLogContent = PostLogContent::BlockAndTxnHashes; + pub const AllowUnprotectedTxs: bool = true; } impl pallet_ethereum::Config for Test { type StateRoot = IntermediateStateRoot<::Version>; type PostLogContent = PostBlockAndTxnHashes; type ExtraDataLength = ConstU32<30>; + type AllowUnprotectedTxs = AllowUnprotectedTxs; } parameter_types! { diff --git a/pallets/moonbeam-foreign-assets/src/mock.rs b/pallets/moonbeam-foreign-assets/src/mock.rs index dc3ac0ab530..cb5c6f956d5 100644 --- a/pallets/moonbeam-foreign-assets/src/mock.rs +++ b/pallets/moonbeam-foreign-assets/src/mock.rs @@ -153,12 +153,14 @@ impl pallet_evm::Config for Test { parameter_types! { pub const PostBlockAndTxnHashes: PostLogContent = PostLogContent::BlockAndTxnHashes; + pub const AllowUnprotectedTxs: bool = true; } impl pallet_ethereum::Config for Test { type StateRoot = IntermediateStateRoot<::Version>; type PostLogContent = PostBlockAndTxnHashes; type ExtraDataLength = ConstU32<30>; + type AllowUnprotectedTxs = AllowUnprotectedTxs; } /// Gets parameters of last `ForeignAssetCreatedHook::on_asset_created` hook invocation diff --git a/runtime/moonbase/src/lib.rs b/runtime/moonbase/src/lib.rs index 4352553f55c..3a0b6c6defb 100644 --- a/runtime/moonbase/src/lib.rs +++ b/runtime/moonbase/src/lib.rs @@ -693,6 +693,7 @@ impl fp_rpc::ConvertTransaction for TransactionConve parameter_types! { pub const PostBlockAndTxnHashes: PostLogContent = PostLogContent::BlockAndTxnHashes; + pub const AllowUnprotectedTxs: bool = true; } impl pallet_ethereum::Config for Runtime { @@ -700,6 +701,7 @@ impl pallet_ethereum::Config for Runtime { pallet_ethereum::IntermediateStateRoot<::Version>; type PostLogContent = PostBlockAndTxnHashes; type ExtraDataLength = ConstU32<30>; + type AllowUnprotectedTxs = AllowUnprotectedTxs; } pub struct EthereumXcmEnsureProxy; diff --git a/runtime/moonbase/tests/xcm_mock/parachain.rs b/runtime/moonbase/tests/xcm_mock/parachain.rs index ed46a854d03..896b7e50d99 100644 --- a/runtime/moonbase/tests/xcm_mock/parachain.rs +++ b/runtime/moonbase/tests/xcm_mock/parachain.rs @@ -885,6 +885,7 @@ impl xcm_primitives::HrmpEncodeCall for MockHrmpEncoder { parameter_types! { pub const PostBlockAndTxnHashes: PostLogContent = PostLogContent::BlockAndTxnHashes; + pub const AllowUnprotectedTxs: bool = true; } impl pallet_ethereum::Config for Runtime { @@ -892,6 +893,7 @@ impl pallet_ethereum::Config for Runtime { pallet_ethereum::IntermediateStateRoot<::Version>; type PostLogContent = PostBlockAndTxnHashes; type ExtraDataLength = ConstU32<30>; + type AllowUnprotectedTxs = AllowUnprotectedTxs; } parameter_types! { pub ReservedXcmpWeight: Weight = Weight::from_parts(u64::max_value(), 0); diff --git a/runtime/moonbeam/src/lib.rs b/runtime/moonbeam/src/lib.rs index 0c27cb1596e..c7fbc544929 100644 --- a/runtime/moonbeam/src/lib.rs +++ b/runtime/moonbeam/src/lib.rs @@ -691,12 +691,14 @@ impl fp_rpc::ConvertTransaction for TransactionConve parameter_types! { pub const PostBlockAndTxnHashes: PostLogContent = PostLogContent::BlockAndTxnHashes; + pub const AllowUnprotectedTxs: bool = true; } impl pallet_ethereum::Config for Runtime { type StateRoot = pallet_ethereum::IntermediateStateRoot; type PostLogContent = PostBlockAndTxnHashes; type ExtraDataLength = ConstU32<30>; + type AllowUnprotectedTxs = AllowUnprotectedTxs; } /// Relay chain slot duration, in milliseconds. diff --git a/runtime/moonbeam/tests/xcm_mock/parachain.rs b/runtime/moonbeam/tests/xcm_mock/parachain.rs index 8ab58e5bd7a..4d4addb9734 100644 --- a/runtime/moonbeam/tests/xcm_mock/parachain.rs +++ b/runtime/moonbeam/tests/xcm_mock/parachain.rs @@ -878,6 +878,7 @@ impl xcm_primitives::HrmpEncodeCall for MockHrmpEncoder { parameter_types! { pub const PostBlockAndTxnHashes: PostLogContent = PostLogContent::BlockAndTxnHashes; + pub const AllowUnprotectedTxs: bool = true; } impl pallet_ethereum::Config for Runtime { @@ -885,6 +886,7 @@ impl pallet_ethereum::Config for Runtime { pallet_ethereum::IntermediateStateRoot<::Version>; type PostLogContent = PostBlockAndTxnHashes; type ExtraDataLength = ConstU32<30>; + type AllowUnprotectedTxs = AllowUnprotectedTxs; } parameter_types! { pub ReservedXcmpWeight: Weight = Weight::from_parts(u64::max_value(), 0); diff --git a/runtime/moonriver/src/lib.rs b/runtime/moonriver/src/lib.rs index d0271a6ae70..dd87a580b7b 100644 --- a/runtime/moonriver/src/lib.rs +++ b/runtime/moonriver/src/lib.rs @@ -694,6 +694,7 @@ impl fp_rpc::ConvertTransaction for TransactionConve parameter_types! { pub const PostBlockAndTxnHashes: PostLogContent = PostLogContent::BlockAndTxnHashes; + pub const AllowUnprotectedTxs: bool = true; } impl pallet_ethereum::Config for Runtime { @@ -701,6 +702,7 @@ impl pallet_ethereum::Config for Runtime { pallet_ethereum::IntermediateStateRoot<::Version>; type PostLogContent = PostBlockAndTxnHashes; type ExtraDataLength = ConstU32<30>; + type AllowUnprotectedTxs = AllowUnprotectedTxs; } pub struct EthereumXcmEnsureProxy; diff --git a/runtime/moonriver/tests/xcm_mock/parachain.rs b/runtime/moonriver/tests/xcm_mock/parachain.rs index 3a652c1ac7b..cdf9add3f28 100644 --- a/runtime/moonriver/tests/xcm_mock/parachain.rs +++ b/runtime/moonriver/tests/xcm_mock/parachain.rs @@ -852,6 +852,7 @@ impl xcm_primitives::HrmpEncodeCall for MockHrmpEncoder { parameter_types! { pub const PostBlockAndTxnHashes: PostLogContent = PostLogContent::BlockAndTxnHashes; + pub const AllowUnprotectedTxs: bool = true; } impl pallet_ethereum::Config for Runtime { @@ -859,6 +860,7 @@ impl pallet_ethereum::Config for Runtime { pallet_ethereum::IntermediateStateRoot<::Version>; type PostLogContent = PostBlockAndTxnHashes; type ExtraDataLength = ConstU32<30>; + type AllowUnprotectedTxs = AllowUnprotectedTxs; } parameter_types! { diff --git a/test/suites/dev/moonbase/test-contract/test-contract-loop-cost.ts b/test/suites/dev/moonbase/test-contract/test-contract-loop-cost.ts index f98f6538880..1fef577cf2c 100644 --- a/test/suites/dev/moonbase/test-contract/test-contract-loop-cost.ts +++ b/test/suites/dev/moonbase/test-contract/test-contract-loop-cost.ts @@ -40,7 +40,7 @@ describeSuite({ txnType, }); - await context.createBlock(rawSigned); + const { result } = await context.createBlock(rawSigned); expect( await context.readContract!({ @@ -49,8 +49,10 @@ describeSuite({ functionName: "count", }) ).toBe(loop); - const block = await context.viem().getBlock(); - expect(block.gasUsed).toBe(gas); + const receipt = await context + .viem() + .getTransactionReceipt({ hash: result!.hash as `0x${string}` }); + expect(receipt.gasUsed).toBe(gas); }, }); } diff --git a/test/suites/dev/moonbase/test-contract/test-contract-methods.ts b/test/suites/dev/moonbase/test-contract/test-contract-methods.ts index 59c9bd95a36..ae1e9cd6d6e 100644 --- a/test/suites/dev/moonbase/test-contract/test-contract-methods.ts +++ b/test/suites/dev/moonbase/test-contract/test-contract-methods.ts @@ -26,9 +26,9 @@ describeSuite({ id: "T01", title: "should appear in the block transaction list", test: async () => { - const block = await context.viem().getBlock(); - const txHash = block.transactions[0]; - expect(txHash).toBe(deployHash); + const tx = await context.viem().getTransaction({ hash: deployHash }); + const block = await context.viem().getBlock({ blockHash: tx.blockHash! }); + expect(block.transactions).toContain(deployHash); }, }); diff --git a/test/suites/dev/moonbase/test-contract/test-contract-variables.ts b/test/suites/dev/moonbase/test-contract/test-contract-variables.ts index 3dc9dba8fe1..9f6f04e333c 100644 --- a/test/suites/dev/moonbase/test-contract/test-contract-variables.ts +++ b/test/suites/dev/moonbase/test-contract/test-contract-variables.ts @@ -32,7 +32,7 @@ describeSuite({ id: "T02", title: "should return parent block number + 1 when accessed by RPC call", test: async function () { - const block = await context.viem().getBlock(); + const header = await context.polkadotJs().rpc.chain.getHeader(); expect( await context.readContract!({ contractName: "BlockVariables", @@ -46,7 +46,7 @@ describeSuite({ contractAddress: blockContract, functionName: "getNumber", }) - ).toBe(block.number); + ).toBe(header.number.toBigInt()); }, }); diff --git a/test/suites/dev/moonbase/test-eth-fee/test-eth-fee-history.ts b/test/suites/dev/moonbase/test-eth-fee/test-eth-fee-history.ts index 5665b13eb77..57da813d29b 100644 --- a/test/suites/dev/moonbase/test-eth-fee/test-eth-fee-history.ts +++ b/test/suites/dev/moonbase/test-eth-fee/test-eth-fee-history.ts @@ -28,7 +28,9 @@ describeSuite({ priority_fees: number[], max_fee_per_gas: string ) { - let nonce = await context.viem().getTransactionCount({ address: ALITH_ADDRESS }); + let nonce = await context + .viem("public") + .getTransactionCount({ address: ALITH_ADDRESS, blockTag: "pending" }); const contractData = fetchCompiledContract("MultiplyBy7"); for (let b = 0; b < block_count; b++) { for (let p = 0; p < priority_fees.length; p++) { @@ -75,9 +77,9 @@ describeSuite({ "should return two-dimensional reward list for the requested block range" ).to.be.eq(block_count); - const failures = feeResults.reward.filter((item) => { - item.length !== reward_percentiles.length; - }); + const failures = feeResults.reward.filter( + (item) => item.length !== reward_percentiles.length + ); expect( failures.length, "each block has a reward list which's size is the requested percentile list" @@ -92,61 +94,35 @@ describeSuite({ const block_count = 2; const reward_percentiles = [20, 50, 70]; const priority_fees = [1, 2, 3]; - const startingBlock = await context.viem().getBlockNumber(); - - const feeHistory = new Promise((resolve) => { - const unwatch = context.viem().watchBlocks({ - onBlock: async (block) => { - if (Number(block.number! - startingBlock) === block_count) { - const result = (await customDevRpcRequest("eth_feeHistory", [ - "0x2", - "latest", - reward_percentiles, - ])) as FeeHistory; - unwatch(); - resolve(result); - } - }, - }); - }); await createBlocks(block_count, priority_fees, parseGwei("10").toString()); - matchExpectations(await feeHistory, block_count, reward_percentiles); + const result = (await customDevRpcRequest("eth_feeHistory", [ + "0x2", + "latest", + reward_percentiles, + ])) as FeeHistory; + matchExpectations(result, block_count, reward_percentiles); }, }); it({ id: "T02", title: "should calculate percentiles", - timeout: 40_000, + timeout: 120_000, test: async function () { const max_fee_per_gas = parseGwei("10").toString(); const block_count = 11; const reward_percentiles = [20, 50, 70, 85, 100]; const priority_fees = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - const startingBlock = await context.viem().getBlockNumber(); - - const feeHistory = new Promise((resolve) => { - const unwatch = context.viem().watchBlocks({ - onBlock: async (block) => { - if (Number(block.number! - startingBlock) === block_count) { - const result = (await customDevRpcRequest("eth_feeHistory", [ - "0xA", - "latest", - reward_percentiles, - ])) as FeeHistory; - - unwatch(); - resolve(result); - } - }, - }); - }); await createBlocks(block_count, priority_fees, max_fee_per_gas); - const feeResults = await feeHistory; + const feeResults = (await customDevRpcRequest("eth_feeHistory", [ + "0xA", + "latest", + reward_percentiles, + ])) as FeeHistory; const localRewards = reward_percentiles .map((percentile) => getPercentile(percentile, priority_fees)) .map((reward) => numberToHex(reward)); @@ -174,32 +150,20 @@ describeSuite({ it({ id: "T03", title: "result length should match spec using an integer block count", - timeout: 40_000, + timeout: 120_000, test: async function () { const block_count = 2; const reward_percentiles = [20, 50, 70]; const priority_fees = [1, 2, 3]; - const startingBlock = await context.viem().getBlockNumber(); - - const feeHistory = new Promise((resolve) => { - const unwatch = context.viem().watchBlocks({ - onBlock: async (block) => { - if (Number(block.number! - startingBlock) === block_count) { - const result = (await customDevRpcRequest("eth_feeHistory", [ - block_count, - "latest", - reward_percentiles, - ])) as FeeHistory; - unwatch(); - resolve(result); - } - }, - }); - }); await createBlocks(block_count, priority_fees, parseGwei("10").toString()); - matchExpectations(await feeHistory, block_count, reward_percentiles); + const result = (await customDevRpcRequest("eth_feeHistory", [ + block_count, + "latest", + reward_percentiles, + ])) as FeeHistory; + matchExpectations(result, block_count, reward_percentiles); }, }); }, diff --git a/test/suites/dev/moonbase/test-eth-tx/test-eth-tx-access-list.ts b/test/suites/dev/moonbase/test-eth-tx/test-eth-tx-access-list.ts index b671fa38ca0..f62ddf03128 100644 --- a/test/suites/dev/moonbase/test-eth-tx/test-eth-tx-access-list.ts +++ b/test/suites/dev/moonbase/test-eth-tx/test-eth-tx-access-list.ts @@ -53,11 +53,10 @@ describeSuite({ ], }); - await context.createBlock(txWithAL); - const block = await context.viem().getBlock(); + const { result } = await context.createBlock(txWithAL); const receipt = await context .viem() - .getTransactionReceipt({ hash: block.transactions[0] as `0x${string}` }); + .getTransactionReceipt({ hash: result!.hash as `0x${string}` }); const gasCostWithAL = receipt.gasUsed; const txSize = txWithAL.length; @@ -117,11 +116,10 @@ describeSuite({ accessList, }); - await context.createBlock(txWithAL); - const block = await context.viem().getBlock(); + const { result } = await context.createBlock(txWithAL); const receipt = await context .viem() - .getTransactionReceipt({ hash: block.transactions[0] as `0x${string}` }); + .getTransactionReceipt({ hash: result!.hash as `0x${string}` }); const gasCostWithAL = receipt.gasUsed; const txSize = txWithAL.length; diff --git a/test/suites/dev/moonbase/test-eth-tx/test-test-tx-nonce.ts b/test/suites/dev/moonbase/test-eth-tx/test-test-tx-nonce.ts index d6d1cc8f14f..119cd4b4bcc 100644 --- a/test/suites/dev/moonbase/test-eth-tx/test-test-tx-nonce.ts +++ b/test/suites/dev/moonbase/test-eth-tx/test-test-tx-nonce.ts @@ -148,7 +148,7 @@ describeSuite({ abi: fetchCompiledContract("Incrementor").abi, functionName: "incr", }); - await context.createBlock( + const { result } = await context.createBlock( context.createTxn!({ privateKey: BALTATHAR_PRIVATE_KEY, to: incrementorAddress, @@ -158,7 +158,10 @@ describeSuite({ txnType: "legacy", }) ); - const block = await context.viem().getBlock({ blockTag: "latest" }); + const receipt = await context + .viem() + .getTransactionReceipt({ hash: result!.hash as `0x${string}` }); + const block = await context.viem().getBlock({ blockHash: receipt.blockHash }); expect(block.transactions.length, "should include the transaction in the block").to.be.eq( 1 ); diff --git a/test/suites/dev/moonbase/test-moon/test-moon-rpc.ts b/test/suites/dev/moonbase/test-moon/test-moon-rpc.ts index a1a08b34ded..2ac1d14b14a 100644 --- a/test/suites/dev/moonbase/test-moon/test-moon-rpc.ts +++ b/test/suites/dev/moonbase/test-moon/test-moon-rpc.ts @@ -89,7 +89,7 @@ describeSuite({ id: "T06", title: "should return as finalized when true", test: async function () { - await context.createBlock( + const { result } = await context.createBlock( await createViemTransaction(context, { to: BALTATHAR_ADDRESS, gas: 12_000_000n, @@ -99,8 +99,7 @@ describeSuite({ { finalize: true } ); - const block = await context.viem().getBlock(); - const resp = await api.rpc.moon.isTxFinalized(block.transactions[0]); + const resp = await api.rpc.moon.isTxFinalized(result!.hash as `0x${string}`); expect(resp.isTrue, "Transaction finalization status mismatch").toBe(true); }, }); @@ -109,7 +108,7 @@ describeSuite({ id: "T07", title: "should return as unfinalized when false", test: async function () { - await context.createBlock( + const { result } = await context.createBlock( await createViemTransaction(context, { to: BALTATHAR_ADDRESS, gas: 12_000_000n, @@ -119,8 +118,7 @@ describeSuite({ { finalize: false } ); - const block = await context.viem().getBlock(); - const resp = await api.rpc.moon.isTxFinalized(block.transactions[0]); + const resp = await api.rpc.moon.isTxFinalized(result!.hash as `0x${string}`); expect(resp.isTrue, "Transaction finalization status mismatch").toBe(false); }, }); @@ -139,7 +137,7 @@ describeSuite({ id: "T09", title: "should return as finalized when new block is true", test: async function () { - await context.createBlock( + const { result } = await context.createBlock( await createViemTransaction(context, { to: BALTATHAR_ADDRESS, gas: 12_000_000n, @@ -148,9 +146,8 @@ describeSuite({ }), { finalize: false } ); - const block = await context.viem().getBlock(); await context.createBlock([], { finalize: true }); - const resp = await api.rpc.moon.isTxFinalized(block.transactions[0]); + const resp = await api.rpc.moon.isTxFinalized(result!.hash as `0x${string}`); expect(resp.isTrue, "Transaction finalization status mismatch").toBe(true); }, }); @@ -159,22 +156,20 @@ describeSuite({ id: "T10", title: "should return as finalized when new block reorg happens", test: async function () { - const blockHash = ( - await context.createBlock( - await createViemTransaction(context, { - to: BALTATHAR_ADDRESS, - gas: 12_000_000n, - gasPrice: BigInt(DEFAULT_TXN_MAX_BASE_FEE), - value: 1_000_000n, - }), - { finalize: false } - ) - ).block.hash; - - const block = await context.viem().getBlock(); + const { block, result } = await context.createBlock( + await createViemTransaction(context, { + to: BALTATHAR_ADDRESS, + gas: 12_000_000n, + gasPrice: BigInt(DEFAULT_TXN_MAX_BASE_FEE), + value: 1_000_000n, + }), + { finalize: false } + ); + const blockHash = block.hash; + await context.createBlock([], { finalize: false }); await context.createBlock([], { finalize: true, parentHash: blockHash }); - const resp = await api.rpc.moon.isTxFinalized(block.transactions[0]); + const resp = await api.rpc.moon.isTxFinalized(result!.hash as `0x${string}`); expect(resp.isTrue, "Transaction finalization status mismatch").toBe(true); }, }); diff --git a/test/suites/dev/moonbase/test-receipt/test-receipt.ts b/test/suites/dev/moonbase/test-receipt/test-receipt.ts index bd5032c42a6..6a6df9f93be 100644 --- a/test/suites/dev/moonbase/test-receipt/test-receipt.ts +++ b/test/suites/dev/moonbase/test-receipt/test-receipt.ts @@ -52,12 +52,10 @@ describeSuite({ data: "0x", txnType: "eip1559", }); - await context.createBlock(rawTxn); - - const block = await context.viem().getBlock(); + const { result } = await context.createBlock(rawTxn); const receipt = await context .viem() - .getTransactionReceipt({ hash: block.transactions[0] as `0x${string}` }); + .getTransactionReceipt({ hash: result!.hash as `0x${string}` }); // The receipt should contain an effective gas price of 2GWEI. expect(receipt.effectiveGasPrice).to.be.eq(maxFeePerGas); }, diff --git a/test/suites/dev/moonbase/test-storage-growth/test-block-storage-growth.ts b/test/suites/dev/moonbase/test-storage-growth/test-block-storage-growth.ts index 27aff014073..3d65e65467e 100644 --- a/test/suites/dev/moonbase/test-storage-growth/test-block-storage-growth.ts +++ b/test/suites/dev/moonbase/test-storage-growth/test-block-storage-growth.ts @@ -32,8 +32,9 @@ describeSuite({ await sendRawTransaction(context, rawTxn); } + const blockNumber = (await context.viem().getBlockNumber()) + 1n; await context.createBlock(); - expect((await context.viem().getBlock()).transactions.length).toBe(264); + expect((await context.viem().getBlock({ blockNumber })).transactions.length).toBe(264); }, }); }, diff --git a/test/suites/dev/moonbase/test-subscription/test-subscription-logs.ts b/test/suites/dev/moonbase/test-subscription/test-subscription-logs.ts index 99e3c0c7b08..e54a4d7d6ea 100644 --- a/test/suites/dev/moonbase/test-subscription/test-subscription-logs.ts +++ b/test/suites/dev/moonbase/test-subscription/test-subscription-logs.ts @@ -27,7 +27,9 @@ describeSuite({ await context.deployContract!("EventEmitter"); }); - const block = await context.viem().getBlock(); + const txHash = logs[0].transactionHash as `0x${string}`; + const tx = await context.viem().getTransaction({ hash: txHash }); + const block = await context.viem().getBlock({ blockHash: tx.blockHash! }); expect(logs[0]).to.include({ blockHash: block.hash, @@ -35,7 +37,7 @@ describeSuite({ data: "0x", logIndex: 0n, removed: false, - transactionHash: block.transactions[0], + transactionHash: txHash, transactionIndex: 0n, }); }, diff --git a/test/suites/dev/moonbase/test-txpool/test-txpool-limits2.ts b/test/suites/dev/moonbase/test-txpool/test-txpool-limits2.ts index 4f7c02f8fbc..c36d61e3b28 100644 --- a/test/suites/dev/moonbase/test-txpool/test-txpool-limits2.ts +++ b/test/suites/dev/moonbase/test-txpool/test-txpool-limits2.ts @@ -31,8 +31,9 @@ describeSuite({ await context.viem().sendRawTransaction({ serializedTransaction: tx }); } + const blockNumber = (await context.viem().getBlockNumber()) + 1n; await context.createBlock(); - expect((await getBlockWithRetry(context)).transactions.length).toBe(284); + expect((await getBlockWithRetry(context, { blockNumber })).transactions.length).toBe(284); }, }); }, diff --git a/test/suites/dev/moonbase/test-xcm-v3/test-mock-hrmp-transact-ethereum-10.ts b/test/suites/dev/moonbase/test-xcm-v3/test-mock-hrmp-transact-ethereum-10.ts index d51b6914d84..d3a60f83591 100644 --- a/test/suites/dev/moonbase/test-xcm-v3/test-mock-hrmp-transact-ethereum-10.ts +++ b/test/suites/dev/moonbase/test-xcm-v3/test-mock-hrmp-transact-ethereum-10.ts @@ -150,15 +150,15 @@ describeSuite({ .as_v3(); // Send an XCM and create block to execute it + const blockNumber = (await context.viem().getBlockNumber()) + 1n; await injectHrmpMessageAndSeal(context, 1, { type: "XcmVersionedXcm", payload: xcmMessage, } as RawXcmMessage); - - const block = await context.viem().getBlock({ blockTag: "latest" }); + const ethBlock = await context.viem().getBlock({ blockNumber }); // Input size is valid - on the limit -, expect block to include a transaction. // That means the pallet-ethereum-xcm decoded the provided input to a BoundedVec. - expect(block.transactions.length).to.be.eq(1); + expect(ethBlock.transactions.length).to.be.eq(1); } }, }); diff --git a/test/suites/tracing-tests/test-trace-5.ts b/test/suites/tracing-tests/test-trace-5.ts index da9d8ef8ba4..9916d466b4a 100644 --- a/test/suites/tracing-tests/test-trace-5.ts +++ b/test/suites/tracing-tests/test-trace-5.ts @@ -105,9 +105,10 @@ describeSuite({ contracts.abiCaller, nonce++ ); + const blockNumber = (await context.viem().getBlockNumber()) + 1n; await context.createBlock(); - const block = await context.viem().getBlock({ blockTag: "latest" }); - const block_number = context.web3().utils.toHex(await context.viem().getBlockNumber()); + const block = await context.viem().getBlock({ blockNumber }); + const block_number = context.web3().utils.toHex(blockNumber); const block_hash = block.hash; // Trace block by number. let traceTx = await customDevRpcRequest("debug_traceBlockByNumber", [ diff --git a/test/suites/tracing-tests/test-trace-erc20-xcm-2.ts b/test/suites/tracing-tests/test-trace-erc20-xcm-2.ts index 6f9aae9f974..e904b35cedf 100644 --- a/test/suites/tracing-tests/test-trace-erc20-xcm-2.ts +++ b/test/suites/tracing-tests/test-trace-erc20-xcm-2.ts @@ -126,7 +126,7 @@ describeSuite({ // By calling deployContract() a new block will be created, // including the ethereum-xcm transaction (on_initialize) + regular ethereum transaction - const { contractAddress: eventEmitterAddress_ } = await context.deployContract!( + const { contractAddress: eventEmitterAddress_, hash } = await context.deployContract!( "EventEmitter", { from: alith.address, @@ -138,7 +138,7 @@ describeSuite({ ).block.header.number.toNumber(); // The old buggy runtime rollback the eth-xcm tx because XCM executor rollback evm reverts - regularEthTxHash = (await context.viem().getBlock()).transactions[0]; + regularEthTxHash = hash; // Compute XCM message ID const messageHash = context.polkadotJs().createType("XcmVersionedXcm", failedXcmMessage).hash; diff --git a/test/suites/tracing-tests/test-trace-erc20-xcm.ts b/test/suites/tracing-tests/test-trace-erc20-xcm.ts index cc930bade25..53baed12782 100644 --- a/test/suites/tracing-tests/test-trace-erc20-xcm.ts +++ b/test/suites/tracing-tests/test-trace-erc20-xcm.ts @@ -27,6 +27,7 @@ describeSuite({ let transactionHash: string; let eventEmitterAddress: `0x${string}`; let createTransactionHash: string; + let deployBlockNumber: number; beforeAll(async () => { const { contractAddress, status } = await context.deployContract!("ERC20WithInitialSupply", { args: ["ERC20", "20S", ALITH_ADDRESS, ERC20_TOTAL_SUPPLY], @@ -116,12 +117,14 @@ describeSuite({ .as_v3(); // Mock the reception of the xcm message + const successfulXcmBlockNumber = (await context.viem().getBlockNumber()) + 1n; await injectHrmpMessageAndSeal(context, paraId, { type: "XcmVersionedXcm", payload: xcmMessage, }); - transactionHash = (await context.viem().getBlock()).transactions[0]; + transactionHash = (await context.viem().getBlock({ blockNumber: successfulXcmBlockNumber })) + .transactions[0]; // Erc20 tokens should have been received expect( @@ -183,15 +186,17 @@ describeSuite({ // By calling deployContract() a new block will be created, // including the ethereum xcm transaction + regular ethereum transaction - const { contractAddress: eventEmitterAddress_ } = await context.deployContract!( + const { contractAddress: eventEmitterAddress_, hash } = await context.deployContract!( "EventEmitter", { from: alith.address, } as any ); eventEmitterAddress = eventEmitterAddress_; - - createTransactionHash = (await context.viem().getBlock()).transactions[0]; + deployBlockNumber = ( + await context.polkadotJs().rpc.chain.getBlock() + ).block.header.number.toNumber(); + createTransactionHash = hash; // Get the latest block events const block = await context.polkadotJs().rpc.chain.getBlock(); @@ -234,9 +239,8 @@ describeSuite({ id: "T02", title: "should doesn't include the failed ERC20 xcm transaction in block trace", test: async function () { - const number = await context.viem().getBlockNumber(); const trace = await customDevRpcRequest("debug_traceBlockByNumber", [ - number.toString(), + deployBlockNumber.toString(), { tracer: "callTracer" }, ]); diff --git a/test/suites/tracing-tests/test-trace-ethereum-xcm-1.ts b/test/suites/tracing-tests/test-trace-ethereum-xcm-1.ts index c19a8e280da..2ec43faa0be 100644 --- a/test/suites/tracing-tests/test-trace-ethereum-xcm-1.ts +++ b/test/suites/tracing-tests/test-trace-ethereum-xcm-1.ts @@ -111,16 +111,16 @@ describeSuite({ }) .as_v3(); + const processedBlockNumber = (await context.viem().getBlockNumber()) + 1n; // Send an XCM and create block to execute it await injectHrmpMessageAndSeal(context, 1, { type: "XcmVersionedXcm", payload: xcmMessage, } as RawXcmMessage); - // Retrieve the stored ethereum transaction hash - transactionHashes.push( - (await context.viem().getBlock({ blockTag: "latest" })).transactions[0] - ); + // Retrieve the processed block tx hash using explicit block number. + const processedBlock = await context.viem().getBlock({ blockNumber: processedBlockNumber }); + transactionHashes.push(processedBlock.transactions[0]); } }); diff --git a/test/suites/tracing-tests/test-trace-ethereum-xcm-3.ts b/test/suites/tracing-tests/test-trace-ethereum-xcm-3.ts index 314fed0e07b..ca648e27ea9 100644 --- a/test/suites/tracing-tests/test-trace-ethereum-xcm-3.ts +++ b/test/suites/tracing-tests/test-trace-ethereum-xcm-3.ts @@ -110,9 +110,11 @@ describeSuite({ } // Block that processes the hrmp messasges in the message queue + const processedBlockNumber = (await context.viem().getBlockNumber()) + 1n; await context.createBlock(); - const txHashes = (await context.viem().getBlock({ blockTag: "latest" })).transactions; + const txHashes = (await context.viem().getBlock({ blockNumber: processedBlockNumber })) + .transactions; expect(txHashes.length).toBe(2); transactionHashes.push(...txHashes); });