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

crossChainAccount derivation improvements for /txs/account #181

Merged
merged 3 commits into from
Jan 30, 2024

Conversation

enobayram
Copy link
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
Copy link
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
5 of 6 checks passed
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.

2 participants