Skip to content

Commit

Permalink
feat: Enable synchronous endpoint for snjp subnet (#1194)
Browse files Browse the repository at this point in the history
  • Loading branch information
DSharifi authored Aug 28, 2024
1 parent 5539cc3 commit 60432db
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions rs/replica/src/setup_ic_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ use ic_types::{
artifact::UnvalidatedArtifactMutation,
consensus::{CatchUpPackage, HasHeight},
messages::SignedIngress,
Height, NodeId, SubnetId,
Height, NodeId, PrincipalId, SubnetId,
};
use ic_xnet_endpoint::{XNetEndpoint, XNetEndpointConfig};
use ic_xnet_payload_builder::XNetPayloadBuilderImpl;
use std::sync::{Arc, RwLock};
use std::{
str::FromStr,
sync::{Arc, RwLock},
};
use tokio::sync::{
mpsc::{channel, UnboundedSender},
watch,
Expand All @@ -45,9 +48,21 @@ use tokio::sync::{
/// the message id and height of messages that complete execution.
const COMPLETED_EXECUTION_MESSAGES_BUFFER_SIZE: usize = 10_000;

/// If enable traffic to `api/v3/call` will be routed to the v3 call handler.
/// Otherwise requests will be routed to the v2 call handler.
const ENABLE_V3_CALL_HANDLER: bool = false;
/// The subnets that can serve synchronous responses to update calls received
/// on the `/api/v3/.../call`` endpoint.
const WHITELISTED_SUBNETS_FOR_SYNCHRONOUS_CALL_V3: [&str; 1] =
["snjp4-xlbw4-mnbog-ddwy6-6ckfd-2w5a2-eipqo-7l436-pxqkh-l6fuv-vae"];

/// Returns true if the subnet is whitelisted to serve synchronous responses to v3
/// update calls.
fn subnet_is_whitelisted_for_synchronous_call_v3(subnet_id: &SubnetId) -> bool {
WHITELISTED_SUBNETS_FOR_SYNCHRONOUS_CALL_V3
.iter()
.any(|s| match PrincipalId::from_str(s) {
Ok(principal_id) => SubnetId::from(principal_id) == *subnet_id,
Err(_) => false,
})
}

/// Create the consensus pool directory (if none exists)
fn create_consensus_pool_dir(config: &Config) {
Expand Down Expand Up @@ -353,7 +368,7 @@ pub fn construct_ic_stack(
tracing_handle,
max_certified_height_rx,
finalized_ingress_height_rx,
ENABLE_V3_CALL_HANDLER,
subnet_is_whitelisted_for_synchronous_call_v3(&subnet_id),
);

Ok((
Expand Down

0 comments on commit 60432db

Please sign in to comment.