cli/core: introduce doublezero-cli-core crate and solana_l1_rpc_url#3753
Open
juan-malbeclabs wants to merge 2 commits into
Open
cli/core: introduce doublezero-cli-core crate and solana_l1_rpc_url#3753juan-malbeclabs wants to merge 2 commits into
juan-malbeclabs wants to merge 2 commits into
Conversation
This was referenced May 22, 2026
ben-dz
reviewed
May 22, 2026
1732849 to
3bd8661
Compare
When the caller supplies ledger_rpc_url but not ledger_ws_rpc_url, the builder now derives the WebSocket URL by scheme swap (https to wss, http to ws) instead of leaving the env default in place. Without this, ctx.ledger_rpc_url and ctx.ledger_ws_rpc_url could disagree when only the RPC URL was overridden, silently pairing a custom RPC with a stale env-default WS endpoint. Adds builder tests covering both schemes, the explicit-WS-wins case, the env-only regression path, and extends the existing per-field override test to assert the WS is derived from the custom RPC.
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.
RFC-20 implementation stack
This PR is part of a 9-PR chain delivering RFC-20: CLI standardization. Each PR's diff is only its own contribution; reviewers should consume them in order.
doublezero-cli-corefoundation crate +solana_l1_rpc_url--solana-url+--log-verboseglobal flags + tracing initCliContextbuilt inmain+ centralized error renderingdoublezero_cli→doublezero-serviceability-clilocation getas the async +CliContextreference verbdocs/cli-standard.md+CLAUDE.mdpointerServiceabilityCommandenum + async dispatcher#[command(flatten)]+ collapse binary dispatchThis PR: #3753 — position 1 of 9. Previous: (none — base is
main) · Next: #3754Summary of Changes
doublezero-cli-core(crates/doublezero-cli-core/), the shared library crate everydoublezero-<module>-cliwill reuse per RFC-20. ShipsCliContext+CliContextBuilder,RequirementCheckbitflags (bit values aligned with the legacyCHECK_ID_JSON | CHECK_BALANCE | CHECK_FOUNDATION_ALLOWLISTconstants), the shared validators (validate_pubkey,validate_pubkey_or_code,validate_code,validate_parse_bandwidth,validate_parse_delay_ms,validate_parse_jitter_ms,validate_parse_delay_override_ms), theDisplayVecformatter, atracing+tracing-subscriberinit_logging(verbosity)helper that writes to stderr, andtestinghelpers (cli_context_for_tests,cli_context_default_for_tests).solana_l1_rpc_urltodoublezero-config::NetworkConfigwith the per-environment defaults from RFC-20 §Environments (mainnet-beta -> Solana mainnet-beta; testnet and devnet -> Solana testnet; local ->http://localhost:8899) plus aDZ_SOLANA_RPC_URLenv-var override mirroring the existingDZ_LEDGER_RPC_URL/DZ_LEDGER_WS_RPC_URLoverrides.validators.rsandformatters.rsout ofsmartcontract/cli/into the new core crate. Existing import paths continue to compile via thinpub usere-export shims insmartcontract/cli/src/{validators,formatters}.rs, so the rest of the workspace is unaffected.Diff Breakdown
Introduces ~620 lines of shared CLI utility code in the new core crate while shrinking
smartcontract/cliby replacing its validator and formatter implementations with thin re-export shims; no behavior change.Key files (click to expand)
crates/doublezero-cli-core/src/context.rs-CliContext,OutputFormat, and theCliContextBuilderthat resolves--envdefaults fromdoublezero-configand applies per-field overrides.crates/doublezero-cli-core/src/validators.rs- sharedclapvalue-parsers (pubkey, code, pubkey-or-code, bandwidth, delay, jitter, delay-override) with their unit tests; moved verbatim fromsmartcontract/cli/src/validators.rs.crates/doublezero-cli-core/src/requirements.rs-RequirementCheckbitflags type (KEYPAIR / BALANCE / FOUNDATION_ALLOWLIST) with bit values preserved for ABI continuity with the legacyu8constants.crates/doublezero-cli-core/src/testing.rs-cli_context_for_tests()/cli_context_default_for_tests()helpers for module-crate verb tests.crates/doublezero-cli-core/src/formatters.rs-DisplayVec+stringify_vecmoved fromsmartcontract/cli.crates/doublezero-cli-core/src/error.rs-Resultalias,CliError,render_eyrehelper for chain-of-causes rendering.crates/doublezero-cli-core/src/logging.rs-init_logging(verbosity)viatracing-subscriberwith stderr writer; honorsRUST_LOGwhen set.config/src/env.rs- addssolana_l1_rpc_urltoNetworkConfig, wires it through per environment, and addsDZ_SOLANA_RPC_URLoverride plus tests.Testing Verification
cargo test -p doublezero-cli-corepasses (16 tests across validators, requirements bitflags, context builder, testing helpers, formatters).cargo test -p doublezero-configpasses (9 tests including two new ones covering the Solana L1 URL resolution per environment and theDZ_SOLANA_RPC_URLoverride).make rust-testgreen, including the program-accounts-compat run.make rust-lintclean.smartcontract/cliconsumers continue to compile against the shim files (use doublezero_cli::validators::*and friends resolve through the re-export).