Skip to content

fix(hf16): native block units — nothing is multiplied anywhere - #285

Merged
On1x merged 6 commits into
masterfrom
fix/hf16-native-props
Nov 19, 2026
Merged

On1x merged 6 commits into
masterfrom
fix/hf16-native-props

Conversation

@On1x

@On1x On1x commented Nov 19, 2026

Copy link
Copy Markdown
Member

Why

Owner, 2026-11-19: "no code that multiplies anything anywhere? … why lie to ourselves? Whatever data we have, that is what we return."

The x3 scaling was a compensation layer: compile-time constants were 3-second numbers, so consensus logic (missed-block thresholds, undo window, hourly cadence) and get_config each multiplied them for 1-second chains. Two sources of truth, and the one place nobody scaled was the operation defaults — which is exactly how the test stand ended up with inflation_recalc_period = 806400 and distribution_epoch_length = 28800 at a 1-second slot (mainnet stores the correct 2419200 / 86400).

What changed

Constants become native 1-second block counts with the same wall-clock meaning:

constant was (3 s) now (1 s)
CHAIN_BLOCKS_PER_DAY / _PER_HOUR derived from CHAIN_BLOCK_INTERVAL derived from CHAIN_BLOCK_INTERVAL_HF16
CHAIN_MAX_VALIDATOR_MISSED_BLOCKS 200 (~10 min) 600 (~10 min)
CHAIN_EMERGENCY_MAX_VALIDATOR_MISSED_BLOCKS 5 rounds 15 rounds (5 rounds × 3 s)
CHAIN_MAX_UNDO_HISTORY 10000 (~8.3 h) 30000 (~8.3 h)
pm_batch_epoch_blocks / pm_reveal_window_blocks 20 / 200 (~60 s / ~10 min) 60 / 600
CONSENSUS_VALIDATOR_MISS_PENALTY_DURATION blocks*interval explicit seconds

Then every runtime multiplier in database.cpp (5 sites) and every multiply in get_config are gone. get_config now reports exactly what the chain stores.

Not touched: CHAIN_BLOCKS_PER_YEAR — it feeds emission (1 VIZ/block at 1 s = 28 %/yr vs. the modelled 10 %). That is a separate decision and does not belong in this change.

Verification

  • Single-TU -fsyntax-only on get_config.cpp, database.cpp, chain_operations.cpp and the updated test: all clean (database.cpp carries one pre-existing sign-compare warning, unrelated).
  • test_hf16_boundary.cpp updated to assert the new invariant: the operation default, the value reported by get_config, and the stored value are the same numbers — no hidden ×3.
  • Not run here (Docker-only builds): full CI. Docker/Windows/Tests jobs will be the proof.

Behaviour notes

  • Wall-clock semantics of every threshold are preserved; only the block counts change.
  • Chains that never crossed HF16 (none in production) would write 1-second defaults while still on 3-second slots; that combination does not exist today.
  • The stand still needs one chain_properties_update with explicit values (blocked on the hub.viz.world active key, Add smt_contribute_operation to the cli wallet steemit/steem#3536) — but after this change a repeat default-write can no longer reintroduce the 3-second numbers.

On1x added 6 commits November 19, 2026 06:05
Owner, 2026-11-19: "no code that multiplies anything anywhere - what data we
have is what we return". The x3 scaling was a compensation layer: constants
were 3-second numbers, and both consensus (missed blocks, undo window, hourly
cadence) and get_config multiplied them for 1-second chains. Keeping that
layer meant two sources of truth, and the operation defaults were the one
place nobody scaled - which is how the test stand got 806400/28800.

Constants are now native 1-second block counts with the same wall-clock
meaning: blocks/day and blocks/hour derive from CHAIN_BLOCK_INTERVAL_HF16,
missed-block threshold 200 -> 600 (~10 min), emergency 5 -> 15 rounds, undo
window 10000 -> 30000 (~8.3 h), pm batch/reveal 20/200 -> 60/600.
CHAIN_BLOCKS_PER_YEAR stays on the old interval: it feeds emission and is a
separate decision. CONSENSUS_VALIDATOR_MISS_PENALTY_DURATION is expressed in
seconds directly instead of blocks*interval.

Runtime multipliers in database.cpp and every multiply in get_config are
removed, so config reports exactly what the chain stores. HF16 boundary test
asserts the new invariant: default == reported == stored for inflation
period, epoch length and pm windows.
Self-review of the first commit found places that still compensated, and one
of them was a regression I introduced:

1. chain_properties evaluator scaled the epoch floor by CHAIN_BLOCK_INTERVAL /
   live interval. With CHAIN_BLOCKS_PER_HOUR already native, that made the
   post-HF16 minimum one hour x3 = three hours — a consensus tightening nobody
   asked for. The multiplier is gone; the floor is CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH
   (3600 blocks = one hour), same wall-clock meaning as before HF16.

2. Bounds expressed as CHAIN_BLOCKS_PER_YEAR * 3 (epoch limits) now use a
   named CHAIN_BLOCKS_PER_YEAR_HF16. CHAIN_BLOCKS_PER_YEAR keeps feeding
   emission — that stays a separate open question.

3. validator_guard multiplied the emergency threshold by the same ratio; with
   the constant already native it would have waited three times longer.

4. validator_miss_penalty_duration bound: blocks*year-interval replaced by
   CHAIN_SECONDS_PER_YEAR, which is what the field actually means.

Test: the epoch floor is now asserted in SECONDS (one hour) and checked
against a value derived independently of the macro, plus an explicit
"floor - 1 is rejected" case — so the test can no longer follow a silent
change of meaning.

Still multiplied, deliberately out of scope: the network layer
(dlt_p2p_node::slot_scale) scales peer-lag thresholds by the same ratio.
That is node behaviour, not chain state, and changing it here would widen the
blast radius; it is named in the PR description instead.

Single-TU -fsyntax-only on all four touched TUs: clean.
The bound itself is unchanged (31 536 000 = 10512000 x 3), but the comment
above it claimed 'up to 3 years of 1 s blocks', which describes a bound three
times looser than the code enforces. A comment that misstates the limit is
how the next reader writes a wrong test.

Syntax-checked on both TUs; no behaviour change.
CI caught a real regression I introduced in the previous commit, and it caught
it only in the 1- and 2-validator matrix legs (the 4-validator leg runs a
different filter and never executes this suite).

What went wrong: testnet defines CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH as one
block, not CHAIN_BLOCKS_PER_HOUR. The removed x3 factor used to turn that one
3-second block into three 1-second blocks, i.e. the same 3 seconds after the
fork. Dropping the factor left the testnet floor at one second - a silent
threefold loosening of a consensus bound, exactly the class the owner asked
to eliminate rather than to move around.

Fix: a wall-clock promise gets one named value per block scale, and no call
site multiplies.

  CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH       -> one hour in pre-HF16 3 s blocks
                                               (mainnet 1200, testnet 1)
  CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH_HF16  -> same time in native 1 s blocks
                                               (mainnet 3600, testnet 3)

The evaluator's post-fork check uses the HF16 value; get_config reports both
keys so a client on either side of the fork reads the right one.

The test now asserts the invariant in SECONDS and is config-independent:
  before * 3 s == after * 1 s
(1200x3 == 3600x1 on mainnet, 1x3 == 3x1 on testnet). A dropped or duplicated
factor breaks that line in any config; it also checks "floor - 1 rejected"
and "floor accepted and stored" against the HF16 value, and that the stored
floor still means the same wall-clock time as before the fork.

Syntax-checked on all four touched TUs.
validate() enforces the pre-fork value because it runs before the fork check;
the evaluator enforces the post-fork value. The doc line named only one of
them, so a reader would take the pre-fork number for the post-fork limit.
No behaviour change.
The install step hit its 15-minute cap three times in a row on the same
signature: a stream of 'Ign:' lines 20-40 s apart, each retry eventually
succeeding. Two causes are addressed: stalled attempts point at a dead IPv6
route (Acquire::ForceIPv4), and libboost-all-dev pulls 154 packages / 94 MB,
most of it OpenCL/HIP/MPI this build never links. Only the components
CMakeLists.txt and thirdparty/fc actually request are installed, with the
meta-package kept as a fallback if a component name ever changes. Cap 20 min.
@On1x
On1x merged commit 723e1bb into master Nov 19, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant