Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] feat: new lockbox #192

Open
wants to merge 3 commits into
base: sc-feat/add-shared-lockbox
Choose a base branch
from

Conversation

agusduha
Copy link
Member

@agusduha agusduha commented Jan 9, 2025

No description provided.

@agusduha agusduha self-assigned this Jan 9, 2025
@@ -28,9 +28,6 @@ contract SharedLockbox is ISemver {
/// @notice The address of the SuperchainConfig contract.
ISuperchainConfig public immutable SUPERCHAIN_CONFIG;
Copy link

Choose a reason for hiding this comment

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

We should not leak the fact that this is immutable into the abi, could we add a superchainConfig()(address) getter and make internal immutable SUPERCHAIN_CONFIG ?

Copy link
Member Author

Choose a reason for hiding this comment

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

This contract address should never change, the SharedLockbox should always have the same SuperchaingConfig contract address, or were you thinking of something else?

/// @notice
contract UpgradeHandler {
function addDependency(address _supechainConfig, uint256 _chainId, address _systemConfig) external {
if (msg.sender != Constants.DEPOSITOR_ACCOUNT) revert Unauthorized(); // TODO: check if this is safe enough
Copy link

Choose a reason for hiding this comment

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

This is safe enough because only the derivation pipeline can mock this identity

/// @title UpgradeHandler
/// @notice
contract UpgradeHandler {
function addDependency(address _supechainConfig, uint256 _chainId, address _systemConfig) external {
Copy link

Choose a reason for hiding this comment

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

nit: typo _superchainConfig


IL2ToL1MessagePasser(payable(Predeploys.L2_TO_L1_MESSAGE_PASSER)).initiateWithdrawal(
_supechainConfig,
400_000, // TODO: find an arbitrary value that is enough
Copy link

Choose a reason for hiding this comment

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

We need to remove the gas limit on withdrawals, its the source of so much pain


event ETHMigrated(uint256 amount);

function migrateLiquidity() external {
Copy link

Choose a reason for hiding this comment

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

Do you think its better to move away from the intermediate upgrade contract?

Copy link

Choose a reason for hiding this comment

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

This approach does simplify multisig operations which is nice

Copy link
Member Author

@agusduha agusduha Jan 10, 2025

Choose a reason for hiding this comment

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

Yes! Also you can be sure that the ETH liquidity migration is done at the same time as the portal is authorized to withdraw from the lockbox. The other way it has to be manually done and checked before processing the addDependency withdrawal tx .

@@ -174,19 +175,11 @@ contract CrossL2Inbox is ISemver, TransientReentrancyAware {
// We need to know if this is being called on a depositTx
if (IL1BlockInterop(Predeploys.L1_BLOCK_ATTRIBUTES).isDeposit()) revert NoExecutingDeposits();

// Check the Identifier.
_checkIdentifier(_id);
if (!IDependencySet(Predeploys.L1_BLOCK_ATTRIBUTES).isInDependencySet(_id.chainId)) revert InvalidChainId();
Copy link

Choose a reason for hiding this comment

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

If we have this, then we will need the first block to set the dependency set, which makes testing a bit more complicated. The real benefit that I see is on outgoing messages from the L2 to L2 xdm

Copy link

@tynes tynes Jan 10, 2025

Choose a reason for hiding this comment

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

We need to make sure that we do not have unprovable logs. Its most simple to assume that you cannot consume logs before the interop start. We would need to move that logic offchain in the block builder, proof and fork choice rule if its not onchain. I think we can get away with keeping everything that was in _checkIdentifier offchain, it will save a bit of gas over time

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok perfect, we will remove the check from here but leave it in the L2toL2CDM

@@ -0,0 +1,30 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
Copy link

Choose a reason for hiding this comment

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

Curious if you have an opinion on the dependency set living in this contract vs the L1Block contract. The tradeoff is with it being in the L1Block contract, it expands the ABI, which causes more gas cost for every single system transaction doing 4byte selector matching. Its likely a minimal amount of gas but it adds up every block. Historically we just always added things to L1Block but this consideration exists

Copy link
Member Author

Choose a reason for hiding this comment

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

I like this approach, as we talked, we can have a DependencyManager predeploy handling this

@tynes
Copy link

tynes commented Jan 10, 2025

These changes generally look good to me

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.

3 participants