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: tx pool endpoint to return queued txs and apply mempool wrapper #77

Merged
merged 5 commits into from
Oct 22, 2024

Conversation

beer-1
Copy link
Member

@beer-1 beer-1 commented Oct 22, 2024

Description

Closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • New Features

    • Enhanced transaction pool functionality to include both pending and queued transactions, improving visibility and management.
    • Added a new RPC method for querying the ERC20 wrapper contract address.
    • Introduced new fields for handling access lists in transaction messages, enhancing Ethereum transaction capabilities.
  • Bug Fixes

    • Improved error handling during initialization and setup processes in the application.
  • Documentation

    • Reformatted fields in Protocol Buffers for better readability without altering functionality.
  • Chores

    • Updated .gitignore to exclude test-scripts directory from version control.

@beer-1 beer-1 requested a review from a team as a code owner October 22, 2024 04:39
Copy link

coderabbitai bot commented Oct 22, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces several changes across multiple files. Notably, the .gitignore file now includes an entry for test-scripts, allowing these files to be ignored by Git. In app/app.go, the MinitiaApp structure has been enhanced with a new evmIndexer field, and several methods have been modified or added to improve transaction handling and indexing. The jsonrpc/backend/txpool.go file has been updated to include logic for handling queued transactions, enhancing transaction pool functionality. Additionally, new fields and methods have been introduced in various Protocol Buffers files, and the ERC20 wrapper contract has been updated to improve its functionality.

Changes

File Change Summary
.gitignore Added entry for test-scripts under # testing section.
app/app.go - Added evmIndexer field to MinitiaApp struct.
- Introduced SetEVMIndexer and SetKVIndexer methods.
- Modified SetCheckTx, SetMempool, and CheckTx methods to enhance transaction handling.
jsonrpc/backend/txpool.go - Enhanced TxPoolContent to include queued transactions.
- Updated TxPoolContentFrom, TxPoolStatus, and TxPoolInspect methods for improved transaction handling and clarity.
proto/minievm/evm/v1/tx.proto Reformatted access_list field declarations for readability in MsgCreate, MsgCreate2, and MsgCall.
proto/minievm/evm/v1/types.proto - Added field num_retain_block_hashes to Params message.
- Added newline at the end of the file.
api/minievm/evm/v1/auth.pulsar.go Added code_hash field to ContractAccount message and updated associated methods.
api/minievm/evm/v1/query.pulsar.go Introduced new RPC method ERC20Wrapper and request/response message types.
api/minievm/evm/v1/tx.pulsar.go Added AccessList field to MsgCreate, MsgCreate2, and MsgCall message types with associated logic.
api/minievm/evm/v1/types.pulsar.go - Added GasRefundRatio and NumRetainBlockHashes fields to Params.
- Introduced AccessTuple struct.
app/upgrade.go Updated upgradeName from "0.5.3" to "0.5.7" and added new upgrade handler logic.
indexer/abci.go Updated comment in ListenFinalizeBlock method regarding block hash tracking.
x/evm/autocli.go Added new RPC command for querying the ERC20 wrapper contract address.
x/evm/contracts/erc20_wrapper/ERC20Wrapper.go Regenerated file with updates to the contract's ABI and bytecode, including new functions and events.
x/evm/contracts/erc20_wrapper/ERC20Wrapper.sol Updated documentation for the wrap function.
x/evm/keeper/genesis.go Restructured Initialize and InitializeWithDecimals methods to improve ERC20 contract deployment.
x/evm/keeper/keeper.go Added StoreService method and updated TrackBlockHash logic for block hash retention.
x/evm/keeper/params.go Introduced NumRetainBlockHashes method to retrieve parameter value.
x/evm/types/errors.go Added new error variable ErrInvalidNumRetainBlockHashes.
x/evm/types/params.go Updated DefaultParams and Validate methods to include NumRetainBlockHashes field.

Possibly related PRs

  • fix: support accesslist type tx and handle rpc transaction #73: This PR enhances the handling of JSON RPC access list type transactions, which is relevant as the main PR modifies the .gitignore to ignore test-scripts, potentially related to testing access list functionalities.
  • feat: erc20 wrapper #75: This PR introduces an ERC20 wrapper that facilitates IBC transfers, which may involve testing scripts that could be ignored as per the changes in the main PR's .gitignore.
  • feat: track latest 256 cosmos block hashes #76: This PR tracks the latest 256 cosmos block hashes, which may also relate to testing and development scripts that could be included in the ignored test-scripts directory.

🐇 In the meadow where bunnies play,
New scripts to hide, we say hooray!
With apps that hop and pools that gleam,
Our code now dances, a joyful dream!
So let's rejoice, with carrots in hand,
For changes made, oh how grand! 🌼


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.

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

🧹 Outside diff range and nitpick comments (1)
.gitignore (1)

57-58: LGTM! Consider specifying if it's a directory.

The addition of test-scripts to .gitignore is appropriate for excluding test-related files from version control. This aligns well with the PR objectives, as new tests might be introduced for the transaction pool endpoint changes.

For clarity, consider specifying whether this is a directory or specific files. If it's a directory, you might want to add a trailing slash:

 # testing
-test-scripts
+test-scripts/

This makes it explicit that you're ignoring a directory and all its contents.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0874f6d and 452d721.

📒 Files selected for processing (5)
  • .gitignore (1 hunks)
  • app/app.go (1 hunks)
  • jsonrpc/backend/txpool.go (3 hunks)
  • proto/minievm/evm/v1/tx.proto (3 hunks)
  • proto/minievm/evm/v1/types.proto (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • proto/minievm/evm/v1/tx.proto
  • proto/minievm/evm/v1/types.proto
🧰 Additional context used
🔇 Additional comments (5)
jsonrpc/backend/txpool.go (5)

60-87: Proper use of mutex for thread safety

The mutex lock is correctly applied when accessing b.queuedTxs, ensuring thread-safe operations when retrieving queued transactions.


98-99: Correct inclusion of queued transactions in TxPoolContentFrom

Including the queued transactions in the accountContent map provides a complete view of an account's transactions, both pending and queued.


111-114: Thread-safe retrieval of queued transaction count

The mutex lock is appropriately used when accessing b.queuedTxs.Len(), ensuring accurate and thread-safe retrieval of the queued transaction count.


116-117: Accurate reporting of queued transactions in TxPoolStatus

Adding the "queued" key with the count of queued transactions enhances the transparency of the transaction pool's status.


149-155: Including queued transactions in TxPoolInspect output

Extending the inspection output to include queued transactions allows for better monitoring and debugging of the transaction pool state.

Comment on lines +60 to +87
// load queued txs
b.mut.Lock()
queuedTxs := b.queuedTxs.Values()
b.mut.Unlock()

for _, tx := range queuedTxs {
cosmosTx, err := b.app.TxDecode(tx)
if err != nil {
return nil, err
}

ethTx, account, err := txUtils.ConvertCosmosTxToEthereumTx(ctx, cosmosTx)
if err != nil {
return nil, err
}
if ethTx == nil {
continue
}

dump, ok := content["queued"][account.Hex()]
if !ok {
dump = make(map[string]*rpctypes.RPCTransaction)
content["queued"][account.Hex()] = dump
}

dump[fmt.Sprintf("%d", ethTx.Nonce())] = rpctypes.NewRPCTransaction(ethTx, common.Hash{}, 0, 0, chainID)
}

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider limiting the number of queued transactions processed

While pending transactions are limited to 100 transactions, the queued transactions are processed without any limit. If the number of queued transactions becomes large, this could lead to performance issues. Consider implementing a similar limit for queued transactions to ensure consistent performance.

app/app.go Show resolved Hide resolved
Copy link

codecov bot commented Oct 22, 2024

Codecov Report

Attention: Patch coverage is 32.00000% with 68 lines in your changes missing coverage. Please review.

Project coverage is 28.17%. Comparing base (0874f6d) to head (61c141c).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
jsonrpc/backend/txpool.go 0.00% 36 Missing ⚠️
app/upgrade.go 0.00% 15 Missing ⚠️
x/evm/keeper/keeper.go 37.50% 4 Missing and 1 partial ⚠️
app/app.go 0.00% 2 Missing and 1 partial ⚠️
x/evm/keeper/genesis.go 84.21% 2 Missing and 1 partial ⚠️
x/evm/keeper/params.go 50.00% 2 Missing and 1 partial ⚠️
x/evm/types/params.go 57.14% 2 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #77      +/-   ##
==========================================
- Coverage   28.21%   28.17%   -0.05%     
==========================================
  Files         124      124              
  Lines       13544    13621      +77     
==========================================
+ Hits         3822     3838      +16     
- Misses       9168     9224      +56     
- Partials      554      559       +5     
Files with missing lines Coverage Δ
indexer/abci.go 0.00% <ø> (ø)
x/evm/autocli.go 100.00% <100.00%> (ø)
x/evm/contracts/erc20_wrapper/ERC20Wrapper.go 0.00% <ø> (ø)
x/evm/types/errors.go 0.00% <ø> (ø)
app/app.go 55.32% <0.00%> (-0.50%) ⬇️
x/evm/keeper/genesis.go 50.80% <84.21%> (+0.52%) ⬆️
x/evm/keeper/params.go 35.71% <50.00%> (+3.89%) ⬆️
x/evm/types/params.go 63.33% <57.14%> (-5.90%) ⬇️
x/evm/keeper/keeper.go 71.21% <37.50%> (-2.60%) ⬇️
app/upgrade.go 15.00% <0.00%> (-35.00%) ⬇️
... and 1 more

@beer-1 beer-1 merged commit f5f60c3 into main Oct 22, 2024
4 of 5 checks passed
@beer-1 beer-1 deleted the fix/txpool branch October 22, 2024 06:20
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