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/create evm smart contract from internal tx main #824

Merged
merged 2 commits into from
Jun 25, 2024

Conversation

phamphong9981
Copy link
Contributor

@phamphong9981 phamphong9981 commented Jun 24, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced transaction processing to include internal transactions (CREATE, CALL, DELEGATECALL, CREATE2).
  • Improvements

    • Improved tracking and processing of internal contract creations within transactions.

@phamphong9981 phamphong9981 requested a review from peara June 24, 2024 07:45
@phamphong9981 phamphong9981 self-assigned this Jun 24, 2024
Copy link

coderabbitai bot commented Jun 24, 2024

Walkthrough

The changes involve enhancements to the EVM transaction processing system, incorporating evm_internal_transactions into the data model and extending functionality to filter and track internal contract creation types. crawl_contract_evm.service.ts has been updated to integrate these additions, particularly modifying the control flow to process internal transactions more efficiently. Static properties have been added to the EvmInternalTransaction class for better type management.

Changes

Files Summary
src/models/evm_internal_transaction.ts Added a static property TYPE with values CREATE, CALL, DELEGATECALL, and CREATE2 in the EvmInternalTransaction class.
src/models/evm_transaction.ts Introduced an import statement for EvmInternalTransaction and added a new relation for evm_internal_transactions with corresponding join conditions.
src/services/evm/crawl_contract_evm.service.ts Imported Dictionary from lodash, added EvmInternalTransaction, adjusted BULL_JOB_NAME constants, fetched evm_internal_transactions, filtered creation types, and enhanced processing logic.

Sequence Diagrams

sequenceDiagram
    participant Service as crawl_contract_evm.service.ts
    participant EVM as EVMTransaction
    participant InternalTx as EvmInternalTransaction
    
    Service->>EVM: Fetch evm_internal_transactions
    EVM->>InternalTx: Get all transactions
    InternalTx-->>EVM: Return transactions
    Service->>InternalTx: Filter for CREATE types
    InternalTx-->>Service: Return filtered transactions
    Service->>Service: Track creation of internal contracts
    Service->>Service: Process addresses and enhanced logic
Loading

Poem

In the world of EVM delight,
Transactions now take to flight.
With CREATE, CALL, and DELEGATECALL in sight,
Internal contracts come to light.
Our code hops forward, swift and bright,
Processing flows, a rabbit's might! 🐇✨


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

@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)
src/models/evm_transaction.ts (1)

7-7: Ensure proper handling of cyclic dependencies.

The import of EvmInternalTransaction from within evm_transaction.ts could potentially lead to cyclic dependencies, especially since both models might cross-reference each other. Consider using TypeScript's dynamic imports or ensuring that the models are structured to prevent such cycles.

src/services/evm/crawl_contract_evm.service.ts (1)

Line range hint 92-92: Consider using optional chaining.

Given the complexity of the data structures involved, using optional chaining for accessing properties would enhance the robustness of the code by safely handling cases where data might be undefined.

- isCreationInternalContracts[address]
+ isCreationInternalContracts?.[address]
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bfc535b and 5ea9a69.

Files selected for processing (3)
  • src/models/evm_internal_transaction.ts (1 hunks)
  • src/models/evm_transaction.ts (2 hunks)
  • src/services/evm/crawl_contract_evm.service.ts (5 hunks)
Files skipped from review due to trivial changes (1)
  • src/models/evm_internal_transaction.ts
Additional context used
Biome
src/services/evm/crawl_contract_evm.service.ts

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

Unsafe fix: Change to an optional chain.

Additional comments not posted (6)
src/models/evm_transaction.ts (1)

87-94: Properly defined relation for internal transactions.

The relation mapping for evm_internal_transactions is well-defined, adhering to the structure expected by Objection.js. This setup facilitates easy retrieval of related internal transactions directly from an EVM transaction instance, enhancing data accessibility.

src/services/evm/crawl_contract_evm.service.ts (5)

4-6: Review of new imports and configurations.

The addition of Dictionary from lodash and the updated import paths reflect a move towards more structured data handling and configuration management. This change supports the dynamic needs of the service, especially in handling complex data types efficiently.


14-14: Import of EvmInternalTransaction model.

Importing EvmInternalTransaction is crucial for the service's functionality to process internal transactions. This aligns with the service's expanded role in handling more complex transaction types.


44-47: Updated job handling constants.

The constants related to job names are well-organized and reflect the service's operational requirements. This change likely supports better management and scalability of job processing within the service.


66-80: Enhanced query logic for fetching EVM data.

The modifications to the query logic, particularly the addition of withGraphFetched and modifyGraph, enhance the service's ability to fetch and process related data efficiently. This is crucial for handling complex relationships in blockchain data.


Line range hint 87-108: Logic to track and process internal transactions.

The logic to track creation of internal contracts and the handling of addresses is robust, facilitating detailed tracking and processing of blockchain data. This functionality is crucial for accurate data representation and further processing.

@peara peara merged commit 860f163 into main Jun 25, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants