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

chore: move NewTracer to keeper #126

Merged
merged 1 commit into from
Sep 27, 2024
Merged

chore: move NewTracer to keeper #126

merged 1 commit into from
Sep 27, 2024

Conversation

gartnera
Copy link
Member

@gartnera gartnera commented Sep 24, 2024

Avoid references to vm.DefaultActivePrecompiles in types to ensure that types can be imported without requiring replace github.com/ethereum/go-ethereum => github.com/zeta-chain/go-ethereum v1.10.26-spc

Summary by CodeRabbit

  • New Features

    • Introduced a new NewTracer function for enhanced logging capabilities in the Ethermint library, allowing for various formats of EVM transaction tracing.
  • Bug Fixes

    • Updated the Tracer method to call NewTracer directly, ensuring consistent functionality without altering parameters or return types.
  • Refactor

    • Removed the previous NewTracer function from the types package, streamlining the codebase by consolidating tracer functionality.

@gartnera gartnera requested a review from a team September 24, 2024 18:10
Copy link

coderabbitai bot commented Sep 24, 2024

Walkthrough

Walkthrough

The changes involve the refactoring of the NewTracer function within the Ethermint library. The function has been moved from the x/evm/types/tracer.go file to a new file, x/evm/keeper/tracer.go, while the Tracer method in x/evm/keeper/keeper.go has been updated to call this new function directly. This restructuring simplifies the code and enhances the logging capabilities for EVM transactions by allowing different tracer formats.

Changes

Files Change Summary
x/evm/keeper/keeper.go Updated the Tracer method to call NewTracer directly instead of types.NewTracer. No changes to parameters or return type.
x/evm/keeper/tracer.go Introduced a new NewTracer function that creates a logger tracer for EVM transactions, supporting multiple tracer types.
x/evm/types/tracer.go Removed the existing NewTracer function, eliminating the logic for creating various tracer types and simplifying the code.

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>, please review it.
    -- 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @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.

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.

gartnera added a commit to zeta-chain/node that referenced this pull request Sep 24, 2024
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: 3

Outside diff range and nitpick comments (1)
x/evm/keeper/tracer.go (1)

29-31: Add function documentation.

Please add a comprehensive documentation comment for the NewTracer function, describing its purpose, parameters, and return value. This will enhance code readability and maintainability.

Consider adding a comment like this:

// NewTracer creates a new EVMLogger based on the specified tracer type.
// It supports various tracer types including AccessList, JSON, Markdown, and Struct.
//
// Parameters:
// - tracer: A string specifying the type of tracer to create.
// - msg: The core.Message containing transaction details.
// - cfg: The chain configuration.
// - height: The current block height.
//
// Returns:
// An vm.EVMLogger implementation based on the specified tracer type.
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2fad916 and 9c12024.

Files selected for processing (3)
  • x/evm/keeper/keeper.go (1 hunks)
  • x/evm/keeper/tracer.go (1 hunks)
  • x/evm/types/tracer.go (0 hunks)
Files not reviewed due to no reviewable changes (1)
  • x/evm/types/tracer.go
Additional comments not posted (3)
x/evm/keeper/tracer.go (2)

1-16: License header and package declaration are correct.

The license header is properly formatted and the package declaration is accurate.


18-27: Verify usage of all imported packages.

Please ensure that all imported packages are utilized within the code. Unused imports should be removed to maintain code cleanliness.

Run the following script to check for unused imports:

x/evm/keeper/keeper.go (1)

289-289: Approve the change and verify import statements

The modification to call NewTracer directly instead of types.NewTracer is correct and aligns with the PR objective of eliminating references to vm.DefaultActivePrecompiles within types. This change enhances the modularity of the codebase.

To ensure the change is complete, please verify that the necessary import statements have been updated accordingly. Run the following script to check for any remaining references to types.NewTracer and to confirm that NewTracer is properly imported or defined within the current package:

Verification successful

Verified: Import statements are correctly updated

