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

Add scripts/find-transaction-from-timestamp #6380

Merged
merged 1 commit into from
Feb 10, 2025
Merged

Conversation

dskloetd
Copy link
Contributor

Motivation

I created these scripts when debugging an issue.
Perhaps they'll be useful again in the future.

Changes

  1. Add scripts/get-transaction which lets you get a transaction, taking care of getting it from an archive canister if necessary.
  2. Add scripts/find-transaction-from-timestamp which binary searches transactions for a specific timestamp and outputs the transaction index.

Tests

Tested manually:

$ scripts/find-transaction-from-timestamp --network mainnet --ledger_canister_id oj6if-riaaa-aaaaq-aaeha-cai --timestamp 1738364400
Binary searching for timestamp 1738364400
Searching in range [0, 56367) of length 56367. 17 steps remaining.
Searching in range [28184, 56367) of length 28183. 16 steps remaining.
Searching in range [42276, 56367) of length 14091. 15 steps remaining.
Searching in range [42276, 49321) of length 7045. 14 steps remaining.
Searching in range [45799, 49321) of length 3522. 13 steps remaining.
Searching in range [45799, 47560) of length 1761. 12 steps remaining.
Searching in range [46680, 47560) of length 880. 11 steps remaining.
Searching in range [47121, 47560) of length 439. 10 steps remaining.
Searching in range [47121, 47340) of length 219. 9 steps remaining.
Searching in range [47231, 47340) of length 109. 8 steps remaining.
Searching in range [47286, 47340) of length 54. 7 steps remaining.
Searching in range [47314, 47340) of length 26. 6 steps remaining.
Searching in range [47314, 47327) of length 13. 5 steps remaining.
Searching in range [47321, 47327) of length 6. 4 steps remaining.
Searching in range [47321, 47324) of length 3. 3 steps remaining.
Searching in range [47323, 47324) of length 1. 1 steps remaining.
Found index: 47324

scripts/get-transaction --network mainnet --ledger_canister_id oj6if-riaaa-aaaaq-aaeha-cai -i 47324
{
  "approve": null,
  "burn": null,
  "kind": "transfer",
  "mint": null,
  "timestamp": "1738364454077498613",
  "transfer": [
    {
      "amount": "98_420_721_060",
      "created_at_time": null,
      "fee": [
        "500_000_000"
      ],
      "from": {
        "owner": "2ipq2-uqaaa-aaaar-qailq-cai",
        "subaccount": null
      },
      "memo": null,
      "spender": null,
      "to": {
        "owner": "yw25v-ob2wi-lssuy-yocex-hp63m-hwsrr-zc3rr-s4yb5-kdgwz-hrwwl-xqe",
        "subaccount": null
      }
    }
  ]
}

Todos

  • Add entry to changelog (if necessary).
    not necessary

@dskloetd dskloetd marked this pull request as ready for review February 10, 2025 10:54
@dskloetd dskloetd requested a review from a team as a code owner February 10, 2025 10:54
@dskloetd dskloetd enabled auto-merge February 10, 2025 10:54
Copy link
Contributor

@yhabib yhabib left a comment

Choose a reason for hiding this comment

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

Thanks

@dskloetd dskloetd added this pull request to the merge queue Feb 10, 2025
Merged via the queue into main with commit 6cb1480 Feb 10, 2025
32 checks passed
@dskloetd dskloetd deleted the kloet/tx-timestamp branch February 10, 2025 11:34
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