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

Enable fee indexing and fix some issues #15

Merged
merged 2 commits into from
Jul 24, 2024
Merged

Conversation

Inkvi
Copy link
Collaborator

@Inkvi Inkvi commented Jul 23, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced event handling with indexed parameters for improved querying of the SendPacketFeeDeposited event.
    • Introduced distinct fields for gas limits and prices, enhancing clarity and usability in gas-related operations.
    • Added new contract address entries for fee management functionality in both base and optimism chains.
  • Bug Fixes

    • Improved data structure returned by fee handling functions to include unique identifiers for better tracking and validation of gas data.

@Inkvi Inkvi requested a review from dshiell July 23, 2024 23:08
Copy link

coderabbitai bot commented Jul 23, 2024

Walkthrough

The recent updates enhance event handling capabilities and contract management within the blockchain application. Key changes include indexing parameters in the SendPacketFeeDeposited event for improved log querying, the addition of new contract addresses for fee management, and enhancements in fee handling functions to include unique identifiers. Overall, these updates facilitate better performance and tracking of events while streamlining event handling logic for clarity and efficiency.

Changes

File Change Summary
src/abi/fee.ts Updated SendPacketFeeDeposited event parameters to be indexed for better querying efficiency; modified gas limit/price fields in GraphQL schema.
src/chains/base.ts Added process.env.FEE_VAULT_BASE! to the CONTRACTS array, enhancing contract address configurations.
src/chains/optimism.ts Added process.env.FEE_VAULT_OPTIMISM! to the CONTRACTS array, expanding fee management functionalities.
src/handlers/fees.ts Added id property in return objects of handleSendPacketFee and handleOpenChannelFee functions for tracking; validated gas limits and prices.
src/model/generated/sendPacketFeeDeposited.model.ts Removed old gas limits/prices arrays and replaced them with distinct bigint properties for sending and acknowledgment operations.
db/migrations/1721827264108-Data.js Introduced migration to update send_packet_fee_deposited table by dropping old gas columns and adding new ones for better data handling.
schema.graphql Modified SendPacketFeeDeposited entity by replacing gas limits/prices fields with new distinct attributes.

Poem

In the meadow, where fees do play,
New events dance in a bright bouquet.
With indexed logs, they hop and bound,
Making tracking fun, where joy is found!
A vault for fees, a cheerful cheer,
Let's celebrate, for spring is here! 🐇✨


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 Configuration 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

@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, codebase verification and nitpick comments (2)
src/chains/base.ts (1)

12-12: Ensure process.env.FEE_VAULT_BASE is set.

The environment variable FEE_VAULT_BASE is not set in any configuration files within the repository. Please ensure that this variable is properly set in all relevant environments to avoid runtime errors.

  • src/chains/base.ts: Line 12
Analysis chain

Ensure process.env.FEE_VAULT_BASE is set.

The addition of process.env.FEE_VAULT_BASE! to the CONTRACTS array is correct. However, ensure that this environment variable is properly set in all relevant environments to avoid runtime errors.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if `process.env.FEE_VAULT_BASE` is set in the environment configuration files.

# Test: Search for the environment variable definition. Expect: The variable is set.
rg --type env 'FEE_VAULT_BASE'

Length of output: 58


Script:

#!/bin/bash
# Description: Verify if `process.env.FEE_VAULT_BASE` is set in common environment configuration files.

