celestiaorg / go-header

Go library with all the services needed to request, sync and store blockchain headers.
Apache License 2.0
17 stars 16 forks source link

store: Head of store needs to be the *contiguous* head of the store #201

Open renaynay opened 4 days ago

renaynay commented 4 days ago

Currently in main, the head of the store is updated when an Append is done (via #186) because the assumption was that the syncer only does contiguous Appends to the store. This is actually not true because the syncer can write to the store via Append inside incomingNetHead whereby a header that comes in through headersub (or via p2p.Exchange request) can be verified non-adjacently and then applied to the store if it passes the non-adjacent verification.

We need to fix this by ensuring that the store knows of its own highest header that is contiguous (meaning all headers below the head are adjacent).

Note: once the Tail() method is implemented, the head of the store should be the highest header that is contiguous all the way down to the Tail().Height()

renaynay commented 4 days ago

Needs a test on the store to ensure that an Append that occurs that is non-adjacent to the highest head written to disk would still be successfully written to the disk but NOT reflected in Head() method until all headers below that height have also been written to the disk.