Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

feat: support backup relayers #640

Merged
merged 5 commits into from
Dec 4, 2023
Merged

Conversation

rach-id
Copy link
Member

@rach-id rach-id commented Dec 3, 2023

Overview

Closes #624

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

Summary by CodeRabbit

  • New Features

    • Introduced backup relayer functionality with configurable wait time.
    • Enhanced relayer logic to support conditional backup relaying operations.
  • Improvements

    • Updated configuration settings to include new backup relayer options.
    • Enhanced validation for backup relayer settings in the configuration.
  • Bug Fixes

    • Adjusted test cases to align with new parameters in the NewRelayer function call.

@rach-id rach-id added enhancement New feature or request relayer relayer related labels Dec 3, 2023
@rach-id rach-id self-assigned this Dec 3, 2023
@rach-id rach-id requested a review from evan-forbes as a code owner December 3, 2023 21:09
Copy link
Contributor

coderabbitai bot commented Dec 3, 2023

Walkthrough

The code changes introduce a backup relayer mechanism that allows for a secondary relaying process to take over if the primary relayer fails. This includes new flags for enabling the backup relayer and setting a wait time before it takes action, as well as logic to handle the conditional relaying based on these settings.

Changes

File Path Change Summary
cmd/blobstream/.../config.go Added flags for backup relayer and wait time, with corresponding getter functions.
cmd/blobstream/relayer/cmd.go Modified Start function to include new backup relayer parameters.
cmd/blobstream/relayer/config.go Added flags and fields for backup relayer settings, updated validation and parsing functions.
relayer/relayer.go Added fields to Relayer struct, updated NewRelayer function, and modified Start method for backup relayer logic.
testing/blobstream.go Updated NewRelayer function call with additional arguments for backup relayer.

Assessment against linked issues

Objective Addressed Explanation
Support backup relayers with a flag to act as backup if the official relayer fails (#624) The code changes include the implementation of flags and logic to support backup relayers.

Related issues

  • Document backup relayers #641: This issue about documenting backup relayers could be linked to the PR, as the code changes implement the backup relayer functionality that would need documentation.

Poem

In the code where logic streams, 🐇💻
A backup plan now brightly gleams.
Should the main relayer ever fail, 🛡️
The backup hops in without fail. 🐾🔁


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

Note: For conversation with the bot, please use the review comments on code diffs or files.

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

Copy link
Contributor

@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: 4

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 95e2ae1 and fca9e0f.
Files selected for processing (5)
  • cmd/blobstream/base/config.go (2 hunks)
  • cmd/blobstream/relayer/cmd.go (1 hunks)
  • cmd/blobstream/relayer/config.go (3 hunks)
  • relayer/relayer.go (5 hunks)
  • testing/blobstream.go (1 hunks)
Additional comments: 11
cmd/blobstream/base/config.go (4)
  • 85-91: The addition of the new flags FlagBackupRelayer and FlagBackupRelayerWaitTime aligns with the PR objective to introduce backup relayer functionality. These flags will enable the configuration of a relayer to act as a backup and define the wait time before taking action.

  • 277-282: The AddBackupRelayerFlag function correctly adds a boolean flag to enable the backup relayer functionality. The description provided in the flag is clear and indicates the intended behavior when the flag is set to true.

  • 294-298: The AddBackupRelayerWaitTimeFlag function adds a flag to specify the wait time for a backup relayer. The default value is set to 15, which is assumed to be minutes based on the comment. Please verify that this unit is intentional and consistent with the rest of the system's time units.

  • 277-311: The newly added functions for handling the backup relayer flags are consistent with the existing pattern of flag management in the file. This maintains a clean and consistent codebase.

cmd/blobstream/relayer/cmd.go (1)
  • 206-211: The changes to the NewRelayer function call with the addition of config.isBackupRelayer and time.Duration(config.backupRelayerWaitTime)*time.Minute align with the PR objective to implement backup relayer functionality. Ensure that all other parts of the codebase that interact with the NewRelayer function are updated to handle the new signature.
cmd/blobstream/relayer/config.go (2)
  • 140-141: The validation logic in ValidateBasics correctly ensures that backupRelayerWaitTime is not zero when isBackupRelayer is set to true, aligning with the PR objective to handle backup relayer functionality.

  • 266-276: The parsing logic in parseRelayerStartFlags correctly handles the new backup relayer flags and updates the StartConfig struct accordingly.

relayer/relayer.go (3)
  • 33-43: The addition of IsBackupRelayer and BackupRelayerWaitTime fields to the Relayer struct aligns with the PR objective to support backup relayers.

  • 52-71: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [46-70]

The NewRelayer function correctly accepts and initializes the new IsBackupRelayer and BackupRelayerWaitTime fields, which is necessary for the backup relayer feature.

  • 102-118: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [77-146]

The conditional logic in the Start method based on the IsBackupRelayer field correctly implements the intended behavior for backup relayers to wait before relaying if the official relayer fails.

testing/blobstream.go (1)
  • 49-53: The changes to the NewRelayer function call in the test file correctly reflect the updated function signature and the intent to not use the backup relayer functionality in tests.

cmd/blobstream/relayer/config.go Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Dec 3, 2023

Codecov Report

Attention: 68 lines in your changes are missing coverage. Please review.

Comparison is base (2496504) 25.91% compared to head (e935809) 25.44%.
Report is 2 commits behind head on main.

Files Patch % Lines
relayer/relayer.go 0.00% 68 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #640      +/-   ##
==========================================
- Coverage   25.91%   25.44%   -0.48%     
==========================================
  Files          29       29              
  Lines        3044     3101      +57     
==========================================
  Hits          789      789              
- Misses       2160     2217      +57     
  Partials       95       95              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@evan-forbes evan-forbes left a comment

Choose a reason for hiding this comment

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

👍

@rach-id rach-id enabled auto-merge (squash) December 4, 2023 13:10
Copy link
Contributor

@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: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 7f681bb and e935809.
Files selected for processing (1)
  • relayer/relayer.go (5 hunks)
Additional comments: 5
relayer/relayer.go (5)
  • 36-46: The addition of IsBackupRelayer and BackupRelayerWaitTime fields to the Relayer struct aligns with the PR objective to support backup relayers.

  • 55-74: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [49-73]

The NewRelayer function has been correctly updated to accept and initialize the new IsBackupRelayer and BackupRelayerWaitTime fields.

  • 83-85: The introduction of backupRelayerShouldRelay variable is consistent with the PR objective to control when the backup relayer should start relaying.

  • 142-146: The reset mechanism for backupRelayerShouldRelay after a successful transaction is a good practice to ensure the backup relayer only acts when necessary.

  • 105-121: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [80-149]

The processFunc within the Start method has been modified to include conditional behavior based on the IsBackupRelayer field. This change is in line with the PR objective to introduce conditional behavior for backup relayers.

relayer/relayer.go Show resolved Hide resolved
relayer/relayer.go Show resolved Hide resolved
@rach-id rach-id merged commit a9f64c3 into celestiaorg:main Dec 4, 2023
17 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request relayer relayer related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support backup relayers
3 participants