Skip to content

fix(tx-history): token information and query#2404

Merged
shamardy merged 14 commits intodevfrom
fix-token-query-and-info
Apr 11, 2025
Merged

fix(tx-history): token information and query#2404
shamardy merged 14 commits intodevfrom
fix-token-query-and-info

Conversation

@onur-ozkan
Copy link
Copy Markdown

@onur-ozkan onur-ozkan commented Mar 25, 2025

Previously it was not possible to query history of Tendermint tokens. This PR makes that
possible. It also breaks the tx-history logic due to the new internal ID computation. But still users will not notice this change as it will be handled silently in the background.

Fixes: #2395 and #2315

Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
@onur-ozkan onur-ozkan force-pushed the fix-token-query-and-info branch from 8dde850 to eae2619 Compare March 25, 2025 13:30
Signed-off-by: onur-ozkan <work@onurozkan.dev>
@onur-ozkan onur-ozkan force-pushed the fix-token-query-and-info branch 3 times, most recently from ab18e1f to c0af309 Compare March 25, 2025 14:48
// it can be the platform ticker instead of the token ticker for a pre-saved record
if details.coin != request.coin {
details.coin = request.coin.clone();
}
Copy link
Copy Markdown
Author

@onur-ozkan onur-ozkan Mar 25, 2025

Choose a reason for hiding this comment

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

I have no idea how this helps to other protocols but it's buggy (hiding actual token tickers) on Tendermint, so I moved it here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Apparently this was added for BCH and SLP tx history, SLP tokens are included in a BCH transaction and it might be saved with a BCH ticker. EVMs were not added to v2 tx history so the only tokens protocol that uses this is slp, maybe we should specify this.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

awesome let's please add a comment about this then.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added a TODO note.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would actually use the BCH/SLP protocol instead of _ wildcard, otherwise this will cause a similar bug that will be hard to detect when we add other protocols with tokens. I am fixing it now in a commit.

Copy link
Copy Markdown
Collaborator

@shamardy shamardy Apr 11, 2025

Choose a reason for hiding this comment

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

Done here 2812ff8 can one of you @mariocynicys @onur-ozkan please check it and resolve this commit if it's fine. I will then merge the PR.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
@onur-ozkan onur-ozkan force-pushed the fix-token-query-and-info branch from c0af309 to 5b8e290 Compare March 25, 2025 15:18
Signed-off-by: onur-ozkan <work@onurozkan.dev>
@onur-ozkan onur-ozkan force-pushed the fix-token-query-and-info branch from 5e2e150 to 3fc5e0e Compare March 26, 2025 07:01
@onur-ozkan
Copy link
Copy Markdown
Author

Would be nice to have an approval from the QA team.

cc @KomodoPlatform/qa

@smk762
Copy link
Copy Markdown

smk762 commented Mar 31, 2025

Error in response:


        "sync_status": {
            "state": "Error",
            "additional_info": {
                "message": "StorageError(\"add_transactions_to_history failed: sql_tx_history_storage_v2:474] SqliteFailure(Error { code: ConstraintViolation, extended_code: 2067 }, Some(\\\"UNIQUE constraint failed: IRIS_tx_history.internal_id\\\"))\")"
            }
        },

and console log:

31 09:10:37, coins::tendermint::tendermint_tx_history_v2:1113] INFO Stopping tx history fetching for IRIS. Reason: StorageError("add_transactions_to_history failed: sql_tx_history_storage_v2:474] SqliteFailure(Error { code: ConstraintViolation, extended_code: 2067 }, Some(\"UNIQUE constraint failed: IRIS_tx_history.internal_id\"))")

After moving DB/ folder to backup (i.e. clean slate), response returned expected result.

After restoring backup, on second attempt, response returned expected result. If this is intended (repaired on second restart), I can approve.

@onur-ozkan

This comment was marked as outdated.

@onur-ozkan
Copy link
Copy Markdown
Author

Can you re-check? That shouldn't happen anymore @smk762

@onur-ozkan onur-ozkan force-pushed the fix-token-query-and-info branch 4 times, most recently from 49f3587 to a78a316 Compare April 1, 2025 06:43
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
@smk762 smk762 self-requested a review April 2, 2025 09:08
smk762
smk762 previously approved these changes Apr 2, 2025
Copy link
Copy Markdown

@smk762 smk762 left a comment

Choose a reason for hiding this comment

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

Confirmed history now returns for IBC tokens. Thanks!

Copy link
Copy Markdown
Collaborator

@mariocynicys mariocynicys left a comment

Choose a reason for hiding this comment

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

Thanks!
First review iter, getting to know things.

Copy link
Copy Markdown
Collaborator

@mariocynicys mariocynicys left a comment

Choose a reason for hiding this comment

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

Thanks!
~zero or one last iter for these comments and that's it :)

@@ -513,9 +519,11 @@ impl MmCoin for TendermintToken {
internal_id,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Comment on lines +212 to 216
TransactionType::TendermintIBCTransfer { token_id }
| TransactionType::CustomTendermintMsg { token_id, .. } => {
if let Some(token_id) = token_id {
let mut bytes_for_hash = tx_hash.0.clone();
bytes_for_hash.extend_from_slice(&token_id.0);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

where as here in tx_hist, we do embed token_id into the internal identifer

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

That looks weird. 🤔 We shouldn't do that probably, but I don't want remove it and go that far in this PR...

for id in [old_internal_id, old_internal_id_for_fees] {
if let Ok(Some(_)) = storage.get_tx_from_history(&wallet_id, &id).await {
if let Err(e) = storage.remove_tx_from_history(&wallet_id, &id).await {
log::debug!("Failed to remove old transaction history record. {e:?}");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this shouldn't happen, but if it happened it is worthy to be logged as an error!.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I don't think we should do that.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why don't u think so?

let old_internal_id_for_fees: BytesJson = H256::from(old_internal_id_hash).to_vec().into();

for id in [old_internal_id, old_internal_id_for_fees] {
if let Ok(Some(_)) = storage.get_tx_from_history(&wallet_id, &id).await {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

shouldn't we also log errors from here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No we shouldn't. It's totally fine to skip this silently.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ummm, if it't just not found, that's OK,
but if we encounter a DB error, we probably wanna know why such an error occurs.

}

fn history_sync_status(&self) -> HistorySyncState { HistorySyncState::NotEnabled }
fn history_sync_status(&self) -> HistorySyncState { self.platform_coin.history_sync_status() }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

quoting from the PR's post:

Previously it was not possible to query history of Tendermint tokens. This PR makes that
possible.

Q: is this the change that made it possible to query tendermint token history? if not, could you guide me to the change please, as there is no dedicated commit for it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No, not this. It's the changes made in mm2src/coins/tendermint/tendermint_tx_history_v2.rs.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
@onur-ozkan onur-ozkan force-pushed the fix-token-query-and-info branch from 971b405 to 3aea946 Compare April 3, 2025 17:43
@smk762 smk762 self-requested a review April 8, 2025 08:38
smk762
smk762 previously approved these changes Apr 8, 2025
shamardy
shamardy previously approved these changes Apr 10, 2025
Copy link
Copy Markdown
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

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

LGTM! Only nits!

// it can be the platform ticker instead of the token ticker for a pre-saved record
if details.coin != request.coin {
details.coin = request.coin.clone();
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Apparently this was added for BCH and SLP tx history, SLP tokens are included in a BCH transaction and it might be saved with a BCH ticker. EVMs were not added to v2 tx history so the only tokens protocol that uses this is slp, maybe we should specify this.

mariocynicys
mariocynicys previously approved these changes Apr 11, 2025
Copy link
Copy Markdown
Collaborator

@mariocynicys mariocynicys left a comment

Choose a reason for hiding this comment

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

My previous comment threads are non-blocking. Will continue the convo in them later.

LGTM

Signed-off-by: onur-ozkan <work@onurozkan.dev>
@onur-ozkan onur-ozkan dismissed stale reviews from mariocynicys, shamardy, and smk762 via 04392d2 April 11, 2025 07:23
Copy link
Copy Markdown
Collaborator

@mariocynicys mariocynicys left a comment

Choose a reason for hiding this comment

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

Re-lgtm

mariocynicys
mariocynicys previously approved these changes Apr 11, 2025
@shamardy shamardy merged commit 468b553 into dev Apr 11, 2025
23 of 24 checks passed
@shamardy shamardy deleted the fix-token-query-and-info branch April 11, 2025 21:57
dimxy pushed a commit to dimxy/komodo-defi-framework that referenced this pull request May 13, 2025
* dev: (26 commits)
  chore(deps): remove base58 and replace it completely with bs58 (GLEECBTC#2427)
  feat(tron): initial groundwork for full TRON integration (GLEECBTC#2425)
  fix(UTXO): improve tx fee calculation and min relay fee handling (GLEECBTC#2316)
  deps(timed-map): bump to 1.3.1 (GLEECBTC#2413)
  improvement(tendermint): safer IBC channel handler (GLEECBTC#2298)
  chore(release): complete v2.4.0-beta changelogs  (GLEECBTC#2436)
  fix(event-streaming): initial addresses registration in utxo balance streaming (GLEECBTC#2431)
  improvement(watchers): re-write use-watchers handling (GLEECBTC#2430)
  fix(evm): make withdraw_nft work in HD mode (GLEECBTC#2424)
  feat(taproot): support parsing taproot output address types
  chore(RPC): use consistent param name for QTUM delegation (GLEECBTC#2419)
  fix(makerbot): add LiveCoinWatch price provider (GLEECBTC#2416)
  chore(release): add changelog entries for v2.4.0-beta (GLEECBTC#2415)
  fix(wallets): prevent path traversal in `wallet_file_path` and update file extension (GLEECBTC#2400)
  fix(nft): make `update_nft` work with hd wallets using the enabled address (GLEECBTC#2386)
  fix(wasm): unify error handling for mm2_main (GLEECBTC#2389)
  fix(tx-history): token information and query (GLEECBTC#2404)
  test(electrums): fix failing test_one_unavailable_electrum_proto_version (GLEECBTC#2412)
  improvement(network): remove static IPs from seed lists (GLEECBTC#2407)
  improvement(best-orders): return an rpc error when we can't find best orders (GLEECBTC#2318)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants