Skip to content
This repository was archived by the owner on Jan 9, 2026. It is now read-only.

crossChainAccount derivation improvements for /txs/account#181

Merged
enobayram merged 3 commits intomasterfrom
enis/xchain-source-from-x-resume
Jan 30, 2024
Merged

crossChainAccount derivation improvements for /txs/account#181
enobayram merged 3 commits intomasterfrom
enis/xchain-source-from-x-resume

Conversation

@enobayram
Copy link
Copy Markdown
Contributor

@enobayram enobayram commented Jan 30, 2024

This PR improves the derivation of the crossChainAccount (and crossChainId) information for cross-chain transfers served by the /txs/account endpoint.:

  • For the send side, it removes the parity check comparing the amount fields of the TRANSFER and the TRANSFER_XCHAIN events. The check is redundant and it's fragile due to the volatility of decimal representations.
  • For the receive side, it switches to using the X_RESUME event on the receiving transaction as the data source, instead of the TRANSFER_XCHAIN event on the sending transaction. This has 2 benefits: It allows us to remove the amount check due to the same reasons, and it avoids relying on the data from an independent block being present.

Special thanks to @Takadenoshi for identifying this issue, helping me analyze it and suggesting the fix involving the X_RESUME event!

@enobayram enobayram requested a review from Takadenoshi January 30, 2024 10:07
@enobayram
Copy link
Copy Markdown
Contributor Author

Given that CWDURL points at a chainweb-data instance listening to testnet:

Outgoing xchain transfer:

$ curl -s  "$CWDURL/txs/account/k:d63cee9e2069173f2bdd23f4739fd6f184b53b016e65fdf363f8faa569d3792f?maxheight=3980404&limit=1&offset=1" | jq -C
[
  {
    "amount": "50.0",
    "blockHash": "YAK6e67qIyCaq5oOa2RTvTw4AfUCOBNuV7OofJ0HZtI",
    "blockTime": "2024-01-24T14:29:41.078169Z",
    "chain": 4,
    "crossChainAccount": "k:58aa1853a0c1e53997c076ff9f274423f9f7548a1c22ea3210af3afeadc557e3",
    "crossChainId": 5,
    "fromAccount": "k:d63cee9e2069173f2bdd23f4739fd6f184b53b016e65fdf363f8faa569d3792f",
    "height": 3980404,
    "idx": 2,
    "requestKey": "g4bfNTgrrFf60eW0RfV7i5ix2SXGKsA-5Q7QxgoWFlM",
    "toAccount": "",
    "token": "coin"
  }
]

Incoming xchain transfer:

$ curl -s  "$CWDURL/txs/account/k:58aa1853a0c1e53997c076ff9f274423f9f7548a1c22ea3210af3afeadc557e3?maxheight=3980414&limit=1" | jq -C
[
  {
    "amount": "50.0",
    "blockHash": "B958BmmyXf3qOcpYKKDVtr5ris5mPsNSXb6JWQNEZvA",
    "blockTime": "2024-01-24T14:34:33.986913Z",
    "chain": 5,
    "crossChainAccount": "k:d63cee9e2069173f2bdd23f4739fd6f184b53b016e65fdf363f8faa569d3792f",
    "crossChainId": 4,
    "fromAccount": "",
    "height": 3980414,
    "idx": 1,
    "requestKey": "SAkgHdUXWCwDnuT9MYFbwyBKvqXXCUf-_-A0IIM1nvs",
    "toAccount": "k:58aa1853a0c1e53997c076ff9f274423f9f7548a1c22ea3210af3afeadc557e3",
    "token": "coin"
  }
]

@enobayram enobayram merged commit 5293771 into master Jan 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants