Page MenuHomePhabricator

[Cashtab] Implement latest chronik-client
ClosedPublic

Authored by bytesofman on Dec 29 2023, 21:42.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Commits
rABC163de5aca435: [Cashtab] Implement latest chronik-client
Summary

Implement updated chronik-client in Cashtab

Cashtab implemented backend switching before it was integrated in the library. Deprecate Cashtab's switching mechanism and rely on the library.

Note there is an expected behavior change in Cashtab from this implementation. Previously, Cashtab would cycle through available chronik instances perpetually until one connected. Now, once all instances fail, the app will not reconnect unless it is refreshed.

Test Plan

npm test

npm start and send some transactions

Change the url array in config.chronik to have some bad urls, verify they autoswitch

Change wallets and send txs, verify notifications work

Diff Detail

Repository
rABC Bitcoin ABC
Branch
cashtab-chronik-update
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 26223
Build 52018: Build Diffcashtab-tests
Build 52017: arc lint + arc unit

Event Timeline

Tail of the build log:

/work/cashtab /work/abc-ci-builds/cashtab-tests
npm WARN deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.
npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
npm WARN deprecated rollup-plugin-terser@7.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser
npm WARN deprecated text-encoding@0.6.4: no longer maintained
npm WARN deprecated ts-custom-error@2.2.2: npm package tarball contains useless codeclimate-reporter binary, please update to version 3.1.1. See https://github.com/adriengibrat/ts-custom-error/issues/32

added 1714 packages, and audited 1716 packages in 23s

236 packages are looking for funding
  run `npm fund` for details

4 moderate severity vulnerabilities

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.

> cashtab@1.0.0 build
> node scripts/build.js

Creating an optimized production build...
Failed to compile.

Module not found: Error: Can't resolve 'chronik-client' in '/work/cashtab/src/hooks'


Build cashtab-tests failed with exit code 1

update webpack to support latest chronik-client's axios

back out chronik-client changes

Tail of the build log:

  opreturn.js                  |     100 |      100 |     100 |     100 |                                                                                                                                 
  token.js                     |       0 |      100 |     100 |       0 | 7                                                                                                                               
  tokenBlacklist.js            |     100 |      100 |     100 |     100 |                                                                                                                                 
  websocket.js                 |       0 |      100 |     100 |       0 | 8                                                                                                                               
 src/hooks                     |       0 |        0 |       0 |       0 |                                                                                                                                 
  useImage.js                  |       0 |        0 |       0 |       0 | 1-199                                                                                                                           
  useInnerScroll.js            |       0 |      100 |       0 |       0 | 3-6                                                                                                                             
  useInterval.js               |       0 |        0 |       0 |       0 | 6-20                                                                                                                            
  usePrevious.js               |       0 |      100 |       0 |       0 | 3-14                                                                                                                            
  useWallet.js                 |       0 |        0 |       0 |       0 | 51-1540                                                                                                                         
  useWindowDimensions.js       |       0 |      100 |       0 |       0 | 7-28                                                                                                                            
 src/opreturn                  |   96.55 |       88 |     100 |   96.55 |                                                                                                                                 
  index.js                     |   96.55 |       88 |     100 |   96.55 | 147,175                                                                                                                         
 src/opreturn/fixtures         |     100 |      100 |     100 |     100 |                                                                                                                                 
  vectors.js                   |     100 |      100 |     100 |     100 |                                                                                                                                 
 src/slpv1                     |     100 |      100 |     100 |     100 |                                                                                                                                 
  index.js                     |     100 |      100 |     100 |     100 |                                                                                                                                 
 src/slpv1/fixtures            |     100 |      100 |     100 |     100 |                                                                                                                                 
  vectors.js                   |     100 |      100 |     100 |     100 |                                                                                                                                 
 src/transactions              |     100 |      100 |     100 |     100 |                                                                                                                                 
  index.js                     |     100 |      100 |     100 |     100 |                                                                                                                                 
 src/transactions/fixtures     |     100 |      100 |     100 |     100 |                                                                                                                                 
  mocks.js                     |     100 |      100 |     100 |     100 |                                                                                                                                 
  vectors.js                   |     100 |      100 |     100 |     100 |                                                                                                                                 
 src/utils                     |   54.94 |     64.9 |   56.42 |    55.3 |                                                                                                                                 
  GoogleAnalytics.js           |       0 |        0 |       0 |       0 | 6-94                                                                                                                            
  aliasUtils.js                |     100 |    71.42 |     100 |     100 | 31-33                                                                                                                           
  cashMethods.js               |   88.28 |    85.93 |   91.11 |   88.02 | 21,129-131,174-181,265,290,316-323,413,449,469,494-501,599,678-679,714,771,782,950,1001-1013,1044,1064,1073,1096,1140-1192,1345 
  chronik.js                   |       0 |        0 |       0 |       0 | 17-1005                                                                                                                         
  coininfo.js                  |       0 |        0 |       0 |       0 | 4-72                                                                                                                            
  context.js                   |       0 |      100 |       0 |       0 | 5-16                                                                                                                            
  debounce.js                  |       0 |        0 |       0 |       0 | 4-8                                                                                                                             
  ecashCoinInfo.js             |       0 |      100 |     100 |       0 | 10-113                                                                                                                          
  formatting.js                |   77.77 |    83.33 |     100 |   77.77 | 15,25,43,53,68-70,109-111                                                                                                       
  retry.js                     |       0 |        0 |       0 |       0 | 1-8                                                                                                                             
  tokenMethods.js              |     100 |      100 |     100 |     100 |                                                                                                                                 
  transactions.js              |       0 |        0 |       0 |       0 | 11-248                                                                                                                          
  validation.js                |   96.32 |    95.53 |     100 |   96.62 | 49-51,85-86,222,281,328,341                                                                                                     
 src/utils/icons               |       0 |        0 |       0 |       0 |                                                                                                                                 
  cropImage.js                 |       0 |        0 |       0 |       0 | 1-78                                                                                                                            
  resizeImage.js               |       0 |        0 |       0 |       0 | 1-51                                                                                                                            
  roundImage.js                |       0 |        0 |       0 |       0 | 1-57                                                                                                                            
