Components
BlockDB’s capabilities come from a set of gRPC services and background services, all of which can be composed flexibly throughcmd/blockdb’s -services flag.
meta-service
meta-service is a standalone metadata process responsible for the lifecycle and schema definitions of logical tables:
The core read and write services fetch table metadata from meta-service through a Meta client (
pkg/blockdb/meta) and hold no physical schema information themselves.
read
Provides row-level reads for regular tables, implementingTableReadService:
GetRow: read a single row by business primary key.BatchGetRows: read multiple primary keys in one RPC.FilterRows: filter rows by condition, with sorting and pagination.
block-read
Provides block-oriented reads for Block tables, implementingBlockReadService and L2BlockReadService:
GetEvent: read events at a block.GetState: read a state snapshot at a block, automatically injectingheight ≤ target height.GetConsensusHeight: get the table’s current consensus height.GetBlockRows: get all rows at a given block height.
scan
Provides full-table streaming scans, implementingTableScanService:
Scan: accepts a SQL query and returns result rows as a stream, avoiding memory blowups.
write
The entry point for real-time writes to all logical tables, aggregatingTableWriteService, BlockWriteService, and TimeWriteService in one service:
- Regular tables:
UpsertRows/DeleteRows. - Block tables:
UpsertBlock. - Time tables:
UpsertTimeRows.
asyncqueue) and flushed by multiple threads, delivering near real-time write responses while the queue capacity protects the database from overload.
See Write architecture.
batch-write
Manages asynchronous batch write jobs for massive datasets, implementingBatchWriteService:
InitWriteJob: initialize a write job and return an S3 presigned upload URL plus a job ID.CommitWriteJob: commit the job, triggering background worker processing.CancelWriteJob: cancel a job.
batch-worker
The background worker that executes batch write jobs, paired withbatch-write:
- Consumes the job files already staged in S3.
- Performs sorting, dedup, and batched ingestion (see Write architecture).
subscribe
Provides streaming block event subscription, implementingBlockSubscribeService:
Subscribe: subscribe to block write events for one or more Block tables.
BlockSubscribeEvent published by the write service through Kafka (eventbus). Subscribers receive events as a gRPC stream, driving downstream incremental consumption. Because it maintains long-lived connections, deploy it standalone.
state-compactor
A periodic background task that recomputes the statelatest table by scanning _archive, keeping the latest-state table consistent with the archived data. It must run as a single instance to avoid concurrent write conflicts.
Core code packages
The core packages behind these services (underpkg/blockdb/):