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

implement statedb #52

Merged
merged 9 commits into from
Aug 27, 2024
Merged

implement statedb #52

merged 9 commits into from
Aug 27, 2024

Conversation

beer-1
Copy link
Member

@beer-1 beer-1 commented Aug 23, 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

    • Introduced support for transient storage in testing and application logic, enhancing state management capabilities.
    • Added new API endpoints for Access Control Lists (ACLs) and parameters, improving functionality related to IBCHooks.
    • Enhanced error handling for invalid fee denominations and introduced new event types.
    • Added a method to validate fee denominations, ensuring only valid parameters are accepted during updates.
  • Bug Fixes

    • Updated error reporting in metadata retrieval to simplify messages.
    • Improved logic for initializing and validating genesis states, streamlining the process.
  • Tests

    • Added new test cases for validating balance retrieval and parameter updates, ensuring robust functionality.
  • Documentation

    • Enhanced API documentation to reflect new endpoints and parameters for better clarity and usability.

@beer-1 beer-1 self-assigned this Aug 23, 2024
Copy link

coderabbitai bot commented Aug 23, 2024

Warning

Rate limit exceeded

@beer-1 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 53 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 742c8d4 and 474f533.

Walkthrough

The changes encompass enhancements to the EVM integration within the Cosmos SDK, focusing on state management, testing infrastructure, and the introduction of transient storage capabilities. Key modifications include the addition of new methods and constants, updates to existing functionalities, and improvements to error handling and API documentation. These adjustments aim to streamline operations related to smart contract interactions and state transitions, ensuring a more robust framework for developers.

Changes

File(s) Change Summary
app/ibc-hooks/common_test.go, x/bank/keeper/common_test.go, x/evm/keeper/common_test.go Enhanced _createTestInput function to support transient store keys and integrate transient storage services.
app/keepers/keepers.go, app/keepers/keys.go Modified NewAppKeeper to include transient store service and updated GenerateKeys method for transient keys.
client/docs/config.json, client/docs/swagger-ui/swagger.yaml Added API endpoint documentation for IBCHooks, including new endpoints and object definitions related to ACLs and parameters.
cmd/minitiad/launch.go, go.mod, integration-tests/go.mod Adjusted handling of the denom parameter and updated dependencies for various libraries.
jsonrpc/types/overrides.go, proto/minievm/evm/v1/genesis.proto Removed Apply methods related to overrides and adjusted GenesisState structure by removing outdated fields.
types/const.go, x/evm/keeper/keeper.go, x/evm/types/errors.go, x/evm/types/events.go, x/evm/types/expected_keeper.go Introduced new constants and error variables, and updated the Keeper struct for improved transient data management.
x/evm/state/common_test.go, x/evm/state/keys.go, x/evm/state/snapshot.go, x/evm/state/state_account.go, x/evm/state/statedb.go, x/evm/state/statedb_test.go Added new files and structures for state management, including snapshots and account handling, with comprehensive test coverage.
x/evm/keeper/msg_server.go, x/evm/keeper/msg_server_test.go Enhanced UpdateParams method and added tests to validate fee denomination updates, ensuring robustness in parameter handling.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant API
    participant Keeper
    participant StateDB

    User->>API: Request to update parameters
    API->>Keeper: Validate parameters
    Keeper->>StateDB: Check fee denomination
    StateDB-->>Keeper: Return validity
    Keeper-->>API: Parameter update success
    API-->>User: Confirm update success
Loading

🐰 In the land of code where bunnies hop,
New features sprout, and old ones stop.
Transient stores and keys align,
Testing grows, oh how divine!
With each change, our world expands,
Hoppy coding, with joyful hands! 🐇✨


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

codecov bot commented Aug 23, 2024

Codecov Report

Attention: Patch coverage is 69.72973% with 168 lines in your changes missing coverage. Please review.

Project coverage is 28.33%. Comparing base (4adcd17) to head (474f533).
Report is 2 commits behind head on main.

Files Patch % Lines
x/evm/state/statedb.go 64.35% 84 Missing and 60 partials ⚠️
x/evm/keeper/msg_server.go 68.96% 6 Missing and 3 partials ⚠️
x/evm/keeper/context.go 84.61% 4 Missing and 4 partials ⚠️
x/evm/keeper/keeper.go 85.71% 1 Missing and 1 partial ⚠️
x/evm/keeper/query_server.go 0.00% 2 Missing ⚠️
x/bank/keeper/grpc_query.go 0.00% 1 Missing ⚠️
x/evm/keeper/genesis.go 0.00% 0 Missing and 1 partial ⚠️
x/evm/types/genesis.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #52      +/-   ##
==========================================
+ Coverage   26.45%   28.33%   +1.88%     
==========================================
  Files         112      114       +2     
  Lines       11895    12189     +294     
==========================================
+ Hits         3147     3454     +307     
+ Misses       8301     8235      -66     
- Partials      447      500      +53     
Files Coverage Δ
app/keepers/keepers.go 98.04% <100.00%> (+<0.01%) ⬆️
app/keepers/keys.go 93.54% <100.00%> (ø)
x/evm/keeper/erc20.go 43.09% <100.00%> (ø)
x/evm/keeper/precompiles.go 85.36% <100.00%> (+2.50%) ⬆️
x/evm/state/keys.go 100.00% <100.00%> (ø)
x/evm/state/snapshot.go 100.00% <100.00%> (ø)
x/evm/state/state_account.go 100.00% <100.00%> (ø)
x/evm/types/errors.go 0.00% <ø> (ø)
x/bank/keeper/grpc_query.go 26.28% <0.00%> (ø)
x/evm/keeper/genesis.go 51.96% <0.00%> (+1.50%) ⬆️
... and 6 more

... and 2 files with indirect coverage changes

@beer-1 beer-1 marked this pull request as ready for review August 26, 2024 07:22
@beer-1 beer-1 requested a review from a team as a code owner August 26, 2024 07:22
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: 14

Outside diff range, codebase verification and nitpick comments (2)
jsonrpc/types/overrides.go (1)

Block Overrides Not Supported

The BlockOverrides functionality is currently not supported, as indicated by the explicit error message in the Call method within jsonrpc/backend/eth.go. Please verify if this is an intentional change or if there are plans to reintroduce the functionality.

  • jsonrpc/backend/eth.go: The Call method returns an error for block overrides.
Analysis chain

Line range hint 19-19: Verify the impact of the removal of the Apply method for BlockOverrides.

The removal of the Apply method suggests a change in how block overrides are applied. Ensure that the functionality is not broken and that the new mechanism for applying block overrides is correctly implemented.

Run the following script to verify the usage of the Apply method for BlockOverrides:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the `Apply` method for `BlockOverrides`.

# Test: Search for the usage of the `Apply` method. Expect: No occurrences of the old method.
rg --type go -A 5 $'BlockOverrides.Apply'

Length of output: 40


Script:

#!/bin/bash
# Description: Search for any new methods or mechanisms related to block overrides.

# Test: Search for functions related to block overrides in the codebase.
rg --type go 'BlockOverrides' -A 10

Length of output: 3285

proto/minievm/evm/v1/genesis.proto (1)

15-25: Issues found with the incomplete removal of the state_root field and potential impact of field reordering.

The state_root field is still referenced in the genesis.pulsar.go file, indicating that its removal is incomplete. This could lead to inconsistencies in the codebase. Additionally, the reordering of fields in the GenesisState message may impact serialization and deserialization processes, which are critical for system functionality.

  • api/minievm/evm/v1/genesis.pulsar.go: Multiple references to state_root field.

Please ensure that these changes are compatible with the existing system and address any lingering references to the state_root field.

Analysis chain

Verify the impact of the removal of the state_root field and reordering of other fields.

The removal of the state_root field and reordering of other fields may impact serialization and deserialization. Ensure that these changes are compatible with the existing system.

Run the following script to verify the usage of the state_root field and the impact of reordering other fields:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the `state_root` field and the impact of reordering other fields.

# Test: Search for the usage of the `state_root` field. Expect: No occurrences of the old field.
rg --type proto -A 5 $'state_root'

# Test: Search for the usage of the `GenesisState` message. Expect: Ensure compatibility with the existing system.
rg --type proto -A 5 $'GenesisState'

Length of output: 129


Script:

#!/bin/bash
# Description: Verify the usage of the `state_root` field and the impact of reordering other fields.

# Test: Search for the usage of the `state_root` field. Expect: No occurrences of the old field.
rg -A 5 'state_root'

# Test: Search for the usage of the `GenesisState` message. Expect: Ensure compatibility with the existing system.
rg -A 5 'GenesisState'

Length of output: 67782

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4adcd17 and e91f4ff.

Files ignored due to path filters (3)
  • go.sum is excluded by !**/*.sum
  • integration-tests/go.sum is excluded by !**/*.sum
  • x/evm/types/genesis.pb.go is excluded by !**/*.pb.go
Files selected for processing (37)
  • app/ibc-hooks/common_test.go (2 hunks)
  • app/keepers/keepers.go (1 hunks)
  • app/keepers/keys.go (1 hunks)
  • client/docs/config.json (1 hunks)
  • client/docs/swagger-ui/swagger.yaml (2 hunks)
  • cmd/minitiad/launch.go (2 hunks)
  • go.mod (5 hunks)
  • integration-tests/go.mod (5 hunks)
  • jsonrpc/types/overrides.go (3 hunks)
  • proto/minievm/evm/v1/genesis.proto (1 hunks)
  • types/const.go (1 hunks)
  • x/bank/keeper/common_test.go (2 hunks)
  • x/bank/keeper/grpc_query.go (1 hunks)
  • x/evm/keeper/common_test.go (2 hunks)
  • x/evm/keeper/context.go (14 hunks)
  • x/evm/keeper/erc20.go (1 hunks)
  • x/evm/keeper/erc20_test.go (1 hunks)
  • x/evm/keeper/genesis.go (4 hunks)
  • x/evm/keeper/genesis_test.go (1 hunks)
  • x/evm/keeper/keeper.go (5 hunks)
  • x/evm/keeper/msg_server.go (3 hunks)
  • x/evm/keeper/msg_server_test.go (2 hunks)
  • x/evm/keeper/precompiles.go (1 hunks)
  • x/evm/keeper/query_server.go (2 hunks)
  • x/evm/keeper/txutils_test.go (1 hunks)
  • x/evm/precompiles/cosmos/contract_test.go (1 hunks)
  • x/evm/state/common_test.go (1 hunks)
  • x/evm/state/keys.go (1 hunks)
  • x/evm/state/snapshot.go (1 hunks)
  • x/evm/state/state_account.go (1 hunks)
  • x/evm/state/statedb.go (1 hunks)
  • x/evm/state/statedb_test.go (1 hunks)
  • x/evm/types/errors.go (1 hunks)
  • x/evm/types/events.go (1 hunks)
  • x/evm/types/expected_keeper.go (1 hunks)
  • x/evm/types/genesis.go (2 hunks)
  • x/evm/types/keys.go (2 hunks)
Files skipped from review due to trivial changes (2)
  • integration-tests/go.mod
  • x/evm/keeper/genesis_test.go
Additional context used
GitHub Check: codecov/patch
x/evm/keeper/query_server.go

[warning] 108-108: x/evm/keeper/query_server.go#L108
Added line #L108 was not covered by tests


[warning] 126-126: x/evm/keeper/query_server.go#L126
Added line #L126 was not covered by tests

x/evm/keeper/msg_server.go

[warning] 211-211: x/evm/keeper/msg_server.go#L211
Added line #L211 was not covered by tests


[warning] 218-219: x/evm/keeper/msg_server.go#L218-L219
Added lines #L218 - L219 were not covered by tests


[warning] 223-224: x/evm/keeper/msg_server.go#L223-L224
Added lines #L223 - L224 were not covered by tests

x/bank/keeper/grpc_query.go

[warning] 196-196: x/bank/keeper/grpc_query.go#L196
Added line #L196 was not covered by tests

x/evm/keeper/keeper.go

[warning] 141-141: x/evm/keeper/keeper.go#L141
Added line #L141 was not covered by tests

x/evm/keeper/context.go

[warning] 148-149: x/evm/keeper/context.go#L148-L149
Added lines #L148 - L149 were not covered by tests


[warning] 153-154: x/evm/keeper/context.go#L153-L154
Added lines #L153 - L154 were not covered by tests

x/evm/state/statedb.go

[warning] 84-85: x/evm/state/statedb.go#L84-L85
Added lines #L84 - L85 were not covered by tests


[warning] 88-89: x/evm/state/statedb.go#L88-L89
Added lines #L88 - L89 were not covered by tests


[warning] 92-93: x/evm/state/statedb.go#L92-L93
Added lines #L92 - L93 were not covered by tests


[warning] 127-127: x/evm/state/statedb.go#L127
Added line #L127 was not covered by tests


[warning] 132-133: x/evm/state/statedb.go#L132-L133
Added lines #L132 - L133 were not covered by tests


[warning] 141-142: x/evm/state/statedb.go#L141-L142
Added lines #L141 - L142 were not covered by tests


[warning] 146-146: x/evm/state/statedb.go#L146
Added line #L146 was not covered by tests


[warning] 151-152: x/evm/state/statedb.go#L151-L152
Added lines #L151 - L152 were not covered by tests


[warning] 160-160: x/evm/state/statedb.go#L160
Added line #L160 was not covered by tests


[warning] 165-166: x/evm/state/statedb.go#L165-L166
Added lines #L165 - L166 were not covered by tests


[warning] 169-170: x/evm/state/statedb.go#L169-L170
Added lines #L169 - L170 were not covered by tests


[warning] 174-174: x/evm/state/statedb.go#L174
Added line #L174 was not covered by tests


[warning] 179-179: x/evm/state/statedb.go#L179
Added line #L179 was not covered by tests


[warning] 189-189: x/evm/state/statedb.go#L189
Added line #L189 was not covered by tests


[warning] 194-194: x/evm/state/statedb.go#L194
Added line #L194 was not covered by tests


[warning] 202-202: x/evm/state/statedb.go#L202
Added line #L202 was not covered by tests


[warning] 206-206: x/evm/state/statedb.go#L206
Added line #L206 was not covered by tests


[warning] 211-211: x/evm/state/statedb.go#L211
Added line #L211 was not covered by tests


[warning] 219-219: x/evm/state/statedb.go#L219
Added line #L219 was not covered by tests


[warning] 232-232: x/evm/state/statedb.go#L232
Added line #L232 was not covered by tests


[warning] 240-240: x/evm/state/statedb.go#L240
Added line #L240 was not covered by tests

Additional comments not posted (94)
client/docs/swagger-ui/swagger.yaml (8)

Line range hint 1-1: New endpoint GET /initia/ibchooks/v1/acls

The endpoint is correctly defined with a clear response schema for ACL entries and pagination.

The code changes are approved.


Line range hint 1-1: New endpoint GET /initia/ibchooks/v1/acls/{address}

The endpoint is correctly defined with a clear response schema for the ACL entry.

The code changes are approved.


Line range hint 1-1: New endpoint GET /initia/ibchooks/v1/params

The endpoint is correctly defined with a clear response schema for the default_allowed setting.

The code changes are approved.


Line range hint 1-1: New object definition initia.ibchooks.v1.ACL

The object definition is correctly defined with clear properties.

The code changes are approved.


Line range hint 1-1: New object definition initia.ibchooks.v1.Params

The object definition is correctly defined with clear properties.

The code changes are approved.


Line range hint 1-1: New object definition initia.ibchooks.v1.QueryACLResponse

The object definition is correctly defined with clear properties.

The code changes are approved.


Line range hint 1-1: New object definition initia.ibchooks.v1.QueryACLsResponse

The object definition is correctly defined with clear properties.

The code changes are approved.


Line range hint 1-1: New object definition initia.ibchooks.v1.QueryParamsResponse

The object definition is correctly defined with clear properties.

The code changes are approved.

types/const.go (1)

5-5: LGTM! But verify the constant usage in the codebase.

The constant value is correctly updated. However, ensure that all references to BaseDenom are updated accordingly.

The code changes are approved.

Run the following script to verify the constant usage:

Verification successful

All references to BaseDenom are correctly updated. The constant is used in several files, and all references are consistent with the updated value "GAS". No further changes are necessary.

  • cmd/minitiad/launch.go: denom = types.BaseDenom
  • cmd/minitiad/init.go: cmd.Flags().String(FlagDenom, minitiatypes.BaseDenom, "genesis file default denom")
  • cmd/minitiad/config.go: srvCfg.MinGasPrices = fmt.Sprintf("0%s", types.BaseDenom)
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to `BaseDenom` are updated accordingly.

# Test: Search for the constant usage. Expect: Only occurrences of the new value.
rg --type go 'BaseDenom'

Length of output: 354

x/evm/state/snapshot.go (3)

9-12: LGTM!

The struct is correctly defined with necessary fields.

The code changes are approved.


14-21: LGTM!

The method is correctly implemented.

The code changes are approved.


23-25: LGTM!

The method is correctly implemented.

The code changes are approved.

x/evm/types/genesis.go (2)

6-10: Verify the impact of removing the StateRoot assignment.

The DefaultGenesis function no longer sets the StateRoot to coretypes.EmptyRootHash[:]. Ensure that this change does not introduce any unintended side effects.

Run the following script to verify the impact of removing the StateRoot assignment:


20-22: Verify the impact of removing the StateRoot validation.

The Validate method no longer checks the length of StateRoot or compares it to coretypes.EmptyRootHash. Ensure that this change aligns with the expected structure or requirements of the genesis state.

Run the following script to verify the impact of removing the StateRoot validation:

x/evm/types/events.go (1)

9-9: Verify the usage of the new constant.

The new constant EventTypeContractCreated enhances the functionality by allowing for the identification of contract creation events. Ensure that this addition does not introduce any unintended side effects.

Run the following script to verify the usage of the new constant:

Verification successful

Usage of EventTypeContractCreated is appropriate.

The constant EventTypeContractCreated is used correctly in the event emission process for contract creation, aligning with its intended functionality. No unintended side effects were found.

  • Location: x/evm/state/statedb.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new constant `EventTypeContractCreated`.

# Test: Search for the constant usage. Expect: No unintended side effects.
rg --type go 'EventTypeContractCreated'

Length of output: 168


Script:

#!/bin/bash
# Extract surrounding lines of code where `EventTypeContractCreated` is used in `x/evm/state/statedb.go`.
rg --type go --context 5 'EventTypeContractCreated' x/evm/state/statedb.go

Length of output: 421

x/evm/state/state_account.go (4)

12-17: LGTM!

The function correctly initializes a StateAccount with default values.

The code changes are approved.


19-21: LGTM!

The function correctly checks if the StateAccount is empty.

The code changes are approved.


23-29: LGTM!

The function correctly serializes the StateAccount to a byte slice.

The code changes are approved.


31-35: LGTM!

The function correctly deserializes a byte slice to a StateAccount.

The code changes are approved.

jsonrpc/types/overrides.go (1)

Line range hint 12-12: Verify the impact of the removal of the Apply method for StateOverride.

The removal of the Apply method suggests a change in how state overrides are applied. Ensure that the functionality is not broken and that the new mechanism for applying state overrides is correctly implemented.

Run the following script to verify the usage of the Apply method for StateOverride:

x/evm/state/keys.go (7)

16-18: LGTM!

The function is correctly implemented and follows best practices for key generation.

The code changes are approved.


20-22: LGTM!

The function is correctly implemented and follows best practices for key generation.

The code changes are approved.


24-26: LGTM!

The function is correctly implemented and follows best practices for key generation.

The code changes are approved.


28-30: LGTM!

The function is correctly implemented and follows best practices for key generation.

The code changes are approved.


32-34: LGTM!

The function is correctly implemented and follows best practices for key generation.

The code changes are approved.


36-39: LGTM!

The function is correctly implemented and follows best practices for byte conversion.

The code changes are approved.


42-44: LGTM!

The function is correctly implemented and follows best practices for byte conversion.

The code changes are approved.

proto/minievm/evm/v1/genesis.proto (3)

Line range hint 28-31: LGTM!

The message is correctly defined and follows best practices for protobuf messages.

The code changes are approved.


Line range hint 34-37: LGTM!

The message is correctly defined and follows best practices for protobuf messages.

The code changes are approved.


Line range hint 40-43: LGTM!

The message is correctly defined and follows best practices for protobuf messages.

The code changes are approved.

cmd/minitiad/launch.go (1)

54-58: LGTM!

The conditional check for converting "umin" to types.BaseDenom enhances the functionality by providing specific handling for a known denomination.

The code changes are approved.

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

67-73: LGTM!

The function toAddrs is correctly implemented and enhances the functionality of the precompiles struct by providing a convenient way to retrieve all associated addresses.

The code changes are approved.

x/evm/types/keys.go (9)

24-24: LGTM!

The constant TransientVMStorePrefix is correctly defined and enhances the functionality by providing a prefix for transient VM store.

The code changes are approved.


25-25: LGTM!

The constant TransientExecIndexPrefix is correctly defined and enhances the functionality by providing a prefix for transient execution index.

The code changes are approved.


26-26: LGTM!

The constant TransientCreatedPrefix is correctly defined and enhances the functionality by providing a prefix for transient created accounts.

The code changes are approved.


27-27: LGTM!

The constant TransientSelfDestructPrefix is correctly defined and enhances the functionality by providing a prefix for transient self-destruct accounts.

The code changes are approved.


28-28: LGTM!

The constant TransientLogsPrefix is correctly defined and enhances the functionality by providing a prefix for transient logs.

The code changes are approved.


29-29: LGTM!

The constant TransientLogSizePrefix is correctly defined and enhances the functionality by providing a prefix for transient log size.

The code changes are approved.


30-30: LGTM!

The constant TransientAccessListPrefix is correctly defined and enhances the functionality by providing a prefix for transient access list.

The code changes are approved.


31-31: LGTM!

The constant TransientRefundPrefix is correctly defined and enhances the functionality by providing a prefix for transient refund.

The code changes are approved.


43-43: Verify the change in byte value.

The change in byte value for ERC20FactoryAddrKey from 0x71 to 0x61 might affect how the contract interacts with the associated storage. Ensure that this change is intentional and does not break any existing functionality.

Run the following script to verify the usage of ERC20FactoryAddrKey:

x/evm/types/errors.go (1)

35-35: LGTM!

The addition of ErrInvalidFeeDenom enhances error handling for invalid fee denominations and follows the existing pattern for error definitions.

The code changes are approved.

x/evm/types/expected_keeper.go (1)

23-23: LGTM!

The addition of RemoveAccount method enhances the AccountKeeper interface by providing a mechanism to delete accounts. Ensure that all implementations of AccountKeeper include logic for account removal.

The code changes are approved.

x/evm/keeper/genesis.go (3)

60-60: LGTM!

The modification to check if the KeyValues slice is empty instead of the state root simplifies the initialization process.

The code changes are approved.


60-66: LGTM!

The removal of code that sets the VMRoot with the StateRoot simplifies the control flow and logic surrounding state management.

The code changes are approved.


60-66: LGTM!

The removal of code that retrieves the stateRoot from VMRoot simplifies the genesis export process by removing dependencies on the state root.

The code changes are approved.

app/keepers/keys.go (1)

60-60: LGTM!

The addition of evmtypes.TStoreKey to NewTransientStoreKeys enhances the key generation logic to handle a broader range of transient store keys.

The code changes are approved.

x/evm/keeper/query_server.go (2)

108-108: LGTM!

The use of NewStateDB with additional parameters enhances the initialization of the state database, potentially improving its configuration or access.

The code changes are approved.

Tools
GitHub Check: codecov/patch

[warning] 108-108: x/evm/keeper/query_server.go#L108
Added line #L108 was not covered by tests


126-126: LGTM!

The use of NewStateDB with additional parameters enhances the initialization of the state database, potentially improving its configuration or access.

The code changes are approved.

Tools
GitHub Check: codecov/patch

[warning] 126-126: x/evm/keeper/query_server.go#L126
Added line #L126 was not covered by tests

client/docs/config.json (1)

149-156: LGTM!

The addition of the new entry for the IBCHooks API endpoint enhances the API's documentation and operational clarity.

The code changes are approved.

x/evm/keeper/msg_server_test.go (3)

141-149: LGTM!

The test case correctly ensures that unsupported fee denominations are rejected.

The code changes are approved.


163-177: LGTM!

The test case correctly ensures that fee denominations without sudoMint and sudoBurn capabilities are rejected.

The code changes are approved.


162-162: LGTM!

The test case correctly ensures that fee denominations without sudoMint and sudoBurn capabilities are rejected.

The code changes are approved.

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

111-116: LGTM!

The modification ensures that the signature bytes are correctly constructed and zero-padded.

The code changes are approved.

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

Line range hint 76-119: LGTM! Verify the initialization of new transient fields.

The initialization of the new transient fields occurs within the constructor. Ensure that the transient data structures are properly set up during the instantiation of the Keeper.

Run the following script to verify the initialization of the new transient fields:

Verification successful

Initialization of Transient Fields Verified: The transient fields in the NewKeeper function are properly initialized using the appropriate collections methods. The setup of transient data structures during instantiation appears to be correctly implemented.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the initialization of new transient fields in the constructor.

# Test: Search for the initialization of the new fields. Expect: Proper initialization.
rg --type go 'collections.NewMap|collections.NewKeySet|collections.NewSequence' -A 5

Length of output: 5515


45-55: LGTM! Verify the usage of new transient storage fields.

The addition of transient storage fields enhances the functionality of the Keeper struct. Ensure that the new fields are correctly initialized and used throughout the codebase.

Run the following script to verify the usage of the new transient storage fields:

Verification successful

Transient storage fields are correctly initialized and used.

The transient storage fields in the Keeper struct are properly initialized with appropriate prefixes and codecs. They are also used in context.go, indicating integration into the broader system.

  • Initialization is done in x/evm/keeper/keeper.go.
  • Prefixes are defined in x/evm/types/keys.go.
  • Usage is evident in x/evm/keeper/context.go.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of new transient storage fields in the codebase.

# Test: Search for the usage of the new fields. Expect: Proper initialization and usage.
rg --type go 'TransientVMStore|TransientLogs|TransientLogSize|TransientRefund|TransientCreated|TransientSelfDestruct|TransientAccessList|TransientExecIndex'

Length of output: 3495

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

190-195: LGTM! Verify the integration of transient store services.

The addition of transient store keys enhances the testing capabilities. Ensure that the transient store services are properly integrated into the application context.

Run the following script to verify the integration of transient store services:

Also applies to: 262-262

Verification successful

Integration of Transient Store Services Verified

The transient store services are properly integrated into the application context across various modules. The consistent use of NewTransientStoreKeys and NewTransientStoreService confirms the correct setup. No issues found in the integration process.

  • Verified in files such as x/evm/state/common_test.go, x/evm/keeper/common_test.go, x/bank/keeper/common_test.go, and app/ibc-hooks/common_test.go.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of transient store services in the test setup.

# Test: Search for the integration of transient store services. Expect: Proper integration.
rg --type go 'NewTransientStoreService|NewTransientStoreKeys' -A 5

Length of output: 3732

x/bank/keeper/common_test.go (2)

302-302: LGTM!

The transient store service is correctly initialized for the EVM keeper.

The code changes are approved.


230-235: LGTM! But verify the function usage in the codebase.

The transient store keys are correctly introduced and mounted. Ensure that all function calls to _createTestInput pass the new tkeys parameter correctly.

The code changes are approved.

Run the following script to verify the function usage:

x/evm/state/common_test.go (1)

1-316: LGTM!

The new file and its functions are well-structured and follow best practices for setting up the test environment for the EVM module.

The code changes are approved.

x/evm/keeper/context.go (6)

28-37: LGTM!

The NewStateDB function is correctly implemented and enhances the state management for the EVM context.

The code changes are approved.


Line range hint 53-112: LGTM!

The changes to buildBlockContext ensure that the fee contract is appropriately utilized during EVM calls, enhancing the robustness of the contract execution process.

The code changes are approved.


140-170: LGTM!

The changes to CreateEVM enhance the EVM context management by integrating the fee contract, improving the overall robustness of the contract execution process.

The code changes are approved.

Tools
GitHub Check: codecov/patch

[warning] 148-149: x/evm/keeper/context.go#L148-L149
Added lines #L148 - L149 were not covered by tests


[warning] 153-154: x/evm/keeper/context.go#L153-L154
Added lines #L153 - L154 were not covered by tests


Line range hint 231-266: LGTM!

The changes to EVMCallWithTracer ensure that the new CreateEVM method is utilized, enhancing the functionality related to state management and contract interactions.

The code changes are approved.


Line range hint 318-363: LGTM!

The changes to EVMCreateWithTracer ensure that the new CreateEVM method is utilized, enhancing the functionality related to state management and contract interactions.

The code changes are approved.


Line range hint 404-409: LGTM!

The changes to NextContractAddress ensure that the new NewStateDB method is utilized, enhancing the functionality related to state management and contract interactions.

The code changes are approved.

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

91-106: Add comments for clarity.

The test function is correctly implemented but lacks comments explaining the test steps. Adding comments will improve readability and maintainability.

func Test_BalanceOf(t *testing.T) {
	ctx, input := createDefaultTestInput(t)

	// Generate two addresses
	_, _, addr := keyPubAddr()
	_, _, addr2 := keyPubAddr()

	// Fund the first address with 100 units of "foo"
	input.Faucet.Fund(ctx, addr, sdk.NewCoin("foo", math.NewInt(100)))

	// Check the balance of the first address
	amount, err := input.EVMKeeper.ERC20Keeper().GetBalance(ctx, addr, "foo")
	require.NoError(t, err)
	require.Equal(t, math.NewInt(100), amount)

	// Check the balance of the second address
	amount, err = input.EVMKeeper.ERC20Keeper().GetBalance(ctx, addr2, "foo")
	require.NoError(t, err)
	require.Equal(t, math.NewInt(0), amount)
}
go.mod (6)

36-36: LGTM!

The update from v1.3.0 to v1.3.1 for github.com/holiman/uint256 is a minor version update, likely including bug fixes or minor improvements.

The code changes are approved.


76-76: LGTM!

The update from v1.12.1 to v1.12.2 for github.com/VictoriaMetrics/fastcache is a minor version update, likely including bug fixes or minor improvements.

The code changes are approved.


110-110: LGTM!

The update from v0.0.0-20231025140028-3c0104f4b233 to v0.0.0-20240223125850-b1e8a79f509c for github.com/crate-crypto/go-ipa is a significant version update, likely including substantial updates or changes in functionality.

The code changes are approved.


126-126: LGTM!

The addition of github.com/ethereum/go-verkle at version v0.1.1-0.20240306133620-7d920df305f0 is likely introduced to provide new functionality.

The code changes are approved.


126-126: LGTM!

The removal of github.com/gballet/go-verkle is likely due to it being replaced by github.com/ethereum/go-verkle.

The code changes are approved.


286-286: LGTM!

The update for the replacement directive of github.com/ethereum/go-ethereum to point to a new version of github.com/initia-labs/evm is likely to include important changes or improvements in the evm module.

The code changes are approved.

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

333-333: LGTM!

The change from nextContractAddress to NextContractAddress aligns with Go's idiomatic practices for exported functions. Ensure that the method is correctly implemented and that the change does not introduce any issues.

The code changes are approved.

app/ibc-hooks/common_test.go (2)

230-235: LGTM!

The transient store keys are correctly introduced and mounted.

The code changes are approved.


310-310: LGTM!

The transient store service is correctly integrated into the application codec setup.

The code changes are approved.

x/evm/state/statedb_test.go (8)

23-110: LGTM!

The Test_SnapshotRevert function is correctly implemented and verifies various state changes before and after reverting to the snapshot.

The code changes are approved.


112-128: LGTM!

The Test_SimpleSnapshotRevert function is correctly implemented and verifies refunds before and after reverting to the snapshot.

The code changes are approved.


130-142: LGTM!

The Test_GetStroageRoot_NonEmptyState function is correctly implemented and verifies the storage root for a non-empty state.

The code changes are approved.


144-160: LGTM!

The Test_GetStorageRoot_NonEmptyCosmosAccount function is correctly implemented and verifies the storage root for a non-empty Cosmos account.

The code changes are approved.


162-225: LGTM!

The Test_SelfDestruct function is correctly implemented and verifies various state changes before and after self-destruct.

The code changes are approved.


227-280: LGTM!

The Test_Selfdestruct6780_InDifferentTx function is correctly implemented and verifies various state changes before and after self-destruct in different transactions.

The code changes are approved.


282-334: LGTM!

The Test_Selfdestruct6780_InSameTx function is correctly implemented and verifies various state changes before and after self-destruct in the same transaction.

The code changes are approved.


336-368: LGTM!

The Test_Empty function is correctly implemented and verifies various state changes for empty and non-empty states.

The code changes are approved.

x/evm/precompiles/cosmos/contract_test.go (9)

Line range hint 38-78: LGTM!

The Test_CosmosPrecompile_IsBlockedAddress function is correctly implemented and verifies various scenarios for blocked and non-blocked addresses.

The code changes are approved.


Line range hint 80-120: LGTM!

The Test_CosmosPrecompile_IsModuleAddress function is correctly implemented and verifies various scenarios for module and non-module addresses.

The code changes are approved.


Line range hint 122-162: LGTM!

The Test_CosmosPrecompile_ToCosmosAddress function is correctly implemented and verifies various scenarios for conversion to Cosmos address.

The code changes are approved.


Line range hint 164-204: LGTM!

The Test_CosmosPrecompile_ToEVMAddress function is correctly implemented and verifies various scenarios for conversion to EVM address.

The code changes are approved.


Line range hint 206-276: LGTM!

The Test_ExecuteCosmos function is correctly implemented and verifies various scenarios for successful and unauthorized executions.

The code changes are approved.


Line range hint 278-328: LGTM!

The Test_QueryCosmos function is correctly implemented and verifies various scenarios for successful queries.

The code changes are approved.


Line range hint 330-370: LGTM!

The Test_ToDenom function is correctly implemented and verifies various scenarios for conversion to denom.

The code changes are approved.


Line range hint 372-412: LGTM!

The Test_ToErc20 function is correctly implemented and verifies various scenarios for conversion to ERC20 address.

The code changes are approved.


482-486: LGTM!

The RemoveAccount method is correctly implemented and handles the account removal from the accounts map.

The code changes are approved.

app/keepers/keepers.go (1)

552-552: Verify the initialization and usage of the transient store key.

Ensure that appKeepers.tkeys[evmtypes.TStoreKey] is correctly initialized and used throughout the codebase.

Run the following script to verify the initialization and usage of the transient store key:

Verification successful

Initialization and usage of the transient store key are correct.

The transient store key evmtypes.TStoreKey is properly initialized in app/keepers/keys.go using storetypes.NewTransientStoreKeys. This ensures its correct usage in the NewAppKeeper function.

  • Initialization found in app/keepers/keys.go.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the initialization and usage of the transient store key.

# Test: Search for the initialization and usage of the transient store key. Expect: Correct initialization and usage.
rg --type go 'appKeepers\.tkeys\[evmtypes\.TStoreKey\]'

Length of output: 154


Script:

#!/bin/bash
# Description: Search for the initialization of appKeepers.tkeys to verify if evmtypes.TStoreKey is included.

# Test: Search for the initialization of appKeepers.tkeys. Expect: Initialization including evmtypes.TStoreKey.
rg --type go 'appKeepers\.tkeys\s*=' -A 5

Length of output: 416

x/evm/keeper/query_server.go Show resolved Hide resolved
x/evm/keeper/query_server.go Show resolved Hide resolved
x/evm/keeper/msg_server.go Show resolved Hide resolved
x/evm/keeper/msg_server.go Outdated Show resolved Hide resolved
x/bank/keeper/grpc_query.go Show resolved Hide resolved
x/evm/state/statedb.go Show resolved Hide resolved
x/evm/state/statedb.go Show resolved Hide resolved
x/evm/state/statedb.go Show resolved Hide resolved
x/evm/state/statedb.go Show resolved Hide resolved
x/evm/state/statedb.go Show resolved Hide resolved
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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e91f4ff and 742c8d4.

Files selected for processing (1)
  • x/evm/keeper/msg_server.go (3 hunks)
Additional context used
GitHub Check: codecov/patch
x/evm/keeper/msg_server.go

[warning] 214-215: x/evm/keeper/msg_server.go#L214-L215
Added lines #L214 - L215 were not covered by tests


[warning] 219-220: x/evm/keeper/msg_server.go#L219-L220
Added lines #L219 - L220 were not covered by tests


[warning] 224-225: x/evm/keeper/msg_server.go#L224-L225
Added lines #L224 - L225 were not covered by tests

Additional comments not posted (2)
x/evm/keeper/msg_server.go (2)

5-8: LGTM!

The new imports are necessary for the added functionality.

The code changes are approved.


186-194: Improve error handling.

Provide more context in the error messages to improve debugging.

Apply this diff to improve error handling:

	err := ms.testFeeDenom(cacheCtx, msg.Params)
	if err != nil {
		return nil, sdkerrors.Wrap(err, "failed to validate fee denomination")
	}

Likely invalid or redundant comment.

x/evm/keeper/msg_server.go Show resolved Hide resolved
Copy link
Contributor

@Vritra4 Vritra4 left a comment

Choose a reason for hiding this comment

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

LGTM

@beer-1 beer-1 merged commit 1062a0a into main Aug 27, 2024
8 checks passed
@beer-1 beer-1 deleted the feat/statedb branch August 27, 2024 15:35
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.

2 participants