Skip to content

feat(consensus): raise registration PoW target to 28 bits at HF4 (anti wallet-spam) - #76

Closed
DDerona wants to merge 2 commits into
DEROFDN:community-devfrom
DDerona:fix/registration-pow-hf4
Closed

feat(consensus): raise registration PoW target to 28 bits at HF4 (anti wallet-spam)#76
DDerona wants to merge 2 commits into
DEROFDN:community-devfrom
DDerona:fix/registration-pow-hf4

Conversation

@DDerona

@DDerona DDerona commented Aug 16, 2026

Copy link
Copy Markdown

Summary

Raises the registration PoW target from 24 to 28 leading zero bits at a new HF4, restoring the per-wallet anti-spam cost of wallet registration after client-side mining loops were optimized (~10-20x faster hashing). This addresses a wallet-spam / regpool-flooding attack class that has occurred before.

⛔ REQUIRED BEFORE MERGE

MAJOR_HF4_HEIGHT is currently a placeholder:

  • mainnet: 9000000
  • testnet: 3000000

Set the real activation heights before this merges. The fork rule stays dormant until then (the placeholder values are far in the future), but shipping with placeholder heights would be unsafe.

What changed

  • config: MAJOR_HF4_HEIGHT added for mainnet/testnet (TODO: real height).
  • transaction: RegistrationPoWSolved(bits) helper — 28 bits = 3 zero bytes plus a zero high nibble on byte 3 (16x harder than the historical 24).
  • blockchain: mempool and block validation enforce 28 bits at HF4 and keep the 24-bit rule before the fork, via a single registrationPoWRequiredBits(height, hf4Height) helper.
  • dero-wallet-cli / webwallet: registration miners always target 28 bits.

Why "always 28" on the client

A 28-bit winner trivially satisfies the 24-bit consensus check, so wallets mined at 28 remain valid on both sides of the fork — a wallet mining 24-bit right at the fork could be rejected. Optimized clients (Engram) keep their fast loop while old hardware still registers in ~30-50 min instead of hours, and the per-wallet spam cost returns to pre-optimization levels.

Verification

  • Private testnet with MAJOR_HF4_HEIGHT = 0 (fork active from genesis):
    • 24-bit winner (25 leading zero bits — passes the old rule) → rejected: "TX doesn't solve Pow"
    • 28-bit winner → accepted by the daemon
  • go build ./... and go test ./transaction/ pass.
  • Engram client end-to-end against a local testnet daemon: real 28-bit registration accepted.

MemeTactician and others added 2 commits August 16, 2026 02:22
…i wallet-spam)

Client-side registration miners were optimized (increment-optimized nonce
search) and now hash ~10-20x faster, which makes mass wallet registration
cheap again and enables regpool flooding / wallet-spam attacks that
previously occurred. The historical 24-bit target was calibrated around the
old slow hashing, so this restores the per-wallet cost of registration.

- Add MAJOR_HF4_HEIGHT to mainnet/testnet config (TODO: set real height).
- Add transaction.RegistrationPoWSolved(bits) helper; 28 bits = 3 zero
  bytes plus a zero high nibble on byte 3 (16x harder than 24 bits).
- Enforce the 28-bit target at HF4 in the mempool and block validation;
  keep the 24-bit rule before the fork. The fork rule is derived from
  chain height through a single registrationPoWRequiredBits(height, hf4)
  helper so it lives in one place.
- CLI and webwallet registration miners always target 28 bits: a 28-bit
  winner also satisfies the 24-bit check, so wallets stay valid on both
  sides of the fork, and Engram can keep its optimized loop (old hardware
  still registers in ~30-50 min instead of hours).

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
The 1.1GB build/ directory from `go build -o build/...` was untracked
and unprotected, so an accidental `git add .` would stage a gigabyte of
binaries. Ignore it.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@DDerona

DDerona commented Aug 24, 2026

Copy link
Copy Markdown
Author

Closing as superseded by #122 — the HF5 registration-activation cooldown (availability-style: a wallet becomes usable 50 blocks ≈ 15 min after registration, layered on top of this HF4 PoW bump). Keeping this PR's PoW discussion as the motivating context.

@DDerona DDerona closed this Aug 24, 2026
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