Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snapshot metadata #16

Open
placer14 opened this issue May 9, 2022 · 8 comments
Open

Snapshot metadata #16

placer14 opened this issue May 9, 2022 · 8 comments
Labels
enhancement New feature or request

Comments

@placer14
Copy link

placer14 commented May 9, 2022

In order to understand their contents before downloading the whole snapshot, as a consumer of these snapshots I would like separate metadata published for these snapshots such that I can programmatically parse and understand the snapshot.

Details to include:

  • creation date,
  • lotus version,
  • epochs included
  • (maybe) metadata version, so we can include additional fields later to be parsed conditioned on this version.

If you expect one snapshot to differ from another in ways other than the epochs covered (like the snapshot has a different finality of epochs, or manages the data in a different way) it would be useful to include some structure to capture these details.

@frrist
Copy link
Member

frrist commented May 9, 2022

Additionally, I'd like the following pieces of metadata:

  1. Snapshot Size in Bytes
  2. Root Tipset of Snapshot (largest height)
    • this is already in the CAR file header, but I'd I don't want to download the entire car file to get this info
  3. Last TipSet in Snapshot (smallest height)

@frrist
Copy link
Member

frrist commented May 9, 2022

From our in-person conversation if I want 3. someone (I volunteer) will need to add a new a new method:

ChainExportRange(from, to types.TipSetKey) (<-chan []byte, error)

or similar to Lotus.

@travisperson
Copy link
Contributor

This is what I think I can get without having to wait for a new lotus release

Property Type Description
CreatedAt time.Time Timestamp when snapshot export starts
Export.TipSet types.TipSet Tipset used on call to Filecoin.ChainExport
Export.Height types.ChainEpoch Height of TipSet
Export.Timestamp uint64 Unix Epoch for TipSet
Export.HeightDelta types.ChainEpoch Value used in call to Filecoin.ChainExport for staterootsIncluded
LotusVersion string Version of lotus software used to create export
Size int64 Size of car file in bytes

We can then later add a new property Export.LastTipSet, Export.LastHeight.

^ input welcome on naming / structure

@travisperson travisperson added the enhancement New feature or request label May 9, 2022
@travisperson travisperson added this to the v1 Initial Release milestone May 10, 2022
@placer14
Copy link
Author

placer14 commented May 10, 2022

  • I like including a unit where it's unclear. size_bytes
  • If you could use the HeightDelta to accurately show <epochFirst> - <epochLast> (inclusive) for included states, that would reduce off-by-one confusion.

Suggestions:

  • createdAt
  • tipsetID (I assume tipset is what is at epochLast)
  • tipsetEpoch
  • tipsetUnix
  • epochStart
  • epochEnd
  • sizeBytes
  • lotusVersion
  • metadataVersion (always 0 until the meta properties change)

Either Snakecase or camelcase is okay w me. Camelcase is my personal pref.

@frrist
Copy link
Member

frrist commented May 10, 2022

If you could use the HeightDelta to accurately show - (inclusive) for included states, that would reduce off-by-one confusion.

This isn't possible with the current lotus API implementation due to null rounds, which is why I suggested: #16 (comment)

@travisperson
Copy link
Contributor

travisperson commented May 10, 2022

Picking out the last TipSet that is included in the export isn't easy to do accurately because it's an implementation detail of ChainExport.

In this code b is the current TipSet being exported, ts is the provided TipSet to the ChainExport method and inclRecentRoots is the provided nroots to the ChainExport method.

b.Height > ts.Height()-inclRecentRoots

https://github.com/filecoin-project/lotus/blob/v1.15.2/chain/store/snapshot.go#L128

The last TipSet in the export depends on the operand used in the comparison as well as the null arounds around ts.Height()-inclRecentRoots.

To do this accurately and consistently we need a new export method that allows us to specify the last TipSet. Otherwise we can only really say it doesn't included states before some height, and even that is subject to off by one errors if lotus changes the operand.

For archival purposes of chain state we need the new method.

@placer14
Copy link
Author

Okay, I understand that including the firstHeight would not be accurate.

When I consume these snapshots, is it reasonable for me to infer the latest possible firstHeight to be included in any snapshot would be lastHeight - heightDelta?

Additionally, since the snapshots will be performed (I assume) at regular intervals with coverage over every epoch, that worst case there would sometimes be duplicated state exported in two different exports (until snapshots start consuming this new Export method).

@f8-ptrk
Copy link

f8-ptrk commented Aug 5, 2022

  • adding when x+1 will be created/available in the meta data of x will be beneficial
  • the exact params used to export the snapshot would be a nice addition

@travisperson travisperson removed this from the v1 Initial Release milestone Aug 11, 2022
@travisperson travisperson added this to the Archival Snapshots milestone Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

4 participants