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

Stateful precompiled contracts #64

Closed
wants to merge 2 commits into from

Conversation

fbac
Copy link
Contributor

@fbac fbac commented Jul 17, 2024

  • Add stateful precompiled contracts.

Summary by CodeRabbit

  • New Features

    • Added support for precompile interface and initialization of precompiled contracts in the EVM.
    • Improved cache management for key-value stores to enhance performance.
  • Bug Fixes

    • Corrected parsing of transaction logs to ensure accurate event processing.
  • Refactor

    • Updated initialization and method calls to streamline interactions with EVM and context structures.
    • Reorganized import statements and function signatures for better code clarity and maintenance.
  • Performance

    • Introduced caching strategies and efficient iteration methods for better performance in key-value store operations.
  • Tests

    • Added comprehensive benchmarking and testing functions to ensure reliability and performance of new cache management implementations.

dongsam and others added 2 commits July 17, 2024 15:57
- (evm) crypto-org-chain#328 Support precompile interface.
- (statedb) crypto-org-chain#333 Support native action in statedb, prepare for precompiles.
- (precompile) crypto-org-chain#338 Fix simulation of precompile using context.
- (precompile) crypto-org-chain#342 Problem: native action don't support mem keys
- (precompile) crypto-org-chain#343 Problem: no api to convert native events to logs
- (precompile) crypto-org-chain#344 Fix error handling in precompile context.
- (precompile) crypto-org-chain#346 Add support for new precompile context.
- (precompile) crypto-org-chain#347 Problem: miss contract in ExtStateDB interface
- (precompile) crypto-org-chain#359 Problem: no efficient way to execute read-only native actions
- (precompile) crypto-org-chain#371 Add StateDB itself into native context for precompiles to emit evm logs directly.
- (precompile) crypto-org-chain#380 Allow init precompiled contract with rules when new evm.
* Problem: no access to ctx params in precompile

* Update CHANGELOG.md

Signed-off-by: mmsqe <mavis@crypto.com>

---------

Signed-off-by: mmsqe <mavis@crypto.com>
Copy link

coderabbitai bot commented Jul 17, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The recent changes introduce significant enhancements and refactorings across various components of the Ethereum Virtual Machine (EVM) within the project. Key updates include support for precompiled contracts, modifications to the EVMKeeper interface, improvements in transaction log parsing, and the addition of new caching mechanisms aimed at performance optimization. Multiple files have seen adjustments to handle these new features, ranging from EVM initialization to state management and benchmarking.

Changes

File/Path Change Summary
CHANGELOG.md Added AI-generated summary of changes.
app/ante/eth.go Refactored NewCanTransferDecorator and changed method calls in AnteHandle.
app/ante/interfaces.go Modified EVMKeeper interface return type.
app/app.go Removed geth import, adjusted NewEthermintApp function logic.
go.mod Updated dependencies, added new ones, removed old ones.
rpc/backend/utils.go Improved transaction log parsing in ParseTxLogsFromEvent.
store/cachekv/... Introduced cache store with benchmarking, BTree, and iterator functionalities.
x/evm/keeper/... Added support for custom contracts and updated keeper logic.
x/evm/statedb/... Added native action handling, event emission, and cache management.
x/evm/statedb/native.go Introduced nativeChange for state journaling.
x/evm/statedb/statedb_test.go Added and updated multiple test functions for new state management features.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Contract
    participant EVM
    participant StateDB
    participant CacheKVStore

    User->>Contract: Deploy Contract
    Contract->>EVM: Initialize with Precompiled Contracts
    EVM->>StateDB: Access State
    StateDB->>CacheKVStore: Cache Reads/Writes
    Contract->>EVM: Execute Transaction
    EVM->>StateDB: Commit Changes
    StateDB->>CacheKVStore: Write to Backend Store
Loading

Poem

In the realm of code so fine,
EVM's magic does now shine.
Precompiles and caches new,
Speed and features all in view.
Logs are parsed, and states restored,
Performance gains, our grand reward.
CodeRabbit hops with glee,
For improvements all can see. 🐰✨


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.

@fbac fbac closed this Jul 17, 2024
@fbac fbac deleted the stateful-precompiled-contracts branch July 17, 2024 14:07
store/cachemulti/store.go Dismissed Show dismissed Hide dismissed
store/cachemulti/store.go Dismissed Show dismissed Hide dismissed
store/cachemulti/store.go Dismissed Show dismissed Hide dismissed
store/cachemulti/store.go Dismissed Show dismissed Hide dismissed
x/evm/statedb/transient_storage.go Dismissed Show dismissed Hide dismissed
x/evm/keeper/state_transition.go Dismissed Show dismissed Hide dismissed
store/cachemulti/store.go Dismissed Show dismissed Hide dismissed
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.

3 participants