Repository navigation
feat: implement saving ENR/s to file and loading ENR/s from file #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e4bacdc
feat:init enr load from file and save to file
GrapeBaBa 4a6393c
feat:update ci and readme
GrapeBaBa 403cfd7
fix: fix wrong module expose
GrapeBaBa 5f4eea0
fix:remove auto-generated comment and throw error
GrapeBaBa c7698ed
fix:remove auto generated comment in zon file
GrapeBaBa f7572a5
fix:elimate duplicate code
GrapeBaBa 72e8c5d
fix:update install zig in CI
GrapeBaBa 247fadd
fix:elimate duplicate code in test
GrapeBaBa 95b441c
fix:remove auto generated comment
GrapeBaBa ae60122
fix:reduce stack memory used
GrapeBaBa 1f8aad4
fix:fix duplicate and add more tests
GrapeBaBa 38540b3
feat:remove discv5 dep
GrapeBaBa de1e4b1
fix:replace setup-zig
GrapeBaBa 702fc22
feat: add helper function for SignableENR
GrapeBaBa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| name: Enr CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| ZIG_VERSION: 0.14.1 | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Zig | ||
| uses: korandoru/setup-zig@v1 | ||
| with: | ||
| zig-version: 0.14.1 | ||
|
|
||
| - name: Formatting | ||
| run: zig fmt --check --color on . | ||
|
|
||
| - name: Unit testing | ||
| run: zig build test --summary all | ||
|
|
||
| - name: Building | ||
| run: zig build -Doptimize=ReleaseSafe |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,49 @@ | ||
| # enr | ||
| About Ethereum Node Records (ENR) | ||
| Ethereum Node Records (ENR) utility in Zig. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Zig 0.14.1 | ||
|
|
||
| ## Building | ||
|
|
||
| To build the project, run the following command in the root directory of the project: | ||
|
|
||
| ```bash | ||
| zig build -Doptimize=ReleaseSafe | ||
| ``` | ||
|
|
||
| ## Running Tests | ||
|
|
||
| To run the tests, run the following command in the root directory of the project: | ||
|
|
||
| ```bash | ||
| zig build test --summary all | ||
| ``` | ||
|
|
||
| ## Docs | ||
|
|
||
| To generate documentation for the project, run the following command in the root directory of the project: | ||
|
|
||
| ```bash | ||
| zig build docs | ||
| ``` | ||
|
|
||
| # Usage | ||
|
|
||
| Update `build.zig.zon`: | ||
|
|
||
| ```sh | ||
| zig fetch --save git+https://github.com/blockblaz/enr | ||
| ``` | ||
|
|
||
| In your `build.zig`: | ||
|
|
||
| ```zig | ||
| const enr_dep = b.dependency("zig_enr", .{ | ||
| .target = target, | ||
| .optimize = optimize, | ||
| }); | ||
| const enr_module = enr_dep.module("zig-enr"); | ||
| root_module.addImport("zig-enr", enr_module); | ||
| ``` |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| const std = @import("std"); | ||
|
|
||
| pub fn build(b: *std.Build) !void { | ||
| const target = b.standardTargetOptions(.{}); | ||
|
|
||
| const optimize = b.standardOptimizeOption(.{}); | ||
|
|
||
| const discv5 = b.dependency("discv5", .{}); | ||
|
|
||
| const enr_mod = discv5.module("enr"); | ||
|
|
||
| const lib_mod = b.createModule(.{ | ||
| .root_source_file = b.path("src/root.zig"), | ||
| .target = target, | ||
| .optimize = optimize, | ||
| }); | ||
|
|
||
| lib_mod.addImport("enr", enr_mod); | ||
|
|
||
| try b.modules.put(b.dupe("zig-enr"), lib_mod); | ||
| const lib = b.addLibrary(.{ | ||
| .linkage = .static, | ||
| .name = "enr", | ||
| .root_module = lib_mod, | ||
| }); | ||
|
|
||
| b.installArtifact(lib); | ||
|
|
||
| const lib_unit_tests = b.addTest(.{ | ||
| .root_module = lib_mod, | ||
| }); | ||
|
|
||
| const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests); | ||
|
|
||
| const test_step = b.step("test", "Run unit tests"); | ||
| test_step.dependOn(&run_lib_unit_tests.step); | ||
|
|
||
| const install_docs = b.addInstallDirectory(.{ | ||
| .source_dir = lib.getEmittedDocs(), | ||
| .install_dir = .prefix, | ||
| .install_subdir = "docs", | ||
| }); | ||
| const docs_step = b.step("docs", "Generate documentation"); | ||
| docs_step.dependOn(&install_docs.step); | ||
| } |
|
GrapeBaBa marked this conversation as resolved.
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| .{ | ||
| .name = .zig_enr, | ||
|
|
||
| .version = "0.0.0", | ||
|
|
||
| .fingerprint = 0x499ae5d25c594f6a, | ||
|
|
||
| .minimum_zig_version = "0.14.1", | ||
|
|
||
| .dependencies = .{ | ||
| .discv5 = .{ | ||
| .url = "git+https://github.com/blockblaz/zig-discv5#31f46b3b5e5b25a68638bb320545b74c642c6caa", | ||
| .hash = "discv5-0.1.0-fkJduLBkAQBQHUJxdOEqCR2YMKfF1lNhaLM_FgonkFRW", | ||
| }, | ||
| }, | ||
| .paths = .{ | ||
| "build.zig", | ||
| "build.zig.zon", | ||
| "src", | ||
| "LICENSE", | ||
| "README.md", | ||
| }, | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.