Skip to content

Commit d3cc7df

Browse files
chore(hermes): Remove git from build, vendor WH & Google protos (#2097)
* chore: remove git from build script, vendor wormhole and google protobufs * chore: update gitignore * fix: address pr comments
1 parent 059b7b9 commit d3cc7df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+6635
-52
lines changed

.pre-commit-config.yaml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,26 @@ repos:
33
rev: v3.2.0
44
hooks:
55
- id: trailing-whitespace
6-
exclude: target_chains/sui/vendor/|patches/
6+
exclude: >
7+
(?x)^(
8+
target_chains/sui/vendor/|
9+
patches/|
10+
apps/hermes/server/proto/vendor/
11+
)
712
- id: end-of-file-fixer
8-
exclude: target_chains/sui/vendor/|patches/|apps/api-reference/public/currency-icons/
13+
exclude: >
14+
(?x)^(
15+
target_chains/sui/vendor/|
16+
patches/|
17+
apps/api-reference/public/currency-icons/|
18+
apps/hermes/server/proto/vendor/
19+
)
920
- id: check-added-large-files
10-
exclude: target_chains/sui/vendor/|patches/
21+
exclude: >
22+
(?x)^(
23+
target_chains/sui/vendor/|
24+
patches/
25+
)
1126
# Hook to format many type of files in the repo
1227
# including solidity contracts.
1328
- repo: https://github.com/pre-commit/mirrors-prettier

apps/hermes/server/.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@
55
src/network/p2p.pb.go
66
src/network/p2p.proto
77
tools/
8-
9-
# Ignore Wormhole cloned repo
10-
wormhole*/

apps/hermes/server/build.rs

Lines changed: 16 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,28 @@
1-
use std::{
2-
env,
3-
path::PathBuf,
4-
process::Command,
5-
};
1+
use std::path::PathBuf;
62

3+
/// Custom build script to compile and include the wormhole protobufs into the source.
4+
/// The wormhole protobufs are vendored from the Wormhole git repository at https://github.com/wormhole-foundation/wormhole.git
5+
/// They reference other protobufs from the Google API repository at https://github.com/googleapis/googleapis.git , which are also vendored.
6+
/// Our copies live in `proto/vendor`.
77
fn main() {
8-
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
8+
let proto_dir = PathBuf::from("proto/vendor");
99

10-
// Print OUT_DIR for debugging build issues.
11-
println!("OUT_DIR={}", out_dir.display());
10+
// Tell cargo to recompile if any .proto files change
11+
println!("cargo:rerun-if-changed=proto/");
1212

13-
// We'll use git to pull in protobuf dependencies. This trick lets us use the Rust OUT_DIR
14-
// directory as a mini-repo with wormhole and googleapis as remotes, so we can copy out the
15-
// TREEISH paths we want.
16-
let protobuf_setup = r#"
17-
set -e
18-
git init .
19-
git clean -df
20-
git remote add wormhole https://github.com/wormhole-foundation/wormhole.git || true
21-
git remote add googleapis https://github.com/googleapis/googleapis.git || true
22-
git fetch --depth=1 wormhole main
23-
git fetch --depth=1 googleapis master
24-
git reset
25-
rm -rf proto/
26-
git read-tree --prefix=proto/ -u wormhole/main:proto
27-
git read-tree --prefix=proto/google/api/ -u googleapis/master:google/api
28-
"#;
29-
30-
// Run each command to prepare the OUT_DIR with the protobuf definitions. We need to make sure
31-
// to change the working directory to OUT_DIR, otherwise git will complain.
32-
let output = Command::new("sh")
33-
.args(["-c", protobuf_setup])
34-
.current_dir(&out_dir)
35-
.output()
36-
.expect("failed to run protobuf setup commands");
37-
if !output.status.success() {
38-
panic!(
39-
"failed to setup protobuf definitions: {}",
40-
String::from_utf8_lossy(&output.stderr)
41-
);
42-
}
43-
44-
// We build the resulting protobuf definitions using Rust's prost_build crate, which generates
45-
// Rust code from the protobuf definitions.
13+
// Build the wormhole and google protobufs using Rust's prost_build crate.
14+
// The generated Rust code is placed in the OUT_DIR (env var set by cargo).
15+
// `network/wormhole.rs` then includes the generated code into the source while compilation is happening.
4616
tonic_build::configure()
4717
.build_server(false)
4818
.compile(
4919
&[
50-
out_dir.join("proto/spy/v1/spy.proto"),
51-
out_dir.join("proto/gossip/v1/gossip.proto"),
52-
out_dir.join("proto/node/v1/node.proto"),
53-
out_dir.join("proto/publicrpc/v1/publicrpc.proto"),
20+
proto_dir.join("spy/v1/spy.proto"),
21+
proto_dir.join("gossip/v1/gossip.proto"),
22+
proto_dir.join("node/v1/node.proto"),
23+
proto_dir.join("publicrpc/v1/publicrpc.proto"),
5424
],
55-
&[out_dir.join("proto")],
25+
&[proto_dir],
5626
)
5727
.expect("failed to compile protobuf definitions");
5828
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## API Protos
2+
3+
This folder contains the schema of the configuration model for Google's
4+
internal API serving platform, which handles routing, quotas, monitoring,
5+
logging, and the like.
6+
7+
Google refers to this configuration colloquially as the "service config",
8+
and the `service.proto` file in this directory is the entry point for
9+
understanding these.
10+
11+
## Using these protos
12+
13+
To be honest, we probably open sourced way too much of this (basically by
14+
accident). There are a couple files in here you are most likely to be
15+
interested in: `http.proto`, `documentation.proto`, `auth.proto`, and
16+
`annotations.proto`.
17+
18+
### HTTP and REST
19+
20+
The `http.proto` file contains the `Http` message (which then is wrapped
21+
in an annotation in `annotations.proto`), which provides a specification
22+
for REST endpoints and verbs (`GET`, `POST`, etc.) on RPC methods.
23+
We recommend use of this annotation for describing the relationship
24+
between RPCs and REST endpoints.
25+
26+
### Documentation
27+
28+
The `documentation.proto` file contains a `Documentation` message which
29+
provides a mechanism to fully describe an API, allowing a tool to build
30+
structured documentation artifacts.
31+
32+
### Authentication
33+
34+
The `auth.proto` file contains descriptions of both authentication rules
35+
and authentication providers, allowing you to describe what your services
36+
expect and accept from clients.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package google.api;
18+
19+
import "google/api/http.proto";
20+
import "google/protobuf/descriptor.proto";
21+
22+
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
23+
option java_multiple_files = true;
24+
option java_outer_classname = "AnnotationsProto";
25+
option java_package = "com.google.api";
26+
option objc_class_prefix = "GAPI";
27+
28+
extend google.protobuf.MethodOptions {
29+
// See `HttpRule`.
30+
HttpRule http = 72295728;
31+
}

0 commit comments

Comments
 (0)