Skip to content

[Flow EVM] Upgrade to Ethereum Glamsterdam hard-fork#8554

Open
m-Peter wants to merge 29 commits into
masterfrom
mpeter/flow-evm-glamsterdam-upgrade
Open

[Flow EVM] Upgrade to Ethereum Glamsterdam hard-fork#8554
m-Peter wants to merge 29 commits into
masterfrom
mpeter/flow-evm-glamsterdam-upgrade

Conversation

@m-Peter

@m-Peter m-Peter commented May 9, 2026

Copy link
Copy Markdown
Collaborator

Closes: #8553

Description

Upgrade Flow EVM with the upcoming changes included in the Ethereum Glamsterdam hard-fork.
Updated return value of GenesisTimestamp() for Emulator & Previenet networks, to 2024-01-01 so that we have a deterministic value for the SLOTNUM opcode.

See description in #8553, for more details regarding the upgrade changes involved.

Summary by CodeRabbit

  • New Features

    • Amsterdam-era activation per network and per-transaction state-access tracking; slot number added to block context
  • Bug Fixes

    • Safer gas-price/fee handling and gas-limit validation; improved numeric overflow checks
    • Corrected self-destruct/finalization to produce ETH burn logs; more robust deploy/dry-run and code-size/gas accounting
  • Tests

    • Added/updated tests for burn-log emission, deployments, gas-limit and deposit/withdraw scenarios
  • Chores

    • Bumped core dependencies (including Go-Ethereum and OpenTelemetry)

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds Amsterdam fork activation and slot-number support, migrates EVM numeric fields to holiman/uint256, implements per-transaction state-access tracking and burn logs, refactors deployment/run paths, updates error mappings and tests, and bumps go-ethereum and related dependencies.

Changes

Glamsterdam Hard-fork Integration

Layer / File(s) Summary
Dependency Updates & Type Infrastructure
go.mod, insecure/go.mod, integration/go.mod, fvm/evm/types/emulator.go, fvm/evm/emulator/config.go
Bumps ethereum/go-ethereum and related modules; adds holiman/uint256 import and BlockContext.SlotNum.
Block Context, Slot Number, and Fork Activation
fvm/evm/types/block.go, fvm/evm/types/block_test.go, fvm/evm/emulator/config.go, fvm/evm/handler/handler.go
Adds GenesisTimestamp case for Emulator/Previewnet, BlockProposal.SlotNumber, Amsterdam activation timestamps, WithSlotNum option, and handler wiring to set SlotNum.
Transaction Message & Gas Handling
fvm/evm/types/call.go, fvm/evm/emulator/emulator.go
Converts message numeric fields to uint256, refactors DryRunTransaction to build gethCore.Message with explicit overflow checks and effective gas-price computation, and adjusts EIP‑7825 gas-limit validation for Amsterdam rules.
State Access Tracking & EIP-7928 Implementation
fvm/evm/emulator/state/stateDB.go
Adds stateReadList for per-transaction access tracking when Amsterdam is active, recordStateAccess, Touch, LogsForBurnAccounts, changes Finalise to return the access list, records access across state APIs, and makes SelfDestruct void/conditional.
Deployment & Contract Initialization Refactoring
fvm/evm/emulator/emulator.go
Refactors deployAt and procedure.run: caller funds/nonce checks, conditional account creation, CreateContract usage, gas budget/init execution, create-data gas accounting, max init-code checks, and conditional code storage; updates gas-pool usage.
Error Code Mappings for Init Code Size
fvm/evm/types/codeFinder.go
Maps ValidationErrCodeMaxInitCodeSizeExceeded to gethVM.ErrMaxInitCodeSizeExceeded consistently.
Test Contracts & Solidity Updates
fvm/evm/testutils/contracts/factory.sol, fvm/evm/testutils/contracts/factory_abi.json, fvm/evm/testutils/contracts/factory_bytes.hex, fvm/evm/testutils/contract.go
Adds depositDeployAndDestroyWithBurn test path, updates ABI/bytecode, and funds test contract deployments with non-zero value.
Emulator & StateDB Unit Tests
fvm/evm/emulator/emulator_test.go, fvm/evm/emulator/state/stateDB_test.go
Updates tests for ABI numeric boundaries, Finalise return expectations, SelfDestruct renames/semantics, and burn-log assertions.
EVM Integration Tests for Glamsterdam Features
fvm/evm/evm_test.go
Revises integration tests: Amsterdam gas-limit behavior, COA deposit/transfer/deploy validations with RLP-decoded ETH logs and topic/data checks, file-system contract gas updates, batch-run messaging, and adds TestEthLogEmissionWithSelfDestruct.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Possibly related PRs

Suggested labels

