Skip to content

Commit

Permalink
[avalanche-types] Set max message size to usize.MAX for gRPC client/s…
Browse files Browse the repository at this point in the history
…evers (#77)

* [avalanche-types] Set max message size to usize.MAX for gRPC client/servers
* Add coverage for HTTP client

---------

Signed-off-by: Sam Batschelet <sam.batschelet@avalabs.org>
  • Loading branch information
hexfusion authored Oct 19, 2023
1 parent 41332f4 commit eee26d7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ pub struct DatabaseClient {
impl DatabaseClient {
pub fn new(client_conn: Channel) -> BoxedDatabase {
Box::new(Self {
inner: RpcDbDatabaseClient::new(client_conn),
inner: RpcDbDatabaseClient::new(client_conn)
.max_decoding_message_size(usize::MAX)
.max_encoding_message_size(usize::MAX),
closed: Arc::new(AtomicBool::new(false)),
})
}
Expand Down
4 changes: 3 additions & 1 deletion crates/avalanche-types/src/subnet/rpc/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ pub struct Client {
impl Client {
pub fn new(client_conn: Channel) -> Box<dyn subnet::rpc::http::Handler + Send + Sync> {
Box::new(Client {
inner: pb::http::http_client::HttpClient::new(client_conn),
inner: pb::http::http_client::HttpClient::new(client_conn)
.max_decoding_message_size(usize::MAX)
.max_encoding_message_size(usize::MAX),
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/avalanche-types/src/subnet/rpc/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ where
.add_service(reflection_service)
.add_service(VmServer::new(vm))
.serve_with_shutdown(addr, stop_ch.recv().map(|_| ()))
.max_decoding_message_size(usize::MAX)
.max_encoding_message_size(usize::MAX)
.await
.map_err(|e| Error::new(ErrorKind::Other, format!("grpc server failed: {:?}", e)))?;
log::info!("grpc server shutdown complete: {}", addr);
Expand Down
4 changes: 3 additions & 1 deletion crates/avalanche-types/src/subnet/rpc/runtime/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ pub struct Client {
impl Client {
pub fn new(client_conn: Channel) -> Self {
Self {
inner: RuntimeClient::new(client_conn),
inner: RuntimeClient::new(client_conn)
.max_decoding_message_size(usize::MAX)
.max_encoding_message_size(usize::MAX),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ pub struct AppSenderClient {
impl AppSenderClient {
pub fn new(client_conn: Channel) -> Self {
Self {
inner: app_sender_client::AppSenderClient::new(client_conn),
inner: app_sender_client::AppSenderClient::new(client_conn)
.max_decoding_message_size(usize::MAX)
.max_encoding_message_size(usize::MAX),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ pub struct ValidatorStateClient {
impl ValidatorStateClient {
pub fn new(client_conn: Channel) -> Self {
Self {
inner: validator_state_client::ValidatorStateClient::new(client_conn),
inner: validator_state_client::ValidatorStateClient::new(client_conn)
.max_decoding_message_size(usize::MAX)
.max_encoding_message_size(usize::MAX),
}
}
}
Expand Down

0 comments on commit eee26d7

Please sign in to comment.