- JavaScript 75%
- Python 24.3%
- Shell 0.7%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .env.example | ||
| .gitignore | ||
| archive-repos.py | ||
| mainnet-credentials.conf | ||
| package-lock.json | ||
| package.json | ||
| publish.mjs | ||
| publish.test.mjs | ||
| README.md | ||
| run.sh | ||
| tarball-blobs@.service | ||
| test-archive-repos.py | ||
| test-wallet-terminal.py | ||
| wallet.mjs | ||
| wallet.test.mjs | ||
Tarball → Ethereum blobs
Note written by Samuel: ERC7588 not followed because it consumes too much calldata gas. invented custom metadata format that is human-readable enough to decode without a spec document, and also efficient in terms of calldata gas
The code and documentation were written by gpt-6-astra high (high reasoning effort), except for Samuel's note above.
A small Node.js publisher using ethers and c-kzg. The production entry point
is publish.mjs. It republishes the whole
latest text_english_tarball_md_YYYYMMDD.tar, even when the file is unchanged.
Production uses Ethereum mainnet only. The schedule is:
| Archive | Schedule |
|---|---|
| Text markdown | Daily at 00:00 UTC |
| All public repositories (optional) | Every 17 days at 00:00 UTC |
| Non-text/non-video tarball (optional) | Every 17 days at 00:00 UTC |
All three share one wallet and worker, with separate transaction chains and checkpoints.
Run
Requires Linux, Node.js 22+, flock (util-linux), and a C/C++ build toolchain and
Python for c-kzg (sudo apt-get install build-essential python3 util-linux).
npm ci
npm test
npm run check # download + read-only mainnet RPC check; no key needed
cp .env.example .env
chmod 600 .env
# Edit .env for optional source and fee settings.
# Use the wallet and systemd setup below to start publishing on mainnet.
The default network is mainnet. No keys are bundled. Keep .env,
custom RPC URLs and runtime state private; .gitignore excludes local secrets,
dependencies and downloads. package-lock.json pins dependencies. The package's
private setting prevents accidental npm publication; the Git repo is publishable.
Always launch through run.sh / npm so flock prevents overlapping workers.
The fee defaults are 0.001 ETH per transaction and 0.001 ETH per publication,
including execution gas and blob gas at their maximum signed prices. Both are
configurable in .env. The publication cap applies separately to each archive,
so publishing all three has a combined ceiling of 0.003 ETH.
Confirmations default to two (CONFIRMATIONS). Use a
separate wallet for each network/service and do not send unrelated transactions
from it. The publisher does not fund wallets.
Mainnet hot wallet
Create a new wallet locally using the OS cryptographic random generator:
sudo npm run wallet -- create
This prints only the address. It stores the private key encrypted by
systemd-creds in /etc/credstore.encrypted/tarball-blobs-mainnet.cred and writes
the public expected address and fee limits to /etc/tarball-blobs/mainnet.env.
Both files are owner-only (600) in private directories (700). It refuses to
overwrite files, verifies encryption/decryption, and fsyncs before reporting success.
The private key is never written to a plaintext file, environment variable, command
line, repository or log by the generator. No mnemonic is generated or stored.
The npm command and service disable core dumps; direct invocation should do so too.
The publisher reads the decrypted key from systemd's service credential directory
at runtime. Mainnet requires this credential and an EXPECTED_ADDRESS match;
it will not use PRIVATE_KEY from an environment file.
This server has no usable TPM. Host-key encryption supports unattended restarts, but root access or a disk image containing both the credential and the host key can recover the wallet. A compromised publisher can also use its loaded key. Keep only the operating funds needed in a hot wallet; code fee caps do not constrain an attacker who obtains the key. JavaScript cannot guarantee wiping every memory copy of a key. See systemd credentials.
Make a portable encrypted recovery backup in your own SSH terminal before funding:
sudo npm run wallet -- backup /root/.config/tarball-blobs/mainnet.keystore.json
Enter and confirm a long unique passphrase (at least 16 characters) at the hidden prompts. Do not put it in chat, shell arguments or environment variables. The command uses the standard ethers encrypted JSON keystore, decrypts it to verify the address, and refuses to overwrite an existing backup. Copy the encrypted JSON off the server and store the passphrase separately, for example in your password manager. Loss of the server and host key without a portable backup loses access to the wallet. The encrypted systemd credential alone is not a portable backup.
Keep running after reboot
The included systemd service restarts after failures and boots automatically when
enabled. Install the code in /opt/tarball-blobs and keep credentials outside it:
sudo install -d /opt/tarball-blobs /etc/tarball-blobs
sudo cp publish.mjs archive-repos.py wallet.mjs run.sh package.json package-lock.json /opt/tarball-blobs/
sudo npm ci --prefix /opt/tarball-blobs
sudo install -m 644 tarball-blobs@.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl disable --now tarball-blobs@sepolia
sudo systemctl mask tarball-blobs@sepolia
For production, first create and back up the mainnet wallet as above, then install the mainnet-only credential configuration:
sudo install -d /etc/systemd/system/tarball-blobs@mainnet.service.d
sudo install -m 644 mainnet-credentials.conf /etc/systemd/system/tarball-blobs@mainnet.service.d/credentials.conf
sudo systemctl daemon-reload
# When funded and ready to publish:
sudo systemctl enable --now tarball-blobs@mainnet
journalctl -u tarball-blobs@mainnet -f
Review fee limits in /etc/tarball-blobs/mainnet.env before enabling the service.
The template uses the system node on PATH; a Node installation inside a home
directory is inaccessible to this service.
The archive and signed transactions are stored in systemd's persistent
StateDirectory (/var/lib/tarball-blobs-mainnet). Manual runs use
${XDG_STATE_HOME:-$HOME/.local/state}/tarball-blobs/<network>. Preserve that
directory when moving servers. Do not run a manual worker alongside systemd with
the same wallet and a different state directory: their locks would be separate.
Mainnet waits until the next 00:00 UTC on its first scheduled start, then runs markdown daily and both other archives every 17 days at UTC midnight, independent of the server's local timezone. Deadlines are saved on disk; upgrading an existing mainnet checkpoint aligns its old 24-hour deadline to midnight after the previous publication's start.
Interrupted uploads resume immediately and finish before the next begins. If
downtime, failures or slow inclusion miss a saved deadline, one fresh publication
starts after recovery; there is no backlog of overlapping runs. Mainnet then
sets the next deadline from that publication's start date (one day for markdown,
17 days for code and non-text/non-video). These are start times; confirmations still depend
on the network. --once publishes immediately regardless of the schedule, resuming
any incomplete publication first.
Public repository archive
Set REPOS_URL=https://git.example.org in the private
/etc/tarball-blobs/mainnet.env file and restart tarball-blobs@mainnet to enable
the second archive. Keep the actual server configuration outside the public repo.
For a local read-only check, set REPOS_URL in your ignored .env and run
npm start -- mainnet --check; this downloads and checks all enabled sources without a wallet.
Python 3 is required at runtime for archive-repos.py; it uses only the standard library.
Each run anonymously enumerates every page of the server's public repository list using the Forgejo API, resolves each default branch to a commit, and downloads the archive for that commit. It decompresses and unpacks the repository archives into one uncompressed tar:
manifest.json # public source, repository names, branches, commits
repos/<owner>/<repo>/... # extracted repository files
Empty repositories appear as empty directories with a null commit in the manifest. The list and branch tips are checked again before accepting the snapshot; any failure or change retries the whole build. Requests use unique cache-busting queries and no-cache headers, rejecting reported stale or ambiguous Cloudflare responses. Only explicitly public repositories are included; no Git credentials, SSH keys, API tokens, local working copies or wallet files are used to build this archive. Everything fetched from those public repositories is published, including any sensitive file already committed there; the builder does not redact repository content.
The snapshots contain default-branch files, not Git history, other branches, issues, wikis, release attachments or recursively fetched submodules. Committed archives inside a repository remain ordinary files. Downloaded tar/gzip and ZIP wrappers are unpacked by streaming members into the final tar without extracting onto the host filesystem or executing repository code. Unsafe paths, escaping symlinks and special files are rejected. Each response and the combined tar are limited to 64 MiB; exceeding that limit fails the run instead of publishing a partial archive.
The existing markdown checkpoint stays at state.json / archive.bin in the state
directory. Repositories use repos-state.json / repos-archive.bin; temporary
snapshot files also stay there, outside Git. On mainnet, markdown runs daily and
repositories run every 17 days, both at 00:00 UTC, executing sequentially
when both are due. A newly enabled repository job first waits
until the next midnight.
Existing daily repository checkpoints migrate once to the 17-day interval,
preserving their snapshot, signed transactions and original publication date.
The current Ethereum mainnet configuration
sets a minimum data retention window of 4,096 epochs (about 18.2 days). Seventeen
days leaves roughly 29 hours for uploading and retries; outages or fee-cap delays
can still cause a gap. The schedule does not guarantee permanent availability.
--once publishes each enabled archive once, resuming any unfinished chain first.
An unfinished chain owns the wallet until complete, including across restarts;
source failures before a chain starts allow the other archive to proceed.
Do not remove REPOS_URL while its publication is unfinished: the worker stops
starting new chains until that configuration is restored.
Non-text/non-video archive
Set NON_TEXT_NON_VIDEO_SOURCE_URL=https://example.org/archives/ in the private
mainnet environment file to enable the third archive. This is a directory URL,
including its trailing slash. Each publication selects the latest dated
non_text_non_video_tarball_html_YYYYMMDD.tar (also accepting a date with a time
suffix), downloads it with the same cache checks as markdown, and publishes the
tar unchanged as its own transaction chain. The source does not need to have
generated a new tarball that day.
It first becomes due at the next 00:00 UTC, then every 17 days on mainnet.
The same 0.001 ETH per-archive cap applies.
Its checkpoint and saved download are non_text_non_video-state.json and
non_text_non_video-archive.bin in the persistent state directory. All three
archives run sequentially and unfinished uploads resume first. Disabling a source
with an unfinished publication blocks new chains until its configuration is restored.
Freshness and data format
Both directory listings and downloads use a unique query parameter and no-cache
headers. The directory is checked again after download. Known cached/stale
Cloudflare responses (HIT, STALE, UPDATING), ambiguous Cloudflare statuses,
and responses with a positive Age are rejected. The filename's date determines
the newest file, not the order of the HTML listing. The downloaded tar is published
unchanged; its SHA-256 is checked when resuming.
A client cannot force Cloudflare to bypass a rule that ignores query strings.
For guaranteed origin freshness, configure a Bypass cache rule for
/raw/misc/*, or set SOURCE_URL to a trusted uncached origin directory (with a
trailing slash). If freshness cannot be established, the worker retries rather
than publishing a known cached copy. This checks Cloudflare's reported cache
status, not the freshness of any hidden cache at the origin. See
Cloudflare's cache response definitions.
Each 32-byte field stores 0x00 plus 31 payload bytes. The tar is one continuous
stream across all transactions; only its end receives 0x80 and zero padding.
Groups contain at most six blobs, using EIP-7594
cell proofs and wrapper version 1. Calldata is UTF-8 JSON: the first transaction
contains i (zero), chain_total_tx_count (total transactions), content_type
(application/x-tar) and description (text explaining how to reconstruct the
chain); later ones contain f (the first transaction's hash) and i (the zero-based
transaction index). Transactions send zero ETH to the zero address. Gas accounts for the
EIP-7623 calldata floor.
This matches the public Sepolia example.
The keyless failover endpoints come from ChainList mainnet
and Sepolia, with the selection date in the
code. RPC_URLS can replace the list. Every RPC attempt checks its chain ID;
timeouts, unsupported methods and send failures fall through to the next endpoint.
Public endpoints may rate-limit or refuse blob submissions even if read calls work.
Recovery and verification
Before broadcast, the signed transaction (including blobs) is atomically written and fsynced. After a crash or lost RPC response, the same signed bytes are checked and rebroadcast, preserving the nonce and first transaction hash. Receipt status, canonical block hash and confirmation depth are checked. All saved transactions are checked again on resume and before declaring the upload complete.
Transactions are never automatically replaced with higher-fee versions. This keeps the first transaction's hash stable for its followers. An underpriced saved transaction waits for fees to fall; nonce conflicts or failed transactions need operator attention. Do not delete state while a transaction may still be pending. Completed runs are not monitored indefinitely for reorgs; increase confirmations if that risk matters. Blobs provide temporary data availability, not permanent storage; periodic republication does not make old blob data permanent.
npm test exercises binary boundary round trips, calldata, cache rejection,
latest-file selection, RPC failover, receipt checks, real KZG transaction signing,
fee caps, a lost broadcast acknowledgement, restart recovery and reorg replay.
It also checks three-archive scheduling and recovery priority, filename isolation, pagination, public-only
selection, tar/ZIP unpacking, unsafe paths, size limits and incomplete snapshot rejection.
--check tests the live source and a read-only RPC call; it does not send a
transaction or prove a public RPC accepts blob writes. A funded --once run is
the end-to-end network test.