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

fix(protocol): fix singla service cannot be shared by multiple taiko L1/L2 contracts on the same chain bug #15807

Merged
merged 6 commits into from
Feb 15, 2024

Conversation

dantaik
Copy link
Contributor

@dantaik dantaik commented Feb 15, 2024

In Signal Service, we cannot assume there is only one "taiko" address on a chain so using onlyFromNamed("taiko") is incorrect.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Implemented a system to manage and authorize chain data relayers in the blockchain protocol.
    • Added an event to track changes in relayer authorization status.
  • Tests
    • Enhanced test contracts to support new authorization features for chain data relayers.
  • Refactor
    • Updated existing tests to align with the new relayer authorization system.

@dantaik dantaik marked this pull request as ready for review February 15, 2024 14:28
@dantaik dantaik enabled auto-merge (squash) February 15, 2024 14:28
Copy link

coderabbitai bot commented Feb 15, 2024

Walkthrough

The modifications across the protocol's contracts and tests introduce a new mechanism for authorizing chain data relayers in the SignalService contract. This includes a mapping to manage authorized relayers, a new event to track these changes, and a function to handle authorization. Additionally, the test contracts have been updated to authorize relayers accordingly, enhancing the initialization and configuration of SignalService within different testing environments.

Changes

Files Change Summary
.../contracts/signal/SignalService.sol Introduced isChainDataRelayerAuthorized mapping, RelayerAuthorized event, and authorizeChainDataRelayer function; added authorization check in relayChainData.
.../test/L1/TaikoL1TestBase.sol
.../test/L2/TaikoL2.t.sol
.../test/L2/TaikoL2NoFeeCheck.t.sol
Updated to authorize the chain data relayer via SignalService instance.
.../test/signal/SignalService.t.sol Replaced address setting with relayer authorization in SignalService; updated pranking and relaying chain data tests.

Related issues

  • Add additional solidity tests #14979: The changes in this PR do not directly address the objectives listed in the issue, as it focuses on enhancing test coverage for specific functionalities rather than the authorization of chain data relayers.

Poem

In the code where logic weaves,
A rabbit hopped, through lines and leaves. 🍃
"Authorize!" it said with glee,
As relayers danced, both you and me. 💃🕺
Through tests and contracts, it did hop,
Ensuring data could smoothly flop.
A tale of bytes, so bright and merry,
Signed by a rabbit, oh so cheery! 🐰✨

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 6b46943 and d80bd32.
Files selected for processing (5)
  • packages/protocol/contracts/signal/SignalService.sol (2 hunks)
  • packages/protocol/test/L1/TaikoL1TestBase.sol (1 hunks)
  • packages/protocol/test/L2/TaikoL2.t.sol (2 hunks)
  • packages/protocol/test/L2/TaikoL2NoFeeCheck.t.sol (2 hunks)
  • packages/protocol/test/signal/SignalService.t.sol (2 hunks)
Additional comments: 11
packages/protocol/test/L2/TaikoL2.t.sol (2)
  • 31-39: The deployment of SignalService using deployProxy is correctly implemented, ensuring the contract is initialized with the necessary addressManager.
  • 60-60: Authorization of the chain data relayer for SignalService is correctly performed by calling ss.authorizeChainDataRelayer(address(L2), true);. This aligns with the PR's objective to support multiple taiko contracts.
packages/protocol/test/L2/TaikoL2NoFeeCheck.t.sol (2)
  • 30-38: The deployment of SignalService using deployProxy is correctly implemented, ensuring the contract is initialized with the necessary addressManager.
  • 60-60: Authorization of the chain data relayer for SignalService is correctly performed by calling ss.authorizeChainDataRelayer(address(L2), true);. This aligns with the PR's objective to support multiple taiko contracts.
