Page MenuHomePhabricator

[alias-server] Add function to get only unprocessed txs from chronik tx history
ClosedPublic

Authored by bytesofman on Mar 14 2023, 14:32.

Details

Summary

T2966

Depends on D13329

Add new getUnprocessedTxHistory function using previously introduced processedBlockheight and processedTxCount parameters.

Most of the time, getting the most recent page of chronik tx history will be enough. However there is a complicated edge case when more than 25 txs need to be fetched.

Test Plan

node index.js, register new aliases and send non alias txs to alias registration address, see that unprocessed txs are picked up when the next block is found and logged

Review new unit tests and npm test
Change config.txHistoryPageSize to some value > 11 and npm test again. Tests still pass.
(Note that 2 unit tests are hardcoded to not require additional pages of data based on available mocks data of 11 unconfirmed and then confirmed txs).

Diff Detail

Repository
rABC Bitcoin ABC
Branch
alias-server-incremental-tx-history
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 22459
Build 44543: Build Diff
Build 44542: arc lint + arc unit

Event Timeline

This function needs to be modified so that brutal unit tests may be added. Due to its dependency on changing state of the blockchain, and complication of mocking chronik API responses, function will probably require manual modification to allow it to accept mocks as input parameters.

Unit tests for getUnprocessedTxHistory

Okay. Here are some preliminary unit tests for getUnprocessedTxHistory.

Ultimately this is an array manipulation problem with some important assumptions about chronik performance. One assumption is that chronik will never return a partial tx history, i.e. after a block is found, chronik will always return all of the txs at the registration address from that block.

Because "real" mocks for this unit test would be 100s of mb, I do not think it would be appropriate to include them in the repo. However, a future optimization is a new script to run tests locally using the API.

This revision is now accepted and ready to land.Mar 15 2023, 11:26