Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/dapi-grpc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,10 @@ impl MappingConfig {
let builder = typ
.configure(tonic_prost_build::configure())
.out_dir(out_dir.clone())
// Emit the FileDescriptorSet alongside the generated code so
// consumers can enumerate the served rpcs at test time (e.g.
// rs-dapi asserts its metrics allowlist covers every method).
.file_descriptor_set_path(out_dir.join("descriptor.bin"))
.protoc_arg("--experimental_allow_proto3_optional");

Self {
Expand Down
42 changes: 42 additions & 0 deletions packages/dapi-grpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,26 @@ pub mod core {
env!("DAPI_GRPC_OUT_DIR"),
"/core/wasm/org.dash.platform.dapi.v0.rs"
));

/// Serialized `FileDescriptorSet` for the Core proto — lets consumers
/// enumerate the served rpcs (e.g. to assert metrics allowlists).
#[cfg(all(feature = "server", not(target_arch = "wasm32")))]
pub const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!(concat!(
env!("DAPI_GRPC_OUT_DIR"),
"/core/server/descriptor.bin"
));

/// Serialized `FileDescriptorSet` for the Core proto — lets consumers
/// enumerate the served rpcs (e.g. to assert metrics allowlists).
#[cfg(all(
feature = "client",
not(feature = "server"),
not(target_arch = "wasm32")
))]
pub const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!(concat!(
env!("DAPI_GRPC_OUT_DIR"),
"/core/client/descriptor.bin"
));
}
}

Expand Down Expand Up @@ -53,6 +73,28 @@ pub mod platform {
env!("DAPI_GRPC_OUT_DIR"),
"/platform/wasm/org.dash.platform.dapi.v0.rs"
));

/// Serialized `FileDescriptorSet` for the Platform proto — lets
/// consumers enumerate the served rpcs (e.g. to assert metrics
/// allowlists).
#[cfg(all(feature = "server", not(target_arch = "wasm32")))]
pub const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!(concat!(
env!("DAPI_GRPC_OUT_DIR"),
"/platform/server/descriptor.bin"
));

/// Serialized `FileDescriptorSet` for the Platform proto — lets
/// consumers enumerate the served rpcs (e.g. to assert metrics
/// allowlists).
#[cfg(all(
feature = "client",
not(feature = "server"),
not(target_arch = "wasm32")
))]
pub const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!(concat!(
env!("DAPI_GRPC_OUT_DIR"),
"/platform/client/descriptor.bin"
));
}

#[cfg(feature = "tenderdash-proto")]
Expand Down
2 changes: 2 additions & 0 deletions packages/rs-dapi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ zeroize = "1.8"
tempfile = "3.13.0"
serial_test = "3.1.1"
test-case = "3.3.1"
# Decodes dapi-grpc's FILE_DESCRIPTOR_SET in the metrics allowlist test.
prost-types = "0.14"

[package.metadata.cargo-machete]
ignored = ["rs-dash-event-bus"]
Loading
Loading