-------------------------------|---------|----------|---------|---------|---------------------------------------------------------------------------------------------------------------------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='921']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='4671']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='464']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='2257']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='107']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='1021']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='903']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='4567']
##teamcity[blockClosed name='Code Coverage Summary']
Test Suites: 6 failed, 10 passed, 16 total
Tests:       457 passed, 457 total
Snapshots:   0 total
Time:        9.854 s
Ran all test suites.
Build cashtab-tests failed with exit code 1

Tail of the build log:

  opreturn.js                  |     100 |      100 |     100 |     100 |                                                                                                                                 
  token.js                     |       0 |      100 |     100 |       0 | 7                                                                                                                               
  tokenBlacklist.js            |     100 |      100 |     100 |     100 |                                                                                                                                 
  websocket.js                 |       0 |      100 |     100 |       0 | 8                                                                                                                               
 src/hooks                     |       0 |        0 |       0 |       0 |                                                                                                                                 
  useImage.js                  |       0 |        0 |       0 |       0 | 1-199                                                                                                                           
  useInnerScroll.js            |       0 |      100 |       0 |       0 | 3-6                                                                                                                             
  useInterval.js               |       0 |        0 |       0 |       0 | 6-20                                                                                                                            
  usePrevious.js               |       0 |      100 |       0 |       0 | 3-14                                                                                                                            
  useWallet.js                 |       0 |        0 |       0 |       0 | 51-1540                                                                                                                         
  useWindowDimensions.js       |       0 |      100 |       0 |       0 | 7-28                                                                                                                            
 src/opreturn                  |   96.55 |       88 |     100 |   96.55 |                                                                                                                                 
  index.js                     |   96.55 |       88 |     100 |   96.55 | 147,175                                                                                                                         
 src/opreturn/fixtures         |     100 |      100 |     100 |     100 |                                                                                                                                 
  vectors.js                   |     100 |      100 |     100 |     100 |                                                                                                                                 
 src/slpv1                     |     100 |      100 |     100 |     100 |                                                                                                                                 
  index.js                     |     100 |      100 |     100 |     100 |                                                                                                                                 
 src/slpv1/fixtures            |     100 |      100 |     100 |     100 |                                                                                                                                 
  vectors.js                   |     100 |      100 |     100 |     100 |                                                                                                                                 
 src/transactions              |     100 |      100 |     100 |     100 |                                                                                                                                 
  index.js                     |     100 |      100 |     100 |     100 |                                                                                                                                 
 src/transactions/fixtures     |     100 |      100 |     100 |     100 |                                                                                                                                 
  mocks.js                     |     100 |      100 |     100 |     100 |                                                                                                                                 
  vectors.js                   |     100 |      100 |     100 |     100 |                                                                                                                                 
 src/utils                     |   54.94 |     64.9 |   56.42 |    55.3 |                                                                                                                                 
  GoogleAnalytics.js           |       0 |        0 |       0 |       0 | 6-94                                                                                                                            
  aliasUtils.js                |     100 |    71.42 |     100 |     100 | 31-33                                                                                                                           
  cashMethods.js               |   88.28 |    85.93 |   91.11 |   88.02 | 21,129-131,174-181,265,290,316-323,413,449,469,494-501,599,678-679,714,771,782,950,1001-1013,1044,1064,1073,1096,1140-1192,1345 
  chronik.js                   |       0 |        0 |       0 |       0 | 17-1005                                                                                                                         
  coininfo.js                  |       0 |        0 |       0 |       0 | 4-72                                                                                                                            
  context.js                   |       0 |      100 |       0 |       0 | 5-16                                                                                                                            
  debounce.js                  |       0 |        0 |       0 |       0 | 4-8                                                                                                                             
  ecashCoinInfo.js             |       0 |      100 |     100 |       0 | 10-113                                                                                                                          
  formatting.js                |   77.77 |    83.33 |     100 |   77.77 | 15,25,43,53,68-70,109-111                                                                                                       
  retry.js                     |       0 |        0 |       0 |       0 | 1-8                                                                                                                             
  tokenMethods.js              |     100 |      100 |     100 |     100 |                                                                                                                                 
  transactions.js              |       0 |        0 |       0 |       0 | 11-248                                                                                                                          
  validation.js                |   96.32 |    95.53 |     100 |   96.62 | 49-51,85-86,222,281,328,341                                                                                                     
 src/utils/icons               |       0 |        0 |       0 |       0 |                                                                                                                                 
  cropImage.js                 |       0 |        0 |       0 |       0 | 1-78                                                                                                                            
  resizeImage.js               |       0 |        0 |       0 |       0 | 1-51                                                                                                                            
  roundImage.js                |       0 |        0 |       0 |       0 | 1-57                                                                                                                            
