Skip to content

Conversation

@cloudgray
Copy link
Contributor

Description

Removal of x/authz dependency on precompiles

  • Remove authzKeeper dependency from common Precompile struct
  • For staking and ics20 precompile
    • remove authorization methods (Approve, Revoke, IncreaseAllowance, DecreaseAllowance, Allowance) and its usage.
  • For erc20 precompile
    • Add Allowance state CRUD methods in x/erc20 module
    • Use added Allowance state of x/erc20 module instead of Grant state of x/authz module for authorization methods (Approve, Revoke, IncreaseAllowance, DecreaseAllowance, Allowance)

Closes: #47


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 main branch

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

@cloudgray cloudgray changed the title feat: remove authz dependency from precompiles except for erc20 feat: remove authz dependency from precompiles Apr 9, 2025
@cloudgray cloudgray changed the title feat: remove authz dependency from precompiles feat: remove x/authz dependency from precompiles Apr 9, 2025
Copy link
Contributor

@zsystm zsystm left a comment

Choose a reason for hiding this comment

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

Looks good to me so far — the authz removal seems to be handled well.

I had one question while reviewing the test code, which I left as a comment.

Also, this is not directly related to the scope of your PR, but I noticed that some of the existing test cases don’t validate balance changes. For example, after a delete, there’s no assertion checking whether the delegator’s balance was reduced accordingly. Since the precompiled contract involves complex state transitions, I think it would be valuable to add more thorough state validation to ensure the transitions happen as expected.

This can probably be addressed in a separate PR, so just leaving this here for reference. I opened an issue to track it.

cloudgray and others added 9 commits April 21, 2025 13:35
* feat(x/erc20): add allowance state

* test(x/erc20): add unit test for Allowance

* fix(x/erc20): add deleteAllowances method and modify genesis validation

* fix(x/erc20): validation of SetAllowance/GetAllowance and InitGenesis

* test(x/erc20) add test cases for UnsafeSetAllowance

* chore: fix lint
@zsystm zsystm marked this pull request as ready for review April 22, 2025 13:09
@zsystm zsystm requested a review from dongsam April 22, 2025 13:10
Copy link
Contributor

@dongsam dongsam left a comment

Choose a reason for hiding this comment

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

I haven’t gone through everything yet, but from what I’ve seen so far in app.go and the ics20 precompile section, it looks good

I’ll continue the review when I have more time.

@cloudgray
Copy link
Contributor Author

In the cosmos-evm context, naming convention is interfaces.go, not expected_keepers.go. It's not critical, but I think it would be better to change it for consistency

applied in dc225a2

Copy link
Member

@vladjdk vladjdk left a comment

Choose a reason for hiding this comment

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

Lgtm, thanks for the work :)

@vladjdk vladjdk merged commit 6e67d63 into main May 9, 2025
19 of 20 checks passed
@vladjdk vladjdk deleted the feat/remove-authz-from-precompiles branch May 9, 2025 16:02
@vladjdk vladjdk mentioned this pull request May 9, 2025
9 tasks
Eric-Warehime added a commit that referenced this pull request Jul 17, 2025
zsystm pushed a commit to zsystm/evm that referenced this pull request Nov 2, 2025
* feat: remove authz dependency from precompiles except for erc20

* wip: feat(precompiles): remove x/authz dependency

* test(precompiles): remove x/authz dependent test cases

* feat: remove x/authz dependency from x/erc20 and werc20 precompile

* fix(precompiles): modify contract interface and test contracts

* fix(precompiles): remove unused authz related types and test utils

* fix(precompiles): modify integration test of staking precompile

* feat(x/erc20): add allowance state (cosmos#90)

* feat(x/erc20): add allowance state

* test(x/erc20): add unit test for Allowance

* fix(x/erc20): add deleteAllowances method and modify genesis validation

* fix(x/erc20): validation of SetAllowance/GetAllowance and InitGenesis

* test(x/erc20) add test cases for UnsafeSetAllowance

* chore: fix lint

* wip: test: modify erc20 precompile tests

* test: modify erc20 precompile tests

* test(precompiles): �fix integration test

fix owner == sender case

* refactor(precompiles): remove authz dependent naming and comments

* wip: test(x/vm): modify flashLoan test

* test(x/vm): fix flashLoan integration test

* fix: merge conflict

* chore: fix lint

* chore: fix lint

* feat: remove authz keeper dependency from x/erc20 keeper

* chore: fix lint

* fix: increase consensusVersion of x/erc20 module

* chore: udpate CHANGELOG.md

* chore: update CHANGELOG.md

* chore: add comments to StakingCaller solidity contract

* fix: typo

* fix: remove duplicated test case

* fix: wrong args for ApprovalEvent

* fix: wrong error message for test

* refactor: refine code for staking precompile

* fix: merge conflicts

* refactor: change file name

* refactor(testutil): move constants for test to testutil/constants package

* refactor(erc20): InitGenesis

* test(erc20): add genesis test case

* fix(erc20): revert consensusVersion change

* refactor(erc20): refactor keeper methods of Allowance state

* test(testutil): fix test case and lint

* wip: fix(precompiles/erc20): remove incompatible logic with ERC20 Specification

* fix: add Approval event to transferFrom method and fix integration tests

* fix: FlashLoan.sol contract

* fix(x/erc20): allowance methods and test cases

* test(precompiles): add test cases for erc20 precompile

---------

Co-authored-by: Vlad <vladjdk@gmail.com>
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.

[EPIC] Removal of x/authz dependency on precompiles

6 participants