Skip to content

feat: compact block proposals for faster block propagation#1

Open
thang1119 wants to merge 6 commits intodydx-fork-v0.38.5from
feat/compact-proposals
Open

feat: compact block proposals for faster block propagation#1
thang1119 wants to merge 6 commits intodydx-fork-v0.38.5from
feat/compact-proposals

Conversation

@thang1119
Copy link

@thang1119 thang1119 commented Feb 25, 2026

Summary

Implements compact block proposals (Sei Twin-Turbo style) to reduce block propagation latency. The proposer includes tx hashes + block metadata in the Proposal message itself, enabling validators to reconstruct blocks from their local mempool instantly — without waiting for block parts to gossip.

  • Proposer: Includes TxKeys (SHA-256 hashes), NonMempoolTxs (app-injected txs), CompactHeader, CompactLastCommit, CompactEvidence, and ProposerAddress in Proposal
  • Receiver: Looks up txs in local mempool by key, reconstructs full block, verifies hash matches proposal.BlockID.Hash, enters prevote immediately
  • Fallback: If mempool missing txs or hash mismatch, falls back to traditional block parts gossip
  • Backward compatible: New proto fields 8-14, NOT included in CanonicalProposal (signing unaffected). Old validators ignore unknown fields

Changes

  1. Proto: Add fields 8-14 to Proposal message (tx_keys, non_mempool_txs, non_mempool_indices, compact_header, compact_last_commit, proposer_address, compact_evidence)
  2. Types: Extend native Proposal struct, ToProto/FromProto serialization, HasCompactData() helper
  3. Config: compact_proposals = true (default) consensus config flag
  4. Mempool: GetTxsForKeys(keys []TxKey) batch lookup interface + CListMempool/NopMempool implementations
  5. Consensus: Proposer populates compact data in defaultDecideProposal, receiver reconstructs in defaultSetProposal via tryReconstructBlock(), triggers handleCompleteProposal on success
  6. Metrics: compact_reconstructed, compact_missed, compact_hash_mismatch counters
  7. Wiring: StateMempool option, node/setup.go passes mempool to consensus State

Test plan

  • Proposal proto round-trip test (TestProposalCompactDataRoundTrip)
  • HasCompactData logic test (TestProposalHasCompactData)
  • All existing proposal tests pass
  • Localnet 4 validators: 5000+ blocks, 100% compact reconstruction rate
  • Stress test: 3200 txs/block reconstructed successfully, zero hash mismatches

thang1119 and others added 6 commits February 25, 2026 17:21
Add fields 8-14 to the Proposal protobuf message for compact block
propagation. These optional fields carry tx hashes, app-injected txs,
block header, last commit, evidence, and proposer address — enabling
validators to reconstruct blocks from their local mempool without
waiting for block parts to gossip.

Fields are NOT included in CanonicalProposal, so signing is unaffected.
Backward compatible: old validators ignore unknown fields.
…erialization

Add TxKeys, NonMempoolTxs, NonMempoolIndices, CompactHeader,
CompactLastCommit, CompactEvidence, and ProposerAddress fields to
the native Proposal type. Update ToProto/ProposalFromProto for
serialization. Add HasCompactData() helper and headerFromProtoNoValidate()
for safe deserialization without premature validation.
Default true. When enabled, proposers include compact block data in
Proposal messages and receivers attempt mempool-based reconstruction.
Add GetTxsForKeys(keys []TxKey) to the Mempool interface for O(1)
batch tx lookup by SHA-256 key. CListMempool uses the existing
txsMap (sync.Map) for lock-free reads. NopMempool returns all missing.
Proposer side: populate TxKeys, NonMempoolTxs, CompactHeader, etc.
in defaultDecideProposal when compact_proposals is enabled.

Receiver side: on proposal receipt, attempt block reconstruction via
tryReconstructBlock(). If hash matches proposal.BlockID, set
ProposalBlock immediately and trigger enterPrevote without waiting
for block parts. Falls back to traditional gossip on failure.

Add 3 metrics: compact_reconstructed, compact_missed, compact_hash_mismatch.
Wire mempool into consensus State via StateMempool option.
- Rename proto/dydxcometbft to proto/perpxcometbft
- Update README.md to PerpX/perpx-chain branding
- Update organization references to 1119-Labs
- Update branch naming to perpx-fork
- Regenerate protobuf files with new package names
- Update mempool import path for new proto package location
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.

2 participants