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

Use transient storage in Outbox and Bridge #260

Draft
wants to merge 20 commits into
base: bold-merge
Choose a base branch
from
Draft

Conversation

gvladika
Copy link
Contributor

@gvladika gvladika commented Oct 11, 2024

Integrate transient storage for:

  • L2 to L1 context in Outbox
  • active outbox ref in Bridge when call is executed

Some plugins are temporary disabled as they're not working with the Solidity 0.8.28 due to 'transient' keyword

@cla-bot cla-bot bot added the s label Oct 11, 2024
src/bridge/AbsBridge.sol Fixed Show fixed Hide fixed
@gvladika gvladika changed the base branch from develop to bold-merge October 16, 2024 09:44
@@ -67,6 +70,13 @@ abstract contract AbsBridge is Initializable, DelegateCallAware, IBridge {
_;
}

/// @inheritdoc IBridge
function postUpgradeInit() external onlyDelegated onlyProxyOwner {
Copy link
Contributor

Choose a reason for hiding this comment

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

we can remove the postUpgradeInit from both AbsBridge and AbsOutbox, and just require no active outbox from the upgrade action

i guess this is a bit of a nit / preference thing though

@@ -55,7 +57,8 @@ abstract contract AbsBridge is Initializable, DelegateCallAware, IBridge {

uint256 public override sequencerReportedSubMessageCount;

address internal constant EMPTY_ACTIVEOUTBOX = address(type(uint160).max);
// transient storage vars
address internal transient currentActiveOutbox;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, we could change this and get rid of function activeOutbox()

Suggested change
address internal transient currentActiveOutbox;
/// @dev The address of current active Outbox, or zero if no outbox is active
address public transient activeOutbox;

@@ -42,7 +43,8 @@ abstract contract AbsBridge is Initializable, DelegateCallAware, IBridge {
address[] public allowedDelayedInboxList;
address[] public allowedOutboxList;

address internal _activeOutbox;
// @dev Deprecated in place of transient storage
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// @dev Deprecated in place of transient storage
/// @dev Deprecated in place of transient storage

// we don't return the default context value to avoid a breaking change in the API
if (sender == SENDER_DEFAULT_CONTEXT) return address(0);
return sender;
return contextSender;
Copy link
Contributor

Choose a reason for hiding this comment

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

similar to the comment about removing AbsBridge::activeOutbox() and renaming the transient var, we could do the same with all these context values

Copy link
Contributor

Choose a reason for hiding this comment

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

i guess this would change the return type though. meh maybe not worth

Copy link
Contributor

Choose a reason for hiding this comment

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

we could actually change the variable types to keep the interface the same. The linked code will cost 600 gas regardless of the variable sizes because there's no warm / cold distinction for tstore.

so we could also change their types, eg uint256 public transient l2ToL1Block vs uint128 internal transient contextL2Block

https://github.com/OffchainLabs/nitro-contracts/pull/260/files#diff-13f577425b3126babc4e15316283de14b005409b57732bcd156e67c9418688feR191

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants