Skip to content

Store forged endorser blocks in the LeiosDB - #2442

Draft
dnadales wants to merge 6 commits into
mainfrom
dnadales/eb-forge-store
Draft

dnadales wants to merge 6 commits into
mainfrom
dnadales/eb-forge-store

Conversation

@dnadales

@dnadales dnadales commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

After forgeBlock returns an endorser block, the node kernel writes its point, body and transactions to the LeiosDB.
The point is the slot and the endorser block hash that the ranking-block header announces.

The forge does not await the writes.
Thus a peer can get the header before the LeiosDB stores the endorser block.
This is not a problem yet, because no peer fetches an endorser block from a header.
The node must send offers only after the LeiosDB sends AcquiredEb and AcquiredEbTxs.

On SQLite, the forge blocks while the write queue is full.

If a write fails, the node stops.
For this, the first commit makes the in-memory LeiosDB throw a failed write at submission, as the Promise haddock says.

Part of input-output-hk/ouroboros-leios#1107.

@dnadales
dnadales force-pushed the dnadales/eb-forge-store branch 3 times, most recently from 4eaae39 to 11cd377 Compare October 22, 2026 18:51
A caller that does not await the promise then sees the failure. The 'LeiosDbWriter' documentation now says that a write can throw at submission.
The LeiosDB needs these bytes to store the endorser block. Only 'forgeLeiosEb' builds a 'ForgedLeiosEb'. Thus the bytes always match the references in the endorser block.
Each forging thread opens a LeiosDB writer, and 'storeForgedEb' writes the point, the body and the transactions of each forged endorser block. The forge does not await the writes. On SQLite, it blocks while the write queue is full. If a write fails, the node stops.

'finalize' erases the KES key before 'closeWriter' runs, because 'closeWriter' waits for the LeiosDB write queue.
The test reads the endorser block back from the LeiosDB at the point that the header announces.
The test installs a block forging with 'setBlockForging' on a node over an in-memory LeiosDB. Thus it checks that 'forkBlockForging' gives 'storeForgedEb' to 'forge'.
@dnadales
dnadales force-pushed the dnadales/eb-forge-store branch from 11cd377 to e13e48b Compare October 22, 2026 19:08
@ch1bo ch1bo linked an issue Oct 23, 2026 that may be closed by this pull request
-- The forge does not await the writes. On SQLite, it blocks while the write
-- queue is full. If a write fails, the node stops. Peers can get the header
-- before the endorser block is stored.
storeForgedEb ::

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.

This shouldn't be here, can we move it closer to LeiosDb? Perhaps even in the API?

MkLeiosEb $
V.fromList [(MkTxHash (fromShort (toRawTxIdHash (txId tx))), 0) | tx <- txs]
ebListing :: NonEmpty (GenTx BlockA) -> ForgedLeiosEb
ebListing = forgeLeiosEb . fmap (fromShort . toRawTxIdHash . txId)

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.

ebListing is a foreing concept, this is mkForgedLeiosEb

This branch has not been deployed

No deployments
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.

Production-grade forging of EBs

2 participants