0xPolygonMiden / miden-client

Client library that facilitates interaction with the Miden rollup
MIT License
32 stars 27 forks source link

Improve `block_headers` table for `SqliteStore` #216

Closed igamigo closed 6 months ago

igamigo commented 6 months ago

Currently, the block headers table is defined as follows:

-- Create block headers table
CREATE TABLE block_headers (
    block_num UNSIGNED BIG INT NOT NULL,  -- block number
    header BLOB NOT NULL,                 -- serialized block header
    notes_root BLOB NOT NULL,             -- root of the notes Merkle tree in this block
    sub_hash BLOB NOT NULL,               -- hash of all other header fields in the block
    chain_mmr_peaks BLOB NOT NULL,        -- serialized peaks of the chain MMR at this block
    has_client_notes BOOL NOT NULL,       -- whether the block has notes relevant to the client
    PRIMARY KEY (block_num)
);

This was left over since https://github.com/0xPolygonMiden/miden-client/issues/5#issuecomment-1767221302, but there is no current need to store the serialized block header alongside the notes_root and the sub_hash since this is redundant. We can either remove the columns and keep the serialized block header (probably preferrable), or remove the serialized block header column and store the required parts to build it.