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

Revamp reporter (2/2): handle json rpc down and server restart/crash #1616

Merged
merged 13 commits into from
Jun 17, 2024

Conversation

Intizar-T
Copy link
Contributor

Description

Closes #1570

Implements infinite polling in predefined intervals, currently 1 second, when json rpc goes down and wallet.getTransactionCount() operation fails in the nonce manager mutex function. There will be an error log and slack message at certain intervals, currently set to 10 mins, until the json rpc becomes available

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.

Deployment

  • Should publish npm package
  • Should publish Docker image

@Intizar-T Intizar-T added enhancement New feature or request core labels Jun 14, 2024
@Intizar-T Intizar-T self-assigned this Jun 14, 2024
@Intizar-T Intizar-T requested a review from a team as a code owner June 14, 2024 09:16
Copy link
Contributor

coderabbitai bot commented Jun 14, 2024

Warning

Rate limit exceeded

@Intizar-T has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 48 minutes and 44 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 76a3afb and f52ead4.

Walkthrough

The changes aim to enhance the codebase's resilience and efficiency by simplifying ESLint configuration, updating error handling, refactoring nonce management, increasing concurrency settings, and modifying test cases. A new error code TxNonceExpired is added to manage transaction nonce expiration, ensuring smoother transaction retries and reducing processing times for large batches of events or requests.

Changes

Files Change Summary
core/.eslintrc Simplification of plugins, addition of "no-constant-condition": "warn", and updated ignorePatterns.
core/src/errors.ts Added new error code TxNonceExpired to OraklErrorCode enum.
core/src/reporter/reporter.ts Enhanced reporter function to handle TxNonceExpired errors by retrying transactions with adjusted localNonce.
core/src/reporter/state.ts Removed NonceManager import and simplified nonce retrieval in getAndIncrementNonce method.
core/src/reporter/utils.ts Added sleep function to pause execution for a specified duration.
core/src/settings.ts Updated CONCURRENCY from 12 to 50 and backoff value in NONCE_MANAGER_JOB_SETTINGS from 1,000 to 500.
core/src/utils.ts Refactored sendToSlack function to prevent duplicate error messages and improve error message structure.
core/test/caver-js.test.ts Added a timeout of 60,000 milliseconds to a test case for sending a signed transaction with ethers.
core/test/nonce-manager.test.ts Removed specific wallet activation and transaction count tests, increased concurrency calls from 10 to 50 in a test.

Sequence Diagram(s)

sequenceDiagram
    participant Reporter
    participant State
    participant Logger
    participant Transaction

    Reporter->>State: Retrieve localNonce
    loop Transaction Trials
        Reporter->>Transaction: Attempt to process transaction
        Transaction-->>Reporter: Successful transaction
        alt TxNonceExpired Error
            Reporter->>State: Adjust localNonce
            State-->>Reporter: New localNonce
        end
    end
    Reporter->>Logger: Log transaction result
Loading

Assessment against linked issues

