Skip to content

feat(rpc): finalize SyncChainMmr gRPC endpoint#2075

Open
kkovaacs wants to merge 3 commits into
nextfrom
krisztian/rpc-sync-mmr-remove-arbitrary-block-number-target
Open

feat(rpc): finalize SyncChainMmr gRPC endpoint#2075
kkovaacs wants to merge 3 commits into
nextfrom
krisztian/rpc-sync-mmr-remove-arbitrary-block-number-target

Conversation

@kkovaacs
Copy link
Copy Markdown
Contributor

@kkovaacs kkovaacs commented May 14, 2026

Based on the discussion in PR #2069 and issue #2044 we've converged on some smaller changes to the SyncChainMmr endpoint.

Changes made to the current interface:

  • Removal of the arbitrary block number sync target. Clients can now choose which finality level they'd like to reach but always sync up to the chain tip (proven or committed).
  • We now return the validator signature for the chain tip block header in the response.

The proposed protobuf interface (implemented by this PR) is the following:

// Finality level we'd like to sync up to.
enum FinalityLevel {
    FINALITY_LEVEL_UNSPECIFIED = 0;
    // Sync up to the latest committed block (chain tip).
    FINALITY_LEVEL_COMMITTED = 1;
    // Sync up to the latest proven block.
    FINALITY_LEVEL_PROVEN = 2;
}

// Chain MMR synchronization request.
message SyncChainMmrRequest {
    // Block number from which to synchronize (inclusive). Set this to the last block
    // already present in the caller's MMR so the delta begins at the next block.
    fixed32 current_block_height = 1;

    // Sync target: either the committed or the proven tip.
    FinalityLevel finality_level = 2;
}

// Represents the result of syncing chain MMR.
message SyncChainMmrResponse {
    // For which block range the MMR delta is returned.
    BlockRange block_range = 1;

    // Data needed to update the partial MMR from `request.block_range.current_block_height + 1` to
    // the sync target.
    primitives.MmrDelta mmr_delta = 2;

    // Block header for the sync target.
    blockchain.BlockHeader block_header = 3;

    // Validator signature for the sync target.
    blockchain.BlockSignature block_signature = 4;
}

Closes #2044

@kkovaacs kkovaacs force-pushed the krisztian/rpc-sync-mmr-remove-arbitrary-block-number-target branch from 22c2bad to e76a4b9 Compare May 14, 2026 08:11
@kkovaacs kkovaacs marked this pull request as ready for review May 14, 2026 08:11
Comment thread crates/rpc/src/server/api.rs Outdated
Comment thread crates/store/src/db/mod.rs Outdated
Comment thread crates/store/src/server/rpc_api.rs
@kkovaacs kkovaacs force-pushed the krisztian/rpc-sync-mmr-remove-arbitrary-block-number-target branch from 3e162ee to 7b6e616 Compare May 14, 2026 09:24
@kkovaacs kkovaacs requested a review from SantiagoPittella May 14, 2026 13:23
Copy link
Copy Markdown
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you! I left one small comment inline.

Comment on lines +74 to +89
/// ```sql
/// -- with argument
/// SELECT block_num, block_header, signature
/// FROM block_headers
/// WHERE block_num = ?1
///
/// -- without argument
/// SELECT block_num, block_header, signature
/// FROM block_headers
/// ORDER BY block_num DESC
/// LIMIT 1
/// ```
pub(crate) fn select_block_header_and_signature_by_block_num(
conn: &mut SqliteConnection,
block_number: BlockNumber,
) -> Result<Option<(BlockHeader, Signature)>, DatabaseError> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the two options still relevant? Seems like we always provide block_number now.

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.

SyncChainMmr block range start is exclusive

3 participants