Running a Mina Archive Node

Setting up

  • A mina daemon.
  • The archive node package.
  • A Postgres node, with a database created with the archive node schema.
Simplest configuration of an archive node
The simplest configuration of an archive node

Adding Redundancy

Multiple daemons writing to a single archive process
Multiple daemons writing to a single archive process
ALTER DATABASE <DATABASE NAME> SET DEFAULT_TRANSACTION_ISOLATION TO SERIALIZABLE ;
Multiple daemons writing to multiple archive processes
Multiple daemons writing to multiple archive processes

Alternate storage for block data

Fully redundant archive node setup
Fully redundant archive node setup

Monitoring

SELECT count( * )
FROM (SELECT h::int FROM generate_series(1 , (select max(height) from blocks)) h
LEFT JOIN blocks b
ON h = b.height where b.height is null) as v
select count(*) from blocks where parent_id is null

Archive Tooling

  • mina-missing-blocks-auditor — reports state hashes of blocks missing from archive database.
  • mina-extract-blocks — extracts all blocks or a chain (from a provided start and end hash) from the database.
  • mina-archive-blocks — writes blocks to the archive database.
  • mina-replayer — replays transactions from the archive node.

mina-missing-blocks-auditor

mina-missing-blocks-auditor --archive-uri <POSTGRES_URI>{"timestamp":"2021-04-22 16:36:21.127744Z","level":"Info","source":{"module":"Dune__exe__Missing_blocks_auditor","location":"File \"src/app/missing_blocks_auditor/missing_blocks_auditor.ml\", line 30, characters 10-21"},"message":"Block has no parent in archive db","metadata":{"block_id":1145,"parent_hash":"3NLD34ddu4i8aPF6c7cD4aDh27MFWYTwamAoVRXWBFtcTeAbcJjA","pid":32,"state_hash":"3NK3zgLmMdptx9ubM1H4LTBadSQoQJ3ouYQbR6PQQnbq5vfTpGEo"}}
{"timestamp":"2021-04-22 16:36:21.127756Z","level":"Info","source":{"module":"Dune__exe__Missing_blocks_auditor","location":"File \"src/app/missing_blocks_auditor/missing_blocks_auditor.ml\", line 30, characters 10-21"},"message":"Block has no parent in archive db","metadata":{"block_id":3386,"parent_hash":"3NLk4z4hvUgiWPMyeF7iaKp78XyqHjGUqm2vabJB6v28VLuMyLQ2","pid":32,"state_hash":"3NKrHrebU3mQUiGwynuKxWW3d3snDCP2wczeDKw7S8t54kK8VkSX"}}

mina-extract-blocks

mina-extract-blocks --archive-uri <POSTGRES_URI> --all-blocks

mina-archive-blocks

mina-archive-blocks --extensional 3NKGgTk7en3347KH81yDra876GPAUSoSePrfVKPmwR1KHfMpvJC5.json --archive-uri <POSTGRES_URI>
find . -name "*.json" | xargs -I % mina-archive-blocks --extensional % --archive-uri <POSTGRES_URI> --log-successful false --successful-files success.txt --failed-files failed.txt

mina-replayer

mina-replayer --archive-uri <POSTGRES_URI> --input-file genesis.json --output-file calculated_ledger.json

Bootstrapping

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store