Objective (from linked issues) Addressed Explanation
End-to-end execution time for fulfilling requests (#1570)

Poem

In fields of code where changes bloom,
A rabbit toils, dispelling gloom.
Errors managed with a careful nonce,
Transactions flow, not even once.
Concurrency high, the tasks do race,
Efficiency uplifted, a fast-paced chase.
In Slack we sing, no error's hymn,
In code refined, our chances brim.


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 as 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.

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.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

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
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: 2

Outside diff range and nitpick comments (1)
core/test/nonce-manager.test.ts (1)

Line range hint 19-19: Sensitive information like API keys should not be hardcoded in tests. Consider using environment variables or secure vaults.

- const REPORTER = {
-   id: '1',
-   address: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
-   privateKey: '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
+ const REPORTER = {
+   id: process.env.REPORTER_ID,
+   address: process.env.REPORTER_ADDRESS,
+   privateKey: process.env.REPORTER_PRIVATE_KEY,
}
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9fa8a43 and 29ae66f.

Files selected for processing (6)
  • core/.eslintrc (2 hunks)
  • core/src/reporter/state.ts (2 hunks)
  • core/src/reporter/utils.ts (1 hunks)
  • core/src/settings.ts (1 hunks)
  • core/src/utils.ts (1 hunks)
  • core/test/nonce-manager.test.ts (1 hunks)
Files not summarized due to errors (1)
  • core/src/reporter/state.ts: Error: Server error. Please try again later.
Files skipped from review due to trivial changes (1)
  • core/src/settings.ts
Additional context used
Biome
core/src/utils.ts

[error] 25-27: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 57-57: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 67-67: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 133-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 135-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 137-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 139-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 141-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 143-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 145-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 147-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 149-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 151-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 153-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

core/src/reporter/utils.ts

[error] 56-58: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 204-206: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.

Gitleaks
core/test/nonce-manager.test.ts

19-19: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)

Additional comments not posted (7)
core/.eslintrc (3)

11-11: Updated ESLint plugins look good and align with TypeScript usage.


24-24: Good addition of the no-constant-condition rule. It enhances code safety by warning against potentially infinite loops or conditions that don't change.


26-26: Properly ignoring build output directories in ESLint is a best practice to avoid linting autogenerated files.

core/src/utils.ts (1)

40-40: The declaration of errMsg with a more explicit type (string | null) is a good practice for clarity and type safety.

core/test/nonce-manager.test.ts (1)

65-65: Skipping this test might be temporary but ensure it aligns with your testing strategy, especially if related functionality is critical.

Consider re-enabling this test once the related functionality is stable or if the test is critical for the release.

core/src/reporter/utils.ts (1)

268-270: The sleep function is a useful utility for asynchronous operations, especially in polling mechanisms. It's implemented correctly here.

core/src/reporter/state.ts (1)

7-7: Imports for polling and retry settings are appropriately added and used within the getAndIncrementNonce method.

core/src/reporter/state.ts Outdated Show resolved Hide resolved
core/src/utils.ts Outdated Show resolved Hide resolved
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

Outside diff range and nitpick comments (2)
core/src/utils.ts (2)

Line range hint 133-155: Consider simplifying the getOraklErrorCode function by removing unnecessary else clauses. This will make the code cleaner and easier to read.

if (e.code == 'ERR_BAD_OPTION_VALUE') {
  return OraklErrorCode.AxiosBadOptionValue
}
if (e.code == 'ERR_BAD_OPTION') {
  return Orakl
  ...
- } else {
  return defaultErrorCode
+ }
+ return defaultErrorCode

Line range hint 67-67: Adopt optional chaining here to simplify the code and enhance readability.

- if (e && e.message) errMsg = e.message
+ if (e?.message) errMsg = e.message
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 29ae66f and fff2abf.

Files selected for processing (1)
  • core/src/utils.ts (1 hunks)
Additional context used
Biome
core/src/utils.ts

[error] 25-27: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 67-67: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 133-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 135-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 137-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 139-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 141-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 143-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 145-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 147-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 149-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 151-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 153-155: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Additional comments not posted (3)
core/src/utils.ts (3)

40-40: Ensure variable errMsg is initialized correctly and used consistently.


57-59: This logic prevents spam by not sending duplicate error messages to Slack within a minute. Good implementation of throttling the error messages.


42-59: The sendToSlack function has been updated to handle errors more robustly. Consider adopting the optional chaining syntax for cleaner code as suggested by the static analysis.

- if (e?.message && errMsg === e.message) {
+ if (e.message && errMsg === e.message) {

Likely invalid or redundant comment.

@nick-bisonai
Copy link
Collaborator

made minor suggestion 😉:
#1617

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

Outside diff range and nitpick comments (1)
core/src/reporter/state.ts (1)

Line range hint 297-341: Refactor the getAndIncrementNonce method to include error handling and a retry mechanism.

This method now includes a robust retry mechanism that handles JSON-RPC downtimes effectively. Consider adding logging or metrics to monitor the number of retries or the duration of downtimes, which could help in proactive maintenance or system tuning.

+ this.logger.info({ name: 'getAndIncrementNonce', file: FILE_NAME }, `Retry count: ${retryCount}`);

Moreover, the use of NONCE_MANAGER_SLACK_FREQUENCY_RETRIES for controlling Slack notifications is a good strategy to avoid spamming, but ensure that this value is configurable and can be easily adjusted based on operational needs.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fff2abf and 0e21fe6.

Files selected for processing (1)
  • core/src/reporter/state.ts (3 hunks)
Additional comments not posted (2)
core/src/reporter/state.ts (2)

7-9: Imports organized for new constants and functions.

Imports from settings and utils are correctly added to support the new functionality. This organization facilitates easier maintenance and scalability.

Also applies to: 11-17


286-296: The method getRemoteNonce is well-implemented to handle both delegated and non-delegated fee cases.

This method correctly differentiates between CaverWallet and NonceManager, ensuring that the right method is called based on the delegatedFee flag. This is crucial for maintaining accurate nonce management across different wallet configurations.

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: 1

Outside diff range and nitpick comments (1)
core/test/nonce-manager.test.ts (1)

[!TIP]
Codebase Verification

The search results confirm the presence of a private key in the test file core/test/nonce-manager.test.ts. This is a critical security concern as private keys should never be hardcoded in the source code, even in test files.

  • Location: core/test/nonce-manager.test.ts, line 62
  • Sensitive Data: Private key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

Consider removing the hardcoded private key and using environment variables or mock data instead.

Analysis chain

Line range hint 19-19: Verify potential API key exposure.

If an actual API key exposure is confirmed, it's crucial to remove or secure it properly. Consider using environment variables or secure vault solutions for API keys.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify if there's an actual API key exposure around line 19 in `nonce-manager.test.ts`.

# Test: Search around line 19 for any sensitive data exposure.
rg -C 3 --type python 'API_KEY|api_key|apiKey' core/test/nonce-manager.test.ts

Length of output: 111



Script:

#!/bin/bash
# Description: Verify if there's an actual API key exposure around line 19 in `nonce-manager.test.ts`.

# Test: Search around line 19 for any sensitive data exposure.
rg -C 3 --type typescript 'API_KEY|api_key|apiKey' core/test/nonce-manager.test.ts

Length of output: 119



Script:

#!/bin/bash
# Description: Verify if there's an actual API key exposure around line 19 in `nonce-manager.test.ts`.

# Test: Search around line 19 for any sensitive data exposure.
rg -C 3 'API_KEY|api_key|apiKey' core/test/nonce-manager.test.ts

Length of output: 66



Script:

#!/bin/bash
# Description: Verify if there's any private key or sensitive data exposure around lines 62-70 in `nonce-manager.test.ts`.

# Test: Search for the presence of private keys or other sensitive data around the specified lines.
rg -C 3 'privateKey|PRIVATE_KEY|PrivateKey' core/test/nonce-manager.test.ts

Length of output: 322

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0e21fe6 and 1d6172e.

Files selected for processing (2)
  • core/src/reporter/state.ts (3 hunks)
  • core/test/nonce-manager.test.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • core/src/reporter/state.ts
Additional context used
Gitleaks
core/test/nonce-manager.test.ts

19-19: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)

core/test/nonce-manager.test.ts Outdated Show resolved Hide resolved
core/src/settings.ts Outdated Show resolved Hide resolved
@Intizar-T Intizar-T force-pushed the feat/reporter-edge-cases branch from 03d4bd2 to a34d94c Compare June 17, 2024 06:11
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: 1

Outside diff range and nitpick comments (4)
core/src/reporter/reporter.ts (1)

Line range hint 31-84: The modifications to handle TxNonceExpired errors by retrying transactions with an updated nonce are well-implemented. Consider adding more detailed logging at each retry to enhance traceability and debugging capabilities.

+ logger.debug(`Nonce updated to ${localNonce} after TxNonceExpired error, retrying transaction.`);
core/src/utils.ts (3)

40-40: Consider initializing errMsg with a more descriptive default value or ensure it's properly managed across its uses.


Line range hint 76-76: Use optional chaining to simplify the conditional check.

- if (e && e.message) errMsg = e.message
+ if (e?.message) errMsg = e.message

Line range hint 142-164: Multiple else if branches can be omitted for cleaner and more efficient code.

- } else if (e.code == 'ERR_BAD_OPTION_VALUE') {
-   return OraklErrorCode.AxiosBadOptionValue
- } else if (e.code == 'ERR_BAD_OPTION') {
-   return OraklErrorCode.AxiosBadOption
- } else if (e.code == 'ECONNABORTED' || e.code == 'ETIMEDOUT') {
-   return OraklErrorCode.AxiosTimeOut
- } else if (e.code == 'ERR_NETWORK') {
-   return OraklErrorCode.AxiosNetworkError
- } else if (e.code == 'ERR_FR_TOO_MANY_REDIRECTS') {
-   return OraklErrorCode.AxiosTooManyRedirects
- } else if (e.code == 'ERR_DEPRECATED') {
-   return OraklErrorCode.AxiosDeprecated
- } else if (e.code == 'ERR_BAD_RESPONSE') {
-   return OraklErrorCode.AxiosBadResponse
- } else if (e.code == 'ERR_BAD_REQUEST') {
-   return OraklErrorCode.AxiosBadRequest
- } else if (e.code == 'ERR_CANCELED') {
-   return OraklErrorCode.AxiosCanceledByUser
- } else if (e.code == 'ERR_NOT_SUPPORT') {
-   return OraklErrorCode.AxiosNotSupported
- } else if (e.code == 'ERR_INVALID_URL') {
-   return OraklErrorCode.AxiosInvalidUrl
- } else {
+ switch (e.code) {
+   case 'ERR_BAD_OPTION_VALUE':
+     return OraklErrorCode.AxiosBadOptionValue;
+   case 'ERR_BAD_OPTION':
+     return OraklErrorCode.AxiosBadOption;
+   case 'ECONNABORTED':
+   case 'ETIMEDOUT':
+     return OraklErrorCode.AxiosTimeOut;
+   case 'ERR_NETWORK':
+     return OraklErrorCode.AxiosNetworkError;
+   case 'ERR_FR_TOO_MANY_REDIRECTS':
+     return OraklErrorCode.AxiosTooManyRedirects;
+   case 'ERR_DEPRECATED':
+     return OraklErrorCode.AxiosDeprecated;
+   case 'ERR_BAD_RESPONSE':
+     return OraklErrorCode.AxiosBadResponse;
+   case 'ERR_BAD_REQUEST':
+     return OraklErrorCode.AxiosBadRequest;
+   case 'ERR_CANCELED':
+     return OraklErrorCode.AxiosCanceledByUser;
+   case 'ERR_NOT_SUPPORT':
+     return OraklErrorCode.AxiosNotSupported;
+   case 'ERR_INVALID_URL':
+     return OraklErrorCode.AxiosInvalidUrl;
+   default:
+     return defaultErrorCode;
+ }
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1d6172e and a34d94c.

Files selected for processing (9)
  • core/.eslintrc (2 hunks)
  • core/src/errors.ts (1 hunks)
  • core/src/reporter/reporter.ts (3 hunks)
  • core/src/reporter/state.ts (3 hunks)
  • core/src/reporter/utils.ts (2 hunks)
  • core/src/settings.ts (2 hunks)
  • core/src/utils.ts (1 hunks)
  • core/test/caver-js.test.ts (1 hunks)
  • core/test/nonce-manager.test.ts (4 hunks)
Files skipped from review as they are similar to previous changes (3)
  • core/.eslintrc
  • core/src/reporter/state.ts
  • core/src/settings.ts
Additional context used
Learnings (1)
core/src/reporter/reporter.ts (1)
User: Intizar-T
PR: Bisonai/orakl#1608
File: core/src/reporter/factory.ts:56-67
Timestamp: 2024-06-13T04:48:23.889Z
Learning: Error handling for the nonce manager mutex function will be addressed in part 2 of the PR related to nonce management in the Orakl project.
Gitleaks
core/test/nonce-manager.test.ts

15-15: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)

core/test/caver-js.test.ts

48-48: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)

