Skip to content

Commit de1a04c

Browse files
committed
chore(kms-connector): remove gw conn from kms-worker
1 parent f6195f3 commit de1a04c

File tree

6 files changed

+10
-84
lines changed

6 files changed

+10
-84
lines changed

kms-connector/config/kms-worker.toml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ chain_id = 54321
1515
# Ex: KMS_CONNECTOR_KMS_CORE_ENDPOINTS="http://[::1]:50051,http://[::1]:50052"
1616
kms_core_endpoints = ["http://[::1]:50051"]
1717

18-
# Gateway WebSocket RPC URL endpoint (required)
19-
# ENV: KMS_CONNECTOR_GATEWAY_URL
20-
gateway_url = "ws://gateway-node:8546"
21-
2218
# URL of the KMS Connector internal database (required)
2319
# Format: see https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING-URIS
2420
# ENV: KMS_CONNECTOR_DATABASE_URL
@@ -37,19 +33,6 @@ address = "0xF0bFB159C7381F7CB332586004d8247252C5b816"
3733
# ENV: KMS_CONNECTOR_DECRYPTION_DOMAIN_VERSION
3834
# domain_version = "1"
3935

40-
# Configuration of the GatewayConfig contract (required)
41-
[gateway_config_contract]
42-
# Address of the GatewayConfig contract (required)
43-
# Format: hex string with 0x prefix
44-
# ENV: KMS_CONNECTOR_GATEWAY_CONFIG_CONTRACT__ADDRESS
45-
address = "0x5ffdaAB0373E62E2ea2944776209aEf29E631A64"
46-
# EIP-712 domain name for GatewayConfig contract (optional, defaults to "GatewayConfig")
47-
# ENV: KMS_CONNECTOR_GATEWAY_CONFIG_CONTRACT__DOMAIN_NAME
48-
# domain_name = "GatewayConfig"
49-
# EIP-712 domain version for GatewayConfig contract (optional, defaults to "1")
50-
# ENV: KMS_CONNECTOR_GATEWAY_CONFIG_CONTRACT__DOMAIN_VERSION
51-
# domain_version = "1"
52-
5336
# The endpoint used to monitor the connector components (optional, defaults to "0.0.0.0:9100")
5437
# ENV: KMS_CONNECTOR_MONITORING_ENDPOINT
5538
# monitoring_endpoint = "0.0.0.0:9100"