Breaking Change, dependencies

Suggested reviewers

  • peterargue
  • turbolent
  • zhangchiqing

"I hopped through code and time so bright,
Amsterdam woke slots into the night,
uint256 counted every tiny fee,
state reads logged what used to be free,
contracts bloom, then vanish—rabbit cheers for the light."

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 29.63% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: upgrading Flow EVM to the Ethereum Glamsterdam hard-fork. It is specific and directly reflects the primary objective of this changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mpeter/flow-evm-glamsterdam-upgrade

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@codecov-commenter

codecov-commenter commented May 9, 2026

Copy link
Copy Markdown

@github-actions

This comment was marked as outdated.

@@ -188,7 +196,7 @@ func WithOrigin(origin gethCommon.Address) Option {
// WithGasPrice sets the gas price for the transaction (usually the one sets by the sender)
func WithGasPrice(gasPrice *big.Int) Option {

@m-Peter m-Peter May 11, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

WithGasPrice seems to be not used in flow-go or flow-evm-gateway. Seems like a relic that we could remove entirely.

Comment thread fvm/evm/emulator/emulator.go Outdated
// if the block gas limit is set to anything than max
// we need to update this code.
gasPool := (*gethCore.GasPool)(&proc.config.BlockContext.GasLimit)
gasPool := gethCore.NewGasPool(proc.config.BlockContext.GasLimit)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure why the gasPool used to receive the maximum value as the available gas:

DefaultBlockLevelGasLimit = uint64(math.MaxUint64)

but given that we apply only a single EVM message, per gasPool instance, it might be safer to do what Geth does:

// Do not panic if the gas pool is nil. This is allowed when executing
// a single message via RPC invocation.
if gp == nil {
	gp = NewGasPool(msg.GasLimit)
}

and use as a sane default the GasLimit from the given EVM message.

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.

Good catch. I don't know. I think its because we already checked that there is sufficient gas. Lets leave this as is for this PR but maybe lets revisit it in a separate PR.

@github-actions

This comment was marked as outdated.

3 similar comments
@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@m-Peter m-Peter force-pushed the mpeter/flow-evm-glamsterdam-upgrade branch from a2d3b10 to 9c45c56 Compare May 12, 2026 17:19
@github-actions

This comment was marked as outdated.

2 similar comments
@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@m-Peter m-Peter force-pushed the mpeter/flow-evm-glamsterdam-upgrade branch from 2f6db64 to 99db4ec Compare May 14, 2026 09:23
@github-actions

This comment was marked as outdated.

Comment thread fvm/evm/types/block.go Outdated
// as slot duration we can use the block production rate, which is about 0.8
// seconds on mainnet.
genesisTimestamp := GenesisBlock(chainID).Timestamp
return ((b.Timestamp - genesisTimestamp) * 5) / 4

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We can differentiate the slot duration for testnet, as I recall that it has a different block production rate, compared to mainnet. Does anyone know what that value is?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

testnet is running at 2 block / sec.
mainnet is running at 1.25 block / sec.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe mention these number in the comments ^

@zhangchiqing zhangchiqing May 19, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we want to store this in a slot and read from it to be configable? but that would involve a storage read.

Currently the block rate is configured by smart contract:

import FlowEpoch from 0x8624b52f9ddcd04a

access(all) fun main(): {String: UInt64} {
    let config = FlowEpoch.getConfigMetadata()
    let timing = FlowEpoch.getEpochTimingConfig()

    return {
        "numViewsInEpoch": config.numViewsInEpoch,
        "epochDurationSeconds": timing.duration
    }
}

For mainnet this returns

Result: {"numViewsInEpoch": 756000, "epochDurationSeconds": 604800}
  • 756,000 views per epoch
  • 604,800 seconds (1 week) per epoch
  • so targetViewTime = 604800 / 756000 = 0.8 seconds/block = 800ms/block or 1.25 blocks / sec

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Nice, much thanks 🙌

maybe mention these number in the comments ^

I will update the comments and the calculation accordingly.

Do we want to store this in a slot and read from it to be configable? but that would involve a storage read.

In Ethereum, the slot duration is hard-coded to 12 seconds, on the consensus layer, regardless of whether the block proposer managed to build a block during a given slot. For Flow EVM, I think we can base the slot number calculation on the block production rate for each network. As long as we feed the SLOTNUM opcode a deterministic value, I think we are compatible and good-to-go. I wouldn't go so far to store this in a slot and add 1 more storage read. Note that adding fields in models such as BlockProposal adds a bit more complexity, due to using RLP encoding/decoding for storage.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added comments and updated the calculation per network in 8a3ce81 .

}

// convert tx into message
msg, err := gethCore.TransactionToMessage(

@m-Peter m-Peter May 14, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We can no longer use gethCore.TransactionToMessage, as it returns a nil Message when no valid signature is provided (see https://github.com/ethereum/go-ethereum/blob/v1.17.3/core/state_transition.go#L240-L244). For EVM.dryRun we do not have such signature values, so we have to reconstruct the Message ourselves.

MainnetOsakaActivation = uint64(1764784800) // Wednesday, December 03, 2025 18:00:00 GMT+0000

PreviewnetAmsterdamActivation = uint64(0) // already on Amsterdam for PreviewNet
TestnetAmsterdamActivation = uint64(1798740000) // Thursday, December 31, 2026 at 18:00:00 GMT+0000

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

TestnetAmsterdamActivation & MainnetAmsterdamActivation will be updated accordingly when there's official activation times.

Comment thread fvm/evm/evm_test.go
if i%2 == 0 {
// fail with too low gas limit
gas = 22_000
gas = 23_500

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Change due to EIP-7976: Increase Calldata Floor Cost

Comment thread fvm/evm/evm_test.go
),
big.NewInt(0),
uint64(2_132_171),
uint64(3_375_890),

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Change due to EIP-7976: Increase Calldata Floor Cost

Comment thread fvm/evm/evm_test.go Outdated
//
require.NotEmpty(t, blockEventPayload.Hash)
require.Equal(t, uint64(2_132_170), blockEventPayload.TotalGasUsed)
require.Equal(t, uint64(3_396_880), blockEventPayload.TotalGasUsed)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Change due to EIP-7976: Increase Calldata Floor Cost

Comment thread fvm/evm/evm_test.go
require.Equal(t, types.ValidationErrCodeMisc, res.ErrorCode)
require.Equal(
t,
"transaction gas limit too high (cap: 16777216, tx: 16777226)",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Change due to EIP-8037: State Creation Gas Cost Increase

Comment thread fvm/evm/evm_test.go
let res = EVM.run(tx: tx, coinbase: coinbase)
assert(res.status == EVM.Status.invalid, message: "unexpected status")
assert(res.errorCode == 100, message: "unexpected error code: \(res.errorCode)")
assert(res.errorMessage == "transaction gas limit too high (cap: 16777216, tx: 16777220)")

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Change due to EIP-8037: State Creation Gas Cost Increase

@m-Peter m-Peter force-pushed the mpeter/flow-evm-glamsterdam-upgrade branch from 65d6f28 to 10f911e Compare June 25, 2026 07:57
@blacksmith-sh

This comment has been minimized.

@janezpodhostnik

Copy link
Copy Markdown
Contributor

@m-Peter Thanks for the heads up. As discussed, lets just go forward with the costs defined in eip-8037 without any customization from our side.

We should be careful about this in our future calibration... If we always create a new account in out synthetic traffic, its going to throw off the data.

Comment thread fvm/bootstrap.go Outdated
// Arbitrary high gas limit that can be used for all the
// EVM transactions to ensure none of them run out of gas
gasLimit := 15000000
gasLimit := 16_777_216

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.

Is this the exact limit needed now? If so maybe add some headroom and set it to 20m?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is the max gas limit (2^24) under the currently active hard-fork, which is Fusaka, see the relevant EIP: https://eips.ethereum.org/EIPS/eip-7825 . However, it will be no longer relevant in Glamsterdam, as the max gas limit of 2^24 is being revoked, in favor of EIP-8037: https://eips.ethereum.org/EIPS/eip-8037. Good point, I'll increase it to 20M, so that we don't have to come back to this anytime soon.

@m-Peter m-Peter Jun 29, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Updated in 73f30b8 . The 15M gas limit was not sufficient for Glamsterdam.

Comment thread fvm/evm/types/block.go
// to propose a new block, functioning as the network's "heartbeat" in PoS.
// Slots occur automatically every 12 seconds, and 32 slots are grouped together
// into a 6.4-minute period known as an epoch.
func (b *Block) SlotNumber(chainID flow.ChainID) uint64 {

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.

Do we expect issues if 2 Flow blocks (and Flow EVM blocks) have the same slot number?
That could happen if the chain is running faster than usual.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I really doubt if this will cause any issues, because on Flow EVM we don't really utilize the consensus mechanism of Ethereum mainnet, we simply piggy-back on Flow's consensus mechanism. This is just a rough calculation to provide some sensible values for any dev/team out there that may be using some existing Solidty dApp, which makes use of this opcode. So the main usage of this is to be compatible with the opcodes offered by Ethereum mainnet.

@vishalchangrani vishalchangrani added this pull request to the merge queue Jun 30, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Flow EVM] Upgrade to Ethereum Glamsterdam hard-fork

4 participants