Page MenuHomePhabricator

[chronik-client] Add `plugins` field to outputs/inputs, add `PluginEndpoint`
AbandonedPublicDraft

Authored by tobias_ruck on Jul 29 2024, 15:58.

Details

Reviewers
bytesofman
Group Reviewers
Restricted Project
Summary

Chronik now can use plugins for indexing transactions, but ChronikClientNode doesn't offer an interface for this yet.

This diff adds support for the utxos endpoint and to the plugins field of TxInput, TxOutput, ScriptUtxo and Utxo.

Depends on D16541.

Test Plan

npm run integration-tests

Event Timeline

Failed tests logs:

====== ALP: TxBuilder P2PKH ALP.ALP TxBuilder P2PKH ALP ======
AssertionError: expected [ { outpoint: { …(2) }, …(6) } ] to deeply equal [ { outpoint: { …(2) }, …(5) } ]
    at Context.<anonymous> (tests/alp.test.ts:136:38)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

      + expected - actual

           "outpoint": {
             "outIdx": 1
             "txid": "8ec21bbbd5a58f5ace68629b77425d338d8bc22c8ac55bd64ca582c03b3b5f92"
           }
      -    "plugins": {}
           "token": {
             "amount": "2000"
             "isMintBaton": false
             "tokenId": "8ec21bbbd5a58f5ace68629b77425d338d8bc22c8ac55bd64ca582c03b3b5f92"
====== SLP Integration Test: TxBuilder P2PKH SLP FUNGIBLE.SLP Integration Test TxBuilder P2PKH SLP FUNGIBLE ======
AssertionError: expected [ { outpoint: { …(2) }, …(6) } ] to deeply equal [ { outpoint: { …(2) }, …(5) } ]
    at Context.<anonymous> (tests/slp.test.ts:153:38)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

      + expected - actual

           "outpoint": {
             "outIdx": 1
             "txid": "acb68157659f71440dd10b1f58f055d9c52363b760a1c8f147ecc750e27f6734"
           }
      -    "plugins": {}
           "token": {
             "amount": "2000"
             "isMintBaton": false
             "tokenId": "acb68157659f71440dd10b1f58f055d9c52363b760a1c8f147ecc750e27f6734"
====== SLP Integration Test: TxBuilder P2PKH SLP MINT VAULT.SLP Integration Test TxBuilder P2PKH SLP MINT VAULT ======
AssertionError: expected [ { outpoint: { …(2) }, …(6) } ] to deeply equal [ { outpoint: { …(2) }, …(5) } ]
    at Context.<anonymous> (tests/slp.test.ts:510:38)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

      + expected - actual

           "outpoint": {
             "outIdx": 1
             "txid": "4ec31dd0b7a4db537dec8c8e1243e4acf3bb58dd18802cb8a395612d5e3736ba"
           }
      -    "plugins": {}
           "token": {
             "amount": "2000"
             "isMintBaton": false
             "tokenId": "4ec31dd0b7a4db537dec8c8e1243e4acf3bb58dd18802cb8a395612d5e3736ba"
====== SLP Integration Test: TxBuilder P2PKH SLP NFT1.SLP Integration Test TxBuilder P2PKH SLP NFT1 ======
AssertionError: expected [ { outpoint: { …(2) }, …(6) } ] to deeply equal [ { outpoint: { …(2) }, …(5) } ]
    at Context.<anonymous> (tests/slp.test.ts:784:38)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

      + expected - actual

           "outpoint": {
             "outIdx": 1
             "txid": "25775718144e48e6e8ebe2a9ae8748cb9575d08a1201a52a81f18893c3183bd0"
           }
      -    "plugins": {}
           "token": {
             "amount": "2000"
             "isMintBaton": false
             "tokenId": "25775718144e48e6e8ebe2a9ae8748cb9575d08a1201a52a81f18893c3183bd0"
====== TxBuilder: TxBuilder P2PKH Wallet with mixed outputs (TxOutput, TxOutput with Script.fromAddress(p2pkh), TxOutput with Script.fromAddress(p2sh)).TxBuilder TxBuilder P2PKH Wallet with mixed outputs (TxOutput, TxOutput with Script.fromAddress(p2pkh), TxOutput with Script.fromAddress(p2sh)) ======
AssertionError: expected [ { outpoint: { …(2) }, …(5) } ] to deeply equal [ { outpoint: { …(2) }, …(4) } ]
    at Context.<anonymous> (tests/txBuilder.test.ts:138:40)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

      + expected - actual

           "outpoint": {
             "outIdx": 3
             "txid": "86ccb0f324e1b752b5a22b8b4017db50a812aa8788feabd3f64b02b847ac55c5"
           }
      -    "plugins": {}
           "value": 39574
         }
       ]

Each failure log is accessible here:
ALP: TxBuilder P2PKH ALP.ALP TxBuilder P2PKH ALP
SLP Integration Test: TxBuilder P2PKH SLP FUNGIBLE.SLP Integration Test TxBuilder P2PKH SLP FUNGIBLE
SLP Integration Test: TxBuilder P2PKH SLP MINT VAULT.SLP Integration Test TxBuilder P2PKH SLP MINT VAULT
SLP Integration Test: TxBuilder P2PKH SLP NFT1.SLP Integration Test TxBuilder P2PKH SLP NFT1
TxBuilder: TxBuilder P2PKH Wallet with mixed outputs (TxOutput, TxOutput with Script.fromAddress(p2pkh), TxOutput with Script.fromAddress(p2sh)).TxBuilder TxBuilder P2PKH Wallet with mixed outputs (TxOutput, TxOutput with Script.fromAddress(p2pkh), TxOutput with Script.fromAddress(p2sh))

Tail of the build log:

2024-07-29T16:32:38.485000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/chronik-client-integration-tests/test/tmp/test_runner_₿₵_🏃_20240729_163238/setup_scripts/chronik-client_token_slp_nft1_0
2024-07-29T16:32:40.177000Z TestFramework (INFO): Passed test setup data to mocha
chronikUrl set to ["http://127.0.0.1:28001"]
Mocha timeout set to 240 seconds
2024-07-29T16:32:40.273000Z TestFramework (INFO): Step 1: Send an SLP NFT1 genesis tx
2024-07-29T16:32:40.277000Z TestFramework (INFO): Step 2: Mint a child token
2024-07-29T16:33:40.281000Z TestFramework (INFO): Step 3: Send a child token
2024-07-29T16:34:40.289000Z TestFramework (INFO): Step 4: NFT 1 child genesis
2024-07-29T16:35:40.298000Z TestFramework (INFO): Step 5: Mine a block
token_slp_nft1.ts tests complete, shutting down child process
2024-07-29T16:35:40.333000Z TestFramework (INFO): Got a next message but no more step, exiting
2024-07-29T16:35:40.384000Z TestFramework (INFO): Stopping nodes
2024-07-29T16:35:40.588000Z TestFramework (INFO): Cleaning up /work/abc-ci-builds/chronik-client-integration-tests/test/tmp/test_runner_₿₵_🏃_20240729_163238/setup_scripts/chronik-client_token_slp_nft1_0 on exit
2024-07-29T16:35:40.589000Z TestFramework (INFO): Tests successful
Running Unit Tests for Test Framework Modules
setup_scripts/chronik-client_token_slp_nft1.py started
setup_scripts/chronik-client_token_slp_nft1.py passed, Duration: 182 s

TEST                                           | STATUS    | DURATION

setup_scripts/chronik-client_token_slp_nft1.py | ✓ Passed  | 182 s

ALL                                            | ✓ Passed  | 182 s (accumulated) 
Runtime: 182 s

testRunner complete in token_slp_nft1.ts
Starting test_runner for chronik-client_websocket
Test runner for chronik-client_websocket started
2024-07-29T16:35:40.838000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/chronik-client-integration-tests/test/tmp/test_runner_₿₵_🏃_20240729_163540/setup_scripts/chronik-client_websocket_0
chronikUrl set to ["http://127.0.0.1:28001"]
Mocha timeout set to 240 seconds
2024-07-29T16:35:43.491000Z TestFramework (INFO): Passed test setup data to mocha
2024-07-29T16:35:51.106000Z TestFramework (INFO): Step 1: Avalanche finalize a block
2024-07-29T16:35:53.378000Z TestFramework (INFO): Step 2: Broadcast 1 tx to a p2pk, p2pkh, and p2sh address
2024-07-29T16:35:53.689000Z TestFramework (INFO): Step 3: Mine a block with these txs
2024-07-29T16:35:53.701000Z TestFramework (INFO): Step 4: Park the block containing those txs
2024-07-29T16:35:53.706000Z TestFramework (INFO): Step 5: Unpark the block containing those txs
2024-07-29T16:35:53.710000Z TestFramework (INFO): Step 6: Invalidate the block containing those txs
2024-07-29T16:35:53.713000Z TestFramework (INFO): Step 7: Reconsider the block containing those txs
2024-07-29T16:35:53.717000Z TestFramework (INFO): Step 8: Finalize the block containing these txs with Avalanche
2024-07-29T16:35:56.055000Z TestFramework (INFO): Step 9: Broadcast a tx with mixed outputs
2024-07-29T16:35:56.154000Z TestFramework (INFO): Step 10: Mine another block
websocket.ts tests complete, shutting down child process
2024-07-29T16:35:56.165000Z TestFramework (INFO): Got a next message but no more step, exiting
2024-07-29T16:35:56.216000Z TestFramework (INFO): Stopping nodes
2024-07-29T16:35:56.370000Z TestFramework (INFO): Cleaning up /work/abc-ci-builds/chronik-client-integration-tests/test/tmp/test_runner_₿₵_🏃_20240729_163540/setup_scripts/chronik-client_websocket_0 on exit
2024-07-29T16:35:56.370000Z TestFramework (INFO): Tests successful
Running Unit Tests for Test Framework Modules
setup_scripts/chronik-client_websocket.py started
setup_scripts/chronik-client_websocket.py passed, Duration: 16 s

TEST                                      | STATUS    | DURATION

setup_scripts/chronik-client_websocket.py | ✓ Passed  | 16 s

ALL                                       | ✓ Passed  | 16 s (accumulated) 
Runtime: 16 s

testRunner complete in websocket.ts
Build chronik-client-integration-tests timed out after 3600.0s

Failed tests logs:

====== /blockchain-info: gives us the blockchain info./blockchain-info gives us the blockchain info ======
Error: Error connecting to known Chronik instances
    at FailoverProxy.<anonymous> (src/failoverProxy.ts:37:32)
    at Generator.throw (<anonymous>)
    at rejected (src/failoverProxy.ts:5:3638)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
====== /block/:hash: gives us the Genesis block by hash./block/:hash gives us the Genesis block by hash ======
Error: Error connecting to known Chronik instances
    at FailoverProxy.<anonymous> (src/failoverProxy.ts:37:32)
    at Generator.throw (<anonymous>)
    at rejected (src/failoverProxy.ts:5:3638)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
====== /block/:hash: gives us the Genesis block by height./block/:hash gives us the Genesis block by height ======
Error: Error connecting to known Chronik instances
    at FailoverProxy.<anonymous> (src/failoverProxy.ts:37:32)
    at Generator.throw (<anonymous>)
    at rejected (src/failoverProxy.ts:5:3638)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
====== /blocks/:start/:end: gives us the first few blocks./blocks/:start/:end gives us the first few blocks ======
Error: Error connecting to known Chronik instances
    at FailoverProxy.<anonymous> (src/failoverProxy.ts:37:32)
    at Generator.throw (<anonymous>)
    at rejected (src/failoverProxy.ts:5:3638)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
====== /tx/:txid: results in the right tx./tx/:txid results in the right tx ======
Error: Error connecting to known Chronik instances
    at FailoverProxy.<anonymous> (src/failoverProxy.ts:37:32)
    at Generator.throw (<anonymous>)
    at rejected (src/failoverProxy.ts:5:3638)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
====== /token/:tokenId: gives us a token./token/:tokenId gives us a token ======
Error: Error connecting to known Chronik instances
    at FailoverProxy.<anonymous> (src/failoverProxy.ts:37:32)
    at Generator.throw (<anonymous>)
    at rejected (src/failoverProxy.ts:5:3638)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
====== /validate-utxos: validates the UTXOs./validate-utxos validates the UTXOs ======
Error: Error connecting to known Chronik instances
    at FailoverProxy.<anonymous> (src/failoverProxy.ts:37:32)
    at Generator.throw (<anonymous>)
    at rejected (src/failoverProxy.ts:5:3638)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
====== /script/:type/:payload/history: gives us the first page./script/:type/:payload/history gives us the first page ======
Error: Error connecting to known Chronik instances
    at FailoverProxy.<anonymous> (src/failoverProxy.ts:37:32)
    at Generator.throw (<anonymous>)
    at rejected (src/failoverProxy.ts:5:3638)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
====== /script/:type/:payload/history: gives us an empty page for ?page=1./script/:type/:payload/history gives us an empty page for ?page=1 ======
Error: Error connecting to known Chronik instances
    at FailoverProxy.<anonymous> (src/failoverProxy.ts:37:32)
    at Generator.throw (<anonymous>)
    at rejected (src/failoverProxy.ts:5:3638)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
====== /script/:type/:payload/history: gives us just one tx for ?page_size=1./script/:type/:payload/history gives us just one tx for ?page_size=1 ======
Error: Error connecting to known Chronik instances
    at FailoverProxy.<anonymous> (src/failoverProxy.ts:37:32)
    at Generator.throw (<anonymous>)
    at rejected (src/failoverProxy.ts:5:3638)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
====== /script/:type/:payload/history: gives us the Genesis tx for ?page=1&page_size=1./script/:type/:payload/history gives us the Genesis tx for ?page=1&page_size=1 ======
Error: Error connecting to known Chronik instances
    at FailoverProxy.<anonymous> (src/failoverProxy.ts:37:32)
    at Generator.throw (<anonymous>)
    at rejected (src/failoverProxy.ts:5:3638)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
====== /script/:type/:payload/utxos: gives us the UTXOs./script/:type/:payload/utxos gives us the UTXOs ======
Error: Error connecting to known Chronik instances
    at FailoverProxy.<anonymous> (src/failoverProxy.ts:37:32)
    at Generator.throw (<anonymous>)
    at rejected (src/failoverProxy.ts:5:3638)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
====== /ws: connects to the ws./ws connects to the ws ======
Error: Error connecting to known Chronik websockets
    at FailoverProxy.<anonymous> (src/failoverProxy.ts:53:9)
    at Generator.next (<anonymous>)
    at fulfilled (src/failoverProxy.ts:5:3451)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
====== /ws: connects to a working ws in an array of broken ws./ws connects to a working ws in an array of broken ws ======
Error: Error connecting to known Chronik websockets
    at FailoverProxy.<anonymous> (src/failoverProxy.ts:53:9)
    at Generator.next (<anonymous>)
    at fulfilled (src/failoverProxy.ts:5:3451)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

Each failure log is accessible here:
/blockchain-info: gives us the blockchain info./blockchain-info gives us the blockchain info
/block/:hash: gives us the Genesis block by hash./block/:hash gives us the Genesis block by hash
/block/:hash: gives us the Genesis block by height./block/:hash gives us the Genesis block by height
/blocks/:start/:end: gives us the first few blocks./blocks/:start/:end gives us the first few blocks
/tx/:txid: results in the right tx./tx/:txid results in the right tx
/token/:tokenId: gives us a token./token/:tokenId gives us a token
/validate-utxos: validates the UTXOs./validate-utxos validates the UTXOs
/script/:type/:payload/history: gives us the first page./script/:type/:payload/history gives us the first page
/script/:type/:payload/history: gives us an empty page for ?page=1./script/:type/:payload/history gives us an empty page for ?page=1
/script/:type/:payload/history: gives us just one tx for ?page_size=1./script/:type/:payload/history gives us just one tx for ?page_size=1
/script/:type/:payload/history: gives us the Genesis tx for ?page=1&page_size=1./script/:type/:payload/history gives us the Genesis tx for ?page=1&page_size=1
/script/:type/:payload/utxos: gives us the UTXOs./script/:type/:payload/utxos gives us the UTXOs
/ws: connects to the ws./ws connects to the ws
/ws: connects to a working ws in an array of broken ws./ws connects to a working ws in an array of broken ws