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

Make client code call into the new ABCI queries tx endpoints #619

Conversation

sug0
Copy link
Contributor

@sug0 sug0 commented Oct 17, 2022

Based on #610

Implements the fourth task of issue #563

@sug0 sug0 force-pushed the tiago/ethbridge/impl-events-endpoint-client-tx branch from 1e50da7 to 7d42d0f Compare October 17, 2022 14:24
@sug0 sug0 force-pushed the tiago/ethbridge/impl-events-endpoint-client-tx branch from 7d42d0f to d703fa1 Compare October 17, 2022 14:28
@sug0 sug0 marked this pull request as ready for review October 17, 2022 15:19
apps/src/lib/client/tx.rs Outdated Show resolved Hide resolved
apps/src/lib/client/tx.rs Show resolved Hide resolved
Comment on lines +95 to 103
impl TxResponse {
/// Convert an [`Event`] to a [`TxResponse`], or error out.
pub fn from_event(event: Event) -> Self {
event.try_into().unwrap_or_else(|err| {
eprintln!("Error fetching TxResponse: {err}");
safe_exit(1);
})
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't need this, we can just use .try_from() and handle/log the error as appropriate. Having these safe_exits is especially pernicious as it breaks the test runner, if this code ever ends up being used in a Rust test (this is the root cause of #104 )

Copy link
Contributor

Choose a reason for hiding this comment

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

To do later - anoma/anoma#1049 - these safe_exits need to be removed

Copy link
Member

Choose a reason for hiding this comment

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

This sounds like an issue with the test runner. It is supposed to watch the exit status and return an error if it gets a non-zero value.

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good if the test runner could catch that, but it's still bad that we have these functions maybe taking a decision to terminate the process

apps/src/lib/client/rpc.rs Outdated Show resolved Hide resolved
eprintln!("Transaction status query deadline of {deadline:?} exceeded");
})
.and_then(|result| result)
.unwrap_or_else(|_| cli::safe_exit(1))
Copy link
Contributor

Choose a reason for hiding this comment

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

Return Err here instead of exiting? The caller could then log the error and decide to exit or pass on the responsibility. Or at least a None or false or something which indicated we didn't succeed.

apps/src/lib/client/rpc.rs Outdated Show resolved Hide resolved
apps/src/lib/client/rpc.rs Outdated Show resolved Hide resolved
Comment on lines +70 to +81
let initialized_accounts = event
.get("initialized_accounts")
.map(String::as_str)
// TODO: fix finalize block, to return initialized accounts,
// even when we reject a tx?
.or(Some("[]"))
// NOTE: at this point we only have `Some(vec)`, not `None`
.ok_or_else(|| unreachable!())
.and_then(|initialized_accounts| {
serde_json::from_str(initialized_accounts)
.map_err(|err| format!("JSON decode error: {err}"))
})?;
Copy link
Contributor

Choose a reason for hiding this comment

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

What do we expect event.get("initialized_accounts") to look like now? It could be useful to factor out and have a test specifically for this parsing workaround we're doing. Is this an issue with Tendermint?

Copy link
Contributor Author

@sug0 sug0 Oct 18, 2022

Choose a reason for hiding this comment

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

no it's an issue with our finalize block implementation. at first I thought it was tendermint's fault, but it's namada code's. when we reject a tx, initialized_accounts is not set in the Event attributes, so we need to do this crap, which is a bit unfortunate.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah right, I made an issue - #643 , we can eventually fix it and simplify this

@james-chf james-chf self-requested a review October 17, 2022 18:18
@sug0 sug0 force-pushed the tiago/ethbridge/impl-events-endpoint-client-tx branch from dab19ad to e0c93da Compare October 18, 2022 08:32
@sug0 sug0 marked this pull request as draft October 18, 2022 09:10
Copy link
Member

@batconjurer batconjurer left a comment

Choose a reason for hiding this comment

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

These look fine to me, but see my comments on the PR it is built off of

@sug0 sug0 force-pushed the tiago/ethbridge/impl-events-endpoint-client-tx branch from b2aece9 to 92dec57 Compare October 18, 2022 10:00
@sug0 sug0 marked this pull request as ready for review October 18, 2022 11:49
@sug0
Copy link
Contributor Author

sug0 commented Oct 18, 2022

@james-chf left the safe_exit discussion a bit open ended. for this PR, I'm just going to follow the general pattern of the rest of the code already in the client.

Copy link
Contributor

@james-chf james-chf left a comment

Choose a reason for hiding this comment

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

tested locally and works well, the safe_exit calls should be cleared up at some point

@sug0 sug0 merged commit 08a67d5 into tiago/ethbridge/impl-events-endpoint Oct 19, 2022
@sug0 sug0 deleted the tiago/ethbridge/impl-events-endpoint-client-tx branch October 19, 2022 11:31
phy-chain pushed a commit to phy-chain/namada that referenced this pull request Mar 1, 2024
- Add atoms for accounts, balances, chain config, fiat rates, fiat
  currency setting, and temporary redux store atom

- Fetch balances, accounts etc. for jotai as well as redux

- Use jotai instead of redux for displaying data in DerivedAccounts

- Remove redux coins slice

- Calculate total balance in AccountOverview instead of DerivedAccounts

- Display "-" instead of "0" when balance for an account is loading

- Refactor DerivedAccounts with smaller FiatBalanceDisplay component

- Only fetch fiat rates when DerivedAccounts is first mounted and remove
apparently broken timestamp code
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.

3 participants