The modification to call NewTracer directly has been successfully verified. No remaining references to types.NewTracer were found, and NewTracer is properly defined within the current package.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify import statements and usage of NewTracer

# Check for remaining references to types.NewTracer
echo "Checking for remaining references to types.NewTracer:"
rg --type go "types\.NewTracer"

# Check for the import or definition of NewTracer in the current package
echo "Checking for import or definition of NewTracer:"
rg --type go "^(import\s+.*NewTracer|func\s+NewTracer)"

Length of output: 438

x/evm/keeper/tracer.go Show resolved Hide resolved
x/evm/keeper/tracer.go Show resolved Hide resolved
x/evm/keeper/tracer.go Show resolved Hide resolved
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 52.63158% with 9 lines in your changes missing coverage. Please review.

Project coverage is 67.81%. Comparing base (2fad916) to head (9c12024).

Files with missing lines Patch % Lines
x/evm/keeper/tracer.go 50.00% 9 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #126      +/-   ##
==========================================
+ Coverage   67.74%   67.81%   +0.07%     
==========================================
  Files         124      125       +1     
  Lines       11451    11451              
==========================================
+ Hits         7757     7766       +9     
+ Misses       3253     3244       -9     
  Partials      441      441              
Files with missing lines Coverage Δ
x/evm/keeper/keeper.go 87.50% <100.00%> (ø)
x/evm/types/tracer.go 20.00% <ø> (+12.85%) ⬆️
x/evm/keeper/tracer.go 50.00% <50.00%> (ø)

Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

Are TODOs part of copied code? I think we should still track these if it makes sense

x/evm/keeper/tracer.go Show resolved Hide resolved
x/evm/keeper/tracer.go Show resolved Hide resolved
@gartnera gartnera merged commit f34e2a4 into main Sep 27, 2024
25 of 26 checks passed
gartnera added a commit to zeta-chain/node that referenced this pull request Sep 27, 2024
github-merge-queue bot pushed a commit to zeta-chain/node that referenced this pull request Sep 27, 2024
* ci: add rpcimportable test

* add ci

* fmt

* use github.com/btcsuite/btcd/btcutil in pkg/chains

* remove app imports types tests

* use standalone sdkconfig package

* fix policies test

* move crosschain keeper tests from types to keeper

* never seal config in tests

* use zeta-chain/ethermint#126

* add some comments

* use merged ethermint hash

* show resulting go.mod
morde08 pushed a commit to zeta-chain/node that referenced this pull request Oct 2, 2024
* ci: add rpcimportable test

* add ci

* fmt

* use github.com/btcsuite/btcd/btcutil in pkg/chains

* remove app imports types tests

* use standalone sdkconfig package

* fix policies test

* move crosschain keeper tests from types to keeper

* never seal config in tests

* use zeta-chain/ethermint#126

* add some comments

* use merged ethermint hash

