Skip to content

Commit fce43dd

Browse files
committed
chore(consensus): Split of utils
1 parent e41f97f commit fce43dd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+403
-224
lines changed

Cargo.lock

+50-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ members = [
4141
"rs/certification/test-utils",
4242
"rs/config",
4343
"rs/consensus",
44+
"rs/consensus/mocks",
45+
"rs/consensus/utils",
4446
"rs/constants",
4547
"rs/criterion_time",
4648
"rs/crypto",

rs/consensus/BUILD.bazel

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ DEPENDENCIES = [
77
# Keep sorted.
88
"//rs/artifact_pool",
99
"//rs/config",
10+
"//rs/consensus/utils",
1011
"//rs/crypto",
11-
"//rs/crypto/prng",
1212
"//rs/crypto/test_utils/canister_threshold_sigs",
1313
"//rs/interfaces",
1414
"//rs/interfaces/https_outcalls_adapter_client",
@@ -27,7 +27,6 @@ DEPENDENCIES = [
2727
"//rs/types/ic00_types",
2828
"//rs/types/types",
2929
"//rs/utils",
30-
"@crate_index//:hex",
3130
"@crate_index//:num-integer",
3231
"@crate_index//:prometheus",
3332
"@crate_index//:rand_0_8_4",
@@ -40,6 +39,7 @@ DEPENDENCIES = [
4039
DEV_DEPENDENCIES = [
4140
# Keep sorted.
4241
"//rs/bitcoin/types/internal",
42+
"//rs/consensus/mocks",
4343
"//rs/crypto/temp_crypto",
4444
"//rs/cycles_account_manager",
4545
"//rs/execution_environment",
@@ -136,6 +136,7 @@ rust_bench(
136136
":consensus",
137137
"//rs/artifact_pool",
138138
"//rs/config",
139+
"//rs/consensus/utils",
139140
"//rs/constants",
140141
"//rs/execution_environment",
141142
"//rs/ingress_manager",

rs/consensus/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ edition = "2021"
66
[dependencies]
77
ic-artifact-pool = { path = "../artifact_pool" }
88
ic-config = { path = "../config" }
9+
ic-consensus-utils = { path = "./utils" }
910
ic-constants = { path = "../constants" }
1011
ic-crypto = { path = "../crypto" }
11-
ic-crypto-prng = { path = "../crypto/prng" }
1212
ic-crypto-test-utils-canister-threshold-sigs = { path = "../crypto/test_utils/canister_threshold_sigs", optional = true }
1313
ic-error-types = { path = "../types/error_types" }
1414
ic-ic00-types = { path = "../types/ic00_types" }
@@ -17,7 +17,6 @@ ic-interfaces-https-outcalls-adapter-client = { path = "../interfaces/https_outc
1717
ic-interfaces-registry = { path = "../interfaces/registry" }
1818
ic-interfaces-state-manager = { path = "../interfaces/state_manager" }
1919
ic-registry-client-helpers = { path = "../registry/helpers" }
20-
ic-registry-keys = { path = "../registry/keys" }
2120
ic-replicated-state = { path = "../replicated_state" }
2221
ic-logger = { path = "../monitoring/logger" }
2322
ic-metrics = { path = "../monitoring/metrics" }
@@ -26,7 +25,6 @@ ic-registry-subnet-features = { path = "../registry/subnet_features" }
2625
ic-protobuf = { path = "../protobuf" }
2726
ic-types = { path = "../types/types" }
2827
ic-utils = { path = "../utils" }
29-
hex = "0.4.2"
3028
num-integer = "0.1.41"
3129
phantom_newtype = { path = "../phantom_newtype" }
3230
prometheus = { version = "0.12.0", features = [ "process" ] }
@@ -44,6 +42,7 @@ criterion = "0.3"
4442
ic-artifact-pool = { path = "../artifact_pool" }
4543
ic-btc-types-internal = { path = "../bitcoin/types/internal" }
4644
ic-config = { path = "../config" }
45+
ic-consensus-mocks = { path = "./mocks" }
4746
ic-crypto-test-utils-canister-threshold-sigs = { path = "../crypto/test_utils/canister_threshold_sigs" }
4847
ic-crypto-temp-crypto = { path = "../crypto/temp_crypto" }
4948
ic-execution-environment = { path = "../execution_environment" }
@@ -52,6 +51,7 @@ ic-interfaces-certified-stream-store = { path = "../interfaces/certified_stream_
5251
ic-interfaces-state-manager-mocks = { path = "../interfaces/state_manager/mocks" }
5352
ic-messaging = { path = "../messaging" }
5453
ic-registry-client-fake = { path = "../registry/fake" }
54+
ic-registry-keys = { path = "../registry/keys" }
5555
ic-registry-proto-data-provider = { path = "../registry/proto_data_provider" }
5656
ic-replicated-state = { path = "../replicated_state" }
5757
ic-state-manager = { path = "../state_manager" }

rs/consensus/benches/validate_payload.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
use criterion::{black_box, criterion_group, criterion_main, Criterion};
1414
use ic_artifact_pool::{consensus_pool::ConsensusPoolImpl, ingress_pool::IngressPoolImpl};
1515
use ic_config::state_manager::Config as StateManagerConfig;
16-
use ic_consensus::consensus::{payload_builder::PayloadBuilderImpl, pool_reader::PoolReader};
16+
use ic_consensus::consensus::payload_builder::PayloadBuilderImpl;
17+
use ic_consensus_utils::pool_reader::PoolReader;
1718
use ic_constants::MAX_INGRESS_TTL;
1819
use ic_execution_environment::IngressHistoryReaderImpl;
1920
use ic_ic00_types::IC_00;

rs/consensus/mocks/BUILD.bazel

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
load("@rules_rust//rust:defs.bzl", "rust_library")
2+
3+
package(default_visibility = ["//visibility:public"])
4+
5+
DEPENDENCIES = [
6+
# Keep sorted.
7+
"//rs/artifact_pool",
8+
"//rs/config",
9+
"//rs/consensus/utils",
10+
"//rs/interfaces",
11+
"//rs/interfaces/state_manager",
12+
"//rs/monitoring/logger",
13+
"//rs/monitoring/metrics",
14+
"//rs/protobuf",
15+
"//rs/registry/fake",
16+
"//rs/registry/keys",
17+
"//rs/registry/proto_data_provider",
18+
"//rs/test_utilities",
19+
"//rs/test_utilities/artifact_pool",
20+
"//rs/test_utilities/registry",
21+
"//rs/types/types",
22+
"@crate_index//:mockall_0_7_2",
23+
"@crate_index//:slog",
24+
]
25+
26+
rust_library(
27+
name = "mocks",
28+
srcs = glob(["src/**/*.rs"]),
29+
crate_features = select({
30+
"//conditions:default": [],
31+
}),
32+
crate_name = "ic_consensus_mocks",
33+
proc_macro_deps = [
34+
"@crate_index//:strum_macros",
35+
],
36+
version = "0.8.0",
37+
deps = DEPENDENCIES,
38+
)

rs/consensus/mocks/Cargo.toml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[package]
2+
name = "ic-consensus-mocks"
3+
version = "0.8.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
ic-artifact-pool = { path = "../../artifact_pool" }
8+
ic-config = { path = "../../config" }
9+
ic-consensus-utils = { path = "../utils" }
10+
ic-interfaces = { path = "../../interfaces" }
11+
ic-interfaces-state-manager = { path = "../../interfaces/state_manager" }
12+
ic-logger = { path = "../../monitoring/logger" }
13+
ic-metrics = { path = "../../monitoring/metrics" }
14+
ic-protobuf = { path = "../../protobuf" }
15+
ic-registry-client-fake = { path = "../../registry/fake" }
16+
ic-registry-keys = { path = "../../registry/keys" }
17+
ic-registry-proto-data-provider = { path = "../../registry/proto_data_provider" }
18+
ic-test-artifact-pool = { path = "../../test_utilities/artifact_pool" }
19+
ic-test-utilities = { path = "../../test_utilities" }
20+
ic-test-utilities-registry = { path = "../../test_utilities/registry" }
21+
ic-types = { path = "../../types/types" }
22+
mockall = "0.7.2"
23+
slog = { version = "2.5.2", features = ["nested-values", "release_max_level_debug"] }

rs/consensus/src/consensus/mocks.rs renamed to rs/consensus/mocks/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! Contains mocks for traits internal to consensus
2-
use crate::consensus::membership::Membership;
32
use ic_artifact_pool::{
43
canister_http_pool::CanisterHttpPoolImpl, dkg_pool::DkgPoolImpl, ecdsa_pool::EcdsaPoolImpl,
54
};
65
use ic_config::artifact_pool::ArtifactPoolConfig;
6+
use ic_consensus_utils::membership::Membership;
77
use ic_interfaces::{
88
consensus::{PayloadBuilder, PayloadValidationError},
99
validation::ValidationResult,

rs/consensus/src/canister_http/gossip.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! This module contains the gossip implementation of the canister http feature.
22
33
pub use crate::canister_http::pool_manager::CanisterHttpPoolManagerImpl;
4-
use crate::consensus::utils::registry_version_at_height;
4+
use ic_consensus_utils::registry_version_at_height;
55
use ic_interfaces::{
66
artifact_pool::PriorityFnAndFilterProducer, canister_http::CanisterHttpPool,
77
consensus_pool::ConsensusPoolCache,

rs/consensus/src/canister_http/payload_builder.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
//! Implementation of the payload builder of the canister http feature
22
3-
use crate::{
4-
canister_http::{
5-
metrics::CanisterHttpPayloadBuilderMetrics,
6-
payload_builder::utils::{
7-
group_shares_by_callback_id, grouped_shares_meet_divergence_criteria,
8-
},
3+
use crate::canister_http::{
4+
metrics::CanisterHttpPayloadBuilderMetrics,
5+
payload_builder::utils::{
6+
group_shares_by_callback_id, grouped_shares_meet_divergence_criteria,
97
},
10-
consensus::{utils::registry_version_at_height, ConsensusCrypto, Membership},
8+
};
9+
use ic_consensus_utils::{
10+
crypto::ConsensusCrypto, membership::Membership, registry_version_at_height,
1111
};
1212
use ic_interfaces::{
1313
canister_http::{

rs/consensus/src/canister_http/payload_builder/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
//!
44
//! Some tests are run over a range of subnet configurations to check for corner cases.
55
6-
use crate::consensus::mocks::{dependencies_with_subnet_params, Dependencies};
76
use ic_artifact_pool::canister_http_pool::CanisterHttpPoolImpl;
7+
use ic_consensus_mocks::{dependencies_with_subnet_params, Dependencies};
88
use ic_interfaces::{
99
artifact_pool::{MutablePool, UnvalidatedArtifact},
1010
canister_http::{

rs/consensus/src/canister_http/pool_manager.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
//! responsible for managing the flow of requests from execution to the
33
//! networking component, and ensuring that the resulting responses are signed
44
//! and eventually make it into consensus.
5-
use crate::{
6-
canister_http::metrics::CanisterHttpPoolManagerMetrics,
7-
consensus::{utils::registry_version_at_height, ConsensusCrypto, Membership},
5+
use crate::canister_http::metrics::CanisterHttpPoolManagerMetrics;
6+
use ic_consensus_utils::{
7+
crypto::ConsensusCrypto, membership::Membership, registry_version_at_height,
88
};
99
use ic_interfaces::{
1010
artifact_pool::ChangeSetProducer, canister_http::*, consensus_pool::ConsensusPoolCache,
@@ -397,9 +397,9 @@ impl<T: CanisterHttpPool> ChangeSetProducer<T> for CanisterHttpPoolManagerImpl {
397397
#[cfg(test)]
398398
pub mod test {
399399
use super::*;
400-
use crate::consensus::crypto::SignVerify;
401-
use crate::consensus::mocks::{dependencies, Dependencies};
402400
use ic_artifact_pool::canister_http_pool::CanisterHttpPoolImpl;
401+
use ic_consensus_mocks::{dependencies, Dependencies};
402+
use ic_consensus_utils::crypto::SignVerify;
403403
use ic_interfaces::artifact_pool::MutablePool;
404404
use ic_interfaces::time_source::SysTimeSource;
405405
use ic_interfaces_state_manager::Labeled;

rs/consensus/src/certification.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! This module defines the certification component, which is responsible for
22
//! reaching consensus on parts of the replicated state produced by the upper
33
//! layers by signing state hashes.
4-
use crate::consensus::crypto::{Aggregate, SignVerify};
4+
use ic_consensus_utils::crypto::{Aggregate, SignVerify};
55
use ic_interfaces::crypto::{Crypto, ThresholdSigner};
66
use ic_types::signature::*;
77
use ic_types::{

0 commit comments

Comments
 (0)