# Test: Search for the environment variable definition. Expect: The variable is set.
rg 'FEE_VAULT_BASE' .env .env.* config/*.env

Length of output: 104


Script:

#!/bin/bash
# Description: Verify if `process.env.FEE_VAULT_BASE` is set in any file within the repository.

# Test: Search for the environment variable definition. Expect: The variable is set.
rg 'FEE_VAULT_BASE'

Length of output: 68

src/chains/optimism.ts (1)

12-12: Ensure process.env.FEE_VAULT_OPTIMISM is set.

The environment variable process.env.FEE_VAULT_OPTIMISM is not found in any configuration files. Ensure that this variable is properly set in all relevant environments to avoid runtime errors.

  • src/chains/optimism.ts
Analysis chain

Ensure process.env.FEE_VAULT_OPTIMISM is set.

The addition of process.env.FEE_VAULT_OPTIMISM! to the CONTRACTS array is correct. However, ensure that this environment variable is properly set in all relevant environments to avoid runtime errors.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if `process.env.FEE_VAULT_OPTIMISM` is set in the environment configuration files.

# Test: Search for the environment variable definition. Expect: The variable is set.
rg --type env 'FEE_VAULT_OPTIMISM'

Length of output: 62


Script:

#!/bin/bash
# Description: Verify if `process.env.FEE_VAULT_OPTIMISM` is set in any configuration files.

# Test: Search for the environment variable definition across all files. Expect: The variable is set.
rg 'FEE_VAULT_OPTIMISM'

Length of output: 80

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b38624a and ea7732f.

Files selected for processing (5)
  • src/abi/fee.ts (1 hunks)
  • src/chains/base.ts (1 hunks)
  • src/chains/optimism.ts (1 hunks)
  • src/handlers/fees.ts (2 hunks)
  • src/handlers/index.ts (3 hunks)
Additional comments not posted (4)
src/handlers/fees.ts (2)

11-11: LGTM!

The addition of id: log.id to the returned object in handleSendPacketFee is correct and enhances the data structure.


27-27: LGTM!

The addition of id: log.id to the returned object in handleOpenChannelFee is correct and enhances the data structure.

src/abi/fee.ts (1)

8-8: LGTM! Indexing event parameters.

The changes to index the channelId and sequence parameters in the SendPacketFeeDeposited event will improve the efficiency of querying event logs.

src/handlers/index.ts (1)

119-164: LGTM! Consolidated event handling logic.

The consolidation of event handling logic reduces code duplication and enhances readability. Fetching the portPrefix only once per event improves performance.

However, ensure that the changes do not introduce any breaking changes or missed event handling cases.

Verification successful

LGTM! Consolidated event handling logic.

The consolidation of event handling logic reduces code duplication and enhances readability. Fetching the portPrefix only once per event improves performance.

  • The event handling functions are correctly defined and utilized.
  • No missing event handling cases or breaking changes were found.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the consolidated event handling logic does not introduce any breaking changes.

# Test: Search for the event handling functions. Expect: Only occurances of the new consolidated logic.
rg --type typescript -A 5 $'handleSendPacket|handleRecvPacket|handleWriteAckPacket|handleAcknowledgement|handleTimeout|handleWriteTimeoutPacket|handleChannelOpenInit|handleChannelOpenTry|handleChannelOpenAck|handleChannelOpenConfirm'

Length of output: 269


Script:

#!/bin/bash
# Description: Verify that the consolidated event handling logic does not introduce any breaking changes.

# Test: Search for the event handling functions. Expect: Only occurrences of the new consolidated logic.
rg --type-add 'ts:*.ts' -t ts -A 5 'handleSendPacket|handleRecvPacket|handleWriteAckPacket|handleAcknowledgement|handleTimeout|handleWriteTimeoutPacket|handleChannelOpenInit|handleChannelOpenTry|handleChannelOpenAck|handleChannelOpenConfirm'

Length of output: 10197

@Inkvi Inkvi requested a review from mvpoyatt July 24, 2024 00:10
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.

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 ea7732f and b4658c6.

Files selected for processing (3)
  • schema.graphql (1 hunks)
  • src/handlers/fees.ts (2 hunks)
  • src/model/generated/sendPacketFeeDeposited.model.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/handlers/fees.ts
Additional comments not posted (8)
src/model/generated/sendPacketFeeDeposited.model.ts (4)

20-21: LGTM! The sendGasLimit property is appropriately defined.

The use of bigint for gas-related attributes is suitable for handling large numerical values.


23-24: LGTM! The sendGasPrice property is appropriately defined.

The use of bigint for gas-related attributes is suitable for handling large numerical values.


26-27: LGTM! The ackGasLimit property is appropriately defined.

The use of bigint for gas-related attributes is suitable for handling large numerical values.


29-30: LGTM! The ackGasPrice property is appropriately defined.

The use of bigint for gas-related attributes is suitable for handling large numerical values.

schema.graphql (4)

351-351: LGTM! The sendGasLimit field is appropriately defined.

The use of BigInt! ensures that the gas limit is required and appropriately handles large numerical values.


352-352: LGTM! The sendGasPrice field is appropriately defined.

The use of BigInt! ensures that the gas price is required and appropriately handles large numerical values.


353-353: LGTM! The ackGasLimit field is appropriately defined.

The use of BigInt! ensures that the gas limit is required and appropriately handles large numerical values.


354-354: LGTM! The ackGasPrice field is appropriately defined.

The use of BigInt! ensures that the gas price is required and appropriately handles large numerical values.

@Inkvi Inkvi force-pushed the inkvi/enable-fee-indexing branch from b4658c6 to 9b9aaed Compare July 24, 2024 13:29
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.

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 b4658c6 and 9b9aaed.

Files selected for processing (4)
  • db/migrations/1721827264108-Data.js (1 hunks)
  • schema.graphql (1 hunks)
  • src/handlers/fees.ts (2 hunks)
  • src/model/generated/sendPacketFeeDeposited.model.ts (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • schema.graphql
  • src/handlers/fees.ts
  • src/model/generated/sendPacketFeeDeposited.model.ts
Additional comments not posted (2)
db/migrations/1721827264108-Data.js (2)

4-10: Ensure the correctness of SQL queries and data types.

The SQL queries appear correct, but verify that the new columns (send_gas_limit, send_gas_price, ack_gas_limit, ack_gas_price) are intended to be numeric and NOT NULL. Ensure this aligns with the database schema requirements.


13-19: Ensure the correctness of SQL queries and data types.

The SQL queries appear correct, but verify that the reverted columns (gas_limits, gas_prices) are intended to be integer array and NOT NULL. Ensure this aligns with the database schema requirements.

@Inkvi Inkvi merged commit 896b931 into main Jul 24, 2024
4 checks passed
This was referenced Sep 17, 2024
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.

1 participant