From 84254236afd2f85223d0aed7e979741c8d1a501e Mon Sep 17 00:00:00 2001 From: mmsqe Date: Mon, 14 Oct 2024 16:16:54 +0800 Subject: [PATCH] Problem: acknowledgement is not aligned with underlying_app_success (#1633) * Problem: no easy way to detect error ack packet check underlying_app_success * test * Update CHANGELOG.md Signed-off-by: mmsqe * Update x/cronos/keeper/keeper.go Co-authored-by: mmsqe Signed-off-by: yihuang --------- Signed-off-by: mmsqe Signed-off-by: yihuang Co-authored-by: yihuang --- CHANGELOG.md | 1 + integration_tests/test_ica_precompile.py | 23 ++++++++++++++++++++++- x/cronos/keeper/keeper.go | 3 +++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f4734f295..c462329a4f 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 does not succeed. *Sep 13, 2024* diff --git a/integration_tests/test_ica_precompile.py b/integration_tests/test_ica_precompile.py index bd88dae6dd..d3ddba1078 100644 --- a/integration_tests/test_ica_precompile.py +++ b/integration_tests/test_ica_precompile.py @@ -253,7 +253,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() @@ -307,6 +306,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) @@ -315,6 +315,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 diff --git a/x/cronos/keeper/keeper.go b/x/cronos/keeper/keeper.go index 0a53d1d2d2..83693eae5a 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.Success() { + 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