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

Propagate deliver-tx error for all messages in a failed Tx #2334

Merged
merged 11 commits into from
Jul 5, 2022

Conversation

ancazamfir
Copy link
Collaborator

@ancazamfir ancazamfir commented Jun 24, 2022

Closes: #2333

Description


PR author checklist:

  • Added changelog entry, using unclog.
  • Added tests: integration (for Hermes) or unit/mock tests (for modules).
  • Linked to GitHub issue.
  • Updated code comments and documentation (e.g., docs/).

Reviewer checklist:

  • Reviewed Files changed in the GitHub PR explorer.
  • Manually tested (in case integration/unit/mock tests are absent).

@adizere
Copy link
Member

adizere commented Jun 28, 2022

I followed the instructions in the issue but I'm likely doing something wrong, because I can't reproduce the error. Instead of getting deliverTx errors, I'm catching the error at the estimate gas step:

2022-06-28T11:08:53.131609Z ERROR ThreadId(11) send_tx_with_account_sequence_retry{id=ibc-1}:estimate_gas: failed to simulate tx. propagating error to caller: gRPC call failed with status: status: Unknown, message: "failed to execute message; message index: 4: 6998375samoleans is smaller than 9000000samoleans: insufficient funds", details: [], metadata: MetadataMap { headers: {"content-type": "application/grpc", "x-cosmos-block-height": "35000"} }
Error: transfer error: failed while submitting the Transfer message to chain ibc-1: gRPC call failed with status: status: Unknown, message: "failed to execute message; message index: 4: 6998375samoleans is smaller than 9000000samoleans: insufficient funds", details: [], metadata: MetadataMap { headers: {"content-type": "application/grpc", "x-cosmos-block-height": "35000"} }

This happens while I'm running eg.

hermes tx raw ft-transfer ibc-1 ibc-0 transfer channel-0 9000000 -n 15 -o 200 -k wallet1

@ancazamfir
Copy link
Collaborator Author

I followed the instructions in the issue but I'm likely doing something wrong, because I can't reproduce the error. Instead of getting deliverTx errors, I'm catching the error at the estimate gas step:

2022-06-28T11:08:53.131609Z ERROR ThreadId(11) send_tx_with_account_sequence_retry{id=ibc-1}:estimate_gas: failed to simulate tx. propagating error to caller: gRPC call failed with status: status: Unknown, message: "failed to execute message; message index: 4: 6998375samoleans is smaller than 9000000samoleans: insufficient funds", details: [], metadata: MetadataMap { headers: {"content-type": "application/grpc", "x-cosmos-block-height": "35000"} }
Error: transfer error: failed while submitting the Transfer message to chain ibc-1: gRPC call failed with status: status: Unknown, message: "failed to execute message; message index: 4: 6998375samoleans is smaller than 9000000samoleans: insufficient funds", details: [], metadata: MetadataMap { headers: {"content-type": "application/grpc", "x-cosmos-block-height": "35000"} }

This happens while I'm running eg.

hermes tx raw ft-transfer ibc-1 ibc-0 transfer channel-0 9000000 -n 15 -o 200 -k wallet1

Sorry forgot to clarify, you need to inspect the events, e.g.

--- a/relayer/src/transfer.rs
+++ b/relayer/src/transfer.rs
@@ -182,6 +182,7 @@ pub fn build_and_send_transfer_messages<SrcChain: ChainHandle, DstChain: ChainHa
         .send_messages_and_wait_commit(TrackedMsgs::new_static(msgs, "ft-transfer"))
         .map_err(|e| TransferError::submit(packet_src_chain.id(), e))?;

+    dbg!(&events);
     // Check if the chain rejected the transaction
     let result = events
         .iter()

@ancazamfir ancazamfir marked this pull request as ready for review June 29, 2022 07:32
@adizere adizere assigned soareschen and unassigned adizere Jun 30, 2022
relayer/src/chain/cosmos/wait.rs Outdated Show resolved Hide resolved
relayer/src/chain/cosmos/wait.rs Outdated Show resolved Hide resolved
relayer/src/chain/cosmos/wait.rs Outdated Show resolved Hide resolved
@soareschen
Copy link
Contributor

@romac @ancazamfir I added a new TxStatus field in TxSyncResult so that pending TXs have the status TxStatus::Pending, and that wait_for_block_commits returns when all status become TxStatus::ReceivedResponse. With that the IbcEvent::Empty event can be removed.

I also added a test test_error_events to test the number of error events when the transaction failed. If you copy the same test to master branch you should see the test failed, while on this branch it is fixed.

cargo test -p ibc-integration-test -- test_error_events

I also want to note that there is still one call in Link that returns a single ChainError event. In this case the original message count is lost in translation, so it is not possible to fill in the error events with the original count. This in turn means that the RelaySummary returned would still have only one error event.

If you think that needs to be fixed, we should do it in a separate PR and have this PR merged first.

@romac
Copy link
Member

romac commented Jul 5, 2022

With that the IbcEvent::Empty event can be removed.

Sweet! That's a very nice solution, thanks a lot!

I also want to note that there is still one call in Link that returns a single ChainError event. In this case the original message count is lost in translation, so it is not possible to fill in the error events with the original count. This in turn means that the RelaySummary returned would still have only one error event.

I am not fully sure I understand what's going on here, but let's get this merged already and follow-up on this at a later stage. Tracked in #2374, feel free to update the description.

@romac
Copy link
Member

romac commented Jul 5, 2022

Oh and thanks for the corresponding test 🙏

@romac romac dismissed soareschen’s stale review July 5, 2022 12:06

Concerns have been addressed by the reviewer

@romac romac merged commit 385c3ab into master Jul 5, 2022
@romac romac deleted the anca/err_for_all_msgs_in_tx branch July 5, 2022 12:32
hu55a1n1 pushed a commit to hu55a1n1/hermes that referenced this pull request Sep 13, 2022
…nformalsystems#2334)

* When a Tx fails mark all msgs in the Tx as failed

* Remove dbg

* Add changelog

* Refactor update_tx_sync_result

* Add test for error events

* Remove IbcEvent::Empty

* Reword changelog entry

* Small cleanup

Co-authored-by: Soares Chen <[email protected]>
Co-authored-by: Romain Ruetschi <[email protected]>
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.

Sending N messages to a chain does not always return N responses
4 participants