Skip to content

[rooch-relayer] Header-only mode for Bitcoin block sync #3924

@jolestar

Description

@jolestar

Summary

Optimize Bitcoin Relayer to fetch only block headers instead of full blocks, reducing bandwidth consumption. This is a sub-issue of #3922.

Background

After #3923 is implemented, the Move layer will only process block headers and ignore transaction data. However, the Relayer still fetches full blocks from Bitcoin nodes, wasting bandwidth.

Tasks

1. Modify L1BlockWithBody structure

File: crates/rooch-types/src/transaction/ledger_transaction.rs

  • Make block_body field optional: Option<Vec<u8>>
  • Add new_bitcoin_header(height, header) constructor

2. Modify Bitcoin Relayer

File: crates/rooch-relayer/src/actor/bitcoin_relayer.rs

  • Add config option header_only_mode: bool (default: true)
  • When enabled, use get_block_header instead of get_block
  • Modify pop_buffer to create L1BlockWithBody with None body

3. Modify Executor

File: crates/rooch-executor/src/actor/executor.rs

  • Handle block_body: None case in validate_l1_block
  • Call appropriate Move function based on whether body is present

Configuration

Add to BitcoinRelayerConfig:

pub struct BitcoinRelayerConfig {
    // ... existing fields
    
    /// If true, only fetch block headers (default: true after framework upgrade)
    pub header_only_mode: bool,
}

Dependencies

Acceptance Criteria

  • Relayer only fetches block headers when header_only_mode is true
  • Significantly reduced bandwidth usage
  • Block sync continues to work correctly
  • Backward compatible (can still fetch full blocks if needed)

Parent Issue

#3922

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions