Repository navigation
fix(hf16): native block units — nothing is multiplied anywhere - #285
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
x3scaling was a compensation layer: compile-time constants were 3-second numbers, so consensus logic (missed-block thresholds, undo window, hourly cadence) andget_configeach 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 withinflation_recalc_period = 806400anddistribution_epoch_length = 28800at 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:
CHAIN_BLOCKS_PER_DAY/_PER_HOURCHAIN_BLOCK_INTERVALCHAIN_BLOCK_INTERVAL_HF16CHAIN_MAX_VALIDATOR_MISSED_BLOCKSCHAIN_EMERGENCY_MAX_VALIDATOR_MISSED_BLOCKSCHAIN_MAX_UNDO_HISTORYpm_batch_epoch_blocks/pm_reveal_window_blocksCONSENSUS_VALIDATOR_MISS_PENALTY_DURATIONblocks*intervalThen every runtime multiplier in
database.cpp(5 sites) and every multiply inget_configare gone.get_confignow 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
-fsyntax-onlyonget_config.cpp,database.cpp,chain_operations.cppand the updated test: all clean (database.cpp carries one pre-existing sign-compare warning, unrelated).test_hf16_boundary.cppupdated to assert the new invariant: the operation default, the value reported byget_config, and the stored value are the same numbers — no hidden×3.Behaviour notes
chain_properties_updatewith explicit values (blocked on thehub.viz.worldactive 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.