[go: up one dir, main page]

Update block Object to add baseFeePerGas and mixHash

What

Issue #7178 (closed)

This MR adds base_fee_per_gas to results of getBlockBy* RPC.

Why

Fields in the block result of getBlockBy* RPC that we don't have includes.

  • baseFeePerGas: Optional. But we should support it since its a important value for EIP-1559 (Added in this MR)
  • mixHash : Required. This field is only relevant to mining. We can always return empty hash (Added in this MR)
  • withdrawalsRoot: Optional. Related to L1 staking. We can ignore.
  • withdrawals: Optional. Related to L1 staking. We can ignore.
  • blobGasUsed: Optional. Introduced in Dencun for L2. We can ignore
  • excessBlobGas: Optional. Introduced in Dencun for L2. We can ignore
  • parentBeaconBlockRoot: Optional. Introduced in Dencun. We can ignore

How

2 Additional fields are added to blocks type. Since getBlockby* RPC is done by reading the durable storage directly, relevant encode and decode function are updated in both the kernel and the evm node.

Backward Compatibility

The most tricky part of this MR is that we need backward compatibility with existing block. One way to achieve this is to migrate all existing blocks into the new format, which is error prone. Therefore, this MR introduces a backward compatible encoding, designed according to https://docs.google.com/document/d/1t0yTd6-Zp79xhPLQEROY-Ob5aP6xMgUSwb8Rw1eJ4I8/edit (The approach is very similar to encoding of different transaction types in tx_common.rs)

All new blocks would start with a version tag. Those that don't would be identified as legacy blocks.

Manually testing the MR

A new tezt test named "getBlockBy returns base fee per gas and mix hash" is created in evm_rollup.ml to test the change.

Potential issue

The MR failed in a tezt test named "Sequencer can upgrade from ghostnet" from "evm_sequencer". In that test, decoding of a stored block failed and eventually leads to a "path not found" error in a "store_read" function. A hacky fix is made in storage.rs to use from_bytes directly when from_rlp_bytes failed. That fixes all the test cases, but the cause of the failure is still not fully understood. This part should be carefully reviewed

Things to consider

  • What value of base_fee_per_gas should we assign to existing block. Options include:
    • Minimum base fee per gas (Current approach)
    • Zero (In spec for eth_feeHistory https://docs.alchemy.com/reference/eth-feehistory of sequent MR, we can find "BASEFEEPERGAS - An array of block base fees per gas. This includes the next block after the newest of the returned range, because this value can be derived from the newest block. Zeroes are returned for pre-EIP-1559 blocks." )
  • What should we do with irrelevant output field. Option include:
    • Don't return them (Current approach)
    • Return them with default value

Checklist

  • Document the interface of any function added or modified (see the coding guidelines)
  • Document any change to the user interface, including configuration parameters (see node configuration)
  • Provide automatic testing (see the testing guide).
  • For new features and bug fixes, add an item in the appropriate changelog (docs/protocols/alpha.rst for the protocol and the environment, CHANGES.rst at the root of the repository for everything else).
  • Select suitable reviewers using the Reviewers field below.
  • Select as Assignee the next person who should take action on that MR
Edited by Hantang Sun

Merge request reports

Loading