-------------------------------|---------|----------|---------|---------|---------------------------------------------------------------------------------------------------------------------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='921']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='4671']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='464']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='2257']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='107']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='1021']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='903']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='4567']
##teamcity[blockClosed name='Code Coverage Summary']
Test Suites: 6 failed, 10 passed, 16 total
Tests:       457 passed, 457 total
Snapshots:   0 total
Time:        9.846 s
Ran all test suites.
Build cashtab-tests failed with exit code 1

Failed tests logs:

====== /blockchain-info: "before each" hook for "gives us the blockchain info"./blockchain-info "before each" hook for "gives us the blockchain info" ======
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/work/modules/chronik-client/test/integration/blockchain_info.ts)
    at listOnTimeout (node:internal/timers:559:17)
    at processTimers (node:internal/timers:502:7)

Each failure log is accessible here:
/blockchain-info: "before each" hook for "gives us the blockchain info"./blockchain-info "before each" hook for "gives us the blockchain info"

bytesofman retitled this revision from [Cashtab + chronik-client] Testing ws ping to [Cashtab] Implement latest chronik-client.Jan 4 2024, 05:16
bytesofman edited the summary of this revision. (Show Details)
bytesofman edited the test plan for this revision. (Show Details)

rebase, troubleshoot some unit tests

Failed tests logs:

====== CashTab Unit Tests:  Verify handleUpdateWallet() correctly initializes the active wallet ======
Error: expect(received).toBe(expected) // Object.is equality

Expected: true
Received: false
    at Object.<anonymous> (/work/cashtab/src/hooks/__tests__/useWallet.test.js:63:45)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
====== CashTab Unit Tests:  Verify processChronikWsMsg() processes AddedToMempool events ======
Error: expect(received).not.toBe(expected) // Object.is equality

Expected: not false
    at Object.<anonymous> (/work/cashtab/src/hooks/__tests__/useWallet.test.js:75:29)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Each failure log is accessible here:
CashTab Unit Tests: Verify handleUpdateWallet() correctly initializes the active wallet
CashTab Unit Tests: Verify processChronikWsMsg() processes AddedToMempool events

Failed tests logs:

====== CashTab Unit Tests:  Verify handleUpdateWallet() correctly initializes the active wallet ======
Error: expect(received).toBe(expected) // Object.is equality

Expected: true
Received: false
    at Object.<anonymous> (/work/cashtab/src/hooks/__tests__/useWallet.test.js:63:45)
    at runNextTicks (node:internal/process/task_queues:61:5)
    at processImmediate (node:internal/timers:437:9)
====== CashTab Unit Tests:  Verify processChronikWsMsg() processes AddedToMempool events ======
Error: expect(received).not.toBe(expected) // Object.is equality

Expected: not false
    at Object.<anonymous> (/work/cashtab/src/hooks/__tests__/useWallet.test.js:75:29)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Each failure log is accessible here:
CashTab Unit Tests: Verify handleUpdateWallet() correctly initializes the active wallet
CashTab Unit Tests: Verify processChronikWsMsg() processes AddedToMempool events

bytesofman edited the test plan for this revision. (Show Details)
bytesofman published this revision for review.Jan 9 2024, 20:08
bytesofman edited the test plan for this revision. (Show Details)
bytesofman added inline comments.
cashtab/src/components/Common/ApiError.js
10

image.png (197×440 px, 11 KB)

emack requested changes to this revision.EditedJan 10 2024, 03:46
emack added a subscriber: emack.

When you malform all 3 chronik urls, it gives you a rather ungraceful uncaught exception per below, traced back to the update() function in useWallet.js

image.png (737×1 px, 194 KB)

However it does stop cycling after all urls have been exhausted and refreshing upon correction of urls fixes it as intended.

This revision now requires changes to proceed.Jan 10 2024, 03:46

add try...catch around ws connection

Accepted with minor nit - from a BAU perspective, it would be useful to log "Connected to blah.chronik.cash" in the console logs. Just in case there are performance issues or anything unexpected with the instance even though it is responsive.

This revision is now accepted and ready to land.Jan 11 2024, 00:51

Accepted with minor nit - from a BAU perspective, it would be useful to log "Connected to blah.chronik.cash" in the console logs. Just in case there are performance issues or anything unexpected with the instance even though it is responsive.

We currently have this on websocket connection:

image.png (257×485 px, 34 KB)