feat(op-acceptance-tests): l2cm upgrade accaptance tests and fork tests on karst betanet#20668
Conversation
…imal upgrade with l2cm
… and add flags to support running against betanet
| // Skip if not L2 fork test | ||
| skipIfNotL2ForkTest("L2ForkUpgrade: not a fork test"); | ||
|
|
||
| // Skip if L2CM dev feature is not enabled |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
wouldn't the L2CM feature flag be true on the karst betanet?
There was a problem hiding this comment.
Sorry, I meant the check above: skipIfNotL2ForkTest("L2ForkUpgrade: not a fork test");
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
|
/ci authorize da9943e |
|
/ci authorize 331ce17 |
|
/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); |
There was a problem hiding this comment.
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;
…rrent bundle is applied
…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)); |
There was a problem hiding this comment.
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?
|
|
||
| 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 |
There was a problem hiding this comment.
Shouldn't this be also updated to match test-post-karst-betanet-l2-fork-upgrade?
…terFork revert outside l2CMActivationTest
| /// @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)); |
There was a problem hiding this comment.
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()callcreateSelectFork(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
…after activation block number
| address(0), | ||
| topics | ||
| ); | ||
| logs = _ethGetLogsToLogs(ethLogs); |
There was a problem hiding this comment.
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.
|
/ci authorize e05e520 |
|
/ci authorize 33b1700 |
|
|
||
| /// @notice Verify betanet fork upgrade tests switch to the block after the activation block. | ||
| function _executeCurrentBundle() internal virtual override { | ||
| uint256 l2BlockAfterFork = Config.l2BlockAfterFork(); |
There was a problem hiding this comment.
nit: let's fix this indentation
|
/ci authorize 281e44a |
| # Env Vars: | ||
| # - L2_FORK_RPC_URL must be set to a post-Karst betanet L2 RPC URL. | ||
| # - L2_BLOCK_BEFORE_FORK must be set to the block right before the fork | ||
| # - L2_FORK_BLOCK_NUMBER can be set in the env to pin a block (defaults to latest). |
There was a problem hiding this comment.
Can we just clearly document that when running in 'activation mode' this is used as the post-fork block number?
| } | ||
|
|
||
| /// @notice Verify betanet fork upgrade tests switch to the block after the activation block. | ||
| function _executeCurrentBundle() internal virtual override { |
There was a problem hiding this comment.
Just add a short natspec comment clarifying that this doesn't do what the name says it does, ie. it overrides the execution by going to a block after the fork.
| L2VerifyBetanetForkUpgrade_TestInit._executeCurrentBundle(); | ||
| } | ||
|
|
||
| function test_l2ForkUpgrade_upgradeEventsEmitted_succeeds() public override(L2ForkUpgrade_Events_Test) { |
There was a problem hiding this comment.
This test looks very similar to the one in the original test, why does it need to be reimplemented?
There was a problem hiding this comment.
there are some ordering issues which make more sense to fix by an override, but I'll move the verification logic to a shared helper.
|
/ci authorize ba75e97 |
| if (l2CMActivationTest()) { | ||
| return vm.envUint("L2_BLOCK_BEFORE_FORK"); | ||
| } |
There was a problem hiding this comment.
would it be better to have this its own getter?
There was a problem hiding this comment.
this is the only place where it's used, as we are taking advantage of the existing test setup which forks based on this getter.
| // TestWithdrawal_KarstUpgrade is the same withdrawal flow but on a network that | ||
| // started pre-Karst and activated Karst mid-chain via a scheduled upgrade. | ||
| func TestWithdrawal_KarstUpgrade(gt *testing.T) { | ||
| offset := uint64(10) |
There was a problem hiding this comment.
how was this offset picked? would be good to have an inline comment here for this
| /// @notice Converts RPC logs from `vm.eth_getLogs` into the shape returned by `vm.getRecordedLogs`. | ||
| /// @param _ethLogs The RPC logs from `vm.eth_getLogs`. | ||
| /// @return logs_ The logs in the shape returned by `vm.getRecordedLogs`. | ||
| function _ethGetLogsToLogs(Vm.EthGetLogs[] memory _ethLogs) internal pure returns (Vm.Log[] memory logs_) { |
There was a problem hiding this comment.
this is only used in _getLogs i think we can just remove this and do it directly inside the nested loop
| } | ||
| } | ||
|
|
||
| /// @title L2GenesisForkUpgrade_Versions_Test |
| } | ||
|
|
||
| /// @notice Indicates whether a test is running against a Karst betanet L2 fork test. | ||
| function isL2CMActivationTest() public view returns (bool) { |
| returns (uint256) | ||
| { | ||
| for (uint256 i = 0; i < _froms.length; i++) { | ||
| if (_froms[i] == _firstBundleTxn.from && _tos[i] == _firstBundleTxn.to) { |
There was a problem hiding this comment.
since we have the first bundle tx, should we also check the data just to be more robust?
| /// @notice Returns true when the current bundle has already been applied to the forked chain. | ||
| /// Uses two checks: ConditionalDeployer exists (Karst ran) and this bundle's | ||
| /// L2ContractsManager was deployed at its expected address. | ||
| function _isCurrentBundleAlreadyApplied() internal view returns (bool) { |
There was a problem hiding this comment.
i think this should be _isKarstBundleAlreadyApplied or we should add a TODO to change this at some point since the "current" bundle will change
There was a problem hiding this comment.
That wouldn't be correct, that's just the first half of the condition, as we also check that the l2cm matches the current bundle. so it's any current bundle post karst.
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
Additional Context
Setting up a karst betanet is required for running the tests this way.
Metadata
fixes #18870