HomePhabricator

rpc: Avoid getchaintxstats invalid results

Description

rpc: Avoid getchaintxstats invalid results

Summary:
The getchaintxstats RPC reply during AU background download may return non-zero, but invalid, values for window_tx_count and txrate.

For example, txcount may be zero for a to-be-downloaded block, but may be non-zero for an ancestor block which is already downloaded. Thus, the values returned may be negative (and cause intermediate integer sanitizer violations).

Also, txcount may be accurate for the snapshot base block, or a descendant of it. However it may be zero for an ancestor block that still needs to be downloaded. Thus, the values returned may be positive, but wrong.

Fix all issues by skipping the returned value if either txcount is unset (equal to zero).
Also, skip txcount in the returned value, if it is unset (equal to zero).

This is a backport of core#29720

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D18053

Details

Provenance
MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>Authored on Mar 25 2024, 10:33
PiRKCommitted on Tue, May 6, 16:19
PiRKPushed on Tue, May 6, 16:19
Reviewer
Restricted Project
Differential Revision
D18053: rpc: Avoid getchaintxstats invalid results
Parents
rABC5c43c94353ca: test: add a --repeat argument to test_runner.py
Branches
Unknown
Tags
Unknown
References
HEAD -> master