Skip to content

feat(op-acceptance-tests): l2cm upgrade accaptance tests and fork tests on karst betanet#20668

Open
0xCoati wants to merge 17 commits into
ethereum-optimism:developfrom
defi-wonderland:test/l2cm-upgrade-accaptance-test
Open

feat(op-acceptance-tests): l2cm upgrade accaptance tests and fork tests on karst betanet#20668
0xCoati wants to merge 17 commits into
ethereum-optimism:developfrom
defi-wonderland:test/l2cm-upgrade-accaptance-test

Conversation

@0xCoati
Copy link
Copy Markdown

@0xCoati 0xCoati commented May 12, 2026

Description
Ability to run fork tests on karst betanet, add acceptance tests for withdrawal. L2 Fork test for checking the existence of the deterministic-deployment-proxy.

Tests
mise exec -- just test -run TestWithdrawal_Karst ./op-acceptance-tests/tests/karst/

Running L2ForkUpgrade.t.sol with a betanet

export L2_FORK_RPC_URL=<url>
export L2_BLOCK_BEFORE_FORK=<previous blockNumber before activation>
just test-post-karst-betanet-l2-fork-upgrade

Additional Context
Setting up a karst betanet is required for running the tests this way.

Metadata

fixes #18870

// Skip if not L2 fork test
skipIfNotL2ForkTest("L2ForkUpgrade: not a fork test");

// Skip if L2CM dev feature is not enabled
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.

Shouldn't we also check for KARST_BETANET_L2_FORK_TEST before skipping L2 Forked tests? Setting KARST_BETANET_L2_FORK_TEST=true would still just silently skip these.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

wouldn't the L2CM feature flag be true on the karst betanet?

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.

Sorry, I meant the check above: skipIfNotL2ForkTest("L2ForkUpgrade: not a fork test");

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I see. Probably better to adjust the justfile so L2_FORK_TEST=true is set too for the test-karst-betanet-l2-fork-upgrade task? There are quite a few places were we rely on l2ForkTest / isL2ForkTest.

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.

That sounds good.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

actually it's already done, because test-karst-betanet-l2-fork-upgrade starts with prepare-l2-upgrade-env which does set L2_FORK_TEST. I removed a redundant check here 1971c09

Comment thread op-node/rollup/derive/attributes.go Outdated
upgradeGas += nutGas
}

if ba.rollupCfg.IsCustomNUTActivationBlock(nextL2Time) {
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 don't think we should add test-only code in here.

function _executeCurrentBundle() internal virtual {
PastNUTBundles.ForkWrappers memory w = PastNUTBundles.wrappersForFork(currentFork);
PastNUTBundles.executeWithWrappers(executeScript, w.pre, _currentBundleTxns(), w.post);
if (!isKarstForkActivated()) {
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.

Why do we need to skip if Karst is activated? In post-karst upgrades we still want to take chains that are in an "older" state up-to-date so we can execute the NUTs in the current bundle.

@0xOneTony
Copy link
Copy Markdown
Contributor

/ci authorize da9943e

@0xOneTony 0xOneTony changed the title l2cm upgrade accaptance tests and fork tests on karst betanet feat(op-acceptance-tests): l2cm upgrade accaptance tests and fork tests on karst betanet May 13, 2026
@0xOneTony
Copy link
Copy Markdown
Contributor

/ci authorize 331ce17

@0xCoati 0xCoati marked this pull request as ready for review May 13, 2026 20:34
@0xCoati 0xCoati requested review from a team and wwared May 13, 2026 20:34
@0xCoati 0xCoati requested a review from a team as a code owner May 13, 2026 20:34
@0xiamflux
Copy link
Copy Markdown
Contributor

/ci authorize 96f15bc


/// @notice Executes the current generated NUT bundle with any fork-specific wrappers.
function _executeCurrentBundle() internal virtual {
PastNUTBundles.ForkWrappers memory w = PastNUTBundles.wrappersForFork(currentFork);
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 think I see this more clearly here, it should be able to skip the current bundle if it's already applied not only if karst is applied:

if (_isCurrentBundleAlreadyApplied()) return;

0xCoati added 2 commits May 15, 2026 14:51
…with before/after blocknumbers and capture events from the activation block
return vm.envString("KARST_BETANET_L2_FORK_RPC_URL");
/// @notice Returns the L2 block after the fork.
function l2BlockAfterFork() internal view returns (uint256) {
return vm.envOr("L2_FORK_BLOCK_NUMBER", uint256(0));
Copy link
Copy Markdown
Contributor

@0xiamflux 0xiamflux May 18, 2026

Choose a reason for hiding this comment

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

I would think it should be an error to either attempt to use this on a non-activation test or try to use it during a activation test while it is 0. wdyt?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed in fff70c2

Comment thread packages/contracts-bedrock/justfile Outdated

test-karst-betanet-l2-fork-upgrade-rerun *ARGS:
test-post-karst-betanet-l2-fork-upgrade-rerun *ARGS:
just test-karst-betanet-l2-fork-upgrade {{ARGS}} --rerun -vvvv
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.

Shouldn't this be also updated to match test-post-karst-betanet-l2-fork-upgrade?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed in fff70c2

/// @notice Returns the L2 block after the fork.
function l2BlockAfterFork() internal view returns (uint256) {
if (l2CMActivationTest()) {
return vm.envOr("L2_FORK_BLOCK_NUMBER", uint256(0));
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 think this needs to be fixed before merge.

The justfile documents L2_BLOCK_AFTER_FORK, but this reads L2_FORK_BLOCK_NUMBER and defaults to 0. I assume 0 is meant to preserve the existing "use latest" behaviour from the normal L2 fork setup. But activation mode passes this value directly to createSelectFork(url, block), so following the documented command makes the post upgrade fork select explicit block 0, not latest or the intended after fork block.

Could we do one of the following:

  • Read a mandatory L2_BLOCK_AFTER_FORK
  • Keep 0 as latest and have _executeCurrentBundleOrSwitchFork() call createSelectFork(url) overload when this returns 0?

The pre/post activation flow can become:

  • Fork at L2_BLOCK_BEFORE_FORK
  • Capture pre upgrade state
  • Fork at block 0
  • Verify post upgrade state

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed in d292e28 and e05e520

address(0),
topics
);
logs = _ethGetLogsToLogs(ethLogs);
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.

Currently the L2CM activation path only checks the historical Upgraded(address) logs. That doesn't prove the activation block contained the expected NUT bundle txns.

Can we also assert that the activation block contains the expected activation bundle txns? Otherwise missing, reordered, or corrupted upgrade txns could still be missed if the expected upgrade logs are present.

@0xOneTony
Copy link
Copy Markdown
Contributor

/ci authorize e05e520

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[L2CM Upgrades] Devnet acceptance testing

4 participants