Repository navigation
Description
What's the problem
Part of #2476. Owner priority (2026-10-27): build the opt-in donation feature now, shipping dark. Where donated hashes go (recipient name, project address, endpoint host and port, endpoint kind, optional TLS fingerprint) must not live in config.json or the environment. The commit gate's typed APPLY prevents operator mistakes, not hostile requests (lib/pithead/42-control-policy-and-host-checks.sh:30-31), so any destination an operator or the dashboard can edit is a redirect surface for hashpower. Today there is no destination of any kind, and nothing validates one.
Add the destination as constants that ship inside the dashboard image, empty until the owner fills them:
- New
dashboard/mining_dashboard/config/donation.json, a sibling ofdefaults.json, which is loaded the same way (config/defaults.py:5,Path(__file__).with_name(...)) and ships becausedashboard/Dockerfile:43copies the whole package. - New loader
dashboard/mining_dashboard/config/donation_destination.pyreturning{"available": False, "reason": ...}unless every required field is present and valid. It reads no environment variable, no config key and no path supplied at runtime; only a test may pass a path argument. - Fields and checks:
recipient(non-empty, at most 40 characters);project_address(95 characters, starts with4, base58 alphabet; P2Pool can pay only a primary address,lib/pithead/25-address-types.sh:1-6);endpoint(host:port, port 1 to 65535);kind(onionorclearnet; an onion host is a 56-character base32 name plus.onion);tls_fingerprint(64 hex characters, required forclearnet, absent foronion). - The checksum is not re-implemented in Python.
monero_address_type(lib/pithead/25-address-types.sh:20) is the project's one checksum gate; a stack test calls it on the shipped address. - A provenance guard: a test pins the SHA-256 of
donation.json, so any change to the destination also changes a visible line in the same diff, and a drift test fails if the project address appears inREADME.md,docs/donation.md,docs/privacy.mdand the file with different values.
What it impacts
Everything that routes hashpower reads this file, so a wrong value sends donated hashes to the wrong place. While the file is empty, available is false and the rest of the feature stays hidden. .github/CODEOWNERS:6 is a single catch-all line naming the owner, so a path-specific CODEOWNERS entry would add nothing; the digest pin is the guard.
How I found it
Read-only scan of origin/develop-v2.1.0 at 02852bd on 2026-10-27 from the paths above. Nothing was executed. Unknown: whether the owner will use a dedicated project address or the one at README.md:271-275 (owner decision; the tests must work for either), and the onion address format of the endpoint (assumed v3).
How important is it
High and sensitive: it is the only place a destination can be set, so the guard is the redirect defence. No risk while empty.
Acceptance criteria
donation.jsonships with every field empty; the loader returnsavailable: Falseand a reason; importing it never raises.- New
dashboard/tests/config/test_donation_destination.py: each malformed field (wrong address length, prefix or alphabet; bad onion host; port 0 or 65536; unknown kind; clearnet without a fingerprint; onion with one) yieldsavailable: Falsewith a reason that names the field and contains no field value; a fixture with all fields valid yieldsavailable: Truewith the fields. - A test shows the loader result does not change when
DONATION_*,XVB_*orP2POOL_*environment variables are set, and a test greps the module foros.environandgetenvand finds none. - New stack test (
tests/stack/): sourceslib/pithead/25-address-types.shand assertsmonero_address_typeisprimaryfor the fixture address (VALID_PRIMARY,tests/stack/lib.sh:237) and for the shipped address when non-empty. With the shipped file empty it reports "skipped: empty", not a pass. - SHA-256 pin test: changing any byte of
donation.jsonwithout updating the digest fails; the failure message says the change needs an owner-approved PR. - Drift test: with a non-empty fixture, every occurrence of the project address in the listed docs equals the constant; with the shipped empty file it checks nothing and says so.
- No code path outside the loader reads
donation.json; the tests for the controller and API children inject a path. make test,make test-patch-coverage(90 % of changed lines) andmake lint-file-budgetpass. No new explanatory code comments.
Possible solutions
- JSON beside
defaults.json(recommended: same loader pattern, ships without packaging changes). - Python module constants: simpler to import, harder to diff and to digest-pin.
- Build-time injection through a Dockerfile argument: more moving parts and a build-path change that needs a
tier4-e2ejob; not recommended.
Part of #2476.
Activity