feat: improve sequencer healthcheck to return chain height

Previously check_health() always returned Ok(()) without checking
anything meaningful. A sequencer could be stuck and still pass.

Now check_health() returns the current chain height (BlockId).
Clients can call this twice with a delay to verify the chain is
progressing.

Refs #244
This commit is contained in:
ygd58 2026-03-28 19:49:00 +01:00
parent fb083ce91e
commit c1924e1ccc
No known key found for this signature in database
GPG Key ID: 82B49AE8D5B28600
2 changed files with 6 additions and 4 deletions

View File

@ -39,9 +39,10 @@ pub trait Rpc {
#[method(name = "sendTransaction")]
async fn send_transaction(&self, tx: NSSATransaction) -> Result<HashType, ErrorObjectOwned>;
// TODO: expand healthcheck response into some kind of report
/// Returns the current chain height (block count).
/// A sequencer is healthy if this value increases over time.
#[method(name = "checkHealth")]
async fn check_health(&self) -> Result<(), ErrorObjectOwned>;
async fn check_health(&self) -> Result<BlockId, ErrorObjectOwned>;
// TODO: These functions should be removed after wallet starts using indexer
// for this type of queries.

View File

@ -82,8 +82,9 @@ impl<BC: BlockSettlementClientTrait + Send + 'static, IC: IndexerClientTrait + S
Ok(tx_hash)
}
async fn check_health(&self) -> Result<(), ErrorObjectOwned> {
Ok(())
async fn check_health(&self) -> Result<BlockId, ErrorObjectOwned> {
let sequencer = self.sequencer.lock().await;
Ok(sequencer.chain_height())
}
async fn get_block(&self, block_id: BlockId) -> Result<Option<Block>, ErrorObjectOwned> {