Skip to content

fix(consensus): rollback weight formula from BQIP-0007 to BQIP-0002#170

Open
AlphaB135 wants to merge 2 commits intomainfrom
fix/bqip0002-weight-rollback
Open

fix(consensus): rollback weight formula from BQIP-0007 to BQIP-0002#170
AlphaB135 wants to merge 2 commits intomainfrom
fix/bqip0002-weight-rollback

Conversation

@AlphaB135
Copy link
Copy Markdown
Owner

@AlphaB135 AlphaB135 commented Mar 27, 2026

Summary

  • Rollback calculate_tx_weight() from BQIP-0007 (base×4 + witness×1) to BQIP-0002 (base + sig_count×384 + witness×0.5)
  • Updated both bitquan-consensus and bitquan-mempool weight calculations to match
  • Simplified deprecated calculate_block_weight_with_beta() since main formula is now beta-based
  • Fixed test assertions for new weight formula

Problem

BQIP-0007 weight formula was copied from Bitcoin SegWit but hurts PQC performance:

  • Bitcoin: sig ~100B, base ~200B → 4:1 discount helps
  • BitQuan: sig ~8,000B, base ~110B → 4:1 discount penalizes base, witness still dominates
Formula Weight/tx tx/block TPS
BQIP-0007 (before) ~7,240 WU ~552 ~0.78
BQIP-0002 (after) ~3,894 WU ~1,027 ~1.45

Motivation

The SegWit-style discount (witness at 1 WU/byte vs base at 4 WU/byte) assumes signatures are small relative to base data. For PQC blockchain with 8KB signatures, this assumption is inverted.

BQIP-0002 uses:

  • Fixed per-signature cost (384 WU) — algorithm-agnostic
  • 50% witness byte discount (beta=0.5) — still discounts large sigs
  • Base at 1× — no penalty on small structural data

Test Plan

  • cargo test -p bitquan-consensus — 146 passed, 0 failed
  • cargo test -p bitquan-mempool — 22 passed, 0 failed
  • cargo test -p bitquan-types — 44 passed, 0 failed
  • cargo clippy — 0 warnings

Closes #169

- whitepaper.tex: 10 sections covering protocol design, cryptography,
  consensus, security analysis, performance, and future work
- Makefile: build (make), clean, view, watch commands
- .gitignore: add LaTeX build artifacts (aux, log, out, toc, etc.)

Build: cd whitepaper && make
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

BQIP-0007 (base×4 + witness×1) was copied from Bitcoin SegWit but
hurts PQC performance because Dilithium5 signatures (~8KB) dwarf base
data (~110B). The SegWit 4:1 discount penalizes the tiny base while
witness still dominates, resulting in 46% fewer txs per block than
the old formula.

BQIP-0002 (base + sig_count×384 + witness×0.5) gives:
- 1.86x more transactions per block (552 → 1,027)
- Algorithm-agnostic: fixed 384 WU per signature regardless of size
- 50% discount on witness bytes

Closes #169
@AlphaB135 AlphaB135 force-pushed the fix/bqip0002-weight-rollback branch from 3a79852 to f1a3270 Compare March 27, 2026 19:45
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.

BQIP-0002: Rollback weight formula from BQIP-0007 to BQIP-0002

1 participant