Skip to content

feat!: IBC v2 #95

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

Merged
merged 8 commits into from
Apr 28, 2025
Merged

feat!: IBC v2 #95

merged 8 commits into from
Apr 28, 2025

Conversation

dongsam
Copy link
Member

@dongsam dongsam commented Apr 24, 2025

Description

Closes: #41

Summary

This PR upgrades IBC from v8 to v10 and includes essential modifications to ensure that the existing ICS20 precompile and ERC20 middleware work properly with IBC v2 components such as packet, channel, and denom rule. To validate this, corresponding E2E test cases have been added.

Changes

This PR consolidates several sub-PRs, each addressing a required sub-task for full IBC v2 support. These changes were all individually reviewed within the team due to their significance. However, merging them independently into the main branch could result in broken functionality for IBC v2. Therefore, they were first merged into the feat/ibc-v10 branch, and this PR is created to apply them atomically into the main branch, ensuring proper integration of the full IBC v2 feature set.

Below is a list of the major changes, along with their corresponding sub-issues and applied PRs:

Description Issue PR
Bump up ibc-go from v8 to v10 #50 #51
Add multi-chain IBC v2 E2E testing package and test cases #46 #63
Replace erc20/ prefix with erc20: in native ERC20 coin denoms #61 #92
Ensure ICS20 precompile and x/ibc module function correctly for both IBC v1 and v2 support #44 #74
Update the x/erc20 module’s IBC middleware, callback logic to cover IBC v2 packet #45 #51, #96

Changes in IBC v2 (ibc-go v10) That Affect ics20 precompile and erc20 middleware

Packet Structure Changes

Denom Trace → Denom

Starting from IBC v9, the DenomTrace endpoint has been renamed and restructured to Denom.

Breaking Changes in the ICS20 Precompile Implementation

Packet Version-Based Validation Logic

  • Since the IBC packet structure differs between v1 and v2, the ICS20 precompile now parses the port and channel values provided in the transfer arguments to determine the packet version.
  • If it is determined to be a v2 packet, the channel value is treated as a client ID.
  • While introducing a dedicated transfer function for v2 packets and channels could improve clarity, it was not added to maintain compatibility with the existing usage of a single MsgTransfer still uses the v1 format even when operating on v2 channels.

Denom Trace → Denom

  • Beginning with v9, the transition from DenomTrace to Denom was adopted.
  • The ics20.sol interface and response type of the ICS20 precompile have been updated to match this change.

Breaking Changes in the erc20 module

Replace erc20/ Prefix to erc20: in Native ERC20 Coin Denoms

  • IBC v2 does not allow / in the base denomination.
  • IBC version 2 introduces a restriction that disallows slashes (/) in base denominations. As a r esult, any denom containing / cannot be transferred using the IBC v2 router.

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

zsystm and others added 6 commits April 25, 2025 15:17
* bump up ibc-go from v8 to v10

- bumped up ibc-go from v8 to v10
- removed unused ibc test codes because bumping unused testing codes are wasting time. we should use ibc testing package instead.

* add ibc v1 transfer test

added ibc v1 test cases to make sure ExampleChain works with ibc v1.
disabled basefee param as default for ExampleChain to make test easier.

* add ibc v2 components (module, middleware)

- added ibc v2 components
- copied basic v2 test cases from ibc-go v10 to make sure v2 components of ExampleChain works well.

* add nil checks and convert erc20 keeper to interface in IBCMiddleware

- added nil checks for app and keeper in NewIBCMiddleware to prevent nil pointer dereference.
- changed erc20 keeper from struct to interface type to enable proper nil checking.

* copy and modify from ibc-go testing

To test certain key scenarios involving EVM messages (e.g., deploying an ERC20 contract), we needed a block header context with a proposer address. This required:
- A custom `TestChain` to handle these messages.
- A custom `SignAndDeliver` function to support the transaction signing and delivery process.
- A custom `Coordinator` to integrate this tailored `TestChain`.

Since `TestChain` and `SignAndDeliver` are directly or indirectly tied to most components in the testing package, and ibc-go cannot use a `TestChain` struct defined in our separate package, we had to copy and adapt nearly all related files to ensure compatibility and functionality.

* fix: ci issues

* replace deprecated functions

* revert disable base fee

Disabling the base fee to simplify testing is not ideal for a reference chain intended for developers building EVM-compatible chains. Ethereum relies on a fee market mechanism, and as a reference implementation, this chain should enable it by default to align with expected behavior.

* update TestGetReceivedCoin

Updated TestGetReceivedCoin to use the newly introduced interface instead of hardcoded strings.
This improves maintainability by making the test logic more aligned with the actual send/receive flow.
It also enhances readability and helps developers better understand how denoms are constructed and handled in real IBC transfers.

* bump up ibc-go from v10.1.0 to v10.1.1
* add basic test cases for ibc middleware v1, v2

more test cases will be added.

* add test cases for ibc middleware v2

* add test cases for ibc middleware v1 and post state check

* add OnAcknowledgementPacket tc for v1 ibc middleware

* add OnTimeoutPacket tc for v1 ibc middleware

* chore: unify variable names

* use internal testing pkg and add TestOnRecvPacketNativeErc20 tc

* add v1 tcs for handling erc20 native coin

OnTimeoutPacket, OnAcknowledgementPacket

* refactor v1 middleware test codes

* apply gci

* fix ci: receiver name should be same

* fix ci: unify receiver name

and also update comments and variable name

* fix ci: run gofumpt and remove tc copy

* test: update TestOnRecvPacket

make sure whether it is registered as dynamic precompiled contract or not

* chore: test suite name convention
* replace erc20 native coin's prefix

from: erc20/
to: erc20

* change prefix to erc20:

* don't allow legacy format

ValidateErc20Denom is not used anywhere except test code, but what if it is used from somewhere else in the future?

We shouldn't treat legacy format as valid.
* test: WIP debugging ibc e2e test

* fix: ics20 precompile receiver addr to bech32, not bech32

* test: add erc20 case for ics20 v1 e2e test

(cherry picked from commit 2737b63160d9cefcad52cf86048638a861a478a5)

* test: add ibc v2 relayer logic on testing package, add v2 ics20 precompile test cases

(cherry picked from commit 886fdb7581cdcd0dcce15592aae0d8206e78a783)

* chore: fix lint Useless assignment to local variable

* fix!: denom trace to denom for ibc v8 -> v10 breaking changes

* fix!: tmp cherry-pick to remove erc20/ Prefix in Native ERC20 Coin Denoms #92

320236a

* test: add native erc20 case on ics20 precompile e2e test

(cherry picked from commit d8db271)

* chore: fix lint

(cherry picked from commit 0d998cefc0c5bb57c396c01544b3ebe610f8a510)

* fix: update comments on ics20.sol

* refactor: Improve variable name clarity, apply suggestions

* Revert "fix!: tmp cherry-pick to remove erc20/ Prefix in Native ERC20 Coin Denoms #92"

This reverts commit e5afb56.

* chore: update omitted contracts json by make contracts-all
* add OnRecvPacketNativeERC20 test case

test scenario where evm chain receives erc20 native coin through IBC

* add OnTimeoutPacketNativeERC20 test case

* fix ci and comments

* fix test case
@dongsam dongsam marked this pull request as ready for review April 25, 2025 06:31
@dongsam dongsam requested a review from vladjdk April 25, 2025 06:31
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.

Tremendous work on this, fellas. Really appreciate this!

Should be good to approve, I mostly have nits, some questions, and a couple of places where I want to add some checks in testing.

@dongsam dongsam requested a review from vladjdk April 28, 2025 19:21
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.

Checked the fixes, LGTM.

@dongsam dongsam merged commit 105ba78 into main Apr 28, 2025
16 checks passed
@dongsam dongsam deleted the feat/ibc-v10 branch April 28, 2025 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment