ZIG: Zcash Config & RPC Compatibility Linter
Upgrading your Zcash stack can be a daunting task. Ensuring compatibility between different Zcash components and configurations is crucial for a smooth transition. This is where ZIG, the Zcash Integration Guardrail, comes in. ZIG is a compatibility linter designed to help you navigate the complexities of Zcash configurations and RPC usage. This article will delve into the details of ZIG, its functionalities, and how it can significantly reduce the risks associated with Zcash stack upgrades.
What is ZIG?
ZIG, the Zcash Integration Guardrail, is a command-line tool and CI-friendly utility designed to streamline the process of upgrading your Zcash stack. It acts as a compatibility linter, meticulously analyzing your Zcash configurations and RPC usage against a chosen target stack. Whether you're transitioning from zcashd to a Zebra-based setup or making other significant changes, ZIG provides a fast, automated way to identify potential incompatibilities. This proactive approach allows you to address issues before they escalate into major problems, saving you time and resources. By highlighting what might break and what needs to change, ZIG reduces migration risk and eliminates the need for manual compatibility checks. This ensures a smoother, more efficient upgrade process. The tool is engineered to standardize compatibility analysis, making it a go-to solution for various integration scenarios within the Zcash ecosystem.
Key Features and Functionalities
ZIG is not just another tool; it's a comprehensive solution packed with features designed to make your Zcash integration seamless. At its core, ZIG is a command-line program with optional CI integration, making it versatile for different environments. One of its key strengths is its ability to analyze three crucial inputs: the current and target stack, Zcash configuration files, and a plain-text file listing RPC methods used by the project. By comparing these inputs against a versioned compatibility profile for the chosen target stack, ZIG generates detailed reports. These reports are crucial for understanding the implications of your upgrade. The human-readable report explains which config keys are safe, which have changed semantics, which are obsolete, and which might be unsafe on the target stack. This clarity helps in making informed decisions and planning the upgrade effectively. Additionally, ZIG produces a JSON report and an exit code that CI can use to block or allow migrations based on the presence of blocking incompatibilities. This feature is invaluable for automating the compatibility checks in your CI/CD pipeline, ensuring that no incompatible changes make their way into production.
The Problem ZIG Solves
Upgrading a Zcash node stack for any serious integration – be it a wallet backend, exchange, explorer, or payment service – has traditionally been a high-risk, manual undertaking. The Zcash ecosystem is intentionally shifting away from the legacy zcashd node toward a more modular, Zebra-based stack, complete with separate services for indexing and light-client access. This transition, while beneficial in the long run, introduces challenges in maintaining compatibility. JSON-RPC methods and configuration options that were relied upon for years may no longer behave the same way, or might even be absent in the new stack. This is where ZIG steps in to bridge the gap. Core developers have acknowledged this challenge, publishing RPC compatibility spreadsheets and actively soliciting feedback from integrators about their zcashd JSON-RPC interface usage. However, for most projects, the actual migration process still involves tedious manual work: sifting through lengthy deprecation documents, poring over logs to identify RPC dependencies, comparing zcash.conf files with new config formats, and conducting trial upgrades to uncover failures. This method is not only time-consuming but also prone to errors. A critical method that an explorer or backend relies on may be removed or require a separate indexer, and this mismatch often surfaces late in testing or, worse, in production. ZIG directly addresses this problem by providing a tool that can analyze configurations and RPC calls, then offer concrete guidance: “If you move from stack A to stack B, these specific settings and methods will cease to function or require modification.” This crucial insight enables teams to prepare and validate their systems proactively, averting costly and risky issues during the upgrade process.
How ZIG Works: A Detailed Look
ZIG operates by automating the compatibility checks that teams currently perform manually when transitioning their Zcash node setup. Let's break down the process:
Inputs
ZIG takes three primary inputs:
- Stack Descriptors: The
--fromand--toflags specify the current and target setups. For instance, transitioning from a zcashd-based deployment to a specific Zebra-based stack. - Configuration Files: A Zcash configuration file, such as
zcash.conf, and optionally azebrad.tomlfile, are provided. - RPC Method List: A plain-text file listing the JSON-RPC methods used by the project, with one method name per line.
Internal Profiles
Internally, ZIG loads versioned "profiles" for both the source and target setups. Each profile contains crucial information:
- Configuration Options: Which config options are recognized and how they are interpreted.
- RPC Methods: Which RPC methods are available, along with important notes about their behavior or dependencies. For example, methods that are only available when an indexer is present.
Analysis and Reporting
When the zig check command is executed, the tool performs the following steps:
- Parses the configuration files and the RPC method list.
- Compares the parsed data against the loaded profiles.
- Generates two types of reports:
- A human-readable report detailing:
- Config keys that are safe.
- Config keys with changed meanings.
- Config keys that are obsolete on the target setup.
- Config keys that may be potentially unsafe.
- RPC calls that are fully supported, changed, or unsupported.
- An optional JSON report and an exit code (0/1/2) for CI integration, allowing automated blocking of changes that introduce incompatibilities.
- A human-readable report detailing:
The Benefits of ZIG's Approach
This methodology provides significant advantages:
- Clear, Project-Specific Answers: Instead of teams manually reviewing compatibility tables, scanning code, and guessing potential issues, ZIG delivers a clear, project-specific assessment of compatibility.
- Data-Driven Profiles: ZIG's profiles are data-driven, meaning new node versions or stack combinations can be supported by simply updating profile files, without modifying the core engine. This makes ZIG adaptable and future-proof.
Key Benefits of Using ZIG
ZIG offers several key advantages for Zcash integrators:
Reduced Migration Risk
ZIG provides a clear, project-specific view of breaking changes, such as missing RPCs and incompatible config options. This enables integrators to address these issues proactively, rather than discovering them in staging or production environments. By identifying potential problems early in the process, ZIG minimizes the risk of unexpected downtime and costly fixes.
Standardized Compatibility Analysis
ZIG replaces the need for repeated manual cross-checking of deprecation tables and documentation. It offers a shared tool that can be run locally or in CI across many different projects. This standardization not only saves time but also ensures consistency in compatibility checks across the organization.
Support for Future Upgrades
ZIG is structured around data-driven "profiles," which means compatibility descriptions for future node versions or stack combinations can be added without altering the engine. This makes ZIG a reusable asset for subsequent network upgrades, saving time and effort in the long run. The ability to adapt to future changes ensures that ZIG remains a valuable tool for Zcash integrators.
Lightweight and Efficient
ZIG is designed to be lightweight, focusing on static analysis of configs and RPC usage. It does not start nodes, connect to networks, or handle wallet data. This makes it a fast, efficient linter that projects can run quickly and easily integrate into their CI pipelines. The lightweight nature of ZIG ensures minimal overhead and seamless integration into existing workflows.
Proposed Solution Format
The solution will be delivered as a software project comprising:
- A command-line application ("ZIG") that runs locally or in CI, distributed as a static binary and optionally as a container image.
- A reusable compatibility engine and profile format (JSON or YAML files) for describing configuration and RPC behavior across different Zcash stacks.
- A minimal library interface (in the same language as the CLI) for projects that prefer programmatic access to ZIG.
- CI integration examples, including a ready-to-use GitHub Actions workflow and a generic script snippet for other CI systems.
- Comprehensive documentation, including a design note, a “Quickstart” guide, example
zcash.confand RPC manifest files, and a description of the JSON report format and exit codes.
Technical Approach
The project will follow a structured technical approach:
- Implementation Language and Packaging:
- Use a language suitable for building cross-platform CLI tools, such as Rust, to ship a single binary per platform.
- Optionally provide a minimal container image for teams that prefer Docker in CI.
- CLI and Core Engine:
- Implement a
zigCLI with achecksubcommand and flags for various inputs and output options. - The CLI will pass inputs to a core engine that performs static checks without starting nodes or connecting to networks.
- Implement a
- Config Parsing and Mapping:
- Implement parsing for
zcash.conf, handling comments, duplicate keys, and common options. - Implement a minimal parser for
zebrad.tomlto read keys relevant to RPC/API behavior and connectivity. - Define mapping rules to classify parsed config keys (OK, changed, obsolete, potentially unsafe).
- Implement parsing for
- RPC Manifest and Compatibility Profiles:
- Use a simple, line-based format for the RPC manifest (
rpc-usage.txt). - Define a JSON or YAML schema for stack profiles, describing RPC methods and their support status.
- Create profiles for clearly defined stacks based on public compatibility information and documentation.
- Use a simple, line-based format for the RPC manifest (
- Reporting and CI Integration:
- Implement a report generator that outputs a clear text summary, an optional JSON report, and exit codes for different outcomes.
- Provide a ready-to-copy GitHub Actions workflow and a generic shell snippet for CI integration.
- Testing, Security, and Reproducibility:
- Add unit tests for config parsing, RPC manifest parsing, and profile loading and matching.
- Add basic fuzz or property tests around parsing and matching logic.
- Set up a reproducible build process, generate an SBOM, and sign git tags and binaries with GPG.
Conclusion
ZIG represents a significant step forward in simplifying Zcash stack upgrades. By automating compatibility checks and providing clear, actionable insights, ZIG empowers integrators to migrate with confidence. As the Zcash ecosystem continues to evolve, tools like ZIG will be crucial for ensuring seamless transitions and maintaining the stability and reliability of the network.
For more information on Zcash and its ecosystem, visit the Zcash Foundation website.