Add regtest network support#1
Open
emersonian wants to merge 7 commits into
Open
Conversation
Thread a `Parameters`-implementing `data::Network` (with a `Regtest(LocalNetwork)` arm) through the wallet stack instead of `zcash_protocol::consensus::Network`, which models only main/test. The wallet DB, key derivation, address encoding and transaction building are all generic over `Parameters`, so this lets devtool operate against a local regtest chain: `--network regtest` parses, persists by name, and reconstructs as a LocalNetwork with every upgrade active from height 1 (NU5/Orchard included), matching the zebra/zcashd regtest convention. `import-ufvk`/`init-fvk` now support regtest instead of rejecting it. This enables zcash-devtool to act as the funding wallet for zecd's regtest end-to-end tests: shield a mined transparent coinbase into Orchard, then send to zecd's unified address. https://claude.ai/code/session_011z9B9k8AMzQNHwFcaoLzVo
`init` previously always prompted for the mnemonic via `rpassword`, which requires a TTY and so can't be driven from a script or test. Add an optional `--mnemonic <PHRASE>` argument: when present it is used directly (and the wallet is treated as a restore); when absent the interactive prompt is unchanged. This lets zcash-devtool be initialised non-interactively as the funding wallet in zecd's regtest end-to-end tests. https://claude.ai/code/session_011z9B9k8AMzQNHwFcaoLzVo
After threading `data::Network` (instead of `consensus::Network`) through the wallet stack, `opts.network.into()` / `self.network.into()` convert the type to itself. Pass the value directly — fixes `clippy::useless_conversion` under `-D warnings`. https://claude.ai/code/session_011z9B9k8AMzQNHwFcaoLzVo
Derives an account's default unified address and its transparent receiver straight from a mnemonic — no chain and no on-disk wallet. This lets automated regtest funding learn the funding wallet's transparent address before any chain exists (zebra needs it as its coinbase `miner_address` at launch), so the funder can stay on a single chain and keep a valid wallet birthday anchor. https://claude.ai/code/session_011z9B9k8AMzQNHwFcaoLzVo
Activating NU6.1 on regtest makes zebra's z_gettreestate fail with "block not in the main chain" under lightwalletd v0.4.19, breaking wallet init. zecd's harness and zecd itself therefore run regtest at NU6; devtool's funding wallet must match or its shield/send transactions are rejected with an incorrect consensus branch id. Real NU6.1/NU6.2 support is gated on a librustzcash bump. https://claude.ai/code/session_011z9B9k8AMzQNHwFcaoLzVo
Bump all librustzcash crates to the current crates.io releases
(zcash_client_backend 0.23, zcash_client_sqlite 0.21, zcash_protocol 0.9,
orchard 0.14, …) and drop the [patch.crates-io] git pin to rev 77c422f.
This pulls in:
- real coinbase-maturity filtering in get_spendable_transparent_outputs
(the pin had none), so `wallet shield` no longer selects immature
coinbases that zebra rejects;
- the orchard 0.14 soundness fixes (retires yanked orchard 0.12.0); and
- NU6.2 support — regtest_local() now activates the full NU6.x line
from genesis.
Adapt to the 0.22→0.23 breaking surface:
- propose_shielding gains a TransparentOutputFilter (use ::All);
- propose_transfer / create_proposed_transactions gain a trailing
proposed_version: Option<TxVersion> (pass None);
- zip321 Payment::new returns Result, not Option;
- transparent::sighash::SignableInput::from_parts takes the bundle and
returns Result;
- pczt into_effects() returns Result;
- LocalNetwork gains nu6_1 / nu6_2 fields.
MSRV → 1.85.1.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
NU6.1's activation block must carry ZIP-271 lockbox disbursements out of the deferred pool, which only accrues once NU6 is live — so the regtest chain activates NU5/NU6 at height 1 and NU6.1/NU6.2 at height 4 (see zecd's regtest-harness). The funder must use the same heights so its transactions commit to the same consensus branch id. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Regtest network support so zcash-devtool can drive a wallet against a local regtest chain (zebra in Regtest mode behind lightwalletd).
librustzcash's
zcash_protocol::consensus::Networkmodels only main/test, but the whole wallet stack (WalletDb, key derivation, address encoding, transaction building) is generic overParameters. This threads devtool's owndata::Network— now implementingParameterswith aRegtest(LocalNetwork)arm — through that stack in place ofconsensus::Network.--network regtestparses, persists by name inkeys.toml, and reconstructs as aLocalNetworkwith every upgrade active from height 1 (NU5/Orchard included) — the zebra/zcashd regtest convention.import-ufvkandinit-fvknow support regtest instead of rejecting it (viaFrom<NetworkType> for Network).remote.rsgain a regtest arm (regtest always uses a custom--server).cargo fmtapplied; adds unit tests for regtest parsing + Orchard-active-from-genesis.Why
This is the enabling half of zecd's regtest end-to-end funding: zcash-devtool acts as the funding wallet — shield a mined transparent coinbase into Orchard, then send to zecd's unified address — so zecd's e2e suite can exercise funded receive/spend on regtest (where mining a shielded coinbase directly to Orchard isn't available).
https://claude.ai/code/session_011z9B9k8AMzQNHwFcaoLzVo
Generated by Claude Code