Skip to content

Comments

feat(l2cm): add a generation script using NUT library, add sample L2CM#663

Merged
0xiamflux merged 3 commits intopoc/l2cu-tx-gen-scriptsfrom
poc/l2cu-xfork-l2cm
Nov 10, 2025
Merged

feat(l2cm): add a generation script using NUT library, add sample L2CM#663
0xiamflux merged 3 commits intopoc/l2cu-tx-gen-scriptsfrom
poc/l2cu-xfork-l2cm

Conversation

@0xiamflux
Copy link

@0xiamflux 0xiamflux commented Oct 30, 2025

Adds a script and contracts to generate Network Upgrade Transactions (NUTs) for L2 contract upgrades during xFork hardforks.

  • TransactionGeneration.s.sol: Script that generates NUTs using the NetworkUpgradeTxns library. Deploys predeploy implementations via CREATE2 and generates the execution transaction for the L2ContractsManager.
  • L2ContractsManager.sol: Base contract with execution hooks for orchestrating L2 contract upgrades.
  • XForkContractsManager.sol: Implementation that inlines ProxyAdmin.upgrade() logic to avoid external call frames. Executes via delegatecall in ProxyAdmin's context, supporting ERC1967, CHUGSPLASH, and RESOLVED proxy types.

If you want to run the tests introduced in this PR you need to provide both FORK_RPC_URL and FORK_BLOCK_NUMBER env variables:

FORK_RPC_URL=<YOUR RPC URL> FORK_BLOCK_NUMBER=143126794 forge test --mc TransactionGenerationTest

Closes OPT-1272


Note

Introduces a NUT generation script and L2 upgrade framework (manager, implementations deployer, ProxyAdmin delegatecall), adds CREATE2 deployer interface, bumps L1Block to v1.8.0, and adds tests.

  • Contracts/Framework:
    • src/L2/L2ContractsManager.sol: Base manager with before/after hooks and _performUpgrades for proxy upgrades.
    • src/L2/XForkContractsManager.sol: Minimal implementation of the manager for xFork.
    • src/L2/L2ImplementationsDeployer.sol: Authorized intermediary that computes and deploys predeploy implementations via CREATE2 (emits events; skips if exists).
    • src/universal/ProxyAdmin.sol: Adds performDelegateCall to delegatecall L2ContractsManager.execute (auth check).
    • interfaces/preinstalls/ICreate2Deployer.sol: Interface for computing and deploying via CREATE2.
  • Scripts:
    • scripts/deploy/TransactionGeneration.s.sol: Generates NUTs—deploys implementations via L2ImplementationsDeployer, deploys L2CM via Create2Deployer, then executes via ProxyAdmin.performDelegateCall; writes artifact.
    • scripts/deploy/PredeployHelper.sol: Collects supported predeploys, handles constructor-arg cases, builds init code, computes implementation CREATE2 addresses.
  • Protocol:
    • src/L2/L1Block.sol: Bump semver to 1.8.0.
  • Tests:
    • test/L2/TransactionGeneration.t.sol: Validates generated transactions, execution flow, and upgrade outcome (L1Block version() == 1.8.0).

Written by Cursor Bugbot for commit f8d6c07. This will update automatically on new commits. Configure here.

@0xiamflux 0xiamflux requested a review from 0xOneTony October 30, 2025 20:48
@0xiamflux 0xiamflux self-assigned this Oct 30, 2025
@linear
Copy link

linear bot commented Oct 30, 2025

OPT-1272 L2CM PoC

@0xiamflux 0xiamflux marked this pull request as ready for review October 30, 2025 20:49
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@0xOneTony 0xOneTony changed the title feat: add a generation script using NUT library, add sample L2CM feat(l2cm): add a generation script using NUT library, add sample L2CM Oct 30, 2025
* feat: add deterministic upgrades to TransactionGeneration script & ProxyUpgrade struct to L2CM

* fix: predeploy deployments with constructor

* feat: add separate interface file for create2 preinstall

* docs: add natspec

* refactor: add single getChangedPredeploys

* feat: add L2ImplementationsDeployer

* refactor: add addFeeVault helper

* refactor: remove l2impldeployer from script

* fix: replace performDelegateCall signature with selector

* refactor: move proxy upgrades logic to L2CM

* refactor: use only upgradeTo

* fix: revert console log
@0xiamflux 0xiamflux requested a review from 0xniha November 10, 2025 19:47
@0xiamflux 0xiamflux merged commit 0ea582e into poc/l2cu-tx-gen-scripts Nov 10, 2025
2 checks passed
0xiamflux added a commit that referenced this pull request Nov 14, 2025
)

* feat: add NUT lib

* refactor: makes txn artifact lib to produce array instead of using keys

* refactor: rename "artifactPath" to "forgeArtifactPath"

* test: add test that checks the file is generated correctly

* refactor: rename UpgradeTxn to NetworkUpgradeTxn

* feat: add readArtifact to lib & fix writeArtifact test

* feat(l2cm): add a generation script using NUT library, add sample L2CM (#663)

* feat: add a generation script using NUT library, add sample L2CM

* chore: rename script to match doc terms

* feat(l2cm): add deterministic upgrades (#665)

* feat: add deterministic upgrades to TransactionGeneration script & ProxyUpgrade struct to L2CM

* fix: predeploy deployments with constructor

* feat: add separate interface file for create2 preinstall

* docs: add natspec

* refactor: add single getChangedPredeploys

* feat: add L2ImplementationsDeployer

* refactor: add addFeeVault helper

* refactor: remove l2impldeployer from script

* fix: replace performDelegateCall signature with selector

* refactor: move proxy upgrades logic to L2CM

* refactor: use only upgradeTo

* fix: revert console log

---------

Co-authored-by: niha <205694301+0xniha@users.noreply.github.com>

* feat: l2cm poc fixes (#674)

* test: add idempotent upgrade test & hard fork name input param

* fix: remove newDeploymentTx helper from NUT lib

* fix: skip proxyadmin accordingly

* fix: move tx gen script test to /scripts

* fix: remove l1block check

* refactor: l2cm execute without args

* test: add implementation checks

* refactor: remove returndata from l2cm functions

* fix: remove extra comment on predeployhelper

* docs: add natspec for XForkContractsManager

* fix: remove xforkcm constructor checks

* test: add expect upgrade event emission

---------

Co-authored-by: Flux <175354924+0xiamflux@users.noreply.github.com>
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.

4 participants