Skip to content

Commit

Permalink
chore(boundary): add metrics and access control to salt_sharing can…
Browse files Browse the repository at this point in the history
…ister (#3762)

**Changes**:
- added metrics
- bazelification
- access control, only API boundary nodes can call the `get_salt()`
- `inspect_message` for early rejections of replicated query calls
- added polling of API boundary nodes
- improved structure by moving implementation of `/logs`

**How to test**:
```
// deploy with dfx
$ dfx deploy salt_sharing -m reinstall --playground --argument \          
    '(record {   
        regenerate_now = true;
        salt_generation_strategy = variant { StartOfMonth };
        registry_polling_interval_secs = 60;
    })'
```
**Check metrics**:
```
https://{canister_id}.raw.icp0.io/metrics
```
**Check logs**:
```
https://{canister_id}.raw.icp0.io/logs
```

---------

Co-authored-by: IDX GitLab Automation <[email protected]>
Co-authored-by: r-birkner <[email protected]>
  • Loading branch information
3 people authored Feb 5, 2025
1 parent 1f525da commit 28c8a07
Show file tree
Hide file tree
Showing 13 changed files with 501 additions and 143 deletions.
23 changes: 13 additions & 10 deletions Cargo.lock

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

46 changes: 46 additions & 0 deletions rs/boundary_node/salt_sharing/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
load("@rules_rust//rust:defs.bzl", "rust_test")
load("//bazel:canisters.bzl", "rust_canister")

package(default_visibility = ["//visibility:public"])

DEPENDENCIES = [
# Keep sorted.
"//rs/boundary_node/salt_sharing/api:salt_sharing_api",
"//rs/nns/constants",
"//rs/rust_canisters/canister_log",
"//rs/rust_canisters/http_types",
"@crate_index//:candid",
"@crate_index//:ic-cdk",
"@crate_index//:ic-cdk-timers",
"@crate_index//:ic-stable-structures",
"@crate_index//:prometheus",
"@crate_index//:serde",
"@crate_index//:serde_cbor",
"@crate_index//:serde_json",
"@crate_index//:time",
]

MACRO_DEPENDENCIES = [
# Keep sorted.
"@crate_index//:ic-cdk-macros",
]

rust_canister(
name = "salt_sharing_canister",
srcs = glob(["canister/**/*.rs"]),
crate_name = "salt_sharing_canister",
crate_root = "canister/lib.rs",
proc_macro_deps = MACRO_DEPENDENCIES,
service_file = "canister/salt_sharing_canister.did",
deps = DEPENDENCIES,
)

rust_test(
name = "unit_tests",
srcs = glob(["canister/**/*.rs"]),
crate_name = "salt_sharing_canister",
crate_root = "canister/lib.rs",
data = ["canister/salt_sharing_canister.did"],
proc_macro_deps = MACRO_DEPENDENCIES,
deps = DEPENDENCIES + ["@crate_index//:candid_parser"],
)
7 changes: 5 additions & 2 deletions rs/boundary_node/salt_sharing/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "salt"
name = "salt_sharing"
version.workspace = true
authors.workspace = true
edition.workspace = true
Expand All @@ -13,14 +13,17 @@ ic-canister-log = { path = "../../rust_canisters/canister_log" }
ic-cdk = { workspace = true }
ic-cdk-macros = { workspace = true }
ic-cdk-timers = { workspace = true }
ic-nns-constants = { path = "../../nns/constants" }
ic-stable-structures = { workspace = true }
salt-api = { path = "./api" }
prometheus = {workspace = true }
salt-sharing-api = { path = "./api" }
serde = { workspace = true }
serde_cbor = { workspace = true }
serde_json = { workspace = true }
time = { workspace = true }

[dev-dependencies]
candid_parser = { workspace = true }

[lib]
crate-type = ["cdylib"]
Expand Down
18 changes: 18 additions & 0 deletions rs/boundary_node/salt_sharing/api/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
load("@rules_rust//rust:defs.bzl", "rust_library")

package(default_visibility = ["//visibility:public"])

DEPENDENCIES = [
# Keep sorted.
"@crate_index//:candid",
"@crate_index//:serde",
]

rust_library(
name = "salt_sharing_api",
srcs = glob(["src/**/*.rs"]),
aliases = {},
crate_name = "salt_sharing_api",
proc_macro_deps = [],
deps = DEPENDENCIES,
)
2 changes: 1 addition & 1 deletion rs/boundary_node/salt_sharing/api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "salt-api"
name = "salt-sharing-api"
version.workspace = true
authors.workspace = true
edition.workspace = true
Expand Down
11 changes: 10 additions & 1 deletion rs/boundary_node/salt_sharing/api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use candid::{CandidType, Deserialize};
use candid::{CandidType, Principal};
use serde::{Deserialize, Serialize};

pub type GetSaltResponse = Result<SaltResponse, GetSaltError>;

Expand Down Expand Up @@ -26,3 +27,11 @@ pub enum GetSaltError {
Unauthorized,
Internal(String),
}

#[derive(CandidType, Serialize, Deserialize, Clone, PartialEq, Debug, Eq)]
pub struct ApiBoundaryNodeIdRecord {
pub id: Option<Principal>,
}

#[derive(CandidType, Deserialize, Clone, Copy, PartialEq, Eq)]
pub struct GetApiBoundaryNodeIdsRequest {}
Loading

0 comments on commit 28c8a07

Please sign in to comment.