Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api_server): fix blob_gas length #2673

Merged
merged 8 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions core/node/api_server/src/web3/namespaces/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions core/tests/ts-integration/tests/api/web3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading