From de587a81d8991fd0c8cda2a6c5fd9d6cb1b0a7dc Mon Sep 17 00:00:00 2001 From: mmsqe Date: Wed, 9 Oct 2024 14:47:58 +0800 Subject: [PATCH 1/4] Problem: no easy way to detect error ack packet check underlying_app_success --- x/cronos/keeper/keeper.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x/cronos/keeper/keeper.go b/x/cronos/keeper/keeper.go index 0a53d1d2d2..cab52b33cb 100644 --- a/x/cronos/keeper/keeper.go +++ b/x/cronos/keeper/keeper.go @@ -317,6 +317,9 @@ func (k Keeper) IBCOnAcknowledgementPacketCallback( if err := k.cdc.UnmarshalJSON(acknowledgement, &ack); err != nil { return err } + if !ack.UnderlyingAppSuccess { + return k.onPacketResult(ctx, packet, false, relayer, contractAddress, packetSenderAddress) + } var res channeltypes.Acknowledgement if err := k.cdc.UnmarshalJSON(ack.AppAcknowledgement, &res); err != nil { return err From 6a98f8a5feef2dcd53a888905c734f0377e596d7 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Wed, 9 Oct 2024 15:39:43 +0800 Subject: [PATCH 2/4] test --- CHANGELOG.md | 1 + integration_tests/test_ica_precompile.py | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f4734f295..7a66f5c786 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ * [#1617](https://github.com/crypto-org-chain/cronos/pull/1617) Fix unsuppored sign mode SIGN_MODE_TEXTUAL for bank transfer. * [#1621](https://github.com/crypto-org-chain/cronos/pull/1621), [1630](https://github.com/crypto-org-chain/cronos/pull/1630) Update ethermint to the fix of broken opBlockhash and tx validation. * [#1623](https://github.com/crypto-org-chain/cronos/pull/1623) Ensure expedited related gov params pass the basic validation. +* [#1633](https://github.com/crypto-org-chain/cronos/pull/1633) Align acknowledgement with underlying_app_success when ack packet not does not succeed. *Sep 13, 2024* diff --git a/integration_tests/test_ica_precompile.py b/integration_tests/test_ica_precompile.py index bc8a0d3a92..5d3e6049c6 100644 --- a/integration_tests/test_ica_precompile.py +++ b/integration_tests/test_ica_precompile.py @@ -252,7 +252,6 @@ def test_sc_call(ibc, order): signer=signer, contract_addr=contract_addr, ) - balance = funds_ica(cli_host, ica_address, signer=signer) assert tcontract.caller.getAccount() == addr assert ( tcontract.functions.callQueryAccount(connid, contract_addr).call() @@ -306,6 +305,7 @@ def submit_msgs_ro(func, str): expected_seq, contract.events.SubmitMsgsResult, channel_id, + need_wait=False, signer=signer, ) submit_msgs_ro(tcontract.functions.delegateSubmitMsgs, str) @@ -314,6 +314,27 @@ def submit_msgs_ro(func, str): wait_for_status_change(tcontract, channel_id, last_seq) status = tcontract.caller.getStatus(channel_id, last_seq) assert expected_seq == last_seq + assert status == Status.FAIL + wait_for_packet_log(start, packet_event, channel_id, last_seq, status) + + expected_seq += 1 + balance = funds_ica(cli_host, ica_address, signer=signer) + start = w3.eth.get_block_number() + str, diff = submit_msgs( + ibc, + tcontract.functions.callSubmitMsgs, + data, + ica_address, + False, + expected_seq, + contract.events.SubmitMsgsResult, + channel_id, + signer=signer, + ) + last_seq = tcontract.caller.getLastSeq() + wait_for_status_change(tcontract, channel_id, last_seq) + status = tcontract.caller.getStatus(channel_id, last_seq) + assert expected_seq == last_seq assert status == Status.SUCCESS wait_for_packet_log(start, packet_event, channel_id, last_seq, status) balance -= diff From 2759bfd85c06e9ffa7e8c3a944554b94fe13a1d3 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Wed, 9 Oct 2024 17:20:40 +0800 Subject: [PATCH 3/4] Update CHANGELOG.md Signed-off-by: mmsqe --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a66f5c786..c462329a4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ * [#1617](https://github.com/crypto-org-chain/cronos/pull/1617) Fix unsuppored sign mode SIGN_MODE_TEXTUAL for bank transfer. * [#1621](https://github.com/crypto-org-chain/cronos/pull/1621), [1630](https://github.com/crypto-org-chain/cronos/pull/1630) Update ethermint to the fix of broken opBlockhash and tx validation. * [#1623](https://github.com/crypto-org-chain/cronos/pull/1623) Ensure expedited related gov params pass the basic validation. -* [#1633](https://github.com/crypto-org-chain/cronos/pull/1633) Align acknowledgement with underlying_app_success when ack packet not does not succeed. +* [#1633](https://github.com/crypto-org-chain/cronos/pull/1633) Align acknowledgement with underlying_app_success when ack packet does not succeed. *Sep 13, 2024* From ea0868ba1f9bbde567040a4356c1ab5a43c40459 Mon Sep 17 00:00:00 2001 From: yihuang Date: Mon, 14 Oct 2024 15:46:25 +0800 Subject: [PATCH 4/4] Update x/cronos/keeper/keeper.go Co-authored-by: mmsqe Signed-off-by: yihuang --- x/cronos/keeper/keeper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/cronos/keeper/keeper.go b/x/cronos/keeper/keeper.go index cab52b33cb..83693eae5a 100644 --- a/x/cronos/keeper/keeper.go +++ b/x/cronos/keeper/keeper.go @@ -317,7 +317,7 @@ func (k Keeper) IBCOnAcknowledgementPacketCallback( if err := k.cdc.UnmarshalJSON(acknowledgement, &ack); err != nil { return err } - if !ack.UnderlyingAppSuccess { + if !ack.Success() { return k.onPacketResult(ctx, packet, false, relayer, contractAddress, packetSenderAddress) } var res channeltypes.Acknowledgement