Skip to content

l2geth: berlin hardfork#1798

Merged
smartcontracts merged 24 commits intodevelopfrom
fix/eip2930
Jan 28, 2022
Merged

l2geth: berlin hardfork#1798
smartcontracts merged 24 commits intodevelopfrom
fix/eip2930

Conversation

@tynes
Copy link
Copy Markdown
Contributor

@tynes tynes commented Nov 22, 2021

Description
Implement the first hard fork to happen on Optimism. It is called "Berlin" but it actually includes 2 EIPs from Berlin and 1 from London. Thoughts on using a different name or is Berlin fine?

The features include:

This will make the network have the same gas metering as mainnet ethereum, while not supporting typed transactions.

EIP 2929 adds the concept of warm and cold storage through access lists. Optimism previously increased the cost of state accessing opcodes above the Istanbul costs to prevent denial of service attacks on the network. These attacks are prohibitively expensive as the base hardware requirement for an L2 node is higher than the base requirement for a L1 node.

EIP 2565 reduces the cost of the modular exponentiation precompile, found at address(5)

EIP 3529 bricks gas token by reducing refunds from selfdestruct. If gas token was allowed, then users would be able to speculate on L1 gas prices on L2 due to the L2 fees being driven by L1 fees.

We need to ensure that this PR can sync existing mainnet without any execution divergences. It should because the existing genesis.json file does not define a berlinBlock hardfork height. We will need to determine the hardfork height and then have all nodes run geth init with the new genesis.json. Once consensus is established around the height at which we will be hardforking, we will make the new genesis.json available. The only change that needs to happen is defining the berlinBlock field.

All node operators must upgrade their software as this is a hardfork. There will be ample communications to ensure that everybody is properly upgraded.

The opcode gas changes for EIP 2929 and EIP 3529 are in 4a85d6b58246da8f1284c12e118407fe8b89802f

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Nov 22, 2021

🦋 Changeset detected

Latest commit: 952b526

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@eth-optimism/integration-tests Patch
@eth-optimism/l2geth Patch
@eth-optimism/contracts Patch
@eth-optimism/batch-submitter Patch
@eth-optimism/data-transport-layer Patch
@eth-optimism/message-relayer Patch
@eth-optimism/sdk Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Nov 22, 2021

Codecov Report

Merging #1798 (952b526) into develop (d14ee9f) will increase coverage by 0.37%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1798      +/-   ##
===========================================
+ Coverage    74.79%   75.16%   +0.37%     
===========================================
  Files           81       81              
  Lines         2698     2702       +4     
  Branches       433      435       +2     
===========================================
+ Hits          2018     2031      +13     
+ Misses         680      671       -9     
Flag Coverage Δ
batch-submitter 62.63% <ø> (+0.13%) ⬆️
contracts 90.48% <ø> (ø)
core-utils 59.39% <ø> (+1.65%) ⬆️
data-transport-layer 38.64% <ø> (ø)
message-relayer 70.86% <ø> (ø)
sdk 85.45% <ø> (+0.85%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ubmitter/src/batch-submitter/tx-batch-submitter.ts 46.07% <0.00%> (+0.18%) ⬆️
...itter/src/batch-submitter/state-batch-submitter.ts 75.30% <0.00%> (+0.30%) ⬆️
packages/sdk/src/cross-chain-messenger.ts 59.32% <0.00%> (+6.69%) ⬆️
packages/core-utils/src/common/hex-strings.ts 100.00% <0.00%> (+15.38%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d14ee9f...952b526. Read the comment docs.

@tynes
Copy link
Copy Markdown
Contributor Author

tynes commented Dec 9, 2021

Upstream changes can be found here: ethereum/go-ethereum@6487c00

@tynes
Copy link
Copy Markdown
Contributor Author

tynes commented Jan 14, 2022

  • Run this code as a replica and ensure that there is no state diff
  • Squash git history into a clean set of commits

@github-actions github-actions bot added the A-integration Area: integration tests label Jan 15, 2022
@tynes tynes force-pushed the fix/eip2930 branch 2 times, most recently from c8f0076 to b28fd40 Compare January 15, 2022 01:23
@tynes tynes changed the title l2geth: initial eip2930 changes l2geth: eip2930 Jan 15, 2022
@Inphi
Copy link
Copy Markdown
Contributor

Inphi commented Jan 18, 2022

there's a fair bit of EIP-2929 (expected since it's access lists depends on it). Would it be possible to cleanly split this PR into two; the EIP-2929 implementation and another for EIP-2930 rebased on top? Or is the refactor pervasive enough that it won't matter.

It would be easier for me to review if this were split up.

@tynes
Copy link
Copy Markdown
Contributor Author

tynes commented Jan 18, 2022

there's a fair bit of EIP-2929 (expected since it's access lists depends on it). Would it be possible to cleanly split this PR into two; the EIP-2929 implementation and another for EIP-2930 rebased on top? Or is the refactor pervasive enough that it won't matter.

