Skip to content

ASERT DAA and timestamp hardening (activation: 2026-04-20)#51

Open
NyanCatTW1 wants to merge 18 commits intoProjectFactor:mainfrom
NyanCatTW1:202603hardfork
Open

ASERT DAA and timestamp hardening (activation: 2026-04-20)#51
NyanCatTW1 wants to merge 18 commits intoProjectFactor:mainfrom
NyanCatTW1:202603hardfork

Conversation

@NyanCatTW1
Copy link
Copy Markdown
Member

Goal

To ensure the chain recovers rapidly after major hashrate fluctuation, while keeping the chain safe from selfish mining attempts.
ASERT combined with hardened timestamp is safe from all except for 51% attacks, in which case we have better things to worry about than selfish mining

Summary

  • ASERT difficulty adjustment: Port BCH's aserti3-2d algorithm, adapted for
    FACTOR's nonlinear (integer) nBits instead of BCH's 256-bit target. Uses a
    precomputed log2 lookup table with Q32.32 fixed-point arithmetic to compute
    2^(exponent) over nBits space. Half-life is 2 days on mainnet, 1 hour on
    testnet/regtest. Activates on mainnet at 2026-04-20 10:09:00 UTC.
  • Timestamp hardening: Enforce monotonic block timestamps, remove peer-time
    adjustment (GetTimeOffset always returns 0), and reduce MAX_FUTURE_BLOCK_TIME
    to 4 seconds. ASERT uses block time directly rather than MTP for activation.

Details

Core implementation:

  • CalculateFACTORASERT() - pure function, no chain-state deps (pow.cpp)
  • asert_table.h - 512-entry log2(compute()) lookup table generated by
    scripts/gen_compute_table.py
  • GetNextWorkRequired() routes to ASERT after activation

Timestamp changes:

  • timedata.cpp ignores median peer offset
  • validation.cpp enforces nTime > prev.nTime (monotonic)
  • MAX_FUTURE_BLOCK_TIME reduced from 2h to 4s

Testing:

  • asert_tests.cpp - unit tests for CalculateFACTORASERT including boundary,
    clamping, degenerate cases, and mainnet anchor
  • pow_tests.cpp - updated for ASERT integration and monotonic timestamps
  • gen_asert_test_vectors.cpp - deterministic test vector generator
  • validate_nbits_aserti3_2d.py - independent Python validation of the
    fixed-point math

Smoke tests performed

  • IBD still works
  • Tested on testnet with 15s block time / 180s half life. Log from test is available here: testnet.txt

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