* show resulting go.mod
github-merge-queue bot pushed a commit to zeta-chain/node that referenced this pull request Oct 3, 2024
…guration (#2953)

* update artillery config

* more fixes

* feat: integrate authenticated calls smart contract functionality into protocol (#2904)

* e2e tests and modifications for authenticated call

* extend test with sender check and revert case

* separate tests into separate files

* cleanup

* withdraw and call support and tests

* bump protocol contracts

* split tests into separate files

* small cleanup

* fmt

* generate

* lint

* changelog

* PR  comments

* fix case in proto

* bump vote inbound gas limit in zetaclient

* fix test

* generate

* fixing tests

* call options non empty

* generate

* test fix

* rename gateway caller

* pr comments rename tests

* PR comment

* generate

* tests

* update tests fixes

* tests fixes

* fix

* test fix

* feat!: bank precompile (#2860)

* feat: bank precompile

* feat: add deposit

* feat: extend deposit

* PoC: spend amount on behalf of EOA

* feat: expand deposit with transferFrom

* use CallEVM instead on ZRC20 bindings

* divide the contract into different files

* initialize e2e testing

* remove duplicated funding

* add codecov

* expand e2e

* fix: wait for deposit tx to be mined

* apply first round of reviews

* cover al error types test

* fixes using time.Since

* Include CallContract interface

* fix eth events in deposit precompile method

* emit Deposit event

* add withdraw function

* finalize withdraw

* pack event arguments generically

* add high level event function

* first round of review fixes

* second round of reviews

* create bank account when instantiating bank

* e2e: add good and bad scenarios

* modify fmt

* chore: group input into eventData struct

* docs: document bank's methods

* chore: generate files with suffix .gen.go

* chore: assert errors with errorIs

* chore: reset e2e test by resetting allowance

* test: add first batch of unit test

* test: cover all cases

* test: complete unit test cases

* include review suggestions

* include e2e through contract

* test: add e2e through contract complete

* test: revert balance between tests

* Update precompiles/bank/const.go

Co-authored-by: Lucas Bertrand <[email protected]>

* fix: changed coin denom

---------

Co-authored-by: skosito <[email protected]>
Co-authored-by: Lucas Bertrand <[email protected]>

* feat: add sender to revert context (#2919)

* e2e tests and modifications for authenticated call

* extend test with sender check and revert case

* separate tests into separate files

* cleanup

* withdraw and call support and tests

* bump protocol contracts

* split tests into separate files

* small cleanup

* fmt

* generate

* lint

* changelog

* PR  comments

* fix case in proto

* bump vote inbound gas limit in zetaclient

* fix test

* generate

* fixing tests

* call options non empty

* generate

* test fix

* rename gateway caller

* pr comments rename tests

* PR comment

* generate

* tests

* add sender in test contract

* extend e2e tests

* generate

* changelog

* PR comment

* generate

* update tests fixes

* tests fixes

* fix

* test fix

* gas limit fixes

* PR comment fix

* fix bad merge

* ci: add option to enable monitoring stack (#2927)

* ci: add option to enable monitoring stack

* start prometheus faster

* update

* ci: add rpcimportable test (#2817)

* ci: add rpcimportable test

* add ci

* fmt

* use github.com/btcsuite/btcd/btcutil in pkg/chains

* remove app imports types tests

* use standalone sdkconfig package

* fix policies test

* move crosschain keeper tests from types to keeper

* never seal config in tests

* use zeta-chain/ethermint#126

* add some comments

* use merged ethermint hash

* show resulting go.mod

* ci: Add SARIF upload to GitHub Security Dashboard (#2929)

* add semgrep sarif upload to GHAS

* added comment to clairfy the usage of the utility script

* use ghcr.io instead

* add tag to image

* bad org name

---------

Co-authored-by: jkan2 <[email protected]>

* fix: add recover to InitChainer to diplay informative message when starting a node from block 1 (#2925)

* add recover to InitChainer

* generate files

* add docs link to error message

* move InitChainErrorMessage to app.go

* Update app/app.go

Co-authored-by: Francisco de Borja Aranda Castillejo <[email protected]>

* use const for message

---------

Co-authored-by: Francisco de Borja Aranda Castillejo <[email protected]>

* test: add wait for block to tss migration test (#2931)

* add wait for block to tss migration test

* add comments

* refactor identifiers

* rename checkNumberOfTssGenerated to checkNumberOfTSSGenerated

* chore: allow full zetaclient config overlay (#2945)

* test(e2e): add gateway upgrade in upgrade test (#2932)

* add gateway upgrade

* change reference

* add v2 setup for all tests

* test v2 in light upgrade

* refactor setup to use custody v2 directly

* chore: improve localnet build performance (#2928)

* chore: improve localnet build performance

* propagate NODE_VERSION and NODE_COMMIT

* update hashes

---------

Co-authored-by: skosito <[email protected]>
Co-authored-by: Francisco de Borja Aranda Castillejo <[email protected]>
Co-authored-by: Lucas Bertrand <[email protected]>
Co-authored-by: Alex Gartner <[email protected]>
Co-authored-by: jkan2 <[email protected]>
Co-authored-by: jkan2 <[email protected]>
Co-authored-by: Tanmay <[email protected]>
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.

4 participants