kms-connector/crates/kms-worker/src/core/config/parsed.rs

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ pub struct Config {
2727
pub chain_id: u64,
2828
/// The `Decryption` contract configuration.
2929
pub decryption_contract: ContractConfig,
30-
/// The `GatewayConfig` contract configuration.
31-
pub gateway_config_contract: ContractConfig,
3230
/// The service name used for tracing.
3331
pub service_name: String,
3432

@@ -84,8 +82,6 @@ impl Config {
8482
.map_err(|e| Error::InvalidConfig(e.to_string()))?;
8583
let decryption_contract =
8684
ContractConfig::parse("Decryption", raw_config.decryption_contract)?;
87-
let gateway_config_contract =
88-
ContractConfig::parse("GatewayConfig", raw_config.gateway_config_contract)?;
8985

9086
// Validate critical configuration parts
9187
if raw_config.gateway_url.is_empty() {
@@ -121,7 +117,6 @@ impl Config {
121117
kms_core_endpoints,
122118
chain_id: raw_config.chain_id,
123119
decryption_contract,
124-
gateway_config_contract,
125120
service_name: raw_config.service_name,
126121
events_batch_size: raw_config.events_batch_size,
127122
grpc_request_retries: raw_config.grpc_request_retries,
@@ -161,7 +156,6 @@ mod tests {
161156
env::remove_var("KMS_CONNECTOR_KMS_CORE_ENDPOINTS");
162157
env::remove_var("KMS_CONNECTOR_CHAIN_ID");
163158
env::remove_var("KMS_CONNECTOR_DECRYPTION_CONTRACT__ADDRESS");
164-
env::remove_var("KMS_CONNECTOR_GATEWAY_CONFIG_CONTRACT__ADDRESS");
165159
env::remove_var("KMS_CONNECTOR_SERVICE_NAME");
166160
env::remove_var("KMS_CONNECTOR_S3_CONFIG__REGION");
167161
env::remove_var("KMS_CONNECTOR_S3_CONFIG__BUCKET");
@@ -193,10 +187,6 @@ mod tests {
193187
Address::from_str(&raw_config.decryption_contract.address).unwrap(),
194188
config.decryption_contract.address,
195189
);
196-
assert_eq!(
197-
Address::from_str(&raw_config.gateway_config_contract.address).unwrap(),
198-
config.gateway_config_contract.address,
199-
);
200190
assert_eq!(raw_config.kms_core_endpoints, config.kms_core_endpoints);
201191
assert_eq!(raw_config.service_name, config.service_name);
202192
assert_eq!(
@@ -219,14 +209,6 @@ mod tests {
219209
raw_config.decryption_contract.domain_version.unwrap(),
220210
config.decryption_contract.domain_version,
221211
);
222-
assert_eq!(
223-
raw_config.gateway_config_contract.domain_name.unwrap(),
224-
config.gateway_config_contract.domain_name,
225-
);
226-
assert_eq!(
227-
raw_config.gateway_config_contract.domain_version.unwrap(),
228-
config.gateway_config_contract.domain_version,
229-
);
230212
assert_eq!(raw_config.s3_config, config.s3_config);
231213
}
232214

@@ -251,10 +233,7 @@ mod tests {
251233
"KMS_CONNECTOR_DECRYPTION_CONTRACT__ADDRESS",
252234
"0x5fbdb2315678afecb367f032d93f642f64180aa3",
253235
);
254-
env::set_var(
255-
"KMS_CONNECTOR_GATEWAY_CONFIG_CONTRACT__ADDRESS",
256-
"0x0000000000000000000000000000000000000001",
257-
);
236+
258237
env::set_var("KMS_CONNECTOR_SERVICE_NAME", "kms-connector-test");
259238
env::set_var("KMS_CONNECTOR_EVENTS_BATCH_SIZE", "15");
260239
env::set_var("KMS_CONNECTOR_GRPC_REQUEST_RETRIES", "5");
@@ -279,10 +258,6 @@ mod tests {
279258
config.decryption_contract.address,
280259
Address::from_str("0x5fbdb2315678afecb367f032d93f642f64180aa3").unwrap()
281260
);
282-
assert_eq!(
283-
config.gateway_config_contract.address,
284-
Address::from_str("0x0000000000000000000000000000000000000001").unwrap()
285-
);
286261
assert_eq!(config.service_name, "kms-connector-test");
287262
assert_eq!(config.events_batch_size, 15);
288263
assert_eq!(config.grpc_request_retries, 5);
@@ -337,10 +312,6 @@ mod tests {
337312
address: "0x0000".to_string(),
338313
..Default::default()
339314
},
340-
gateway_config_contract: RawContractConfig {
341-
address: "0x000010".to_string(),
342-
..Default::default()
343-
},
344315
..Default::default()
345316
};
346317
assert!(matches!(

kms-connector/crates/kms-worker/src/core/config/raw.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ pub struct RawConfig {
3636
pub kms_core_endpoint: Option<String>,
3737
pub chain_id: u64,
3838
pub decryption_contract: RawContractConfig,
39-
pub gateway_config_contract: RawContractConfig,
4039
#[serde(default = "default_service_name")]
4140
pub service_name: String,
4241
#[serde(default = "default_events_batch_size")]
@@ -146,11 +145,6 @@ impl Default for RawConfig {
146145
domain_name: Some("Decryption".to_string()),
147146
domain_version: Some("1".to_string()),
148147
},
149-
gateway_config_contract: RawContractConfig {
150-
address: "0x0000000000000000000000000000000000000000".to_string(),
151-
domain_name: Some("GatewayConfig".to_string()),
152-
domain_version: Some("1".to_string()),
153-
},
154148
service_name: "kms-connector".to_string(),
155149
events_batch_size: 10,
156150
grpc_request_retries: 3,

kms-connector/crates/kms-worker/src/core/kms_worker.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ use crate::{
1010
},
1111
monitoring::health::{KmsHealthClient, State},
1212
};
13-
use connector_utils::{
14-
conn::{GatewayProvider, connect_to_db, connect_to_gateway},
15-
tasks::spawn_with_limit,
16-
};
13+
use connector_utils::{conn::connect_to_db, tasks::spawn_with_limit};
1714
use std::fmt::Display;
1815
use tokio_util::sync::CancellationToken;
1916
use tracing::{error, info, warn};
@@ -94,9 +91,8 @@ where
9491

9592
impl KmsWorker<DbEventPicker, DbEventProcessor, DbKmsResponsePublisher> {
9693
/// Creates a new `KmsWorker` instance from a valid `Config`.
97-
pub async fn from_config(config: Config) -> anyhow::Result<(Self, State<GatewayProvider>)> {
94+
pub async fn from_config(config: Config) -> anyhow::Result<(Self, State)> {
9895
let db_pool = connect_to_db(&config.database_url, config.database_pool_size).await?;
99-
let provider = connect_to_gateway(&config.gateway_url).await?;
10096
let kms_client = KmsClient::connect(&config).await?;
10197
let kms_health_client = KmsHealthClient::connect(&config.kms_core_endpoints).await?;
10298

@@ -108,12 +104,7 @@ impl KmsWorker<DbEventPicker, DbEventProcessor, DbKmsResponsePublisher> {
108104
DbEventProcessor::new(kms_client.clone(), decryption_processor, db_pool.clone());
109105
let response_publisher = DbKmsResponsePublisher::new(db_pool.clone());
110106

111-
let state = State::new(
112-
db_pool,
113-
provider,
114-
kms_health_client,
115-
config.healthcheck_timeout,
116-
);
107+
let state = State::new(db_pool, kms_health_client, config.healthcheck_timeout);
117108
let kms_worker = KmsWorker::new(event_picker, event_processor, response_publisher);
118109
Ok((kms_worker, state))
119110
}

kms-connector/crates/kms-worker/src/monitoring/health.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use actix_web::http::StatusCode;
2-
use alloy::providers::Provider;
3-
use connector_utils::monitoring::health::{Healthcheck, database_healthcheck, gateway_healthcheck};
2+
use connector_utils::monitoring::health::{Healthcheck, database_healthcheck};
43
use serde::{Deserialize, Serialize};
54
use sqlx::{Pool, Postgres};
65
use std::time::Duration;
@@ -13,36 +12,31 @@ use tonic_health::pb::{HealthCheckRequest, HealthCheckResponse, health_client::H
1312

1413
#[derive(Clone)]
1514
/// The struct used to monitor the state of the `KmsWorker`.
16-
pub struct State<P> {
15+
pub struct State {
1716
db_pool: Pool<Postgres>,
18-
provider: P,
1917
kms_health_client: KmsHealthClient,
2018
healthcheck_timeout: Duration,
2119
}
2220

23-
impl<P: Provider> State<P> {
21+
impl State {
2422
pub fn new(
2523
db_pool: Pool<Postgres>,
26-
provider: P,
2724
kms_health_client: KmsHealthClient,
2825
healthcheck_timeout: Duration,
2926
) -> Self {
3027
Self {
3128
db_pool,
32-
provider,
3329
kms_health_client,
3430
healthcheck_timeout,
3531
}
3632
}
3733
}
3834

39-
impl<P: Provider> Healthcheck for State<P> {
35+
impl Healthcheck for State {
4036
async fn healthcheck(&self) -> actix_web::HttpResponse {
4137
let mut errors = vec![];
4238
let database_connected =
4339
database_healthcheck(&self.db_pool, self.healthcheck_timeout, &mut errors).await;
44-
let gateway_connected =
45-
gateway_healthcheck(&self.provider, self.healthcheck_timeout, &mut errors).await;
4640

4741
let mut kms_core_connected = true;
4842
let kms_healtcheck_results = self.kms_health_client.check(self.healthcheck_timeout).await;
@@ -69,7 +63,6 @@ impl<P: Provider> Healthcheck for State<P> {
6963
let status = HealthStatus {
7064
healthy,
7165
database_connected,
72-
gateway_connected,
7366
kms_core_connected,
7467
details: errors.join("; "),
7568
};
@@ -89,8 +82,6 @@ pub struct HealthStatus {
8982
pub healthy: bool,
9083
/// Database connection status.
9184
pub database_connected: bool,
92-
/// Gateway provider connection status.
93-
pub gateway_connected: bool,
9485
/// KMS Core connections status.
9586
pub kms_core_connected: bool,
9687
/// Details about any issues encountered during healthcheck.

kms-connector/crates/kms-worker/tests/health.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use alloy::{
2-
providers::RootProvider,
3-
transports::http::reqwest::{self, StatusCode, Url},
4-
};
1+
use alloy::transports::http::reqwest::{self, StatusCode, Url};
52
use connector_utils::{
63
monitoring::{
74
health::{Healthcheck, query_healthcheck_endpoint},
@@ -23,7 +20,6 @@ async fn test_healthcheck_endpoints() -> anyhow::Result<()> {
2320
KmsHealthClient::connect(&[test_instance.kms_url().to_string()]).await?;
2421
let state = State::new(
2522
test_instance.db().clone(),
26-
test_instance.provider().clone(),
2723
kms_health_client,
2824
Duration::from_secs(5),
2925
);
@@ -61,7 +57,7 @@ async fn test_healthcheck_endpoints() -> anyhow::Result<()> {
6157
assert_eq!(
6258
response.json::<VersionResponse>().await?,
6359
VersionResponse {
64-
name: State::<RootProvider>::service_name().to_string(),
60+
name: State::service_name().to_string(),
6561
version: env!("CARGO_PKG_VERSION").to_string(),
6662
build: GIT_COMMIT_HASH.to_string(),
6763
}

0 commit comments

Comments
 (0)