diff --git a/core/node/api_server/src/web3/namespaces/eth.rs b/core/node/api_server/src/web3/namespaces/eth.rs index fda5ff6f06be..0bc0bce30d73 100644 --- a/core/node/api_server/src/web3/namespaces/eth.rs +++ b/core/node/api_server/src/web3/namespaces/eth.rs @@ -690,15 +690,16 @@ impl EthNamespace { base_fee_per_gas.len() ]); + // `base_fee_per_gas` for next L2 block cannot be calculated, appending last fee as a placeholder. + base_fee_per_gas.push(*base_fee_per_gas.last().unwrap()); + // We do not support EIP-4844, but per API specification we should return 0 for pre EIP-4844 blocks. let base_fee_per_blob_gas = vec![U256::zero(); base_fee_per_gas.len()]; - let blob_gas_used_ratio = vec![0.0; base_fee_per_gas.len()]; + let blob_gas_used_ratio = vec![0.0; gas_used_ratio.len()]; - // `base_fee_per_gas` for next L2 block cannot be calculated, appending last fee as a placeholder. - base_fee_per_gas.push(*base_fee_per_gas.last().unwrap()); Ok(FeeHistory { inner: web3::FeeHistory { - oldest_block: zksync_types::web3::BlockNumber::Number(oldest_block.into()), + oldest_block: web3::BlockNumber::Number(oldest_block.into()), base_fee_per_gas, gas_used_ratio, reward, diff --git a/core/tests/ts-integration/tests/api/web3.test.ts b/core/tests/ts-integration/tests/api/web3.test.ts index 79789e744471..6f1b6c3aa6b8 100644 --- a/core/tests/ts-integration/tests/api/web3.test.ts +++ b/core/tests/ts-integration/tests/api/web3.test.ts @@ -843,6 +843,10 @@ describe('web3 API compatibility tests', () => { expect(parseInt(response.oldestBlock)).toEqual(receipt.blockNumber - 1); expect(response.baseFeePerGas).toHaveLength(3); + expect(response.baseFeePerBlobGas).toHaveLength(3); + expect(response.gasUsedRatio).toHaveLength(2); + expect(response.blobGasUsedRatio).toHaveLength(2); + expect(response.l2PubdataPrice).toHaveLength(2); for (let i = 0; i < 2; i += 1) { const expectedBaseFee = (await alice.provider.getBlock(receipt.blockNumber - 1 + i)).baseFeePerGas; expect(BigInt(response.baseFeePerGas[i])).toEqual(expectedBaseFee);