diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 948a070a44..e9fe99a8a9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -108,17 +108,26 @@ jobs: # and when that mirror goes quiet apt retries it until the job's 180-minute timeout # instead of failing (seen 2026-08-19; the guarded form had been added everywhere # except here, the one job that runs on every code PR and every master push). - timeout-minutes: 15 + # 2026-11-19: same fix as the testnet arms below — ForceIPv4 (stalled attempts on a + # dead IPv6 route showed up as `Ign:` lines 20-40 s apart) and only the Boost + # components the build requests instead of the 154-package meta-package. + timeout-minutes: 20 run: | set -euo pipefail sudo sed -i 's|azure.archive.ubuntu.com|archive.ubuntu.com|g' \ /etc/apt/apt-mirrors.txt /etc/apt/sources.list 2>/dev/null || true - apt="sudo apt-get -o Acquire::Retries=3 -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20" + apt="sudo apt-get -o Acquire::Retries=3 -o Acquire::ForceIPv4=true -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20" $apt update $apt install -y --no-install-recommends \ - build-essential ccache cmake libboost-all-dev libssl-dev \ + build-essential ccache cmake libssl-dev \ libbz2-dev liblzma-dev libzstd-dev libreadline-dev \ libtool ncurses-dev pkg-config zlib1g-dev + $apt install -y --no-install-recommends \ + libboost-thread-dev libboost-date-time-dev libboost-filesystem-dev \ + libboost-program-options-dev libboost-serialization-dev libboost-chrono-dev \ + libboost-test-dev libboost-context-dev libboost-locale-dev libboost-coroutine-dev \ + libboost-iostreams-dev libboost-regex-dev \ + || $apt install -y --no-install-recommends libboost-all-dev # ccache >= 4 keeps its cache in ~/.cache/ccache, not ~/.ccache, so the old path # never existed and nothing was ever saved ("Path Validation Error"). Pin the @@ -200,17 +209,32 @@ jobs: # Runners fetch packages from azure.archive.ubuntu.com; when that mirror goes quiet # apt keeps retrying it and the job hangs for hours instead of failing (seen # 2026-08-19). Pin the canonical mirror, bound the wait, and cap the step. - timeout-minutes: 15 + # 2026-11-19: the 15-minute cap was hit three times in a row on the same signature — + # a stream of `Ign:` lines 20-40 s apart where the retry then succeeded. Two causes + # are addressed here: stalled attempts usually mean a dead IPv6 route (ForceIPv4), + # and `libboost-all-dev` pulls 154 packages / 94 MB, most of it OpenCL/HIP/MPI that + # this build never links. Only the components CMakeLists actually requests are + # installed, with the meta-package kept as a fallback if a component is ever renamed. + timeout-minutes: 20 run: | set -euo pipefail sudo sed -i 's|azure.archive.ubuntu.com|archive.ubuntu.com|g' \ /etc/apt/apt-mirrors.txt /etc/apt/sources.list 2>/dev/null || true - apt="sudo apt-get -o Acquire::Retries=3 -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20" + apt="sudo apt-get -o Acquire::Retries=3 -o Acquire::ForceIPv4=true -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20" $apt update $apt install -y --no-install-recommends \ - build-essential ccache cmake libboost-all-dev libssl-dev \ + build-essential ccache cmake libssl-dev \ libbz2-dev liblzma-dev libzstd-dev libreadline-dev \ libtool ncurses-dev pkg-config zlib1g-dev + # Mirrors the components the build actually requests: BOOST_COMPONENTS in CMakeLists.txt + # (thread date_time filesystem program_options serialization chrono unit_test_framework + # context locale coroutine), plus iostreams (thirdparty/fc) and regex (cli_wallet). + $apt install -y --no-install-recommends \ + libboost-thread-dev libboost-date-time-dev libboost-filesystem-dev \ + libboost-program-options-dev libboost-serialization-dev libboost-chrono-dev \ + libboost-test-dev libboost-context-dev libboost-locale-dev libboost-coroutine-dev \ + libboost-iostreams-dev libboost-regex-dev \ + || $apt install -y --no-install-recommends libboost-all-dev # One cache per matrix arm: CHAIN_TESTNET_VALIDATORS changes compile flags. - name: Restore ccache diff --git a/libraries/chain/chain_properties_evaluators.cpp b/libraries/chain/chain_properties_evaluators.cpp index 9aa89f97f7..70169e0536 100644 --- a/libraries/chain/chain_properties_evaluators.cpp +++ b/libraries/chain/chain_properties_evaluators.cpp @@ -99,7 +99,8 @@ namespace graphene { namespace chain { FC_ASSERT( _db.has_hardfork(CHAIN_HARDFORK_4), "versioned_chain_properties_update_evaluator not enabled until HF 4" ); _db.get_account(o.owner); // verify owner exists - // #6737: protocol validate() allows up to 3 years of 1 s blocks; until HF16 the old + // #6737: protocol validate() allows up to one year counted in LIVE blocks (31 536 000 at + // 1 s, the same number the old `CHAIN_BLOCKS_PER_YEAR * 3` produced); until HF16 the // one-year-of-3-s-blocks bound stays consensus (the stored props are checked after the // visit, so a rejected op leaves nothing behind - the whole op is rolled back). const auto check_year_bound = [&](const chain_properties& p) { @@ -110,8 +111,11 @@ namespace graphene { namespace chain { FC_ASSERT(p.pm_closed_market_retention_sec > reveal_blocks * _db.block_interval(), "retention must exceed the live worst-case commit reveal deadline"); if (_db.has_hardfork(CHAIN_HARDFORK_16)) { - FC_ASSERT(p.distribution_epoch_length >= - CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH * (CHAIN_BLOCK_INTERVAL / _db.block_interval()), + // The floor is a wall-clock promise, so it has one named value per block scale. + // No multiplication here: the pre-HF16 value (CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH) + // counts 3 s blocks, this one counts live 1 s blocks, and both mean the same time + // (owner 19.11.2026: nothing is multiplied). + FC_ASSERT(p.distribution_epoch_length >= CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH_HF16, "distribution_epoch_length must preserve the minimum epoch duration after HF16"); return; } diff --git a/libraries/chain/database.cpp b/libraries/chain/database.cpp index 80a4d0d769..00ecac92e5 100644 --- a/libraries/chain/database.cpp +++ b/libraries/chain/database.cpp @@ -3464,8 +3464,8 @@ namespace graphene { namespace chain { } void database::update_bandwidth_reserve_candidates() { - // HF16: keep the hourly cadence in wall time (3x more blocks per hour at 1 s). - if ((head_block_num() % (CHAIN_BLOCKS_PER_HOUR * (CHAIN_BLOCK_INTERVAL / block_interval()))) != 0) return; + // HF16: CHAIN_BLOCKS_PER_HOUR is already in native 1 s blocks, so no runtime scaling. + if ((head_block_num() % CHAIN_BLOCKS_PER_HOUR) != 0) return; uint32_t bandwidth_reserve_candidates = 1; const auto &gprops = get_dynamic_global_properties(); const validator_schedule_object &consensus = get_validator_schedule_object(); @@ -3651,8 +3651,8 @@ namespace graphene { namespace chain { } } } - // HF16: same wall-time cadence as with 3 s slots. - if ((head_block_num() % (COMMITTEE_REQUEST_PROCESSING * (CHAIN_BLOCK_INTERVAL / block_interval()))) != 0) return; + // HF16: COMMITTEE_REQUEST_PROCESSING is already in native 1 s blocks (10 min cadence). + if ((head_block_num() % COMMITTEE_REQUEST_PROCESSING) != 0) return; uint32_t committee_payment_request_count = 1; const auto &idx4_count = get_index().indices().get(); auto itr3 = idx4_count.lower_bound(4); @@ -6742,11 +6742,11 @@ namespace graphene { namespace chain { if (w.signing_key != public_key_type() && head_block_num() - w.last_confirmed_block_num > - CHAIN_EMERGENCY_MAX_VALIDATOR_MISSED_BLOCKS * (CHAIN_BLOCK_INTERVAL / block_interval())) { + CHAIN_EMERGENCY_MAX_VALIDATOR_MISSED_BLOCKS) { elog("Emergency consensus: Validator ${w} missed ${missed} blocks since last confirmed ${lc} " "(threshold=${t}), blanking signing_key", ("w", w.owner)("missed", head_block_num() - w.last_confirmed_block_num) - ("lc", w.last_confirmed_block_num)("t", CHAIN_EMERGENCY_MAX_VALIDATOR_MISSED_BLOCKS * (CHAIN_BLOCK_INTERVAL / block_interval()))); + ("lc", w.last_confirmed_block_num)("t", CHAIN_EMERGENCY_MAX_VALIDATOR_MISSED_BLOCKS)); w.signing_key = public_key_type(); push_virtual_operation(shutdown_validator_operation(w.owner)); } @@ -6772,7 +6772,7 @@ namespace graphene { namespace chain { if (w.signing_key != public_key_type() && head_block_num() - w.last_confirmed_block_num > - CHAIN_MAX_VALIDATOR_MISSED_BLOCKS * (CHAIN_BLOCK_INTERVAL / block_interval())) { + CHAIN_MAX_VALIDATOR_MISSED_BLOCKS) { elog("Validator ${w} missed too many blocks (${missed} since last confirmed ${lc}), blanking signing_key (was ${k})", ("w", w.owner)("missed", head_block_num() - w.last_confirmed_block_num) ("lc", w.last_confirmed_block_num)("k", w.signing_key)); @@ -6842,11 +6842,9 @@ namespace graphene { namespace chain { }); if (!(skip & skip_undo_history_check)) { - // HF16 (1 s blocks, Q#3108=A): the undo window is counted in blocks, so keep it equal in TIME — - // 3× the blocks, otherwise a LIB stall halts the chain after 2.8 h instead of 8.3 h. - const uint32_t max_undo = has_hardfork(CHAIN_HARDFORK_16) - ? CHAIN_MAX_UNDO_HISTORY * (CHAIN_BLOCK_INTERVAL / CHAIN_BLOCK_INTERVAL_HF16) - : CHAIN_MAX_UNDO_HISTORY; + // HF16 (1 s blocks, Q#3108=A): CHAIN_MAX_UNDO_HISTORY is already in native 1 s blocks + // (same 8.3 h wall-clock window), so no runtime scaling. + const uint32_t max_undo = CHAIN_MAX_UNDO_HISTORY; CHAIN_ASSERT( _dgp.head_block_number - _dgp.last_irreversible_block_num < max_undo, undo_database_exception, diff --git a/libraries/protocol/get_config.cpp b/libraries/protocol/get_config.cpp index a3addffef4..7da1d538cf 100644 --- a/libraries/protocol/get_config.cpp +++ b/libraries/protocol/get_config.cpp @@ -14,7 +14,6 @@ namespace graphene { fc::variant_object get_config(uint32_t live_block_interval) { const uint32_t interval = live_block_interval ? live_block_interval : CHAIN_BLOCK_INTERVAL; FC_ASSERT(interval == CHAIN_BLOCK_INTERVAL || interval == CHAIN_BLOCK_INTERVAL_HF16); - const uint32_t scale = CHAIN_BLOCK_INTERVAL / interval; fc::mutable_variant_object result; result["CHAIN_100_PERCENT"] = CHAIN_100_PERCENT; @@ -53,7 +52,7 @@ namespace graphene { result["CHAIN_MAX_SIG_CHECK_DEPTH"] = CHAIN_MAX_SIG_CHECK_DEPTH; result["CHAIN_MAX_TIME_UNTIL_EXPIRATION"] = CHAIN_MAX_TIME_UNTIL_EXPIRATION; result["CHAIN_MAX_TRANSACTION_SIZE"] = CHAIN_MAX_TRANSACTION_SIZE; - result["CHAIN_MAX_UNDO_HISTORY"] = uint32_t(CHAIN_MAX_UNDO_HISTORY * scale); + result["CHAIN_MAX_UNDO_HISTORY"] = uint32_t(CHAIN_MAX_UNDO_HISTORY); result["CHAIN_MAX_VOTE_CHANGES"] = CHAIN_MAX_VOTE_CHANGES; result["CHAIN_MAX_TOP_VALIDATORS"] = CHAIN_MAX_TOP_VALIDATORS; result["CHAIN_MAX_WITHDRAW_ROUTES"] = CHAIN_MAX_WITHDRAW_ROUTES; @@ -76,19 +75,19 @@ namespace graphene { result["CHAIN_PENDING_TRANSACTION_EXECUTION_LIMIT"] = CHAIN_PENDING_TRANSACTION_EXECUTION_LIMIT; result["CHAIN_DIGITAL_ASSET_ISSUED_PER_BLOCK"] = CHAIN_DIGITAL_ASSET_ISSUED_PER_BLOCK; - // Stored/voted properties are native block counts (owner Q3108=A), not - // hidden 3-second units. Expose live defaults so clients need not re-vote - // stale compile-time values after HF16. + // Stored/voted properties are native block counts of the live chain (owner Q3108=A). + // Compile-time constants are native 1 s blocks too, so nothing is scaled here: what + // the chain stores and what clients receive are the same numbers (owner 19.11.2026: + // "no code that multiplies anything anywhere — what data we have is what we return"). chain_properties_pm defaults; - defaults.inflation_recalc_period *= scale; - defaults.distribution_epoch_length *= scale; - defaults.pm_batch_epoch_blocks *= scale; - defaults.pm_reveal_window_blocks *= scale; result["CHAIN_DEFAULT_CHAIN_PROPERTIES"] = fc::variant(defaults); result["CHAIN_PROPERTY_BLOCK_UNITS"] = "native-blocks"; - result["CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH"] = uint32_t(CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH * scale); - result["CHAIN_MAX_VALIDATOR_MISSED_BLOCKS"] = uint32_t(CHAIN_MAX_VALIDATOR_MISSED_BLOCKS * scale); - result["CHAIN_EMERGENCY_MAX_VALIDATOR_MISSED_BLOCKS"] = uint32_t(CHAIN_EMERGENCY_MAX_VALIDATOR_MISSED_BLOCKS * scale); + // Both scales are named: a client on a pre-HF16 chain reads the first key, a client after + // HF16 reads the second. Neither is derived by multiplying at runtime. + result["CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH"] = uint32_t(CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH); + result["CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH_HF16"] = uint32_t(CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH_HF16); + result["CHAIN_MAX_VALIDATOR_MISSED_BLOCKS"] = uint32_t(CHAIN_MAX_VALIDATOR_MISSED_BLOCKS); + result["CHAIN_EMERGENCY_MAX_VALIDATOR_MISSED_BLOCKS"] = uint32_t(CHAIN_EMERGENCY_MAX_VALIDATOR_MISSED_BLOCKS); return result; } diff --git a/libraries/protocol/include/graphene/protocol/chain_operations.hpp b/libraries/protocol/include/graphene/protocol/chain_operations.hpp index a69e4298b0..69ca1ad061 100644 --- a/libraries/protocol/include/graphene/protocol/chain_operations.hpp +++ b/libraries/protocol/include/graphene/protocol/chain_operations.hpp @@ -466,7 +466,7 @@ namespace graphene { namespace protocol { FC_ASSERT(inflation_ratio_committee_vs_reward_fund <= CHAIN_100_PERCENT); FC_ASSERT(inflation_recalc_period >= 0); // HF16 (#6737): one year is 3x more blocks at 1 s; the pre-HF16 bound is kept by the evaluator. - FC_ASSERT(inflation_recalc_period <= CHAIN_BLOCKS_PER_YEAR * 3); + FC_ASSERT(inflation_recalc_period <= CHAIN_BLOCKS_PER_YEAR_HF16); } chain_properties_hf4& operator=(const chain_properties_init& src) { @@ -499,7 +499,7 @@ namespace graphene { namespace protocol { FC_ASSERT(validator_miss_penalty_percent >= 0); FC_ASSERT(validator_miss_penalty_percent <= CHAIN_100_PERCENT); FC_ASSERT(validator_miss_penalty_duration >= 0); - FC_ASSERT(validator_miss_penalty_duration <= (CHAIN_BLOCKS_PER_YEAR * CHAIN_BLOCK_INTERVAL)); + FC_ASSERT(validator_miss_penalty_duration <= CHAIN_SECONDS_PER_YEAR); } chain_properties_hf6& operator=(const chain_properties_init& src) { @@ -591,7 +591,11 @@ namespace graphene { namespace protocol { * Consensus - Period in blocks between delegator reward distributions. * Each validator accumulates block rewards during this epoch and * distributes the delegator share proportionally at epoch end. - * Allowed range: [CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH, CHAIN_BLOCKS_PER_YEAR]. + * Allowed range: upper bound CHAIN_BLOCKS_PER_YEAR_HF16 (one year in live 1 s blocks, + * the same number as the pre-HF16 year in 3 s blocks). Lower bound is TWO named values + * because it is a wall-clock promise: this validate() enforces the pre-fork value + * CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH, and the post-fork check in the evaluator + * enforces CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH_HF16 (same time, live blocks). */ uint32_t distribution_epoch_length = CHAIN_DEFAULT_DISTRIBUTION_EPOCH_LENGTH; @@ -600,7 +604,7 @@ namespace graphene { namespace protocol { FC_ASSERT(distribution_epoch_length >= CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH, "distribution_epoch_length must be at least ${min} blocks", ("min", CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH)); - FC_ASSERT(distribution_epoch_length <= uint32_t(CHAIN_BLOCKS_PER_YEAR * 3), // HF16: see evaluator + FC_ASSERT(distribution_epoch_length <= uint32_t(CHAIN_BLOCKS_PER_YEAR_HF16), "distribution_epoch_length must not exceed one year in blocks"); } @@ -661,8 +665,8 @@ namespace graphene { namespace protocol { uint16_t pm_no_contest_penalty_percent = 5000; ///< bp of dispute fee (50%) uint32_t pm_dispute_reward_multiplier = 30000; ///< bp multiplier (10000=1x; default 3x) // Batch / commit-reveal - uint32_t pm_batch_epoch_blocks = 20; ///< ~60 s - uint32_t pm_reveal_window_blocks = 200; ///< ~10 min liveness + uint32_t pm_batch_epoch_blocks = 60; ///< ~60 s in native 1 s blocks (was 20 at 3 s) + uint32_t pm_reveal_window_blocks = 600; ///< ~10 min liveness in native 1 s blocks (was 200 at 3 s) uint16_t pm_commit_no_reveal_penalty_percent = 2000; ///< bp (20%) → winners' pool asset pm_min_batch_bet = asset(1000, TOKEN_SYMBOL); ///< 1.000 VIZ anti-dust bool pm_commit_reveal_enabled = true; ///< kill-switch (median-voted) diff --git a/libraries/protocol/include/graphene/protocol/config.hpp b/libraries/protocol/include/graphene/protocol/config.hpp index 76aa0d8745..e34c3d0704 100644 --- a/libraries/protocol/include/graphene/protocol/config.hpp +++ b/libraries/protocol/include/graphene/protocol/config.hpp @@ -34,10 +34,15 @@ #define CHAIN_BLOCK_INTERVAL_HF16 1 // HF16 (#6737, Q#3103=A): slot after the fork block; database::block_interval() #define CHAIN_BLOCK_VALIDATOR_REPEAT 1 #define CHAIN_BLOCKS_PER_YEAR (365*24*60*60/CHAIN_BLOCK_INTERVAL) -#define CHAIN_BLOCKS_PER_DAY (24*60*60/CHAIN_BLOCK_INTERVAL) -#define CHAIN_BLOCKS_PER_HOUR (60*60/CHAIN_BLOCK_INTERVAL) -#define CHAIN_MAX_VALIDATOR_MISSED_BLOCKS 200 // ~10 min; runtime multiplies block threshold by 3 after HF16 -#define CHAIN_EMERGENCY_MAX_VALIDATOR_MISSED_BLOCKS (5 * CHAIN_MAX_VALIDATORS) // in emergency mode, blank key after 5 full rounds of missed scheduled slots (~5 min; runtime threshold scales at HF16) +// A year counted in the LIVE (1 s) blocks. Two named values instead of one obscured by a +// runtime x3: CHAIN_BLOCKS_PER_YEAR keeps feeding emission (its own open question — see +// per-block-constant-changes-meaning-when-cadence-changes), while every HF16-era BOUND +// (epoch limits, penalty limits) uses this one. No multiplication at the call sites. +#define CHAIN_BLOCKS_PER_YEAR_HF16 (365*24*60*60/CHAIN_BLOCK_INTERVAL_HF16) +#define CHAIN_BLOCKS_PER_DAY (24*60*60/CHAIN_BLOCK_INTERVAL_HF16) // native blocks of the live chain +#define CHAIN_BLOCKS_PER_HOUR (60*60/CHAIN_BLOCK_INTERVAL_HF16) // native blocks of the live chain +#define CHAIN_MAX_VALIDATOR_MISSED_BLOCKS 600 // ~10 min in native 1 s blocks (was 200 at 3 s) +#define CHAIN_EMERGENCY_MAX_VALIDATOR_MISSED_BLOCKS (15 * CHAIN_MAX_VALIDATORS) // ~5 min in native 1 s blocks: 5 rounds x 3 s #define CHAIN_INITIATOR_NAME "viz" // Private key: 5JabcrvaLnBTCkCVFX5r4rmeGGfuJuVp4NAKRNLTey6pxhRQmf4 @@ -113,7 +118,7 @@ #define CHAIN_MAX_BLOCK_SIZE_LIMIT (2*1024*1024) // 2Mb p2p graphene limit : /libraries/net/include/graphene/net/config.hpp#L39 #define CHAIN_BLOCK_SIZE (CHAIN_MAX_BLOCK_SIZE_LIMIT*CHAIN_BLOCK_INTERVAL) // initial block size, preset to max block size limit -#define CHAIN_MAX_UNDO_HISTORY 10000 +#define CHAIN_MAX_UNDO_HISTORY 30000 // ~8.3 h in native 1 s blocks (was 10000 at 3 s) /// Emergency consensus mode: activates when no block has been produced for /// this many seconds since the last irreversible block. @@ -161,7 +166,7 @@ #define CONSENSUS_COMMITTEE_REQUEST_APPROVE_MIN_PERCENT 1000 // default: 10.00% #define CONSENSUS_DATA_OPERATIONS_COST_ADDITIONAL_BANDWIDTH 0 #define CONSENSUS_VALIDATOR_MISS_PENALTY_PERCENT 100 // default: 1.00% -#define CONSENSUS_VALIDATOR_MISS_PENALTY_DURATION (CHAIN_BLOCKS_PER_DAY*CHAIN_BLOCK_INTERVAL) // default: 1 day +#define CONSENSUS_VALIDATOR_MISS_PENALTY_DURATION (24*60*60) // default: 1 day, in seconds (was blocks*interval) #define CONSENSUS_CREATE_INVITE_MIN_BALANCE 10000 #define CONSENSUS_COMMITTEE_CREATE_REQUEST_FEE 100000 @@ -211,7 +216,12 @@ /// 21 blocks (1 round) is too short: epoch distribution runs synchronously in _apply_block /// and iterates all validators × all their stakeholders; at 63-second intervals this /// would fire too frequently under any realistic validator/stakeholder count. -#define CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH uint32_t(CHAIN_BLOCKS_PER_HOUR) +#define CHAIN_BLOCKS_PER_HOUR_LEGACY (60*60/CHAIN_BLOCK_INTERVAL) // one hour in the pre-HF16 3 s blocks +// The epoch floor is a WALL-CLOCK promise (one hour), so it has one named value per block scale — +// no call site multiplies. Testnet deliberately keeps a much smaller floor; both configs keep the +// invariant `before * 3 s == after * 1 s`, which the boundary test asserts directly. +#define CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH uint32_t(CHAIN_BLOCKS_PER_HOUR_LEGACY) // one hour before HF16 +#define CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH_HF16 uint32_t(CHAIN_BLOCKS_PER_HOUR) // one hour after HF16 /// Minimum TOKEN amount per stakeholder payout at epoch end (1 atomic unit = 0.001 VIZ). /// Stakeholder rewards below this threshold are not distributed; the validator retains them. diff --git a/libraries/protocol/include/graphene/protocol/config_testnet.hpp b/libraries/protocol/include/graphene/protocol/config_testnet.hpp index f87e745e39..5c153cdb40 100644 --- a/libraries/protocol/include/graphene/protocol/config_testnet.hpp +++ b/libraries/protocol/include/graphene/protocol/config_testnet.hpp @@ -35,10 +35,15 @@ #define CHAIN_BLOCK_INTERVAL_HF16 1 // HF16 (#6737, Q#3103=A): slot after the fork block; database::block_interval() #define CHAIN_BLOCK_VALIDATOR_REPEAT 1 #define CHAIN_BLOCKS_PER_YEAR (365*24*60*60/CHAIN_BLOCK_INTERVAL) -#define CHAIN_BLOCKS_PER_DAY (24*60*60/CHAIN_BLOCK_INTERVAL) -#define CHAIN_BLOCKS_PER_HOUR (60*60/CHAIN_BLOCK_INTERVAL) -#define CHAIN_MAX_VALIDATOR_MISSED_BLOCKS 200 // ~10 min after first missed block for top validator -#define CHAIN_EMERGENCY_MAX_VALIDATOR_MISSED_BLOCKS (5 * CHAIN_MAX_VALIDATORS) // in emergency mode, blank key after 5 full rounds of missed scheduled slots (~5 min) +// A year counted in the LIVE (1 s) blocks. Two named values instead of one obscured by a +// runtime x3: CHAIN_BLOCKS_PER_YEAR keeps feeding emission (its own open question — see +// per-block-constant-changes-meaning-when-cadence-changes), while every HF16-era BOUND +// (epoch limits, penalty limits) uses this one. No multiplication at the call sites. +#define CHAIN_BLOCKS_PER_YEAR_HF16 (365*24*60*60/CHAIN_BLOCK_INTERVAL_HF16) +#define CHAIN_BLOCKS_PER_DAY (24*60*60/CHAIN_BLOCK_INTERVAL_HF16) // native blocks of the live chain +#define CHAIN_BLOCKS_PER_HOUR (60*60/CHAIN_BLOCK_INTERVAL_HF16) // native blocks of the live chain +#define CHAIN_MAX_VALIDATOR_MISSED_BLOCKS 600 // ~10 min in native 1 s blocks (was 200 at 3 s) +#define CHAIN_EMERGENCY_MAX_VALIDATOR_MISSED_BLOCKS (15 * CHAIN_MAX_VALIDATORS) // ~5 min in native 1 s blocks: 5 rounds x 3 s #define CHAIN_INITIATOR_NAME "viz" // Private key: 5JabcrvaLnBTCkCVFX5r4rmeGGfuJuVp4NAKRNLTey6pxhRQmf4 @@ -123,7 +128,7 @@ #define CHAIN_MAX_BLOCK_SIZE_LIMIT (2*1024*1024) // 2Mb p2p graphene limit : /libraries/net/include/graphene/net/config.hpp#L39 #define CHAIN_BLOCK_SIZE (CHAIN_MAX_BLOCK_SIZE_LIMIT*CHAIN_BLOCK_INTERVAL) // initial block size, preset to max block size limit -#define CHAIN_MAX_UNDO_HISTORY 10000 +#define CHAIN_MAX_UNDO_HISTORY 30000 // ~8.3 h in native 1 s blocks (was 10000 at 3 s) /// Emergency consensus mode: activates when no block has been produced for /// this many seconds since the last irreversible block. @@ -172,7 +177,7 @@ #define CONSENSUS_COMMITTEE_REQUEST_APPROVE_MIN_PERCENT 1000 // default: 10.00% #define CONSENSUS_DATA_OPERATIONS_COST_ADDITIONAL_BANDWIDTH 0 #define CONSENSUS_VALIDATOR_MISS_PENALTY_PERCENT 100 // default: 1.00% -#define CONSENSUS_VALIDATOR_MISS_PENALTY_DURATION (CHAIN_BLOCKS_PER_DAY*CHAIN_BLOCK_INTERVAL) // default: 1 day +#define CONSENSUS_VALIDATOR_MISS_PENALTY_DURATION (24*60*60) // default: 1 day, in seconds (was blocks*interval) #define CONSENSUS_CREATE_INVITE_MIN_BALANCE 10000 #define CONSENSUS_COMMITTEE_CREATE_REQUEST_FEE 100000 @@ -218,7 +223,9 @@ #define CHAIN_DEFAULT_DISTRIBUTION_EPOCH_LENGTH CHAIN_BLOCKS_PER_HOUR /// Minimum epoch length: 1 block in testnet to allow any interval. -#define CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH uint32_t(1) +#define CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH uint32_t(1) // testnet floor: one 3 s block +// Same wall-clock value as the pre-HF16 floor above (1 x 3 s), expressed in native 1 s blocks. +#define CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH_HF16 uint32_t(3) // 3 x 1 s /// Minimum TOKEN amount per stakeholder payout (1 atomic unit = 0.001 VIZ). #define CHAIN_MIN_STAKEHOLDER_REWARD_PAYOUT int64_t(1) diff --git a/plugins/validator_guard/validator_guard.cpp b/plugins/validator_guard/validator_guard.cpp index b0f751464e..e4d7d5838b 100644 --- a/plugins/validator_guard/validator_guard.cpp +++ b/plugins/validator_guard/validator_guard.cpp @@ -242,8 +242,9 @@ bool validator_guard_plugin::impl::check_and_restore_internal() { // expression — keep the two in step). Post-HF16 a block is 1 s, so the effective // threshold is about five minutes; that is the wall-clock window compared here. const int64_t block_sec = db().block_interval(); - const int64_t blank_after_blocks = CHAIN_EMERGENCY_MAX_VALIDATOR_MISSED_BLOCKS - * (CHAIN_BLOCK_INTERVAL / block_sec); + // Native 1 s blocks already (owner 19.11.2026: no multiplication anywhere), so the + // threshold is used as is; wall-clock window = blocks x live interval. + const int64_t blank_after_blocks = CHAIN_EMERGENCY_MAX_VALIDATOR_MISSED_BLOCKS; const int64_t now_sec = now.sec_since_epoch(); const auto verdict = _restore_backoff.on_null_key(name, now_sec, diff --git a/tests/consensus_sim/scenarios/test_hf16_boundary.cpp b/tests/consensus_sim/scenarios/test_hf16_boundary.cpp index 3547a77bc7..a60b36ddbb 100644 --- a/tests/consensus_sim/scenarios/test_hf16_boundary.cpp +++ b/tests/consensus_sim/scenarios/test_hf16_boundary.cpp @@ -125,9 +125,19 @@ BOOST_AUTO_TEST_CASE(slot_and_round_switch_at_fork_block) { BOOST_CHECK_EQUAL(live_config["CHAIN_BLOCKS_PER_HOUR"].as_uint64(), 3600u); BOOST_CHECK_EQUAL(live_config["CHAIN_BLOCKS_PER_DAY"].as_uint64(), 86400u); BOOST_CHECK_EQUAL(live_config["CHAIN_BLOCKS_PER_YEAR"].as_uint64(), CHAIN_SECONDS_PER_YEAR); - BOOST_CHECK_EQUAL(live_config["CHAIN_MAX_VALIDATOR_MISSED_BLOCKS"].as_uint64(), CHAIN_MAX_VALIDATOR_MISSED_BLOCKS * 3); - BOOST_CHECK_EQUAL(live_config["CHAIN_DEFAULT_CHAIN_PROPERTIES"].get_object()["inflation_recalc_period"].as_uint64(), - uint64_t(CHAIN_CONSENSUS_INFLATION_RECALC_PERIOD) * 3); + // Owner 19.11.2026: nothing is multiplied anywhere — compile-time constants are native 1 s + // blocks, so config reports them verbatim (this equals 600 blocks = 10 min at 1 s). + BOOST_CHECK_EQUAL(live_config["CHAIN_MAX_VALIDATOR_MISSED_BLOCKS"].as_uint64(), (uint64_t)CHAIN_MAX_VALIDATOR_MISSED_BLOCKS); + BOOST_CHECK_EQUAL(live_config["CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH"].as_uint64(), (uint64_t)CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH); + BOOST_CHECK_EQUAL(live_config["CHAIN_MAX_UNDO_HISTORY"].as_uint64(), (uint64_t)CHAIN_MAX_UNDO_HISTORY); + // The default the operation would store equals what config reports: no hidden x3. + const auto live_defaults = live_config["CHAIN_DEFAULT_CHAIN_PROPERTIES"].get_object(); + BOOST_CHECK_EQUAL(live_defaults["inflation_recalc_period"].as_uint64(), + uint64_t(CHAIN_CONSENSUS_INFLATION_RECALC_PERIOD)); + BOOST_CHECK_EQUAL(live_defaults["distribution_epoch_length"].as_uint64(), + uint64_t(CHAIN_DEFAULT_DISTRIBUTION_EPOCH_LENGTH)); + BOOST_CHECK_EQUAL(live_defaults["pm_batch_epoch_blocks"].as_uint64(), 60u); + BOOST_CHECK_EQUAL(live_defaults["pm_reveal_window_blocks"].as_uint64(), 600u); // The fork block is the anchor: same round as before the switch, next slot is +1 s. const auto& dgp = db.get_dynamic_global_properties(); @@ -275,10 +285,16 @@ BOOST_AUTO_TEST_CASE(minimum_epoch_duration_survives_slot_change) { db.set_hardfork(CHAIN_HARDFORK_16, true); // Other block-denominated settings have been migrated too: start from those props. props = db.get_validator(gp.initiator_name).props; - props.distribution_epoch_length = CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH * 3 - 1; + // The floor is a wall-clock promise. Both configs keep it as one named value per block + // scale, so the invariant to assert is SECONDS, not a macro expression: mainnet + // 1200 x 3 s == 3600 x 1 s, testnet 1 x 3 s == 3 x 1 s. A regression that drops or + // duplicates the factor breaks this line whatever the config is. + BOOST_CHECK_EQUAL(uint64_t(CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH) * CHAIN_BLOCK_INTERVAL, + uint64_t(CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH_HF16) * CHAIN_BLOCK_INTERVAL_HF16); + props.distribution_epoch_length = CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH_HF16 - 1; op.props = props; BOOST_CHECK_THROW(node.push_pending_transaction(sign_ops({op}, gp.initiator_key, node)), std::exception); - props.distribution_epoch_length += 1; + props.distribution_epoch_length = CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH_HF16; auto overflowing = props; overflowing.pm_batch_epoch_blocks = 0x80000000u; overflowing.pm_reveal_window_blocks = 0x80000000u; @@ -293,7 +309,11 @@ BOOST_AUTO_TEST_CASE(minimum_epoch_duration_survives_slot_change) { node.push_pending_transaction(sign_ops({op}, gp.initiator_key, node)); produce(node, gp, when); BOOST_CHECK_EQUAL(db.get_validator(gp.initiator_name).props.distribution_epoch_length, - CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH * 3); + CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH_HF16); + // Same wall-clock floor as before the fork, now counted in 1 s blocks. + BOOST_CHECK_EQUAL(uint64_t(db.get_validator(gp.initiator_name).props.distribution_epoch_length) + * db.block_interval(), + uint64_t(CHAIN_MIN_DISTRIBUTION_EPOCH_LENGTH) * CHAIN_BLOCK_INTERVAL); } // Every CI run now exercises real signatures, QC/LIB, timeout votes, late-QC and