Skip to content

Commit

Permalink
chore(RUN-897): Combine sandbox binary and backend_lib crates
Browse files Browse the repository at this point in the history
  • Loading branch information
adambratschikaye committed Feb 5, 2024
1 parent dcfc4c2 commit 89302e2
Show file tree
Hide file tree
Showing 22 changed files with 96 additions and 134 deletions.
11 changes: 1 addition & 10 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Expand Up @@ -45,7 +45,6 @@ members = [
"rs/https_outcalls/consensus",
"rs/https_outcalls/service",
"rs/canister_sandbox",
"rs/canister_sandbox/backend_lib",
"rs/canister_sandbox/common",
"rs/canister_sandbox/replica_controller",
"rs/canister_sandbox/sandbox_launcher",
Expand Down
56 changes: 53 additions & 3 deletions rs/canister_sandbox/BUILD.bazel
@@ -1,17 +1,63 @@
load("@rules_rust//cargo:cargo_build_script.bzl", "cargo_build_script")
load("@rules_rust//rust:defs.bzl", "rust_binary")
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")

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

DEPENDENCIES = [
"//rs/canister_sandbox/backend_lib",
"//rs/canister_sandbox/common",
"//rs/config",
"//rs/constants",
"//rs/cycles_account_manager",
"//rs/embedders",
"//rs/interfaces",
"//rs/memory_tracker",
"//rs/monitoring/logger",
"//rs/replicated_state",
"//rs/sys",
"//rs/system_api",
"//rs/types/base_types",
"//rs/types/types",
"//rs/types/wasm_types",
"//rs/utils",
"@crate_index//:libc",
"@crate_index//:libflate",
"@crate_index//:nix",
"@crate_index//:rayon",
"@crate_index//:serde_json",
"@crate_index//:slog",
"@crate_index//:threadpool",
]

DEV_DEPENDENCIES = [
"//rs/registry/routing_table",
"//rs/registry/subnet_type",
"//rs/test_utilities",
"@crate_index//:mockall",
"@crate_index//:wat",
]

MACRO_DEPENDENCIES = []

ALIASES = {}

rust_library(
name = "backend_lib",
srcs = glob(["src/**/*.rs"]),
aliases = ALIASES,
crate_name = "ic_canister_sandbox_backend_lib",
proc_macro_deps = MACRO_DEPENDENCIES,
version = "0.9.0",
deps = DEPENDENCIES,
)

rust_test(
name = "backend_lib_test",
aliases = ALIASES,
crate = ":backend_lib",
proc_macro_deps = MACRO_DEPENDENCIES,
deps = DEPENDENCIES + DEV_DEPENDENCIES,
)

cargo_build_script(
name = "build_script",
srcs = ["build.rs"],
Expand All @@ -26,5 +72,9 @@ rust_binary(
crate_name = "canister_sandbox",
proc_macro_deps = MACRO_DEPENDENCIES,
version = "0.9.0",
deps = DEPENDENCIES + [":build_script"],
deps = [
":backend_lib",
":build_script",
"@crate_index//:libc",
],
)
34 changes: 31 additions & 3 deletions rs/canister_sandbox/Cargo.toml
@@ -1,5 +1,5 @@
[package]
name = "canister_sandbox"
name = "ic-canister-sandbox-backend-lib"
version.workspace = true
authors.workspace = true
edition.workspace = true
Expand All @@ -10,15 +10,43 @@ documentation.workspace = true
cc = "1.0"

[dependencies]
ic-canister-sandbox-backend-lib = { path = "backend_lib" }
ic-base-types = { path = "../types/base_types" }
ic-canister-sandbox-common = { path = "common" }
ic-cycles-account-manager = { path = "../cycles_account_manager" }
ic-config = { path = "../config" }
ic-constants = { path = "../constants" }
ic-embedders = { path = "../embedders" }
ic-logger = { path = "../monitoring/logger" }
ic-types = { path = "../types/types" }
ic-replicated-state = { path = "../replicated_state" }
ic-interfaces = { path = "../interfaces" }
ic-wasm-types = { path = "../types/wasm_types" }
ic-utils = { path = "../utils" }
ic-sys = { path = "../sys" }
ic-system-api = { path = "../system_api" }
libc = "0.2.119"
libflate = "1.1.2"
memory_tracker = { path = "../memory_tracker" }
nix = { workspace = true }
serde_json = { workspace = true }
slog = { workspace = true }
threadpool = "1.8.1"
rayon = "1.5.1"

[dev-dependencies]
ic-registry-routing-table = { path = "../registry/routing_table" }
ic-registry-subnet-type = { path = "../registry/subnet_type" }
# This makes the dependencies of the binary more consistent
# with the dependencies of execution environment tests and
# allows the binary to reuse most of the build artifacts
# produced by `cargo test`.
ic-test-utilities = { path = "../test_utilities" }
mockall = { workspace = true }
wat = "1.0.52"

[features]
sigsegv_handler_checksum = [ "ic-canister-sandbox-backend-lib/sigsegv_handler_checksum" ]
sigsegv_handler_checksum = ["memory_tracker/sigsegv_handler_checksum"]

[[bin]]
name = "canister_sandbox"
path = "src/main.rs"
9 changes: 2 additions & 7 deletions rs/canister_sandbox/README.md
Expand Up @@ -6,18 +6,13 @@ per canister.

## Code organization

- The top-level `canister_sandbox` crate is the binary that will be run as
the sandbox process. It is just a simple wrapper that launches all logic
implemented in other crates from its `main` function
- The top-level `canister_sandbox` crate contains the `backend_lib` library for
running the sandbox process as well as the sandbox process binary.

- `common` implements the IPC mechanisms and protocols used between replica
and sandbox process. The actual protocol definitions are found in
the `common/src/protocol` module

- `backend_lib` implements the logic to be run in the sandbox process. It is
organized as a library crate, with the main crate just calling its
entry point.

- `replica_controller` implements the replica side control of the sandbox
mechanism. It provides on the one hand the API "glue" towards the execution
layer, and on the other hand all logic to manage and talk to the backend
Expand Down
60 changes: 0 additions & 60 deletions rs/canister_sandbox/backend_lib/BUILD.bazel

This file was deleted.

41 changes: 0 additions & 41 deletions rs/canister_sandbox/backend_lib/Cargo.toml

This file was deleted.

2 changes: 1 addition & 1 deletion rs/canister_sandbox/replica_controller/BUILD.bazel
Expand Up @@ -4,7 +4,7 @@ load("//bazel:defs.bzl", "rust_ic_test")
package(default_visibility = ["//visibility:public"])

DEPENDENCIES = [
"//rs/canister_sandbox/backend_lib",
"//rs/canister_sandbox:backend_lib",
"//rs/canister_sandbox/common",
"//rs/config",
"//rs/embedders",
Expand Down
2 changes: 1 addition & 1 deletion rs/canister_sandbox/replica_controller/Cargo.toml
Expand Up @@ -8,7 +8,7 @@ documentation.workspace = true

[dependencies]
ic-canister-sandbox-common = { path = "../common" }
ic-canister-sandbox-backend-lib = { path = "../backend_lib" }
ic-canister-sandbox-backend-lib = { path = ".." }
ic-embedders = { path = "../../embedders" }
ic-interfaces = { path = "../../interfaces" }
ic-logger = { path = "../../monitoring/logger" }
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion rs/drun/BUILD.bazel
Expand Up @@ -3,7 +3,7 @@ load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")
package(default_visibility = ["//visibility:public"])

DEPENDENCIES = [
"//rs/canister_sandbox/backend_lib",
"//rs/canister_sandbox:backend_lib",
"//rs/canister_sandbox/sandbox_launcher:sandbox_launcher_lib",
"//rs/config",
"//rs/cycles_account_manager",
Expand Down
2 changes: 1 addition & 1 deletion rs/drun/Cargo.toml
Expand Up @@ -7,7 +7,7 @@ description.workspace = true
documentation.workspace = true

[dependencies]
ic-canister-sandbox-backend-lib = { path = "../canister_sandbox/backend_lib" }
ic-canister-sandbox-backend-lib = { path = "../canister_sandbox" }
ic-canister-sandbox-launcher = { path = "../canister_sandbox/sandbox_launcher" }
ic-config = { path = "../config" }
ic-cycles-account-manager = { path = "../cycles_account_manager" }
Expand Down
2 changes: 1 addition & 1 deletion rs/recovery/BUILD.bazel
Expand Up @@ -72,7 +72,7 @@ rust_binary(
proc_macro_deps = MACRO_DEPENDENCIES,
deps = DEPENDENCIES + [
":recovery",
"//rs/canister_sandbox/backend_lib",
"//rs/canister_sandbox:backend_lib",
"//rs/canister_sandbox/sandbox_launcher:sandbox_launcher_lib",
],
)
Expand Down
2 changes: 1 addition & 1 deletion rs/recovery/Cargo.toml
Expand Up @@ -10,7 +10,7 @@ futures = { workspace = true }
hex = "0.4.2"
ic-artifact-pool = { path = "../artifact_pool" }
ic-base-types = { path = "../types/base_types/" }
ic-canister-sandbox-backend-lib = { path = "../canister_sandbox/backend_lib" }
ic-canister-sandbox-backend-lib = { path = "../canister_sandbox" }
ic-canister-sandbox-launcher = { path = "../canister_sandbox/sandbox_launcher" }
ic-config = { path = "../config" }
ic-crypto-utils-threshold-sig-der = { path = "../crypto/utils/threshold_sig_der" }
Expand Down
2 changes: 1 addition & 1 deletion rs/recovery/subnet_splitting/BUILD.bazel
Expand Up @@ -55,7 +55,7 @@ rust_binary(
visibility = ["//visibility:public"],
deps = DEPENDENCIES + [
":subnet_splitting",
"//rs/canister_sandbox/backend_lib",
"//rs/canister_sandbox:backend_lib",
"//rs/canister_sandbox/sandbox_launcher:sandbox_launcher_lib",
],
)
Expand Down
2 changes: 1 addition & 1 deletion rs/replay/BUILD.bazel
Expand Up @@ -5,7 +5,7 @@ package(default_visibility = ["//visibility:public"])
DEPENDENCIES = [
"//rs/artifact_pool",
"//rs/canister_client",
"//rs/canister_sandbox/backend_lib",
"//rs/canister_sandbox:backend_lib",
"//rs/canister_sandbox/sandbox_launcher:sandbox_launcher_lib",
"//rs/config",
"//rs/consensus",
Expand Down
2 changes: 1 addition & 1 deletion rs/replay/Cargo.toml
Expand Up @@ -12,7 +12,7 @@ clap = { workspace = true }
hex = "0.4.2"
ic-artifact-pool = { path = "../artifact_pool" }
ic-canister-client = { path = "../canister_client" }
ic-canister-sandbox-backend-lib = { path = "../canister_sandbox/backend_lib" }
ic-canister-sandbox-backend-lib = { path = "../canister_sandbox" }
ic-canister-sandbox-launcher = { path = "../canister_sandbox/sandbox_launcher" }
ic-config = { path = "../config" }
ic-consensus = { path = "../consensus" }
Expand Down

0 comments on commit 89302e2

Please sign in to comment.