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

feat(BOUN-1233): rework ic-boundary CLI, bump ic-gateway #2451

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
3,170 changes: 2,021 additions & 1,149 deletions Cargo.Bazel.Fuzzing.json.lock

Large diffs are not rendered by default.

585 changes: 357 additions & 228 deletions Cargo.Bazel.Fuzzing.toml.lock

Large diffs are not rendered by default.

3,430 changes: 2,151 additions & 1,279 deletions Cargo.Bazel.json.lock

Large diffs are not rendered by default.

581 changes: 355 additions & 226 deletions Cargo.Bazel.toml.lock

Large diffs are not rendered by default.

410 changes: 275 additions & 135 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions bazel/external_crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def external_crates_repository(name, cargo_lockfile, lockfile, sanitizers_enable
version = "^0.2.2",
),
"clap": crate.spec(
version = "^4.5.18",
version = "^4.5.20",
features = [
"derive",
"string",
Expand Down Expand Up @@ -568,7 +568,7 @@ def external_crates_repository(name, cargo_lockfile, lockfile, sanitizers_enable
),
"ic-bn-lib": crate.spec(
git = "https://github.com/dfinity/ic-bn-lib",
rev = "9abf1e385e4a32279de005d0019c17774e164828",
rev = "526d34d15cfbf369d8baf2dae9932aa18d570a1d",
),
"ic-btc-interface": crate.spec(
version = "^0.2.2",
Expand Down
10 changes: 5 additions & 5 deletions ic-os/boundary-guestos/context/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ WORKDIR /tmp

# Download and verify ic-gateway
RUN \
curl -L -O https://github.com/dfinity/ic-gateway/releases/download/v0.1.58/ic-gateway_0.1.58_amd64.deb && \
echo "d6939a8e4c473cf5af8f63e3ce577d7685ec2bb89428d925f8a55dc87d7a10c1 ic-gateway_0.1.58_amd64.deb" | sha256sum -c
curl -L -O https://github.com/dfinity/ic-gateway/releases/download/v0.1.59/ic-gateway_0.1.59_amd64.deb && \
echo "2d57c4a6e77f974ce4674ebc631ba5f2c7de0bb4bf05069c5bcffb21ec274ea2 ic-gateway_0.1.59_amd64.deb" | sha256sum -c

#
# Second build stage:
Expand Down Expand Up @@ -56,9 +56,9 @@ FROM image-${BUILD_TYPE}

USER root:root

COPY --from=download /tmp/ic-gateway_0.1.58_amd64.deb /tmp/ic-gateway_0.1.58_amd64.deb
RUN dpkg -i --force-confold /tmp/ic-gateway_0.1.58_amd64.deb && \
rm /tmp/ic-gateway_0.1.58_amd64.deb
COPY --from=download /tmp/ic-gateway_0.1.59_amd64.deb /tmp/ic-gateway_0.1.59_amd64.deb
RUN dpkg -i --force-confold /tmp/ic-gateway_0.1.59_amd64.deb && \
rm /tmp/ic-gateway_0.1.59_amd64.deb

RUN mkdir -p /boot/config \
/boot/efi \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,16 @@
[Unit]
Description=IC Boundary Reverse Proxy
Description=IC-Boundary
After=network-online.target
Wants=network-online.target
After=setup-ic-boundary.service
BindsTo=setup-ic-boundary.service

[Service]
LogRateLimitIntervalSec=1ms
LogRateLimitBurst=1000
User=root
Group=root
Restart=always
EnvironmentFile=/run/ic-node/etc/default/ic-boundary
ExecStart=/bin/bash -c ' \
/opt/ic/bin/ic-boundary \
--local-store-path /var/opt/registry/store \
--nns-pub-key-pem /run/ic-node/etc/default/nns_public_key.pem \
--nns-urls "${NNS_URL}" \
--http-port 9000 \
--metrics-addr "[::]:9324" \
--log-stdout \
--log-failed-requests-only \
--nftables-system-replicas-path /run/ic-node/etc/nftables/system_replicas.ruleset \
--retry-update-call \
--rate-limit-per-second-per-subnet "1000" \
--http-client-count "2" \
${CACHE_SIZE:+ --cache-size-bytes "${CACHE_SIZE}"} \
${CACHE_ITEM_MAX_SIZE:+ --cache-max-item-size-bytes "${CACHE_ITEM_MAX_SIZE}"} \
${CACHE_TTL:+ --cache-ttl-seconds "${CACHE_TTL}"} \
'
ExecStart=/opt/ic/bin/ic-boundary

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,20 @@ function generate_config() {

# Generate Configuration
cat >"${ENV_FILE}" <<EOF
NNS_URL=${NNS_URL}
CACHE_SIZE=1073741824
CACHE_ITEM_MAX_SIZE=10485760
CACHE_TTL=1
LISTEN_HTTP_PORT="9000"
NETWORK_HTTP_CLIENT_COUNT="2"
OBS_METRICS_ADDR="[::]:9324"
OBS_LOG_STDOUT="true"
OBS_LOG_FAILED_REQUESTS_ONLY="true"
NFTABLES_SYSTEM_REPLICAS_PATH="/run/ic-node/etc/nftables/system_replicas.ruleset"
RETRY_UPDATE_CALL="true"
RATE_LIMIT_PER_SECOND_PER_SUBNET="1000"
REGISTRY_NNS_URLS="${NNS_URL}"
REGISTRY_NNS_PUB_KEY_PEM="/run/ic-node/etc/default/nns_public_key.pem"
REGISTRY_LOCAL_STORE_PATH="/var/opt/registry/store"
CACHE_SIZE="1GB"
CACHE_MAX_ITEM_SIZE="10MB"
CACHE_TTL="1s"
EOF
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ ENV="${ENV}"
DOMAIN_APP="${DOMAINS_APP}"
DOMAIN_SYSTEM="${DOMAINS_SYSTEM}"
DOMAIN_API="${DOMAINS_API}"
HTTP_SERVER_LISTEN_PLAIN="[::]:80"
HTTP_SERVER_LISTEN_TLS="[::]:443"
LISTEN_PLAIN="[::]:80"
LISTEN_TLS="[::]:443"
DNS_PROTOCOL="https"
METRICS_LISTEN="[::]:9314"
POLICY_PRE_ISOLATION_CANISTERS="${RUN_DIR}/pre_isolation_canisters.txt"
Expand Down
3 changes: 1 addition & 2 deletions rs/boundary_node/ic_boundary/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ http = { workspace = true }
http-body = { workspace = true }
humantime = "2.1"
ic-base-types = { path = "../../types/base_types" }
ic-bn-lib = { git = "https://github.com/dfinity/ic-bn-lib", rev = "9abf1e385e4a32279de005d0019c17774e164828" }
ic-bn-lib = { git = "https://github.com/dfinity/ic-bn-lib", rev = "526d34d15cfbf369d8baf2dae9932aa18d570a1d" }
ic-certification-test-utils = { path = "../../certification/test-utils" }
ic-config = { path = "../../config" }
ic-crypto-ed25519 = { path = "../../crypto/ed25519" }
Expand All @@ -55,7 +55,6 @@ ic-registry-routing-table = { path = "../../registry/routing_table" }
ic-registry-subnet-type = { path = "../../registry/subnet_type" }
ic-types = { path = "../../types/types" }
lazy_static = { workspace = true }
little-loadshedder = "0.2.0"
maxminddb = "0.24"
mockall = { workspace = true }
moka = { version = "0.12.8", features = ["sync", "future"] }
Expand Down
6 changes: 5 additions & 1 deletion rs/boundary_node/ic_boundary/benches/perf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use tokio_util::sync::CancellationToken;
use ic_boundary::test_utils::setup_test_router;

fn gen_request(cli: &reqwest::Client, addr: &SocketAddr, bytes_size: usize) -> reqwest::Request {
let mut rng = rand::thread_rng();
let mut rng = thread_rng();

let canister_id: u64 = rng.gen_range(0..100_000_000);
let canister_id = Principal::from_slice(canister_id.to_be_bytes().as_slice());
Expand Down Expand Up @@ -58,6 +58,10 @@ fn benchmark(c: &mut Criterion) {
http2_keepalive_timeout: Duration::from_secs(30),
grace_period: Duration::from_secs(60),
max_requests_per_conn: Some(1000),
tls_handshake_timeout: Duration::from_secs(10),
read_timeout: Some(Duration::from_secs(10)),
write_timeout: Some(Duration::from_secs(10)),
idle_timeout: Duration::from_secs(10),
};

let runtime = tokio::runtime::Builder::new_current_thread()
Expand Down
10 changes: 5 additions & 5 deletions rs/boundary_node/ic_boundary/src/bouncer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use ratelimit::Ratelimiter;
use tracing::{debug, error, info, warn};

use crate::{
cli::BouncerConfig,
cli,
routes::{ErrorCause, RateLimitCause},
};

Expand Down Expand Up @@ -257,7 +257,7 @@ impl Bouncer {
}
}

pub fn setup(cli: &BouncerConfig, registry: &Registry) -> Result<Arc<Bouncer>, Error> {
pub fn setup(cli: &cli::Bouncer, registry: &Registry) -> Result<Arc<Bouncer>, Error> {
let executor = Arc::new(exec::Executor::new(
cli.bouncer_sudo,
cli.bouncer_sudo_path.clone(),
Expand All @@ -279,9 +279,9 @@ pub fn setup(cli: &BouncerConfig, registry: &Registry) -> Result<Arc<Bouncer>, E
Bouncer::new(
cli.bouncer_ratelimit,
cli.bouncer_burst_size,
Duration::from_secs(cli.bouncer_ban_seconds),
cli.bouncer_ban_time,
cli.bouncer_max_buckets,
Duration::from_secs(cli.bouncer_bucket_ttl),
cli.bouncer_bucket_ttl,
firewall,
registry,
)
Expand All @@ -290,7 +290,7 @@ pub fn setup(cli: &BouncerConfig, registry: &Registry) -> Result<Arc<Bouncer>, E

// Start background task
let bouncer_task = bouncer.clone();
let interval = Duration::from_secs(cli.bouncer_apply_interval);
let interval = cli.bouncer_apply_interval;
tokio::spawn(async move {
bouncer_task.clone().run(interval).await;
});
Expand Down
6 changes: 3 additions & 3 deletions rs/boundary_node/ic_boundary/src/bouncer/firewall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl Set {
}

// Converts a list of ips into an NFTables object
fn convert(&self, addrs: Vec<IpAddr>) -> schema::NfListObject {
fn convert(&self, addrs: Vec<IpAddr>) -> NfListObject {
let elem = addrs
.into_iter()
.map(|x| Expression::String(x.to_string()))
Expand All @@ -110,7 +110,7 @@ impl Set {
// There is a discrepancy between `cargo clippy` and `bazel lint`.
// Remove this once it is fixed.
#[allow(clippy::clone_on_copy)]
schema::NfListObject::Element(schema::Element {
NfListObject::Element(schema::Element {
family: self.family,
table: self.table.clone(),
name: self.name.clone(),
Expand Down Expand Up @@ -338,7 +338,7 @@ mod test {
fw.apply(decisions).await.unwrap();

// Check if the payload sent to executor is correct
let payload_expected = serde_json::json!({
let payload_expected = json!({
"nftables": [
{
"add": {
Expand Down
4 changes: 2 additions & 2 deletions rs/boundary_node/ic_boundary/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ pub struct Cache {
// Estimate rough amount of bytes that cache entry takes in memory
fn weigh_entry(k: &Arc<RequestContext>, v: &CacheItem) -> u32 {
let mut cost = v.body.len()
+ std::mem::size_of::<CacheItem>()
+ std::mem::size_of::<Arc<RequestContext>>()
+ size_of::<CacheItem>()
+ size_of::<Arc<RequestContext>>()
+ k.method_name.as_ref().map(|x| x.len()).unwrap_or(0)
+ k.arg.as_ref().map(|x| x.len()).unwrap_or(0)
+ k.nonce.as_ref().map(|x| x.len()).unwrap_or(0)
Expand Down
Loading
Loading