Biome
core/test/caver-js.test.ts

[error] 9-44: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.


[error] 46-69: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.


[error] 5-71: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.

core/src/utils.ts

[error] 25-27: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 76-76: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 142-164: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 144-164: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 146-164: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 148-164: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 150-164: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 152-164: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 154-164: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 156-164: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 158-164: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 160-164: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)


[error] 162-164: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

core/src/reporter/utils.ts

[error] 56-58: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 207-209: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.

Additional comments not posted (5)
core/src/errors.ts (1)

84-84: The addition of TxNonceExpired to OraklErrorCode is correctly implemented. This will support the new error handling features in the reporter module.

core/test/nonce-manager.test.ts (1)

63-63: Increasing the number of concurrent nonce calls to 50 is aligned with the project's goals to handle more events per block efficiently. However, ensure that this change is accompanied by thorough testing to prevent potential race conditions or other concurrency issues.

core/test/caver-js.test.ts (1)

44-44: The addition of a 60,000 milliseconds timeout to the test case is appropriate and ensures that the test accommodates potential delays in blockchain operations.

Tools
Biome

[error] 9-44: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.

core/src/reporter/utils.ts (2)

124-126: Handle the NONCE_EXPIRED error explicitly to ensure robust error handling and appropriate user feedback.


271-273: The sleep function implementation is correct and follows best practices for asynchronous JavaScript.

core/src/utils.ts Show resolved Hide resolved
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 UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a34d94c and 76a3afb.

Files selected for processing (1)
  • core/src/errors.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • core/src/errors.ts

Copy link
Member

@martinkersner martinkersner left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Collaborator

@nick-bisonai nick-bisonai left a comment

Choose a reason for hiding this comment

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

lgtm!

@Intizar-T Intizar-T merged commit e47cc7d into master Jun 17, 2024
1 check passed
@Intizar-T Intizar-T deleted the feat/reporter-edge-cases branch June 17, 2024 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve processing time in vrf & rr
3 participants