{"id":13712560,"url":"https://github.com/Syndica/sig","last_synced_at":"2025-05-06T22:31:22.628Z","repository":{"id":167702762,"uuid":"643094518","full_name":"Syndica/sig","owner":"Syndica","description":"a Solana validator client implementation written in Zig","archived":false,"fork":false,"pushed_at":"2025-05-02T19:34:30.000Z","size":25867,"stargazers_count":285,"open_issues_count":45,"forks_count":44,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-05-02T19:37:14.591Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://syndica.io/sig","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Syndica.png","metadata":{"files":{"readme":"docs/readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-20T04:54:48.000Z","updated_at":"2025-05-02T04:50:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"3769405c-b406-4db3-bc75-2bead24c6131","html_url":"https://github.com/Syndica/sig","commit_stats":null,"previous_names":["syndica/sig"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Syndica%2Fsig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Syndica%2Fsig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Syndica%2Fsig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Syndica%2Fsig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Syndica","download_url":"https://codeload.github.com/Syndica/sig/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252779028,"owners_count":21802867,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T23:01:19.842Z","updated_at":"2025-05-06T22:31:17.607Z","avatar_url":"https://github.com/Syndica.png","language":"Zig","funding_links":[],"categories":["Applications","Network \u0026 Web"],"sub_categories":["Web3 Framework"],"readme":"\u003cbr/\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ch1 align=\"center\"\u003e\u0026nbsp;🤖⚡ \u0026nbsp;\u003ccode\u003eSig\u003c/code\u003e - a Solana Zig validator client\u003c/h1\u003e\n    \u003cbr/\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/syndica/sig/releases/latest\"\u003e\u003cimg alt=\"Version\" src=\"https://img.shields.io/github/v/release/syndica/sig?include_prereleases\u0026label=version\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/syndica/sig/actions/workflows/check.yml\"\u003e\u003cimg alt=\"Build status\" src=\"https://img.shields.io/github/actions/workflow/status/syndica/sig/check.yml?branch=main\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://ziglang.org/download\"\u003e\u003cimg alt=\"Zig\" src=\"https://img.shields.io/badge/zig-0.13.0-green.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/syndica/sig/blob/main/LICENSE\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/badge/license-Apache_2.0-blue.svg\"\u003e\u003c/a\u003e\n  \u003c/div\u003e\n\u003c/p\u003e\n\u003cbr/\u003e\n\n_Sig_ is a Solana validator client implemented in Zig. Read the [introductory blog post](https://blog.syndica.io/introducing-sig-by-syndica-an-rps-focused-solana-validator-client-written-in-zig/) for more about the goals of this project.\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n⚠️ NOTE: This is a WIP, please open any issues for any bugs/improvements.\n\n## File Structure \n\n```\ndata/\n├─ genesis-files/\n├─ test-data/\ndocs/\n├─ debugging.md\n├─ fuzzing.md\n├─ sig-cli.md\nmetrics\n├─ prometheus/\n├─ grafana/\nscripts/\nsrc/\n├─ main.zig # exec entrypoint \n├─ sig.zig # library entrypoint\n├─ tests.zig \n├─ fuzz.zig \n├─ benchmarks.zig \n```\n\n\n## 📋 Setup\n\n### Build Dependencies\n\n- Zig 0.13.0 - Choose one:\n  - [Binary Releases](https://ziglang.org/download/) (extract and add to PATH)\n  - [Install with a package manager](https://github.com/ziglang/zig/wiki/Install-Zig-from-a-Package-Manager)\n  - Manage multiple versions with [zigup](https://github.com/marler8997/zigup) or [zvm](https://www.zvm.app/)\n\n\u003cdetails\u003e\u003csummary\u003e\n\n### Developer Tools\u003c/summary\u003e\n\nThese tools are optional but recommended for a smooth development process.\n\n- [Zig Language Server (ZLS) 0.13.0](https://github.com/zigtools/zls/wiki/Installation)\n- [lldb](https://lldb.llvm.org/): [Zig CLI Debugging](https://devlog.hexops.com/2022/debugging-undefined-behavior/)\n- [Zig Language](https://marketplace.visualstudio.com/items?itemName=ziglang.vscode-zig) VS Code extension\n- [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb) VS Code extension\n\n#### Visual Studio Code\n\nIf you use VS Code, you should install the [Zig Language](https://marketplace.visualstudio.com/items?itemName=ziglang.vscode-zig) extension. It can use your installed versions of Zig and ZLS, or it can download and manage its own internal versions.\n\nYou can use [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb) to debug Zig code with lldb in VS Code's debugging GUI. If you'd like to automatically build the project before running the debugger, you'll need a `zig build` task.\n\n\u003cdetails\u003e\u003csummary\u003etasks.json\u003c/summary\u003e\n\n```yaml\n{ ? // See https://go.microsoft.com/fwlink/?LinkId=733558\n    // for the documentation about the tasks.json format\n    \"version\"\n  : \"2.0.0\", \"tasks\": [{ \"label\": \"zig build\", \"type\": \"shell\", \"command\": \"zig\", \"args\": [\"build\", \"--summary\", \"all\"], \"options\": { \"cwd\": \"${workspaceRoot}\" }, \"presentation\": { \"echo\": true, \"reveal\": \"always\", \"focus\": false, \"panel\": \"shared\", \"showReuseMessage\": true, \"clear\": false }, \"problemMatcher\": [], \"group\": { \"kind\": \"build\", \"isDefault\": true } }] }\n```\n\n\u003c/details\u003e\n\nTo run the debugger, you need a run configuration. This launch.json includes an example for debugging gossip. Customize the args as desired.\n\n\u003cdetails\u003e\u003csummary\u003elaunch.json\u003c/summary\u003e\n\n```json\n{\n  \"version\": \"0.2.0\",\n  \"configurations\": [\n    {\n      \"type\": \"lldb\",\n      \"request\": \"launch\",\n      \"name\": \"Debug Gossip Mainnet\",\n      \"program\": \"${workspaceFolder}/zig-out/bin/sig\",\n      \"args\": [\n        \"gossip\",\n        \"--entrypoint\",\n        \"entrypoint.mainnet-beta.solana.com:8001\",\n        \"--entrypoint\",\n        \"entrypoint2.mainnet-beta.solana.com:8001\",\n        \"--entrypoint\",\n        \"entrypoint3.mainnet-beta.solana.com:8001\",\n        \"--entrypoint\",\n        \"entrypoint4.mainnet-beta.solana.com:8001\",\n        \"--entrypoint\",\n        \"entrypoint5.mainnet-beta.solana.com:8001\"\n      ],\n      \"cwd\": \"${workspaceFolder}\",\n      \"preLaunchTask\": \"zig build\"\n    }\n  ]\n}\n```\n\n\u003c/details\u003e\n\n\u003c/details\u003e\n\n## 🔧 Build\n\n```bash\nzig build\n```\n\n## 🚀 Run\n\nRun Sig with `zig` or execute the binary you already built:\n\n```bash\nzig build run -- --help\n```\n\n```bash\n./zig-out/bin/sig --help\n```\n\nThese commands will be abbreviated as `sig` in the rest of this document.\n\n### 👤 Identity\n\nSig stores its private key in `~/.sig/identity.key`. On its first run, Sig will automatically generate a key if no key exists. To see the public key, use the `identity` subcommand.\n\n```bash\nsig identity\n```\n\n### 📞 Gossip\n\nTo run Sig as a Solana gossip client, use the `gossip` subcommand. Specify entrypoints to connect to a cluster. Optionally use `-p` to specify a custom listening port (default is 8001). For more info about gossip, see the [readme](src/gossip/readme.md).\n\n```bash\nsig gossip -p \u003cPORT\u003e --entrypoint \u003cIP\u003e:\u003cPORT\u003e\n```\n\nThe following IP addresses were resolved from domains found at https://docs.solana.com/clusters.\n\n\u003cdetails\u003e\u003csummary\u003emainnet\u003c/summary\u003e\n\n```bash\nsig gossip --entrypoint entrypoint.mainnet-beta.solana.com:8001 \\\n    --entrypoint entrypoint2.mainnet-beta.solana.com:8001 \\\n    --entrypoint entrypoint3.mainnet-beta.solana.com:8001 \\\n    --entrypoint entrypoint4.mainnet-beta.solana.com:8001 \\\n    --entrypoint entrypoint5.mainnet-beta.solana.com:8001\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003edevnet\u003c/summary\u003e\n\n```bash\nsig gossip --entrypoint entrypoint.devnet.solana.com:8001 \\\n    --entrypoint entrypoint2.devnet.solana.com:8001 \\\n    --entrypoint entrypoint3.devnet.solana.com:8001 \\\n    --entrypoint entrypoint4.devnet.solana.com:8001 \\\n    --entrypoint entrypoint5.devnet.solana.com:8001\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003etestnet\u003c/summary\u003e\n\n```bash\nsig gossip --entrypoint entrypoint.testnet.solana.com:8001 \\\n    --entrypoint entrypoint2.testnet.solana.com:8001 \\\n    --entrypoint entrypoint3.testnet.solana.com:8001\n```\n\n\u003c/details\u003e\u003cbr\u003e\n\n## Develop\n\nSee [Setup](#-setup) to get your environment set up. See [CONTRIBUTING.md](docs/CONTRIBUTING.md) for the code style guide.\n\n### 🧪 Test\n\nRun all tests.\n\n```bash\nzig build test\n```\n\nInclude `--summary all` with any test command to see a summary of the test results.\n\nInclude a filter to limit which tests are run. Sig tests include their module name. For example, you can run all tests in `gossip.table` like this:\n\n```bash\nzig build test --summary all -- gossip.table\n```\n\n### 📊 Benchmark\n\nRun all benchmarks.\n\n```bash\nzig build benchmark\n```\n\nRun a benchmark group: socket_utils, gossip, or sync.\n\n```bash\nzig build benchmark -- gossip\n```\n\n\u003cbr\u003e\n\n## 📦 Import Sig\n\nSig can be included as a dependency in your Zig project using `build.zig.zon` file (available for Zig \u003e= 0.12). See the [API documentation](docs/api.md) to learn more about how to use Sig as a library.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eSteps\u003c/code\u003e - how to install Sig in your Zig project\u003c/summary\u003e\n\n1. Declare Sig as a dependency in `build.zig.zon`:\n\n   ```diff\n   .{\n       .name = \"my-project\",\n       .version = \"1.0.0\",\n       .dependencies = .{\n   +       .sig = .{\n   +           .url = \"https://github.com/syndica/sig/archive/\u003cCOMMIT\u003e.tar.gz\",\n   +       },\n       },\n   }\n   ```\n\n2. Expose Sig as a module in `build.zig`:\n\n   ```diff\n   const std = @import(\"std\");\n\n   pub fn build(b: *std.Build) void {\n       const target = b.standardTargetOptions(.{});\n       const optimize = b.standardOptimizeOption(.{});\n\n   +   const opts = .{ .target = target, .optimize = optimize };\n   +   const sig_module = b.dependency(\"sig\", opts).module(\"sig\");\n\n       const exe = b.addExecutable(.{\n           .name = \"test\",\n           .root_source_file = .{ .path = \"src/main.zig\" },\n           .target = target,\n           .optimize = optimize,\n       });\n   +   exe.addModule(\"sig\", sig_module);\n       exe.install();\n\n       ...\n   }\n   ```\n\n3. Obtain Sig's package hash:\n\n   ```\n   $ zig build\n   my-project/build.zig.zon:6:20: error: url field is missing corresponding hash field\n           .url = \"https://github.com/syndica/sig/archive/\u003cCOMMIT\u003e.tar.gz\",\n                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n   note: expected .hash = \"\u003cHASH\u003e\",\n   ```\n\n4. Update `build.zig.zon` with hash value:\n\n   ```diff\n   .{\n       .name = \"my-project\",\n       .version = \"1.0.0\",\n       .dependencies = .{\n           .sig = .{\n               .url = \"https://github.com/syndica/sig/archive/\u003cCOMMIT\u003e.tar.gz\",\n   +           .hash = \"\u003cHASH\u003e\",\n           },\n       },\n   }\n   ```\n\n      \u003c/details\u003e\n   \u003cbr\u003e\n\n## 🤔 Why Zig?\n\nZig's own definition: `Zig is a general-purpose programming language and toolchain for maintaining robust, optimal and reusable software.`\n\n1. **Optimized performance**: Zig provides control over how your program runs at a low level, similar to languages like C. It allows fine-grained control over aspects such as memory management and system calls, which can lead to improved performance.\n\n2. **Safety focus**: Zig has features built in to prevent common bugs and safety issues common in C. For example, it includes built-in testing and bounds checking, which can help avoid problems such as buffer overflows and undefined behavior.\n\n3. **Readability and maintainability**: Zig syntax is designed to be straightforward and clear. This can make the code easier to understand, more maintainable, and less prone to bugs.\n\n4. **No hidden control flow**: Zig doesn't allow hidden control-flow like exceptions in some other languages. This can make it easier to reason about what your program is doing.\n\n5. **Integration with C**: Zig has excellent interoperation with C. You can directly include C libraries and headers in a Zig program, which can save time when using existing C libraries.\n\n6. **Custom allocators**: Zig allows you to define custom memory allocation strategies for different parts of your program. This provides the flexibility to optimize memory usage for specific use-cases or workloads.\n\n### Note\n\n- Zig is still an evolving language.\n- Many of the low-level APIs have been stabilized but `std.http.Client` and `std.json` are still WIP targetting stable implementations by `\u003e=0.12`.\n- Currently, `std.http.Client` [leaks](https://github.com/ziglang/zig/blob/447a30299073ce88b7b26d18d060a345beac5276/lib/std/http/Client.zig#L913) and is failing some tests, fix is in works.\n  \u003cbr\u003e\u003cbr\u003e\n\n## 🧩 Modules\n\n- **[Gossip](src/gossip)** - A gossip spy node, run by: `sig gossip` or `zig build run -- gossip`\n\n- **[Core](src/core)** - Core data structures shared across modules.\n\n- **[RPC Client](src/rpc)** ([docs](docs/api.md#rpcclient---api-reference)) - A fully featured HTTP RPC client with ability to query all on-chain data along with sending transactions.\n  \u003cbr\u003e\u003cbr\u003e\n\n## 📚 Learn More\n\n[Zig](https://ziglang.org/)\n\n- [Official Documentation](https://ziglang.org/documentation/0.13.0/)\n- [zig.guide](https://zig.guide/)\n- [Ziglings Exercises](https://github.com/ratfactor/ziglings)\n- [Learning Zig](https://www.openmymind.net/learning_zig/)\n\n[Solana](https://solana.com/)\n\n- [Validator Anatomy](https://docs.solana.com/validator/anatomy)\n- [RPC API](https://docs.solana.com/api)\n- [Code](https://github.com/solana-labs/solana)\n\nSig\n\n- [Introduction](https://blog.syndica.io/introducing-sig-by-syndica-an-rps-focused-solana-validator-client-written-in-zig/)\n- [Gossip Deep Dive](https://blog.syndica.io/sig-engineering-1-gossip-protocol/)\n- [Solana's AccountsDB](https://blog.syndica.io/sig-engineering-part-3-solanas-accountsdb/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSyndica%2Fsig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSyndica%2Fsig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSyndica%2Fsig/lists"}