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: move interval assignment out of cctx loop #2842

Merged
merged 2 commits into from
Sep 10, 2024
Merged

Conversation

brewmaster012
Copy link
Collaborator

@brewmaster012 brewmaster012 commented Sep 6, 2024

Description

The criticalInterval and nonCriticalInterval should not mutate inside the cctx loop in the
EVM outbound scheduler.

As it was before they could mutate because outboundScheduleInterval could change.

How Has This Been Tested?

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Summary by CodeRabbit

  • New Features
    • Improved handling of outbound transactions with defined retry intervals for critical and non-critical transactions.
    • Enhanced clarity and maintainability of transaction scheduling logic.

those things should not mutate in the loop. As it was before
they could mutate because outboundScheduleInterval could change.
Copy link
Contributor

coderabbitai bot commented Sep 6, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Walkthrough

The changes involve modifications to the ScheduleCctxEVM function in the Orchestrator class within orchestrator.go. Two new variables, criticalInterval and nonCriticalInterval, are introduced to manage retry intervals for outbound transactions. The logic for processing transaction lists is updated to utilize these centralized intervals, enhancing clarity and maintainability.

Changes

File Path Change Summary
zetaclient/orchestrator/orchestrator.go Introduced criticalInterval and nonCriticalInterval for managing retry intervals in ScheduleCctxEVM. Removed local declarations within the loop to centralize interval handling.

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 testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 testing code 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 and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Sep 6, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 66.94%. Comparing base (ba3b1c0) to head (721f403).
Report is 7 commits behind head on develop.

Files with missing lines Patch % Lines
zetaclient/orchestrator/orchestrator.go 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #2842   +/-   ##
========================================
  Coverage    66.94%   66.94%           
========================================
  Files          370      370           
  Lines        20965    20965           
========================================
  Hits         14035    14035           
  Misses        6290     6290           
  Partials       640      640           
Files with missing lines Coverage Δ
zetaclient/orchestrator/orchestrator.go 22.04% <0.00%> (ø)

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.

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ba3b1c0 and cc35c7c.

Files selected for processing (1)
  • zetaclient/orchestrator/orchestrator.go (2 hunks)
Additional context used
Path-based instructions (1)
zetaclient/orchestrator/orchestrator.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

GitHub Check: codecov/patch
zetaclient/orchestrator/orchestrator.go

[warning] 455-456: zetaclient/orchestrator/orchestrator.go#L455-L456
Added lines #L455 - L456 were not covered by tests

Additional comments not posted (1)
zetaclient/orchestrator/orchestrator.go (1)

455-456: Refactor and Test Coverage Required for Interval Assignment

The changes made to the interval assignment in ScheduleCctxEVM are crucial for ensuring that criticalInterval and nonCriticalInterval remain stable throughout the function execution. This is a positive change as it prevents unintended mutations of these intervals within the loop, aligning with the PR objectives.

However, it's important to ensure that these intervals are used consistently and correctly throughout the function. Additionally, static analysis has flagged these lines as not covered by tests.

I recommend adding comprehensive unit tests to cover these new lines to ensure their functionality under various conditions. This will help in maintaining the reliability of the scheduling process.

To verify the correct usage of these intervals, consider running the following script:

Verification successful

Intervals Correctly Used; Add Test Coverage

The criticalInterval and nonCriticalInterval are used consistently and correctly within the ScheduleCctxEVM function. They are not reassigned, ensuring stability in their values throughout the function execution. The logic for adjusting the outboundScheduleInterval based on these intervals is sound and aligns with the intended refactor.

However, it is crucial to add comprehensive unit tests to cover these lines and ensure their functionality under various conditions. This will enhance the reliability of the scheduling process and prevent potential issues in production.

  • Test Coverage: Add unit tests to verify the behavior of criticalInterval and nonCriticalInterval in different scenarios.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct usage of `criticalInterval` and `nonCriticalInterval` throughout the function.

# Test: Search for the usage of these intervals in the function. Expect: Consistent usage without reassignment.
rg --type go --context 5 $'criticalInterval|nonCriticalInterval' zetaclient/orchestrator/orchestrator.go

Length of output: 1632

Tools
GitHub Check: codecov/patch

[warning] 455-456: zetaclient/orchestrator/orchestrator.go#L455-L456
Added lines #L455 - L456 were not covered by tests

@swift1337 swift1337 added the SOLANA_TESTS Run make start-solana-test label Sep 9, 2024
@lumtis
Copy link
Member

lumtis commented Sep 9, 2024

This PR prevents it already but as an extra safety measure we should also include the change to prevent 0 division:
#2840
#2841

@lumtis lumtis added this pull request to the merge queue Sep 10, 2024
Merged via the queue into develop with commit 9df6938 Sep 10, 2024
30 of 31 checks passed
@lumtis lumtis deleted the fix-evm-outtx-scheduler branch September 10, 2024 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SOLANA_TESTS Run make start-solana-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants