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

wip: fixing dynamic precompiles. Re-writing integration-tests for werc20 #2343

Merged
merged 29 commits into from
Feb 15, 2024

Conversation

ramacarlucho
Copy link
Contributor

Description

We need to move wevmos contract to be part of the static precompiles. This introduces several changes.
There were several conflicts from the integration tests setup for werc20. Decided to update to the new integration tests setup.

Closes: XAP-113


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...

  • tackled an existing issue or discussed with a team member
  • left instructions on how to review the changes
  • targeted the correct branch (see PR Targeting)

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...

  • added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • confirmed all author checklist items have been addressed
  • confirmed that this PR does not change production code
  • reviewed content
  • tested instructions (if applicable)
  • confirmed all CI checks have passed

Copy link

linear bot commented Feb 9, 2024

Copy link

coderabbitai bot commented Feb 9, 2024

Important

Auto Review Skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.

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-tests for this file.
  • 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 tests 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 from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@MalteHerrmann MalteHerrmann left a comment

Choose a reason for hiding this comment

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

leaving some remarks here so I can address them 👍

if slices.Contains(existingPrecompiles, address.String()) {
return nil, fmt.Errorf("precompile already registered: %s", address)
if !slices.Contains(existingPrecompiles, address.String()) {
// return nil, fmt.Errorf("precompile already registered: %s", address)
Copy link
Contributor

Choose a reason for hiding this comment

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

remove if not necessary

Copy link
Contributor

Choose a reason for hiding this comment

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

how come we don't want the duplicates check anymore? Should this not return an error?

x/erc20/types/mocks/BankkKeeper.go Outdated Show resolved Hide resolved
Comment on lines 90 to 92
} else {
WEVMOSAddress = common.HexToAddress(erc20precompile.WEVMOSContractTestnet)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no safe guard currently for a wrong chain ID - do we want to return an error if that's the case?

x/evm/keeper/precompiles.go Outdated Show resolved Hide resolved
x/evm/keeper/precompiles.go Outdated Show resolved Hide resolved
precompiles/werc20/werc20.go Outdated Show resolved Hide resolved
precompiles/werc20/tx.go Outdated Show resolved Hide resolved
precompiles/werc20/utils_test.go Outdated Show resolved Hide resolved
precompiles/werc20/integration_test.go Outdated Show resolved Hide resolved
precompiles/werc20/integration_test.go Outdated Show resolved Hide resolved
precompiles/werc20/tx.go Show resolved Hide resolved
precompiles/werc20/integration_test.go Outdated Show resolved Hide resolved
precompiles/erc20/integration_test.go Outdated Show resolved Hide resolved
@MalteHerrmann MalteHerrmann marked this pull request as ready for review February 14, 2024 16:05
@MalteHerrmann MalteHerrmann requested a review from a team as a code owner February 14, 2024 16:05
@MalteHerrmann MalteHerrmann requested review from hanchon and Vvaradinov and removed request for a team February 14, 2024 16:05
@MalteHerrmann
Copy link
Contributor

The suggestion here is to merge this PR now and then remove the whole WERC-20 precompile on a follow-up PR. This way we can revert/get this code back should it ever be necessary, now that the integration tests have been fixed / updated.

The failing tests are not part of the WERC-20 integration tests which are the focus of this PR 👀

@MalteHerrmann MalteHerrmann merged commit 4c35162 into facs95/dynamic-precompiles Feb 15, 2024
24 of 25 checks passed
@MalteHerrmann MalteHerrmann deleted the rama/dynamic-fixes branch February 15, 2024 08:15
Vvaradinov added a commit that referenced this pull request Feb 21, 2024
* add new param

* full implementation

* load abi correctly

* update contract instance

* run make format

* rename function

* add mocks

* run make format

* make erc20keeper a pointer on app.go

* fix typo

* fix EnableDynamicPrecompiles

* improve error

* add comment to app.go

* run make format

* review comments

* remove data folders

* run make format

* refractor state_transition

* fix lint

* run make format

* update comments

* remove unused functions

* wip: fixing dynamic precompiles. Re-writing integration-tests for werc20 (#2343)

* wip: fixing dynamic precompiles. Re-writing integration-tests for werc20

* run make format

* address some linter warnings

* remove unnecessary werc20 event constants

* remove duplicate import

* revert adding args to deposit and withdraw functions

* fix some missing imports

* WIP test refactors

* WIP more test refactors

* re-add wevmos precompile to static precompiles

* use base denom for wevmos token pair

* more WIP

* more WIP

* run make format

* remove unnecessary level of nesting

* run gofumpt

* fix tests

* remove unused utils and move test runner into integration test file

* remove mentions of deposit and withdraw events in tx.go

* add some todo comments

* remove unnecessary print statement

* remove unnecessary migration test flows that now live in the v17 upgrades folder

* remove unnecessary ordered instruction for integration tests

* only use two keys for the integration tests

* address linters

---------

Co-authored-by: ramacarlucho <ramacarlucho@users.noreply.github.com>
Co-authored-by: MalteHerrmann <42640438+MalteHerrmann@users.noreply.github.com>
Co-authored-by: MalteHerrmann <malte@evmos.org>
Co-authored-by: MalteHerrmann <MalteHerrmann@users.noreply.github.com>

* fix regression

* imp(evm): Check for dynamic extensions during EVM initialization (#2356)

check for active dynamic precompiles as well as static ones in HasCustomPrecompiles

* imp(werc20): Remove WERC-20 precompile and register WEVMOS as standard ERC-20 precompile (#2352)

* move WEVMOS contract to contracts directory

* remove werc20 precompile

* add utility to get token pair from grpc handler

* adjust integration tests and upgrade logic to account for WEVMOS being registered as an ERC-20 token pair and precompile

* run make format

* add changelog entry

* make addNewTokenPair public

* move RegisterEVMExtensions util to v17 migration logic

* remove unused methods

* run gofumpt

* Update app/upgrades/v17/migration.go

* address review comments

* remove duplicate params checks in tests

* update RegisterERC20Extensions upgrade handler

* update NewTokenPair function

* remove unnecessary param

* update mocks

* run make format

* delete unnecessary keepers from migration logic

* fix test

* run make format

* dont use new function to register aevmos token pair

* remove unused keepers in migration logic

* remove incorrect test

* fix test for p256

---------

Co-authored-by: MalteHerrmann <MalteHerrmann@users.noreply.github.com>
Co-authored-by: Freddy Caceres <facs95@gmail.com>
Co-authored-by: facs95 <facs95@users.noreply.github.com>
Co-authored-by: Ramiro Carlucho <ramirocarlucho@gmail.com>
Co-authored-by: ramacarlucho <ramacarlucho@users.noreply.github.com>

* add wevmos pair to local node

* tests(strv2): Add unit tests for dynamic precompiles (#2366)

* add unit tests

* run make format

* test expected panic

* run make format

* check errors

---------

Co-authored-by: ramacarlucho <ramacarlucho@users.noreply.github.com>

* chore(strv2): Rename static precompiles (#2365)

* rename static precompiles

* rename upgrade

* read evmchannels from params

* fix old migration

* fix lint

* not break protobuf

* fix tests

---------

Co-authored-by: Vladislav Varadinov <vladislav.varadinov@gmail.com>
Co-authored-by: Freddy Caceres <facs95@gmail.com>

* remove unnecessary function

* remove unnecessary import

* make enable dynamic precompiles more efficient

* run make format

* fix old register proto

* address pr comments

---------

Co-authored-by: facs95 <facs95@users.noreply.github.com>
Co-authored-by: MalteHerrmann <42640438+MalteHerrmann@users.noreply.github.com>
Co-authored-by: Ramiro Carlucho <ramirocarlucho@gmail.com>
Co-authored-by: ramacarlucho <ramacarlucho@users.noreply.github.com>
Co-authored-by: MalteHerrmann <malte@evmos.org>
Co-authored-by: MalteHerrmann <MalteHerrmann@users.noreply.github.com>
Co-authored-by: Vladislav Varadinov <vladislav.varadinov@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants