Skip to content

Publishing the Unchained Index Manifest

Thomas Jay Rush edited this page Sep 28, 2024 · 17 revisions

Before doing anything else

Try chifra chunks manifest --chain <chain> --pin --rewrite --remote (after starting IPFS). It should just "do the right thing."

How to Pin Chunk Manifests

Instructions for pinning chunk manifests to IPFS and Pinata.

Prepare the environment

Export the default chain (or use --chain chain in the following commands).

export TB_SETTINGS_DEFAULTCHAIN=chain

Update the index to the latest block

Either catch up to the tip of the chain with

chifra scrape

or copy the index from somewhere else using

# first...
cd ~/Data/trueblocks/v1.0.0/unchained/ && code **/get_index.sh ; cd -
# then...
cd ~/Data/trueblocks/v1.0.0/unchained/ && ./get_index.sh ; cd -

Pin the chunks to both IPFS and Pinata

Make sure the index passes checks. (Note: this may fail if there is no published manifest.)

chifra chunks index --check

Find the latest block in the manifest ($lastBlock). (Note: it may be zero.)

chifra chunks manifest | tail -1 | cut -f1 | cut -f2 -d'-' | sed 's/^0*//'

Subtract one from the latest block to ensure no off-by-one errors. Tell the next processes where to start pinning...

export TB_CHUNKS_PINFIRSTBLOCK=[$lastBlock]   # adjust for your shell

Start the IPFS daemon in a new shell.

ipfs daemon

Pin all chunks (--deep) to both local daemon and Pinata (--remote). Sleep to avoid rate limiting.

echo no | chifra chunks manifest --pin --deep --remote --sleep 1 

The echo no disables the check that would happen otherwise.

The above writes the new manifest to a temporary folder (check report at end of the processing). Double check the new manifest against the existing manifest. Nothing should have changed other than new records added.

Update the manifest.json file

Report on the latest LOCAL manifest record

chifra chunks manifest

Report on the latest REMOTE manifest record

chifra chunks manifest --remote

Bring the local manifest up to date with the local index files

echo no | chifra chunks manifest --pin --remote --rewrite

Note: Do not include --deep here. The above overwrites the local manifest. CIDs are shown on the console. Both of the above two commands should report the same index chunks.

Publish the manifest.json to the smart contract

Eventually

chifra chunks index --publish

which must run --pin first and produce two CIDs (for chain and chain-ts -- and maybe chain-names, etc.).

But until then:

  • Use EtherScan to publish to the smart contract.

Check your work

chifra init all --chain chain

chifra chunks index --check --chain chain

Control+C to stop an upload

It's okay to hit Control+C to stop a pinning session. The manifest is written to its destination at the end of each loop, so it's always up to date.

Also, this command:

chifra chunks manifest --pin --rewrite --remote --chain chain

will basically "freshen." Any chunks that are not in the manifest will be pinned.

Producing the manifest.json file

To produce a complete version of the manifest.json file, start ipfs and then run the following command:

chifra chunks manifest --pin --deep --remote --rewrite

Correcting a single chunk

THIS IS NOT YET TESTED

Not sure if this works, but you should be able to export two variables and re-run with --deep to post a single chunk to Pinata and this should update the manifest (but this is not clear).

export TB_CHUNKS_PINFIRSTBLOCK=block
export TB_CHUNKS_PINLASTBLOCK=block
echo no | chifra chunks manifest --pin --deep --remote --sleep 1

If updating the manifest doesn't work, you can run without --remote and --rewrite to update the local manifest and then run the --publish command.

echo no | chifra chunks manifest --pin --deep --sleep 1
chifra chunks manifest --pin --rewrite
chifra chunks index --publish