get history, which is covered in Environment Preparation.
Getting to a complete archive takes two stages:
- Configuring your node to publish, described in the sections below. This fills the archive forward from the moment your node starts.
- Completing the archive, which backfills everything from before that point.
Caching and History Archives
The primary cost of running a validator will very likely be egress bandwidth. A crucial part of your strategy to manage those costs should be caching. You can significantly reduce these data transfer costs by using common caching techniques or a CDN. Three simple rules apply to caching the History archives:- Do not cache the archive state file
.well-known/stellar-history.json(Cache-Control: no-cache) - Do not cache HTTP 4xx responses (
Cache-Control: no-cache) - Cache everything else for as long as possible (> 1 day)
Local History Archive Using nginx
Here, we’ll demonstrate how you can configure your node to store its history files in the local filesystem, and then publish that history using nginx for our webserver software. First, you must add a history configuration stanza to your/etc/stellar/stellar-core.cfg configuration file.
new-hist command to create the local history archive.
Amazon S3 History Archive
Now, let’s demonstrate a configuration where your node stores its history files using Amazon’s S3 service. You can then publish that history using an Amazon S3 static site, or again use nginx for your webserver software. This time, using nginx, we’ll include some proxy and CDN configuration, as well. Start by adding a history configuration stanza to your/etc/stellar/stellar-core.cfg configuration file.
new-hist command to create and initialize the S3 archive.
Backfilling a History Archive
Given the choice, it’s best to configure your history archive prior to your node’s initial sync with an existing network. That way your validator’s history publishes as you join, and subsequently sync with, the network. However, if you have not published an archive during the node’s initial sync, the steps required to start publishing from an existing validator are quite straightforward. This is the first of the two stages on the way to a Full Validator; completing the archive follows. First, you’ll need to stop yourstellar-core instance:
/etc/stellar/stellar-core.cfg configuration file.
new-hist command to create and initialize the local archive. (This is done as the stellar user.)
Complete History Archive
This is the second stage. A Full Validator publishes an archive reaching back to the network’s first ledger. The stellar-archivist command line tool gives you what you need to close the gap.Installing stellar-archivist
Using the SDF package repositories, you can install it by running:stellar-archivist-rs --help (or stellar-archivist --help if installed from crates.io).
Where to run stellar-archivist
stellar-archivist is a standalone tool. It does not link against or communicate withstellar-core; all it needs is read and write access to the archive itself. That access can be a local filesystem path (file://), an HTTP(S) source, or a cloud object store (s3://, gcs://, azblob://, b2://), so you can run it from any machine that can reach your archive.
Choosing a command
All three accept
--low and --high to restrict the work to a ledger range; both bounds are rounded outward to the nearest checkpoint.
Checking file contents with --verify
By default, every command checks only that files exist. Adding --verify also checks that their contents are sound, which requires significantly more CPU and memory.
Leave it off for routine completeness checks and for fixing missing files. Turn it on to find and fix corruption, where a file exists but its contents are wrong.
Scanning an archive
scan is read-only. It walks the archive and reports the files that are missing, which is how you find out whether your archive has a gap and exactly where it is.1
--report writes the same findings as JSON:
filesmaps a checkpoint ledger to the file types broken at that checkpoint.bucketslists bucket hashes that are missing or failed their SHA-256 check.checkpointslists cross-file and hash chain failures, which are re-fetched whole.well_knownis the checkpoint to restore.well-known/stellar-history.jsonfrom, ornullwhen it is healthy.
Repairing an archive
Once a scan has told you what is broken,repair fixes it in place: it identifies missing or broken files at the destination and re-fetches them from a known-good source — such as the SDF public history archive.
Mirroring an archive
mirror copies a source archive to a destination. It is the command to reach for when backfilling: run it once to build a complete archive from scratch, or scope it with --low and --high to fill in just the range of history your validator did not publish itself.
For example, run the following command against an empty destination:
Footnotes
-
The sample output on this page was captured with
--verify, which is why it reports hash mismatches alongside the missing files. ↩