Page MenuHomePhabricator

[chronik] Electrum: add the blockchain.headers.subscribe endpoint
ClosedPublic

Authored by Fabien on Mon, May 12, 15:40.

Details

Summary

Subscribe to get the new header when a block is connected.

This requires karyon version 0.2.2 so we can inject our own custom notification encoding function.
The format has been fixed since D18068.

Test Plan
./test/functional/test_runner.py chronik_electrum_*

In terminal 1:

./src/bitcoind -regtest -debug=chronik -chronik -chronikscripthashindex -chronikelectrumbind="127.0.0.1:50001"

In terminal 2 (can be done in several terminals):

echo '{"jsonrpc": "2.0", "method": "blockchain.headers.subscribe", "params": [], "id": "test"}' | nc 127.0.0.1 50001 | jq

in terminal 3:

./src/bitcoin-cli -regtest createwallet regtest
./src/bitcoin-cli -regtest -generate 1

Event Timeline

Fabien requested review of this revision.Mon, May 12, 15:40

Tail of the build log:

      groups: "a"
      data: "abc"
    }
  }
}
time_first_seen: 1747065062
size: 178
])
2025-05-12T15:51:03.059000Z TestFramework (INFO): Stopping nodes
2025-05-12T15:51:03.163000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/chronik-client-integration-tests/test/tmp/test_runner_₿₵_🏃_20250512_155101_7290/setup_scripts/chronik-client_plugins_0
2025-05-12T15:51:03.163000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/chronik-client-integration-tests/test/tmp/test_runner_₿₵_🏃_20250512_155101_7290/setup_scripts/chronik-client_plugins_0/test_framework.log
2025-05-12T15:51:03.163000Z TestFramework (ERROR): 
2025-05-12T15:51:03.164000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/chronik-client-integration-tests/test/tmp/test_runner_₿₵_🏃_20250512_155101_7290/setup_scripts/chronik-client_plugins_0' to consolidate all logs
2025-05-12T15:51:03.164000Z TestFramework (ERROR): 
2025-05-12T15:51:03.165000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2025-05-12T15:51:03.165000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2025-05-12T15:51:03.166000Z TestFramework (ERROR): 
Running Unit Tests for Test Framework Modules
setup_scripts/chronik-client_plugins.py started
setup_scripts/chronik-client_plugins.py failed, Duration: 2 s

stdout:

stderr:


TEST                                    | STATUS    | DURATION

setup_scripts/chronik-client_plugins.py | ✖ Failed  | 2 s

ALL                                     | ✖ Failed  | 2 s (accumulated) 
Runtime: 2 s

Test runner for chronik-client_plugins completed with code 1
----------------------|---------|----------|---------|---------|------------------------------------
File                  | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                  
----------------------|---------|----------|---------|---------|------------------------------------
All files             |   30.98 |    12.36 |   27.88 |   30.98 |                                    
 chronik-client       |     100 |      100 |     100 |     100 |                                    
  index.ts            |     100 |      100 |     100 |     100 |                                    
 chronik-client/proto |   23.53 |     9.16 |   17.05 |   23.74 |                                    
  chronik.ts          |   23.53 |     9.16 |   17.05 |   23.74 | ...4,6520-6523,6529-6571,6607-6616 
 chronik-client/src   |   63.59 |    48.82 |   59.86 |   63.16 |                                    
  ChronikClient.ts    |   55.77 |    47.54 |   56.63 |   56.18 | ...2,1463-1471,1479-1544,1552-1557 
  failoverProxy.ts    |   79.09 |    58.06 |   69.23 |    78.5 | ...282-285,288,301,308,312,317,321 
  hex.ts              |   89.47 |       50 |      75 |   87.87 | 58,66-68                           
  validation.ts       |    75.6 |       40 |      75 |   72.97 | 17,21,33,38-49,62-63               
----------------------|---------|----------|---------|---------|------------------------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='996']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='3214']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='260']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='2102']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='162']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='581']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='984']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='3176']
##teamcity[blockClosed name='Code Coverage Summary']
Build chronik-client-integration-tests failed with exit code 1
PiRK added a subscriber: PiRK.

looks good. Tested on mainnet, results are identical to electrum.bitcoinabc.org

This revision is now accepted and ready to land.Mon, May 12, 18:42
This revision was landed with ongoing or failed builds.Mon, May 12, 22:24
This revision was automatically updated to reflect the committed changes.