Skip to content

feat: Rollup contracts moves msgs between L1 and L2#609

Merged
LHerskind merged 3 commits into
masterfrom
lh/rollup-in-out
May 17, 2023
Merged

feat: Rollup contracts moves msgs between L1 and L2#609
LHerskind merged 3 commits into
masterfrom
lh/rollup-in-out

Conversation

@LHerskind

@LHerskind LHerskind commented May 17, 2023

Copy link
Copy Markdown
Contributor

Description

Fixes #523.

  • Moves messages between L1 and L2.
  • Deploys registry, inbox and outbox for E2E tests

Checklist:

  • I have reviewed my diff in github, line by line.
  • Every change is related to the PR description.
  • I have linked this pull request to the issue(s) that it resolves.
  • There are no unexpected formatting changes, superfluous debug logs, or commented-out code.
  • The branch has been merged or rebased against the head of its merge target.
  • I'm happy for the PR to be merged at the reviewer's next convenience.

@LHerskind LHerskind marked this pull request as ready for review May 17, 2023 14:47
@LHerskind LHerskind requested a review from Maddiaa0 May 17, 2023 14:55
const slot = keccak256(Buffer.concat([l1ToL2Messages[i].toBuffer(), fr(0).toBuffer()]));
const value = 1n | ((2n ** 32n - 1n) << 128n);
// we are using Fr for the value as an easy way to get a correctly sized buffer and string.
const params = `["${inboxAddress}", "${slot}", "0x${new Fr(value).toBuffer().toString('hex')}"]`;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd probably refactor this such that there is a method

const overwriteSlot = (address: EthAddress, slot: number, value: Buffer) => {
    // throw anvil stuff in here
}

^ this can be hidden away somewhere.

Then have forceInsertionIndex be nice n tidy in this file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I created #613 as I think it is a tad too cheeky to jump in and overwrite storage slots manually for integration tests.

@Maddiaa0 Maddiaa0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Im happy with this, have a few suggestions, other comment would to just call inbox.sendMessage rather than overwriting the slots

rollupStateHash = newStateHash;

// @todo (issue #605) handle fee collector
IInbox inbox = REGISTRY.getInbox();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

would it be more gas efficient to just make one external call getting all addresses then destructure?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If getting all the addresses we will be reading an extra storage slot for the rollup address as well, e.g., 1 contract access + 3 storage reads. Here we have 1 cold contract access and 1 hot + 2 storage reads.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sounds right

@LHerskind LHerskind merged commit 436e5df into master May 17, 2023
@LHerskind LHerskind deleted the lh/rollup-in-out branch May 17, 2023 15:23
@LHerskind LHerskind mentioned this pull request May 18, 2023
6 tasks
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.

Add registry and update rollup contract to consume/push message in boxes

3 participants