Skip to content

feat: introduce SharedLockbox#13144

Closed
agusduha wants to merge 58 commits intoethereum-optimism:feat/interop-stable-devnetfrom
defi-wonderland:sc-feat/add-shared-lockbox
Closed

feat: introduce SharedLockbox#13144
agusduha wants to merge 58 commits intoethereum-optimism:feat/interop-stable-devnetfrom
defi-wonderland:sc-feat/add-shared-lockbox

Conversation

@agusduha
Copy link
Contributor

@agusduha agusduha commented Nov 29, 2024

Description

Introducing the SharedLockbox contract to improve the Superchain’s interoperable ETH withdrawal user experience, preventing withdrawal failures caused by insufficient ETH in the OptimismPortal. Additionally, the SuperchainConfig is being updated to manage the network’s dependency set.

Tests

  • Add SharedLockbox tests
  • Adjust corresponding integration tests from OptimismPortal, SuperchainConfig and SystemConfig

Additional context

As we talked, this should be applied on the Isthmus upgrade.

  • Remove OPContractsManagerInterop and SystemConfigInterop because its only purpose was to set the denpendencyManager address and is not needed anymore
  • Refactor DeploySuperchain script to enforce contract deployment order to precalculate addresses. This is needed because the SharedLockbox and the SuperchainConfig initializers have a cross dependency.
  • Additional check can be added to the addDependency function to enforce the chain ID and SystemConfig address compatibility as mentioned in the spec, but there is no current source of truth for that

Metadata

Closes #13143

0xDiscotech and others added 11 commits November 20, 2024 18:24
* feat: create shared lockbox contract with its interface and unit tests

* chore: polish tests and interfaces

* chore: run pre-pr

* chore: improve natspec

* chore: run pre-pr

* chore: update compiler version
* feat: integrate portal to lockbox

* fix: pr fixes

* test: refactor assert
#128)

* feat: create shared lockbox contract with its interface and unit tests

* chore: polish tests and interfaces

* chore: run pre-pr

* chore: improve natspec

* chore: run pre-pr

* feat: add liqudity migrator contract with its unit test and interface

* chore: remove underscore on stack var

* chore: add todo

* chore: run pre-pr

* chore: add contract title natspec and proxied

* refactor: integrate testing suite with common test

* chore: pre-pr

* chore: add spec test
* feat: integrate portal to lockbox

* fix: pr fixes

* test: refactor assert

* feat: integrate system config with superchain config

* fix: remove OPCM interop

* test: add dependency counter test
* feat: Add pause check

Co-authored-by: 0xParticle <particle@defi.sucks>
Co-authored-by: gotzenx <78360669+gotzenx@users.noreply.github.com>
Co-authored-by: Joxess <joxes@defi.sucks>

* test: add tests natspecs

---------

Co-authored-by: 0xParticle <particle@defi.sucks>
Co-authored-by: gotzenx <78360669+gotzenx@users.noreply.github.com>
Co-authored-by: Joxess <joxes@defi.sucks>
@agusduha agusduha requested a review from a team as a code owner November 29, 2024 18:24
@protolambda protolambda added A-interop A-pkg-contracts-bedrock Area: packages/contracts-bedrock labels Dec 16, 2024
agusduha and others added 6 commits December 24, 2024 16:04
* feat: liquidity migrator deployment

* test: fix comment

* test: fix internal variables names
* feat: dependency set refactor

* fix: deploy script variable name

* fix: pr

* fix: pr
Copy link
Contributor

@ControlCplusControlV ControlCplusControlV left a comment

Choose a reason for hiding this comment

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

looks good overall, just some general stylistic comments

emit ETHLocked(msg.sender, msg.value);
}

/// @notice Unlocks ETH from the lockbox.
Copy link
Contributor

Choose a reason for hiding this comment

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

Would add natspec alerts that it cannot be called when paused as well

/// @notice Internal initializer.
/// @param _guardian Address of the guardian, can pause the OptimismPortal.
/// @param _paused Initial paused status.
function _initialize(address _guardian, bool _paused) internal {
Copy link
Contributor

Choose a reason for hiding this comment

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

may be a dumb q but why are these functions seperate?

Copy link
Contributor Author

@agusduha agusduha Feb 4, 2025

Choose a reason for hiding this comment

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

To be reused in the inherited contract. This is because there is a semgrep rule that force the initialize function to be external and to have the initializer modifier


/// @notice The address of the cluster manager, which can add a chain to the dependency set.
/// It can only be modified by an upgrade.
bytes32 public constant CLUSTER_MANAGER_SLOT = bytes32(uint256(keccak256("superchainConfig.clusterManager")) - 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Inconsistent with OPTIMISM_PORTAL_STORAGE_SLOT which just sets the resulting value, we should use one format (value and preimagei n comments, or vice versa) across everything, I would favor pre-image and then let the value be determined at compile time

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are trying to follow the ERC7201 for unstructured storage in general, this was an exception because the SuperchainConfig guardian role is being defined like this


/// @notice Storage slot that the SuperchainConfigDependencies struct is stored at.
/// keccak256(abi.encode(uint256(keccak256("superchainConfig.dependencies")) - 1)) & ~bytes32(uint256(0xff));
bytes32 internal constant SUPERCHAIN_CONFIG_DEPENDENCIES_SLOT =
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as above with OPTIMISM_PORTAL_STORAGE_SLOT


/// @notice Checks if a chain is part or not of the dependency set.
/// @param _chainId The chain ID to check for.
function isInDependencySet(uint256 _chainId) public view returns (bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this function documented in the spec?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it should, the specs are gonna be refactored too tho

event DependencyAdded(uint256 indexed chainId, address indexed systemConfig, address indexed superchainConfig);

/// @notice The minimum gas limit for the withdrawal tx to update the dependency set on L1.
uint256 internal constant ADD_DEPENDENCY_WITHDRAWWAL_GAS_LIMIT = 400_000;
Copy link
Contributor

Choose a reason for hiding this comment

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

where does this value come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We made some gas consumption tests, we put a high minimum gas limit to ensure the withdrawal doesn't fail.

This code is not going to be used though

@mslipper
Copy link
Collaborator

/ci authorize f805e78

@tynes
Copy link
Contributor

tynes commented Jan 31, 2025

We made the following decisions:

  • remove ability to auth portals via withdrawals, only auth via multisig
  • dont put the dep set manager in state for now

This will make us code complete for the audit, pending any other fixes the wonderland security team finds

agusduha and others added 7 commits February 3, 2025 14:47
* feat: descope dependency manager

* test: fix tests

* test: fix tests
* fix: I-0

* fix: I-1

* fix: I-2

* fix: I-3

* fix: I-6

* fix: I-7

* fix: I-9

* fix: pre pr
* fix: portal withdrawal checks

* fix: include current withdrawal check
@agusduha agusduha changed the base branch from develop to feat/interop-stable-devnet February 5, 2025 13:17
@tynes
Copy link
Contributor

tynes commented Feb 5, 2025

/ci authorize 2860621

@tynes
Copy link
Contributor

tynes commented Feb 5, 2025

Not sure what the problem is with the go tests, we may need to rebase

@mslipper
Copy link
Collaborator

mslipper commented Feb 5, 2025

@tynes these are not flakes, these are real bugs.

@mslipper
Copy link
Collaborator

mslipper commented Feb 5, 2025

/ci authorize d1e7d79

@tynes
Copy link
Contributor

tynes commented Feb 5, 2025

/ci authorize 24476ae

@tynes
Copy link
Contributor

tynes commented Feb 5, 2025

Looks like there are still some failing go tests

@tynes
Copy link
Contributor

tynes commented Feb 5, 2025

--- FAIL: TestInteropDeployment (0.68s)
panic: revision id 1 cannot be reverted [recovered]
	panic: revision id 1 cannot be reverted

what does this mean?

@agusduha agusduha requested a review from a team as a code owner February 5, 2025 23:53
@mslipper
Copy link
Collaborator

mslipper commented Feb 6, 2025

It means that there's a revert preventing OP Deployer from deploying the contracts. I'll look into it.

@mslipper
Copy link
Collaborator

mslipper commented Feb 6, 2025

Replaced by #14199.

@mslipper mslipper closed this Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-pkg-contracts-bedrock Area: packages/contracts-bedrock H-interop Hardfork: change planned for interop upgrade

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement ETH Lockbox

7 participants

Comments