Skip to content

Commit 28c8a07

Browse files
nikolay-komarevskiysa-idx-adminr-birkner
authored
chore(boundary): add metrics and access control to salt_sharing canister (dfinity#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]>
1 parent 1f525da commit 28c8a07

File tree

13 files changed

+501
-143
lines changed

13 files changed

+501
-143
lines changed

Cargo.lock

Lines changed: 13 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
load("@rules_rust//rust:defs.bzl", "rust_test")
2+
load("//bazel:canisters.bzl", "rust_canister")
3+
4+
package(default_visibility = ["//visibility:public"])
5+
6+
DEPENDENCIES = [
7+
# Keep sorted.
8+
"//rs/boundary_node/salt_sharing/api:salt_sharing_api",
9+
"//rs/nns/constants",
10+
"//rs/rust_canisters/canister_log",
11+
"//rs/rust_canisters/http_types",
12+
"@crate_index//:candid",
13+
"@crate_index//:ic-cdk",
14+
"@crate_index//:ic-cdk-timers",
15+
"@crate_index//:ic-stable-structures",
16+
"@crate_index//:prometheus",
17+
"@crate_index//:serde",
18+
"@crate_index//:serde_cbor",
19+
"@crate_index//:serde_json",
20+
"@crate_index//:time",
21+
]
22+
23+
MACRO_DEPENDENCIES = [
24+
# Keep sorted.
25+
"@crate_index//:ic-cdk-macros",
26+
]
27+
28+
rust_canister(
29+
name = "salt_sharing_canister",
30+
srcs = glob(["canister/**/*.rs"]),
31+
crate_name = "salt_sharing_canister",
32+
crate_root = "canister/lib.rs",
33+
proc_macro_deps = MACRO_DEPENDENCIES,
34+
service_file = "canister/salt_sharing_canister.did",
35+
deps = DEPENDENCIES,
36+
)
37+
38+
rust_test(
39+
name = "unit_tests",
40+
srcs = glob(["canister/**/*.rs"]),
41+
crate_name = "salt_sharing_canister",
42+
crate_root = "canister/lib.rs",
43+
data = ["canister/salt_sharing_canister.did"],
44+
proc_macro_deps = MACRO_DEPENDENCIES,
45+
deps = DEPENDENCIES + ["@crate_index//:candid_parser"],
46+
)

rs/boundary_node/salt_sharing/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "salt"
2+
name = "salt_sharing"
33
version.workspace = true
44
authors.workspace = true
55
edition.workspace = true
@@ -13,14 +13,17 @@ ic-canister-log = { path = "../../rust_canisters/canister_log" }
1313
ic-cdk = { workspace = true }
1414
ic-cdk-macros = { workspace = true }
1515
ic-cdk-timers = { workspace = true }
16+
ic-nns-constants = { path = "../../nns/constants" }
1617
ic-stable-structures = { workspace = true }
17-
salt-api = { path = "./api" }
18+
prometheus = {workspace = true }
19+
salt-sharing-api = { path = "./api" }
1820
serde = { workspace = true }
1921
serde_cbor = { workspace = true }
2022
serde_json = { workspace = true }
2123
time = { workspace = true }
2224

2325
[dev-dependencies]
26+
candid_parser = { workspace = true }
2427

2528
[lib]
2629
crate-type = ["cdylib"]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
load("@rules_rust//rust:defs.bzl", "rust_library")
2+
3+
package(default_visibility = ["//visibility:public"])
4+
5+
DEPENDENCIES = [
6+
# Keep sorted.
7+
"@crate_index//:candid",
8+
"@crate_index//:serde",
9+
]
10+
11+
rust_library(
12+
name = "salt_sharing_api",
13+
srcs = glob(["src/**/*.rs"]),
14+
aliases = {},
15+
crate_name = "salt_sharing_api",
16+
proc_macro_deps = [],
17+
deps = DEPENDENCIES,
18+
)

rs/boundary_node/salt_sharing/api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "salt-api"
2+
name = "salt-sharing-api"
33
version.workspace = true
44
authors.workspace = true
55
edition.workspace = true

rs/boundary_node/salt_sharing/api/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
use candid::{CandidType, Deserialize};
1+
use candid::{CandidType, Principal};
2+
use serde::{Deserialize, Serialize};
23

34
pub type GetSaltResponse = Result<SaltResponse, GetSaltError>;
45

@@ -26,3 +27,11 @@ pub enum GetSaltError {
2627
Unauthorized,
2728
Internal(String),
2829
}
30+
31+
#[derive(CandidType, Serialize, Deserialize, Clone, PartialEq, Debug, Eq)]
32+
pub struct ApiBoundaryNodeIdRecord {
33+
pub id: Option<Principal>,
34+
}
35+
36+
#[derive(CandidType, Deserialize, Clone, Copy, PartialEq, Eq)]
37+
pub struct GetApiBoundaryNodeIdsRequest {}

0 commit comments

Comments
 (0)