Skip to content

feat[contracts]: Add block/allow and pausing to the L1 Messenger#579

Merged
gakonst merged 10 commits intomasterfrom
feat/pauseBlockAllowL1Msgr
Apr 29, 2021
Merged

feat[contracts]: Add block/allow and pausing to the L1 Messenger#579
gakonst merged 10 commits intomasterfrom
feat/pauseBlockAllowL1Msgr

Conversation

@maurelian
Copy link
Contributor

@maurelian maurelian commented Apr 23, 2021

Description

This PR adds safety functionality to the L1 Messenger:

  • Pausable except with the 'Context._msgSender()` thing removed.
  • Ownable
  • blockMessage
  • allowMessage

Additional context

I think the main design decision worth discussing here is the additional gas cost of needing to SLOAD from the blockedMessages mapping on every relayMessage() call. The alternative would be to use the successfulMessages mapping to block messages. The very large downside of that is it gives the owner the ability to allow a message to be relayed twice (or more).

IMO the cost is probably acceptable consider the frequency of use.

@changeset-bot
Copy link

changeset-bot bot commented Apr 23, 2021

🦋 Changeset detected

Latest commit: 78246e1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@eth-optimism/contracts Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

***************/

/**
* Pass a default zero address to the address resolver. This will be updated when initialized.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I felt like this comment was slightly misleading, as the constructor is setting nothing in the proxy.

override
public
nonReentrant
onlyRelayer()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked elsewhere: using brackets on modifiers with no args was inconsistent with other parts of the code.

/**
* Relays a cross domain message to a contract.
* @inheritdoc iOVM_L1CrossDomainMessenger
* This function executes a transaction on L1, which was initiated on L2.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I brought these doc strings in here from the interface.

Copy link
Contributor

Choose a reason for hiding this comment

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

The docs should live in the interface, so let's revert this change.

@maurelian maurelian requested a review from K-Ho April 23, 2021 14:26
Copy link
Collaborator

@ben-chain ben-chain left a comment

Choose a reason for hiding this comment

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

Looking good, requested a quick additional test.

@K-Ho this code doesn't feel super meaningful to me without removing the onlyRelayer. I feel like we should:

  1. Make this PR be against the 0.3.0 RC
  2. Remove the onlyRelayer and MultiMessageRelayer.

Maybe there's an argument for having 2. in a separate step though?

Copy link
Contributor

@tynes tynes left a comment

Choose a reason for hiding this comment

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

So, downgrade to patch?

Yup please downgrade this to patch, we will bump the minor version once for the RLP regenesis

@tynes
Copy link
Contributor

tynes commented Apr 23, 2021

Remove the onlyRelayer and MultiMessageRelayer

@ben-chain Isn't the MultiMessageRelayer still useful if somebody wants to do multiple withdrawals when it is not permissioned?

@ben-chain
Copy link
Collaborator

@ben-chain Isn't the MultiMessageRelayer still useful if somebody wants to do multiple withdrawals when it is not permissioned?

This is true, although we have had the idea in the past of using the msg.sender to pay a fee to the relayer, which would break if the msg.sender is always the MultiMessageRelayer. I tend to think that just adding a batchRelayMessages into the L1CrossDomainMessenger itself would be the preferable way to have multiple withdrawals for this reason. That could be a good argument to do that in a separate PR, though.

@tynes
Copy link
Contributor

tynes commented Apr 23, 2021

I tend to think that just adding a batchRelayMessages into the L1CrossDomainMessenger itself would be the preferable way to have multiple withdrawals for this reason. That could be a good argument to do that in a separate PR, though.

I agree that this is a better solution

@maurelian
Copy link
Contributor Author

That could be a good argument to do that in a separate PR, though.

I agree that this is a better solution

#623

@gakonst gakonst force-pushed the feat/pauseBlockAllowL1Msgr branch from 7192f59 to 88bfc22 Compare April 25, 2021 09:11
@gakonst
Copy link
Contributor

gakonst commented Apr 25, 2021

I've rebased and squashed the PR, while resolving merge conflicts. Let's try to avoid git merge master too many times, and favor rebasing and keeping things clean. Also let's make sure that we have passing tests before we dive into reviews!

@gakonst gakonst force-pushed the feat/pauseBlockAllowL1Msgr branch from 88bfc22 to 36909c9 Compare April 25, 2021 09:13
@maurelian maurelian changed the title Add block/allow and pausing to the L1 Messenger Feat[contracts]: Add block/allow and pausing to the L1 Messenger Apr 25, 2021
@maurelian maurelian changed the title Feat[contracts]: Add block/allow and pausing to the L1 Messenger feat[contracts]: Add block/allow and pausing to the L1 Messenger Apr 25, 2021
@maurelian maurelian requested review from ben-chain and tynes and removed request for K-Ho and annieke April 26, 2021 17:08
Copy link
Collaborator

@ben-chain ben-chain left a comment

Choose a reason for hiding this comment

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

This is looking good to me. I have a tiny request to leave a test in, but then I think we'll be good to merge.

@tynes
Copy link
Contributor

tynes commented Apr 26, 2021

Looks like this needs another rebase/squash

@maurelian maurelian requested a review from ben-chain April 27, 2021 01:38
@maurelian maurelian marked this pull request as draft April 27, 2021 02:33
@gakonst gakonst self-assigned this Apr 28, 2021
@maurelian maurelian force-pushed the feat/pauseBlockAllowL1Msgr branch 2 times, most recently from ec46324 to 554e5eb Compare April 28, 2021 20:47
@maurelian maurelian marked this pull request as ready for review April 28, 2021 21:03
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you thought about not adding a blockedMessages mapping and instead just writing to successfulMessages? This would save a SLOAD in relayMessage. The name successfulMessages doesn't really make sense anymore if that was the case, it could be something like messages or relayedMessages

Copy link
Contributor Author

@maurelian maurelian Apr 28, 2021

Choose a reason for hiding this comment

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

Good question! Yes, it's mentioned in the PR description, and called out inline here.

An important downside IMO is that it changes the trust assumptions significantly, because if we retain the allowMessage() functionality, the owner could delete successfulMessages entries, making messages replayable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed that this is not a permission we want to enable.

@tynes
Copy link
Contributor

tynes commented Apr 28, 2021

This PR is on master, I could rebase the v0.3.0-rc branch on top of master again for the next rc release but then our git history would get a little out of whack. I will need to rebase again anyways due to other PRs going into master that need to go into the rc branch before the next release

@maurelian
Copy link
Contributor Author

maurelian commented Apr 28, 2021

This PR is on master, I could rebase the v0.3.0-rc branch on top of master again for the next rc release but then our git history would get a little out of whack. I will need to rebase again anyways due to other PRs going into master that need to go into the rc branch before the next release

@tynes Is there any action you would like me to take? :)

@maurelian maurelian dismissed ben-chain’s stale review April 29, 2021 00:03

The change requested that I not remove a test. The test was not removed, it was simply relocated to the end of the file: https://github.com/ethereum-optimism/optimism/pull/579/files#diff-b54fbcb912d89d7f34df9c51f5476fa991feafec083c879b83a56b50fc52dd40R446

@maurelian maurelian requested a review from tynes April 29, 2021 00:19
@gakonst gakonst force-pushed the feat/pauseBlockAllowL1Msgr branch from fe287a6 to 78246e1 Compare April 29, 2021 09:36
Copy link
Contributor

@gakonst gakonst left a comment

Choose a reason for hiding this comment

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

LGTM - nice work.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed that this is not a permission we want to enable.

@gakonst gakonst merged commit 0ef3069 into master Apr 29, 2021
@gakonst gakonst deleted the feat/pauseBlockAllowL1Msgr branch April 29, 2021 09:56
InoMurko referenced this pull request in omgnetwork/optimism May 25, 2021
* feat(contracts): add pausable.sol

This is identical to Pausable, except for replacing Context._msgSender() with just msg.sender

* feat: add pause, block and allow to L1 messenger

* test(l1-messenger): access control, block, allow

* chore: add changeset

* chore: yarn lint

* test[contracts]: maintain previous test order

* fix[contracts]: add upgradable OZ contracts

* Revert "test[contracts]: maintain previous test order"

This reverts commit 4bbfe60.

* test[contracts]: add initializer modifier

* fix(contracts): delete unused file

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
theochap pushed a commit that referenced this pull request Dec 10, 2025
* feat(derive): holocene frame queue changes

* feat(derive): holocene frame queue

* Update crates/derive/src/stages/frame_queue.rs

Co-authored-by: clabby <ben@clab.by>

* fix(derive): fq nits

---------

Co-authored-by: clabby <ben@clab.by>
theochap pushed a commit that referenced this pull request Jan 15, 2026
emhane pushed a commit that referenced this pull request Feb 4, 2026
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.

4 participants