Page MenuHomePhabricator

add a finalized_blockhash field to getblockchaininfo
ClosedPublic

Authored by PiRK on Sep 2 2025, 13:53.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC5269601c18c2: add a finalized_blockhash field to getblockchaininfo
Summary

This will be useful to automate checkpoints and UTXO snapshots based on the current finalized tip. Using the non-finalized tip for this purpose is risky as it could be reorged or parked.

Test Plan

ninja all check-all

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Failed tests logs:

====== Bitcoin ABC functional tests: abc_p2p_avalanche_voting.py ======

------- Stdout: -------
2025-09-02T13:57:37.279000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-without-wallet/test/tmp/test_runner_โ‚ฟโ‚ต_๐Ÿƒ_20250902_135735_22950/abc_p2p_avalanche_voting_4
2025-09-02T13:57:44.057000Z TestFramework (INFO): Poll for the chain tip...
2025-09-02T13:57:44.113000Z TestFramework (INFO): Poll for a selection of blocks...
2025-09-02T13:57:44.171000Z TestFramework (INFO): Poll for a selection of blocks, but some are now invalid...
2025-09-02T13:57:44.312000Z TestFramework (INFO): Poll for unknown blocks...
2025-09-02T13:57:44.369000Z TestFramework (INFO): Trigger polling from the node...
2025-09-02T13:57:44.813000Z TestFramework (INFO): Answer all polls to finalize...
2025-09-02T13:57:44.814000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 152, in main
    self._run_test_internal()
  File "/work/test/functional/test_framework/test_framework.py", line 142, in _run_test_internal
    self.run_test()
  File "/work/test/functional/abc_p2p_avalanche_voting.py", line 204, in run_test
    assert_equal(node.getblockchaininfo()["finalized_blocks"], -1)
  File "/work/test/functional/test_framework/util.py", line 59, in assert_equal
    raise AssertionError(
AssertionError: not(16 == -1)
2025-09-02T13:57:44.865000Z TestFramework (INFO): Stopping nodes
2025-09-02T13:57:45.017000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-without-wallet/test/tmp/test_runner_โ‚ฟโ‚ต_๐Ÿƒ_20250902_135735_22950/abc_p2p_avalanche_voting_4
2025-09-02T13:57:45.017000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-without-wallet/test/tmp/test_runner_โ‚ฟโ‚ต_๐Ÿƒ_20250902_135735_22950/abc_p2p_avalanche_voting_4/test_framework.log
2025-09-02T13:57:45.017000Z TestFramework (ERROR): 
2025-09-02T13:57:45.018000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-without-wallet/test/tmp/test_runner_โ‚ฟโ‚ต_๐Ÿƒ_20250902_135735_22950/abc_p2p_avalanche_voting_4' to consolidate all logs
2025-09-02T13:57:45.018000Z TestFramework (ERROR): 
2025-09-02T13:57:45.018000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2025-09-02T13:57:45.018000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2025-09-02T13:57:45.018000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests: abc_p2p_avalanche_voting.py

Failed tests logs:

====== Bitcoin ABC functional tests: abc_p2p_avalanche_voting.py ======

------- Stdout: -------
2025-09-02T14:00:37.205000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-debug/test/tmp/test_runner_โ‚ฟโ‚ต_๐Ÿƒ_20250902_140034_10769/abc_p2p_avalanche_voting_4
2025-09-02T14:00:51.175000Z TestFramework (INFO): Poll for the chain tip...
2025-09-02T14:00:51.233000Z TestFramework (INFO): Poll for a selection of blocks...
2025-09-02T14:00:51.294000Z TestFramework (INFO): Poll for a selection of blocks, but some are now invalid...
2025-09-02T14:00:51.893000Z TestFramework (INFO): Poll for unknown blocks...
2025-09-02T14:00:51.950000Z TestFramework (INFO): Trigger polling from the node...
2025-09-02T14:00:53.021000Z TestFramework (INFO): Answer all polls to finalize...
2025-09-02T14:00:53.022000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 152, in main
    self._run_test_internal()
  File "/work/test/functional/test_framework/test_framework.py", line 142, in _run_test_internal
    self.run_test()
  File "/work/test/functional/abc_p2p_avalanche_voting.py", line 204, in run_test
    assert_equal(node.getblockchaininfo()["finalized_blocks"], -1)
  File "/work/test/functional/test_framework/util.py", line 59, in assert_equal
    raise AssertionError(
AssertionError: not(16 == -1)
2025-09-02T14:00:53.073000Z TestFramework (INFO): Stopping nodes
2025-09-02T14:00:53.226000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-debug/test/tmp/test_runner_โ‚ฟโ‚ต_๐Ÿƒ_20250902_140034_10769/abc_p2p_avalanche_voting_4
2025-09-02T14:00:53.226000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-debug/test/tmp/test_runner_โ‚ฟโ‚ต_๐Ÿƒ_20250902_140034_10769/abc_p2p_avalanche_voting_4/test_framework.log
2025-09-02T14:00:53.226000Z TestFramework (ERROR): 
2025-09-02T14:00:53.226000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-debug/test/tmp/test_runner_โ‚ฟโ‚ต_๐Ÿƒ_20250902_140034_10769/abc_p2p_avalanche_voting_4' to consolidate all logs
2025-09-02T14:00:53.226000Z TestFramework (ERROR): 
2025-09-02T14:00:53.227000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2025-09-02T14:00:53.227000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2025-09-02T14:00:53.227000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests: abc_p2p_avalanche_voting.py

Failed tests logs:

====== Bitcoin ABC functional tests: abc_p2p_avalanche_voting.py ======

------- Stdout: -------
2025-09-02T14:04:49.691000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-diff/test/tmp/test_runner_โ‚ฟโ‚ต_๐Ÿƒ_20250902_140447_3798/abc_p2p_avalanche_voting_4
2025-09-02T14:05:01.389000Z TestFramework (INFO): Poll for the chain tip...
2025-09-02T14:05:01.506000Z TestFramework (INFO): Poll for a selection of blocks...
2025-09-02T14:05:01.516000Z TestFramework (INFO): Poll for a selection of blocks, but some are now invalid...
2025-09-02T14:05:01.857000Z TestFramework (INFO): Poll for unknown blocks...
2025-09-02T14:05:01.866000Z TestFramework (INFO): Trigger polling from the node...
2025-09-02T14:05:02.519000Z TestFramework (INFO): Answer all polls to finalize...
2025-09-02T14:05:02.519000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 152, in main
    self._run_test_internal()
  File "/work/test/functional/test_framework/test_framework.py", line 142, in _run_test_internal
    self.run_test()
  File "/work/test/functional/abc_p2p_avalanche_voting.py", line 204, in run_test
    assert_equal(node.getblockchaininfo()["finalized_blocks"], -1)
  File "/work/test/functional/test_framework/util.py", line 59, in assert_equal
    raise AssertionError(
AssertionError: not(16 == -1)
2025-09-02T14:05:02.571000Z TestFramework (INFO): Stopping nodes
2025-09-02T14:05:02.673000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-diff/test/tmp/test_runner_โ‚ฟโ‚ต_๐Ÿƒ_20250902_140447_3798/abc_p2p_avalanche_voting_4
2025-09-02T14:05:02.673000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-diff/test/tmp/test_runner_โ‚ฟโ‚ต_๐Ÿƒ_20250902_140447_3798/abc_p2p_avalanche_voting_4/test_framework.log
2025-09-02T14:05:02.674000Z TestFramework (ERROR): 
2025-09-02T14:05:02.674000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-diff/test/tmp/test_runner_โ‚ฟโ‚ต_๐Ÿƒ_20250902_140447_3798/abc_p2p_avalanche_voting_4' to consolidate all logs
2025-09-02T14:05:02.674000Z TestFramework (ERROR): 
2025-09-02T14:05:02.674000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2025-09-02T14:05:02.674000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2025-09-02T14:05:02.674000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests: abc_p2p_avalanche_voting.py

don't accidentaly finalize blocks when accepting proofs

PiRK published this revision for review.Sep 2 2025, 17:48
Fabien requested changes to this revision.Sep 2 2025, 19:00
Fabien added a subscriber: Fabien.

I would rather create another simple rpc test file instead of using the avalanche voting one. This makes the test harder to maintain especially since it has to keep the block count up to date

src/rpc/blockchain.cpp
1356 โ†—(On Diff #55461)

I don't think this is a good name, nowhere it implies it's a height.
Also you'd better use the finalized tip hash instead of height (or maybe have both hash and height) as hash is less ambiguous and easier to query via getblock

This revision now requires changes to proceed.Sep 2 2025, 19:00
PiRK retitled this revision from add a finalized_blocks field to getblockchaininfo to add a finalized_blockhash field to getblockchaininfo.

return the genesis hash in case there is no final block

fix copyright year for new test

Fabien added inline comments.
test/functional/abc_rpc_getblockchaininfo_avalanche_finalized.py
103 โ†—(On Diff #55507)
This revision is now accepted and ready to land.Sep 8 2025, 07:14