It would be easier for me to review if this were split up.

I can definitely split this up more to make it easier to review

@tynes
Copy link
Copy Markdown
Contributor Author

tynes commented Jan 18, 2022

there's a fair bit of EIP-2929 (expected since it's access lists depends on it). Would it be possible to cleanly split this PR into two; the EIP-2929 implementation and another for EIP-2930 rebased on top? Or is the refactor pervasive enough that it won't matter.

It would be easier for me to review if this were split up.

Ok so EIP-2930 is not included as part of this pull request. There are no typed transactions, its EIP-2929, EIP-3529 and EIP-2565

@tynes tynes force-pushed the fix/eip2930 branch 3 times, most recently from 55743a2 to 274bd43 Compare January 19, 2022 18:21
Add in the berlin precompile maps. This code is adopted from
upstream.

This includes the implementation of EIP-2565 which
makes the modular exponentiation precompile found
at `address(5)` cheaper.

https://eips.ethereum.org/EIPS/eip-2565

The berlin precompile set includes setting the `eip2565`
field to true on the `bigExpMod` struct.

This implementation is directly taken from upstream.
ethereum/go-ethereum@eb21c65
@tynes tynes force-pushed the fix/eip2930 branch 2 times, most recently from b98aac2 to 3207853 Compare January 19, 2022 19:33
tynes added 11 commits January 21, 2022 17:17
These scripts can be used to set up a
local development environment to test
out sending transactions against

If the `DEVELOPMENT` env var is set, then
the initial genesis state will include funds
for the signer address. This prevents the
need to deposit funds or manually edit the
genesis json file.
The hardfork block will need to be determined
and the genesis json file will need to be
recreated. This will by default set the
height to 0 so that the development
networks start with berlin activated.
Add integration tests to test the hardfork logic
@@ -0,0 +1,58 @@
import { task } from 'hardhat/config'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this file used?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use this file to assert that the block hashes of two separate replicas/sequencers match.

)
const preBerlinTrace = await env.l2Provider.send(
'debug_traceTransaction',
['0x2bb346f53544c5711502fbcbd1d78dc4fb61ca5f9390b9d6d67f1a3a77de7c39']
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this transaction hash come from?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the nightly transaction hashes come from a run of the hardfork integration tests before the HF activated on nightly. This lets us prove that the gas schedule was correct before the HF activated without overrides.

)
const preBerlinTrace = await env.l2Provider.send(
'debug_traceTransaction',
[tx.hash, { overrides: { berlinBlock: tip.number * 2 } }]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume berlin should be enabled by default in the integration tests, is this not the case?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is enabled by default. To disable it, we move the activation block out by some amount. In this case we're using tip.number * 2 to account for how nightly is continually ingesting transactions in the background and we need more buffer.

@smartcontracts
Copy link
Copy Markdown
Contributor

Does this include all of the EIPs from Berlin?

@smartcontracts
Copy link
Copy Markdown
Contributor

I think if this does not include all of the EIPs from Berlin, we should probably not call it Berlin. Maybe we can call it Berlondon, lol.

@mslipper
Copy link
Copy Markdown
Contributor

It doesn't contain EIP-2718 and EIP-2930 - basically anything to do with typed transactions.

@smartcontracts
Copy link
Copy Markdown
Contributor

Generally this LGTM with the caveat that I don't think we should call the fork Berlin if we're not actually 1:1 with Berlin yet.

@smartcontracts smartcontracts merged commit 6b70f5d into develop Jan 28, 2022
@smartcontracts smartcontracts deleted the fix/eip2930 branch January 28, 2022 17:54
@smartcontracts smartcontracts restored the fix/eip2930 branch January 28, 2022 17:55
@smartcontracts smartcontracts deleted the fix/eip2930 branch February 4, 2022 19:42
theochap added a commit that referenced this pull request Dec 10, 2025
## Description

This PR adds a CI workflow for e2e testing tools using kurtosis.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cannon Area: cannon A-integration Area: integration tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants