diff --git a/Cargo.lock b/Cargo.lock index a212783229..5657a4dd18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3088,7 +3088,7 @@ dependencies = [ [[package]] name = "fc-api" version = "1.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "async-trait", "fp-storage", @@ -3100,7 +3100,7 @@ dependencies = [ [[package]] name = "fc-consensus" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "async-trait", "fp-consensus", @@ -3116,7 +3116,7 @@ dependencies = [ [[package]] name = "fc-db" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "async-trait", "ethereum", @@ -3146,7 +3146,7 @@ dependencies = [ [[package]] name = "fc-mapping-sync" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "fc-db", "fc-storage", @@ -3169,7 +3169,7 @@ dependencies = [ [[package]] name = "fc-rpc" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "ethereum", "ethereum-types", @@ -3223,7 +3223,7 @@ dependencies = [ [[package]] name = "fc-rpc-core" version = "1.1.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "ethereum", "ethereum-types", @@ -3238,7 +3238,7 @@ dependencies = [ [[package]] name = "fc-storage" version = "1.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "ethereum", "ethereum-types", @@ -3428,7 +3428,7 @@ dependencies = [ [[package]] name = "fp-account" version = "1.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "hex", "impl-serde", @@ -3447,7 +3447,7 @@ dependencies = [ [[package]] name = "fp-consensus" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "ethereum", "parity-scale-codec", @@ -3458,7 +3458,7 @@ dependencies = [ [[package]] name = "fp-ethereum" version = "1.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "ethereum", "ethereum-types", @@ -3470,7 +3470,7 @@ dependencies = [ [[package]] name = "fp-evm" version = "3.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "environmental", "evm", @@ -3486,7 +3486,7 @@ dependencies = [ [[package]] name = "fp-rpc" version = "3.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "ethereum", "ethereum-types", @@ -3502,7 +3502,7 @@ dependencies = [ [[package]] name = "fp-self-contained" version = "1.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "frame-support", "parity-scale-codec", @@ -3514,7 +3514,7 @@ dependencies = [ [[package]] name = "fp-storage" version = "2.0.0" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "parity-scale-codec", "serde", @@ -8584,7 +8584,7 @@ dependencies = [ [[package]] name = "pallet-ethereum" version = "4.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "environmental", "ethereum", @@ -8640,7 +8640,7 @@ dependencies = [ [[package]] name = "pallet-evm" version = "6.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "environmental", "evm", @@ -8663,7 +8663,7 @@ dependencies = [ [[package]] name = "pallet-evm-chain-id" version = "1.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "frame-support", "frame-system", @@ -8758,7 +8758,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-blake2" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "fp-evm", ] @@ -8766,7 +8766,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-bn128" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "fp-evm", "sp-core", @@ -8898,7 +8898,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-dispatch" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "fp-evm", "frame-support", @@ -8974,7 +8974,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-modexp" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "fp-evm", "num", @@ -9219,7 +9219,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-sha3fips" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "fp-evm", "tiny-keccak", @@ -9228,7 +9228,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-simple" version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "fp-evm", "ripemd", @@ -9238,7 +9238,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-storage-cleaner" version = "0.1.0" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "fp-evm", "frame-support", @@ -11976,7 +11976,7 @@ dependencies = [ [[package]] name = "precompile-utils" version = "0.1.0" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "derive_more", "environmental", @@ -12005,7 +12005,7 @@ dependencies = [ [[package]] name = "precompile-utils-macro" version = "0.1.0" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#e4fcc126ef2a584ef6ea361d9ee828aabaeec239" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-stable2407#439e782fb9754c38188158cd65d1eba6fe9f0e65" dependencies = [ "case", "num_enum 0.7.3", 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 2c9e248829..0afc040fc3 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 @@ -20,7 +20,6 @@ describeSuite({ async function createBlocks( block_count: number, - reward_percentiles: number[], priority_fees: number[], max_fee_per_gas: string ) { @@ -45,7 +44,7 @@ describeSuite({ } } - function get_percentile(percentile: number, array: number[]) { + function getPercentile(percentile: number, array: number[]) { array.sort(function (a, b) { return a - b; }); @@ -57,6 +56,30 @@ describeSuite({ } } + function matchExpectations( + feeResults: FeeHistory, + block_count: number, + reward_percentiles: number[] + ) { + expect( + feeResults.baseFeePerGas.length, + "baseFeePerGas should always the requested block range + 1 (the next derived base fee)" + ).toBe(block_count + 1); + expect(feeResults.gasUsedRatio).to.be.deep.eq(Array(block_count).fill(0.0105225)); + expect( + feeResults.reward.length, + "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; + }); + expect( + failures.length, + "each block has a reward list which's size is the requested percentile list" + ).toBe(0); + } + it({ id: "T01", title: "result length should match spec", @@ -83,31 +106,9 @@ describeSuite({ }); }); - await createBlocks( - block_count, - reward_percentiles, - priority_fees, - parseGwei("10").toString() - ); - - const feeResults = await feeHistory; - expect( - feeResults.baseFeePerGas.length, - "baseFeePerGas should always the requested block range + 1 (the next derived base fee)" - ).toBe(block_count + 1); - expect(feeResults.gasUsedRatio).to.be.deep.eq(Array(block_count).fill(0.0105225)); - expect( - feeResults.reward.length, - "should return two-dimensional reward list for the requested block range" - ).to.be.eq(block_count); + await createBlocks(block_count, priority_fees, parseGwei("10").toString()); - 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" - ).toBe(0); + matchExpectations(await feeHistory, block_count, reward_percentiles); }, }); @@ -139,11 +140,11 @@ describeSuite({ }); }); - await createBlocks(block_count, reward_percentiles, priority_fees, max_fee_per_gas); + await createBlocks(block_count, priority_fees, max_fee_per_gas); const feeResults = await feeHistory; const localRewards = reward_percentiles - .map((percentile) => get_percentile(percentile, priority_fees)) + .map((percentile) => getPercentile(percentile, priority_fees)) .map((reward) => numberToHex(reward)); // We only test if BaseFee update is enabled. // @@ -165,5 +166,37 @@ describeSuite({ ).toBe(0); }, }); + + it({ + id: "T03", + title: "result length should match spec using an integer block count", + timeout: 40_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, reject) => { + 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); + }, + }); }, });