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

Feat: Enforce versioning when rollup push/consume messages #1245

Merged
merged 7 commits into from
Jul 29, 2023

Conversation

LHerskind
Copy link
Contributor

Description

Fixes #359 and #624.

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.

@netlify
Copy link

netlify bot commented Jul 27, 2023

Deploy Preview for preeminent-bienenstitch-606ad0 canceled.

Name Link
🔨 Latest commit ec5f90d
🔍 Latest deploy log https://app.netlify.com/sites/preeminent-bienenstitch-606ad0/deploys/64c285844f8a2e0008d150eb

@LHerskind LHerskind marked this pull request as ready for review July 27, 2023 15:32
l1-contracts/src/core/messagebridge/Inbox.sol Show resolved Hide resolved
@@ -87,6 +90,9 @@ contract OutboxTest is Test {
// correctly set message.recipient to this address
_message.recipient = DataStructures.L1Actor({actor: address(this), chainId: block.chainid});

// correctly set the message.sender.version
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add a wrong version test in outbox too?

returns (uint256)
{
(, bool exists) = _getVersionFor(_rollup);
if (exists) revert Errors.Registry__RollupAlreadyRegistered(_rollup);
Copy link
Contributor

Choose a reason for hiding this comment

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

can we just add a dumb test to ensure this never gets deleted

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a registry test file 👍

bytes32[] memory entryKeys = new bytes32[](1);
entryKeys[0] = entryKey;

vm.prank(wrongRollup);
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a comment which says that "this fails because the rollup version is 2 but we have sent a message for 1"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test is named testRevertIfConsumingFromWrongRollup and

    vm.expectRevert(
      abi.encodeWithSelector(Errors.Inbox__InvalidVersion.selector, version, wrongVersion)
    );

makes the explicit check one line later than this.

@LHerskind LHerskind force-pushed the lh/359-rollup-version-consumption branch from a860bbb to 8358a48 Compare July 28, 2023 10:41
@LHerskind
Copy link
Contributor Author

😭 @iAmMichaelConnor remember to format.
image

Copy link
Member

@Maddiaa0 Maddiaa0 left a comment

Choose a reason for hiding this comment

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

lgtm


function _getVersionFor(address _rollup) internal view returns (uint256 version, bool exists) {
version = rollupToVersion[_rollup];
exists = version > 0 || snapshots[0].rollup == _rollup;
Copy link
Member

Choose a reason for hiding this comment

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

could be me being silly, but above it states that the version should start from 1. Why do we ned to check 0. I guess its fine as the check should short circuit but interested in the explicit check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is still the dead one at 0. But might be useless to support returning that 🤷

Copy link
Member

@Maddiaa0 Maddiaa0 Jul 28, 2023

Choose a reason for hiding this comment

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

yeah thats what im thinking, we shouldnt really care whats in 0 if the protocol returns non existent for 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, it is also ensuring that you cannot insert the dead again. But that might also be useless so have removed it.

@iAmMichaelConnor
Copy link
Contributor

iAmMichaelConnor commented Jul 28, 2023

😭 @iAmMichaelConnor remember to format.

Whoops, wasn't aware. Can't we get a commit hook to do that?

@LHerskind LHerskind force-pushed the lh/359-rollup-version-consumption branch from be56a7e to 6f71507 Compare July 28, 2023 21:51
@LHerskind LHerskind merged commit abcf81c into master Jul 29, 2023
@LHerskind LHerskind deleted the lh/359-rollup-version-consumption branch July 29, 2023 09:16
LHerskind added a commit that referenced this pull request Jul 30, 2023
# Description
Fixes #359 and #624.

# Checklist:

- [ ] I have reviewed my diff in github, line by line.
- [ ] Every change is related to the PR description.
- [ ] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

L1 <> L2 messages need to be scoped to a particular version of Aztec
4 participants