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

Tx error handling #39

Merged
merged 5 commits into from
Jan 8, 2025
Merged

Tx error handling #39

merged 5 commits into from
Jan 8, 2025

Conversation

koxu1996
Copy link
Contributor

@koxu1996 koxu1996 commented Dec 29, 2024

We have handling for tx failures, after tx is broadcasted with sync mode:

log::debug!("broadcast_tx response: {:#?}", resp);
let tx_response = resp.tx_response.ok_or("Tx response not found")?;
if tx_response.code != 0 {
return Err(Error::Unknown(format!(
"Transaction failed with code: {} ({})",
tx_response.code, tx_response.raw_log
)));
}

Sync mode means that basic checks are done (structure, signatures, fees), and tx is added to the mempool. However, execution still can fail later.

Currently we fetch the tx response and blindly start parsing its message - even if tx code is non-zero - which results in Error: Unknown("no response message").


This PR improves handling with a dedicated Tx error: hash, code and log included.

For example, instead of "no response message" (like in gevulotnetwork/gvltctl#44), now you will get:

Error: Tx("A3469D4B4A2D046B41752FA8DFA7FA2787881126E3CF1C10AFE6CB3351EACDA7", 11, "out of gas in location: IterNextFlat; gasWanted: 106014, gasUsed: 106022: out of gas")

@koxu1996 koxu1996 requested review from tuommaki and trusch December 29, 2024 05:30
@koxu1996 koxu1996 self-assigned this Dec 29, 2024
@koxu1996 koxu1996 marked this pull request as draft December 29, 2024 05:47
@koxu1996 koxu1996 marked this pull request as ready for review December 29, 2024 06:07
@trusch trusch merged commit 64755bb into main Jan 8, 2025
1 check passed
@trusch trusch deleted the feature/tx-error-handling branch January 8, 2025 12:52
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.

gvltctl task create: unknown error "no response message"
2 participants