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

improve client tx result handling #2276

Merged
merged 24 commits into from
Dec 29, 2023
Merged

Conversation

tzemanovic
Copy link
Member

@tzemanovic tzemanovic commented Dec 13, 2023

Describe your changes

The TxResponse type is updated to contain a typed inner_tx: TxResult for inner txs and some of its other fields are now typed. This is to make it possible to check a tx result in the client before taking further actions that depend on the result.

Stdout from a transaction now looks like this:

Transaction added to mempool.
Wrapper transaction hash: 137DE5305AC348B216D956AC538E6D23E233B20847C7B7EC266F48F2C3BA2CE1
Inner transaction hash: 89A8DBE501CC141508FBD54B9ED747AE3800A3BA299045323A7139988BBA3472
Wrapper transaction accepted at height 202. Used 21 gas.
Waiting for inner transaction result...
Transaction was successfully applied at height 203. Used 7890 gas.

A failed tx prints more info, e.g.:

Transaction added to mempool.
Wrapper transaction hash: 6E9083C5786E144B2BB190467FDC392129E8BC8D59AA1B394A4606F4E1EC5E02
Inner transaction hash: 619B2531D37A5F7F81787B4D5401158579647DDBEFB18BD9C5D4C3414B429777
Wrapper transaction accepted at height 172. Used 20 gas.
Waiting for inner transaction result...
Transaction was rejected by VPs: [
  "tnam1q9rhgyv3ydq0zu3whnftvllqnvhvhm270qxay5tn"
].
Changed keys: [
  "#tnam1pyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqej6juv/#tnam1q9mjvqd45u7w54kee2aquugtv7vn7h3xrcrau7xy/balance/#tnam1q9rhgyv3ydq0zu3whnftvllqnvhvhm270qxay5tn",
  "#tnam1pyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqej6juv/#tnam1q9mjvqd45u7w54kee2aquugtv7vn7h3xrcrau7xy/balance/#tnam1qxfj3sf6a0meahdu9t6znp05g8zx4dkjtgyn9gfu"
]

Indicate on which release or other PRs this topic is based on

#2218 - diff range for review https://github.com/anoma/namada/pull/2276/files/dd28da14cefd6806ebfe71eb6a8ba8c894d975cd..f167f2b5b8396acf148fcc9cf992daf89f3b48a7

Checklist before merging to draft

  • I have added a changelog
  • Git history is in acceptable state

@tzemanovic tzemanovic force-pushed the tomas/nicer-client-tx-result branch 3 times, most recently from 4cc7e5c to ea0a59b Compare December 14, 2023 10:45
apps/src/lib/client/tx.rs Outdated Show resolved Hide resolved
@tzemanovic tzemanovic force-pushed the tomas/nicer-client-tx-result branch from ea0a59b to 306a634 Compare December 14, 2023 10:53
tzemanovic added a commit that referenced this pull request Dec 14, 2023
@tzemanovic tzemanovic marked this pull request as ready for review December 14, 2023 10:58
@tzemanovic tzemanovic requested a review from sug0 December 14, 2023 11:00
@tzemanovic tzemanovic mentioned this pull request Dec 14, 2023
2 tasks
Copy link
Collaborator

@sug0 sug0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple of suggestions

apps/src/lib/client/tx.rs Outdated Show resolved Hide resolved
apps/src/lib/client/tx.rs Outdated Show resolved Hide resolved
core/src/types/transaction/mod.rs Show resolved Hide resolved
sdk/src/tx.rs Outdated Show resolved Hide resolved
sdk/src/tx.rs Outdated Show resolved Hide resolved
tests/src/e2e/ibc_tests.rs Outdated Show resolved Hide resolved
tests/src/integration/masp.rs Outdated Show resolved Hide resolved
@brentstone brentstone force-pushed the tomas/nicer-client-tx-result branch from 627e66c to 54bba83 Compare December 15, 2023 20:18
brentstone pushed a commit that referenced this pull request Dec 15, 2023
@brentstone brentstone mentioned this pull request Dec 15, 2023
@tzemanovic tzemanovic force-pushed the tomas/nicer-client-tx-result branch from 4484648 to f167f2b Compare December 19, 2023 16:42
brentstone added a commit that referenced this pull request Dec 19, 2023
* tomas/nicer-client-tx-result:
  Merge remote-tracking branch 'origin/main'
  refactor and use ProcessTxResponse::is_applied_and_valid
  core: add a note on transaction ResultCode
  Update sdk/src/tx.rs
  tests: add consts for ledger startup exp strings
  tests: replace expected tx failure string with a const
  tests: replace expected tx strings with consts
  changelog: add #2276
  Rename ErrorCodes to ResultCode and make TxReponse.height typed
  sdk: use typed `ErrorCodes` for `TxResponse`
  move tx ErrorCodes type to core
  sdk: remove `initialized_accounts` from `TxResponse` (it's in inner_tx)
  tests: update expected tx result strings
  refactor tx response and result
  sdk/tx: remove unused `ProcessTxResponse` case
brentstone added a commit that referenced this pull request Dec 19, 2023
* tomas/nicer-client-tx-result:
  Merge remote-tracking branch 'origin/main'
  refactor and use ProcessTxResponse::is_applied_and_valid
  core: add a note on transaction ResultCode
  Update sdk/src/tx.rs
  tests: add consts for ledger startup exp strings
  tests: replace expected tx failure string with a const
  tests: replace expected tx strings with consts
  changelog: add #2276
  Rename ErrorCodes to ResultCode and make TxReponse.height typed
  sdk: use typed `ErrorCodes` for `TxResponse`
  move tx ErrorCodes type to core
  sdk: remove `initialized_accounts` from `TxResponse` (it's in inner_tx)
  tests: update expected tx result strings
  refactor tx response and result
  sdk/tx: remove unused `ProcessTxResponse` case
brentstone added a commit that referenced this pull request Dec 29, 2023
* origin/tomas/nicer-client-tx-result:
  Merge remote-tracking branch 'origin/main'
  refactor and use ProcessTxResponse::is_applied_and_valid
  core: add a note on transaction ResultCode
  Update sdk/src/tx.rs
  tests: add consts for ledger startup exp strings
  tests: replace expected tx failure string with a const
  tests: replace expected tx strings with consts
  changelog: add #2276
  Rename ErrorCodes to ResultCode and make TxReponse.height typed
  sdk: use typed `ErrorCodes` for `TxResponse`
  move tx ErrorCodes type to core
  sdk: remove `initialized_accounts` from `TxResponse` (it's in inner_tx)
  tests: update expected tx result strings
  refactor tx response and result
  sdk/tx: remove unused `ProcessTxResponse` case
@brentstone brentstone merged commit 5a9da48 into main Dec 29, 2023
14 of 15 checks passed
@brentstone brentstone deleted the tomas/nicer-client-tx-result branch December 29, 2023 19:37
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.

refactor TxResult event
4 participants