diff --git a/Cargo.lock b/Cargo.lock index bb999b60c7..9b0317ed94 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3389,7 +3389,7 @@ dependencies = [ [[package]] name = "fc-api" version = "1.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "async-trait", "fp-storage", @@ -3401,7 +3401,7 @@ dependencies = [ [[package]] name = "fc-consensus" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "async-trait", "fp-consensus", @@ -3417,7 +3417,7 @@ dependencies = [ [[package]] name = "fc-db" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "async-trait", "ethereum", @@ -3447,7 +3447,7 @@ dependencies = [ [[package]] name = "fc-mapping-sync" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "fc-db", "fc-storage", @@ -3470,7 +3470,7 @@ dependencies = [ [[package]] name = "fc-rpc" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "ethereum", "ethereum-types", @@ -3524,7 +3524,7 @@ dependencies = [ [[package]] name = "fc-rpc-core" version = "1.1.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "ethereum", "ethereum-types", @@ -3539,7 +3539,7 @@ dependencies = [ [[package]] name = "fc-storage" version = "1.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "ethereum", "ethereum-types", @@ -3733,7 +3733,7 @@ dependencies = [ [[package]] name = "fp-account" version = "1.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "hex", "impl-serde 0.4.0", @@ -3751,7 +3751,7 @@ dependencies = [ [[package]] name = "fp-consensus" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "ethereum", "parity-scale-codec", @@ -3762,7 +3762,7 @@ dependencies = [ [[package]] name = "fp-ethereum" version = "1.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "ethereum", "ethereum-types", @@ -3774,7 +3774,7 @@ dependencies = [ [[package]] name = "fp-evm" version = "3.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "evm", "frame-support", @@ -3789,7 +3789,7 @@ dependencies = [ [[package]] name = "fp-rpc" version = "3.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "ethereum", "ethereum-types", @@ -3805,7 +3805,7 @@ dependencies = [ [[package]] name = "fp-self-contained" version = "1.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "frame-support", "parity-scale-codec", @@ -3817,7 +3817,7 @@ dependencies = [ [[package]] name = "fp-storage" version = "2.0.0" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "parity-scale-codec", "serde", @@ -8740,7 +8740,7 @@ dependencies = [ [[package]] name = "pallet-ethereum" version = "4.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "environmental", "ethereum", @@ -8796,7 +8796,7 @@ dependencies = [ [[package]] name = "pallet-evm" version = "6.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "environmental", "evm", @@ -8821,7 +8821,7 @@ dependencies = [ [[package]] name = "pallet-evm-chain-id" version = "1.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "frame-support", "frame-system", @@ -8916,7 +8916,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-blake2" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "fp-evm", ] @@ -8924,7 +8924,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-bn128" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "fp-evm", "sp-core", @@ -9056,7 +9056,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-dispatch" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "fp-evm", "frame-support", @@ -9133,7 +9133,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-modexp" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "fp-evm", "num", @@ -9379,7 +9379,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-sha3fips" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "fp-evm", "tiny-keccak", @@ -9388,7 +9388,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-simple" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "fp-evm", "ripemd", @@ -9398,7 +9398,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-storage-cleaner" version = "0.1.0" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "fp-evm", "frame-support", @@ -12159,7 +12159,7 @@ dependencies = [ [[package]] name = "precompile-utils" version = "0.1.0" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "derive_more", "environmental", @@ -12188,7 +12188,7 @@ dependencies = [ [[package]] name = "precompile-utils-macro" version = "0.1.0" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#45d16ae4c8b32e26fdab8353b704fd59ea0ddb8c" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.11.0#9a91f3d2369c3a9380ef53bdf26fab2679069e52" dependencies = [ "case", "num_enum 0.7.2", diff --git a/client/rpc/finality/src/lib.rs b/client/rpc/finality/src/lib.rs index 988d8d316c..32ad0ca012 100644 --- a/client/rpc/finality/src/lib.rs +++ b/client/rpc/finality/src/lib.rs @@ -37,9 +37,9 @@ pub trait MoonbeamFinalityApi { #[method(name = "moon_isTxFinalized")] async fn is_tx_finalized(&self, tx_hash: H256) -> RpcResult; - /// Gets the latest block hash that is fully indexed in frontier's backend. - #[method(name = "moon_getLatestBlockHash")] - async fn get_latest_block_hash(&self) -> RpcResult; + /// Gets the range of blocks that are fully indexed in frontier's backend. + #[method(name = "moon_getEthSyncBlockRange")] + async fn get_frontier_sync_block_range(&self) -> RpcResult<(H256, H256)>; } pub struct MoonbeamFinality { @@ -88,11 +88,18 @@ where } } - async fn get_latest_block_hash(&self) -> RpcResult { - let res = self.backend.deref().latest_block_hash().await; - match res { - Ok(val) => Ok(val), - Err(e) => Err(ErrorObject::owned( + async fn get_frontier_sync_block_range(&self) -> RpcResult<(H256, H256)> { + match ( + self.backend.deref().first_block_hash().await, + self.backend.deref().latest_block_hash().await, + ) { + (Ok(first), Ok(last)) => Ok((first, last)), + (Err(e), _) => Err(ErrorObject::owned( + jsonrpsee::types::error::UNKNOWN_ERROR_CODE, + "No synced block", + Some(e), + )), + (_, Err(e)) => Err(ErrorObject::owned( jsonrpsee::types::error::UNKNOWN_ERROR_CODE, "No synced block", Some(e), diff --git a/precompiles/proxy/src/tests.rs b/precompiles/proxy/src/tests.rs index 8597a7ac3d..031be2c5e2 100644 --- a/precompiles/proxy/src/tests.rs +++ b/precompiles/proxy/src/tests.rs @@ -579,6 +579,13 @@ fn fails_if_called_by_smart_contract() { .execute_with(|| { // Set code to Alice address as it if was a smart contract. pallet_evm::AccountCodes::::insert(H160::from(Alice), vec![10u8]); + pallet_evm::AccountCodesMetadata::::insert( + H160::from(Alice), + pallet_evm::CodeMetadata { + size: 10, + hash: H256::default(), + }, + ); PrecompilesValue::get() .prepare_test( @@ -777,7 +784,21 @@ fn proxy_proxy_should_fail_if_called_by_smart_contract_for_a_non_eoa_account() { .execute_with(|| { // Set code to Alice & Bob addresses as if they are smart contracts. pallet_evm::AccountCodes::::insert(H160::from(Alice), vec![10u8]); + pallet_evm::AccountCodesMetadata::::insert( + H160::from(Alice), + pallet_evm::CodeMetadata { + size: 10, + hash: H256::default(), + }, + ); pallet_evm::AccountCodes::::insert(H160::from(Bob), vec![10u8]); + pallet_evm::AccountCodesMetadata::::insert( + H160::from(Bob), + pallet_evm::CodeMetadata { + size: 10, + hash: H256::default(), + }, + ); // Bob allows Alice to make calls on his behalf assert_ok!(RuntimeCall::Proxy(ProxyCall::add_proxy { diff --git a/precompiles/xcm-utils/src/tests.rs b/precompiles/xcm-utils/src/tests.rs index 861078690d..01e211101c 100644 --- a/precompiles/xcm-utils/src/tests.rs +++ b/precompiles/xcm-utils/src/tests.rs @@ -244,6 +244,13 @@ fn execute_fails_if_called_by_smart_contract() { .execute_with(|| { // Set code to Alice address as it if was a smart contract. pallet_evm::AccountCodes::::insert(H160::from(Alice), vec![10u8]); + pallet_evm::AccountCodesMetadata::::insert( + H160::from(Alice), + pallet_evm::CodeMetadata { + size: 10, + hash: sp_core::H256::default(), + }, + ); let xcm_to_execute = VersionedXcm::<()>::V4(Xcm(vec![ClearOrigin])).encode(); diff --git a/test/helpers/assets.ts b/test/helpers/assets.ts index c4b47f6a7b..942d885f4e 100644 --- a/test/helpers/assets.ts +++ b/test/helpers/assets.ts @@ -4,9 +4,13 @@ import { BN, hexToU8a, u8aToHex } from "@polkadot/util"; import { expect, DevModeContext } from "@moonwall/cli"; import { blake2AsU8a, xxhashAsU8a } from "@polkadot/util-crypto"; import { KeyringPair } from "@polkadot/keyring/types"; -import type { PalletAssetsAssetAccount, PalletAssetsAssetDetails } from "@polkadot/types/lookup"; +import type { + PalletAssetsAssetAccount, + PalletAssetsAssetDetails, + PalletEvmCodeMetadata, +} from "@polkadot/types/lookup"; import type { AccountId20 } from "@polkadot/types/interfaces/runtime"; -import { encodeFunctionData, parseAbi } from "viem"; +import { encodeFunctionData, keccak256, parseAbi } from "viem"; export const EVM_FOREIGN_ASSETS_PALLET_ACCOUNT = "0x6d6f646c666f7267617373740000000000000000"; export const ARBITRARY_ASSET_ID = 42259045809535163221576417993425387648n; @@ -237,6 +241,18 @@ export async function mockOldAssetBalance( const assetKey = xxhashAsU8a(new TextEncoder().encode("Asset"), 128); const overallAssetKey = new Uint8Array([...module, ...assetKey, ...blake2concatAssetId]); const evmCodeAssetKey = api.query.evm.accountCodes.key("0xFfFFfFff" + assetId.toHex().slice(2)); + const evmCodesMetadataAssetKey = api.query.evm.accountCodesMetadata.key( + "0xFfFFfFff" + assetId.toHex().slice(2) + ); + + const codeSize = DUMMY_REVERT_BYTECODE.slice(2).length / 2; + const codeMetadataHash = keccak256(DUMMY_REVERT_BYTECODE); + const mockPalletEvmCodeMetadata: PalletEvmCodeMetadata = context + .polkadotJs() + .createType("PalletEvmCodeMetadata", { + size: codeSize, + hash: codeMetadataHash, + }); await context.createBlock( api.tx.sudo @@ -250,6 +266,7 @@ export async function mockOldAssetBalance( .toString(16) .padStart(2)}${DUMMY_REVERT_BYTECODE.slice(2)}`, ], + [evmCodesMetadataAssetKey, u8aToHex(mockPalletEvmCodeMetadata.toU8a())], ]) ) .signAsync(sudoAccount) 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 cfd45d7ba8..d32ee383c9 100644 --- a/test/suites/dev/moonbase/test-moon/test-moon-rpc.ts +++ b/test/suites/dev/moonbase/test-moon/test-moon-rpc.ts @@ -161,8 +161,10 @@ describeSuite({ title: "should return latest synced block", test: async function () { const expected = await context.createBlock([], { finalize: true }); - const resp = await customDevRpcRequest("moon_getLatestBlockHash", []); - expect(resp, "Latest block hash").toBe(expected.block.hash); + const firstBlockHash = (await context.polkadotJs().rpc.chain.getBlockHash(0)).toHex(); + const resp = await customDevRpcRequest("moon_getEthSyncBlockRange", []); + expect(resp[0], "First block hash").toBe(firstBlockHash); + expect(resp[1], "Latest block hash").toBe(expected.block.hash); }, }); }, diff --git a/test/suites/dev/moonbase/test-randomness/test-randomness-babe-lottery2.ts b/test/suites/dev/moonbase/test-randomness/test-randomness-babe-lottery2.ts index aaab75412c..98b9664e3b 100644 --- a/test/suites/dev/moonbase/test-randomness/test-randomness-babe-lottery2.ts +++ b/test/suites/dev/moonbase/test-randomness/test-randomness-babe-lottery2.ts @@ -41,7 +41,7 @@ describeSuite({ functionName: "fulfillRequest", args: [0], rawTxOnly: true, - gas: 500_000n, + gas: 700_000n, // TODO: estimate gas and snapshot the estimation privateKey: BALTATHAR_PRIVATE_KEY, }); diff --git a/test/suites/dev/moonbase/test-randomness/test-randomness-vrf-lottery5.ts b/test/suites/dev/moonbase/test-randomness/test-randomness-vrf-lottery5.ts index ba53085240..f4db007ec1 100644 --- a/test/suites/dev/moonbase/test-randomness/test-randomness-vrf-lottery5.ts +++ b/test/suites/dev/moonbase/test-randomness/test-randomness-vrf-lottery5.ts @@ -44,7 +44,7 @@ describeSuite({ precompileName: "Randomness", functionName: "fulfillRequest", args: [0], - gas: 500_000n, + gas: 700_000n, // TODO: estimate gas and snapshot the estimation rawTxOnly: true, }); const { result } = await context.createBlock(rawTxn);