Skip to content
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

chore(protolint): lint proto files, add comments, and add linter #313

Merged
merged 11 commits into from
Aug 22, 2023
6 changes: 6 additions & 0 deletions .cargo-husky/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ cargo clippy --all --all-features -- -D warnings || {
exit 1
}

echo 'Running buf'
buf lint proto/. || {
echo >&2 'Buf failed. This most likely means you have linting errors in .proto files. If needed, try running "brew install buf"'
exit 1
}

declare -a file_array=()
for file in $files_to_git_add; do
file_array+=("${file}")
Expand Down
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ fn generate_protos() -> Result<(), Box<dyn error::Error>> {
let out_dir = PathBuf::from(env::var("OUT_DIR")?);
tonic_build::configure()
.file_descriptor_set_path(out_dir.join("op_pool_descriptor.bin"))
.compile(&["proto/op_pool.proto"], &["proto"])?;
.compile(&["proto/op_pool/op_pool.proto"], &["proto"])?;
tonic_build::configure()
.file_descriptor_set_path(out_dir.join("builder_descriptor.bin"))
.compile(&["proto/builder.proto"], &["proto"])?;
.compile(&["proto/builder/builder.proto"], &["proto"])?;
Ok(())
}

Expand Down
16 changes: 16 additions & 0 deletions proto/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Protocol Buffer Definitions

This directory stores the schema definitions used by Rundler and the supporting gRPC services of it's internal components.

## Building

Rundler builds on [Tonic](https://github.com/hyperium/tonic) to power lightning quick gRPC interfaces between internal components. To re-compile changes to the protocol buffers:

1. Make sure `protoc` is installed locally. On Macs one can run `brew install protobuf`. Otherwise see the official [protobuf docs](https://grpc.io/docs/protoc-installation/) for installation instructions.
2. Run `cargo build` to recompile the protocol buffers as part of the overall binary build. This is configured in `build.rs` in the `generate_protos` function. Adding schemas in new files will require a change to `build.rs`.

## Protocol Buffer to Memory Representation Translation

## Style Guide

Rundler largely relies on the canonical (protobuf style guide)[https://protobuf.dev/programming-guides/style/]. There are a few minor differences captured in `buf.yaml` to support Tonic best practices. Rundler use (buf)[https://buf.build/] to lint the `.proto` files. To use `buf` run `buf lint protos/.`. To install `buf` on Macs, run `brew install bufbuild/buf/buf`.
26 changes: 26 additions & 0 deletions proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: v1
name: ""
deps: []
build:
excludes: []
lint:
use:
- DEFAULT
except:
- PACKAGE_VERSION_SUFFIX
- SERVICE_SUFFIX
ignore: []
ignore_only: {}
allow_comment_ignores: false
enum_zero_value_suffix: _UNSPECIFIED
rpc_allow_same_request_response: false
rpc_allow_google_protobuf_empty_requests: false
rpc_allow_google_protobuf_empty_responses: false
service_suffix: Service
breaking:
use:
- FILE
except: []
ignore: []
ignore_only: {}
ignore_unstable_packages: false
12 changes: 9 additions & 3 deletions proto/builder.proto → proto/builder/builder.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ syntax = "proto3";
package builder;

enum BundlingMode {
UNSPECIFIED = 0;
MANUAL = 1;
AUTO = 2;
BUNDLING_MODE_UNSPECIFIED = 0;
// Test-only bundling mode, should not be used in production. Allows
// triggering of bundles to be built. See the ERC-4337 spec for more
// context:
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4337.md#-debug_bundler_setbundlingmode
BUNDLING_MODE_MANUAL = 1;
// Default bundling mode to auto-build bundles based off of the
// UserOperations present in the mempool.
BUNDLING_MODE_AUTO = 2;
}

service Builder {
Expand Down
143 changes: 0 additions & 143 deletions proto/op_pool.proto

This file was deleted.

Loading
Loading