packages/protocol/contracts/signal/SignalService.sol (4)
  • 42-43: Introduction of isChainDataRelayerAuthorized mapping is correctly implemented to track the authorization status of chain data relayers.
  • 49-49: The RelayerAuthorized event is correctly defined to log changes in authorization status.
  • 66-73: The authorizeChainDataRelayer function is correctly implemented, including validation to prevent redundant authorization changes and emitting the RelayerAuthorized event.
  • 84-84: Modification in the relayChainData function to include an authorization check using isChainDataRelayerAuthorized mapping is correctly implemented, ensuring only authorized relayers can call this function.
packages/protocol/test/L1/TaikoL1TestBase.sol (1)
  • 57-57: Authorization of the chain data relayer for SignalService is correctly performed by calling ss.authorizeChainDataRelayer(address(L1), true);. This aligns with the PR's objective to support multiple taiko contracts.
packages/protocol/test/signal/SignalService.t.sol (2)
  • 55-55: The call to authorizeChainDataRelayer correctly authorizes a relayer. Ensure that corresponding deauthorization logic is also tested for completeness.
  • 304-309: The deauthorization of a chain data relayer and the subsequent expected revert due to unauthorized access is correctly implemented and tested. This ensures that the authorization mechanism is functioning as intended.

@dantaik dantaik changed the title fix(protocol): fix singla service cannot be shared by multiple taiko L1/L2 contracts bug fix(protocol): fix singla service cannot be shared by multiple taiko L1/L2 contracts on the same chain bug Feb 15, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d80bd32 and 9cacc60.
Files selected for processing (7)
  • packages/protocol/contracts/signal/SignalService.sol (1 hunks)
  • packages/protocol/script/DeployOnL1.s.sol (2 hunks)
  • packages/protocol/test/L1/TaikoL1TestBase.sol (1 hunks)
  • packages/protocol/test/L2/TaikoL2.t.sol (2 hunks)
  • packages/protocol/test/L2/TaikoL2NoFeeCheck.t.sol (2 hunks)
  • packages/protocol/test/signal/SignalService.t.sol (2 hunks)
  • packages/protocol/utils/generate_genesis/taikoL2.ts (2 hunks)
Files skipped from review as they are similar to previous changes (4)
  • packages/protocol/test/L1/TaikoL1TestBase.sol
  • packages/protocol/test/L2/TaikoL2.t.sol
  • packages/protocol/test/L2/TaikoL2NoFeeCheck.t.sol
  • packages/protocol/test/signal/SignalService.t.sol
Additional comments: 6
packages/protocol/contracts/signal/SignalService.sol (4)
  • 42-42: Line 42 introduces a new mapping isRelayerAuthorized to track the authorization status of relayers. Ensure that this mapping is appropriately used throughout the contract to enforce relayer authorization checks.
  • 49-49: Line 49 introduces a new event RelayerAuthorized to log changes in relayer authorization status. Verify that this event is emitted correctly in the authorizeRelayer function whenever a relayer's authorization status changes.
  • 66-73: Lines 66-73 introduce the authorizeRelayer function, which allows the contract owner to authorize or deauthorize relayers. Ensure that the function correctly updates the isRelayerAuthorized mapping and emits the RelayerAuthorized event. Also, check for potential reentrancy issues, although it seems unlikely due to the restricted access and nature of operations.
  • 84-84: Line 84 modifies the relayChainData function to check if the caller is an authorized relayer before proceeding. Ensure that this check effectively prevents unauthorized addresses from calling this function.
packages/protocol/script/DeployOnL1.s.sol (1)
  • 94-96: Lines 94-96 introduce a conditional block to authorize a relayer in the SignalService contract if the SHARED_ADDRESS_MANAGER environment variable is not set. Ensure that this logic aligns with the intended deployment and authorization strategy, particularly in relation to the environment setup and the conditions under which a relayer should be authorized.
packages/protocol/utils/generate_genesis/taikoL2.ts (1)
  • 464-466: Lines 464-466 modify the generateContractConfigs function to include isRelayerAuthorized mapping with TaikoL2 set to true in the SignalService contract configuration. Ensure that this change correctly initializes the SignalService contract with the TaikoL2 address authorized as a relayer, aligning with the intended functionality and security model.

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