Skip to content

Commit 0ed515c

Browse files
committed
fix(coprocessor): align host listener and poller dependence params
1 parent 49d10c6 commit 0ed515c

File tree

5 files changed

+61
-8
lines changed

5 files changed

+61
-8
lines changed

charts/coprocessor/values.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ hostListener:
157157

158158
### Dependence chains parameters
159159
# - --dependence-cache-size=10000
160-
# - --dependence-by-connexity # Whether to build connected components or linear chains
161-
# - --dependence-cross-block # Do chains cross L1 block boundaries (default no)
160+
# - --dependence-by-connexity # Whether to build connected components or linear chains (default no)
161+
# - --dependence-cross-block # Do chains cross L1 block boundaries (default yes)
162162

163163
### Catchup parameters (optional)
164164
# - --catchup-margin
@@ -270,6 +270,11 @@ hostListenerPoller:
270270
### Prometheus metrics
271271
- --metrics-addr=0.0.0.0:9100 # Address for Prometheus metrics HTTP server
272272

273+
### Dependence chains parameters
274+
# - --dependence-cache-size=10000
275+
# - --dependence-by-connexity # Whether to build connected components or linear chains (default no)
276+
# - --dependence-cross-block # Do chains cross L1 block boundaries (default yes)
277+
273278
# Service ports configuration
274279
ports:
275280
metrics: 9100

coprocessor/fhevm-engine/host-listener/src/bin/poller.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ use tracing::Level;
99

1010
use fhevm_engine_common::metrics_server;
1111
use fhevm_engine_common::utils::DatabaseURL;
12+
use host_listener::cmd::{
13+
DEFAULT_DEPENDENCE_BY_CONNEXITY, DEFAULT_DEPENDENCE_CACHE_SIZE,
14+
DEFAULT_DEPENDENCE_CROSS_BLOCK,
15+
};
1216
use host_listener::poller::{run_poller, PollerConfig};
1317

1418
#[derive(Parser, Debug, Clone)]
@@ -93,6 +97,27 @@ struct Args {
9397

9498
#[arg(long, default_value = "host-listener-poller")]
9599
service_name: String,
100+
101+
#[arg(
102+
long,
103+
default_value_t = DEFAULT_DEPENDENCE_CACHE_SIZE,
104+
help = "Pre-computation dependence chain cache size"
105+
)]
106+
pub dependence_cache_size: u16,
107+
108+
#[arg(
109+
long,
110+
default_value_t = DEFAULT_DEPENDENCE_BY_CONNEXITY,
111+
help = "Dependence chain are connected components"
112+
)]
113+
pub dependence_by_connexity: bool,
114+
115+
#[arg(
116+
long,
117+
default_value_t = DEFAULT_DEPENDENCE_CROSS_BLOCK,
118+
help = "Dependence chain are across blocks"
119+
)]
120+
pub dependence_cross_block: bool,
96121
}
97122

98123
#[tokio::main]
@@ -131,6 +156,9 @@ async fn main() -> anyhow::Result<()> {
131156
max_http_retries: args.max_http_retries,
132157
rpc_compute_units_per_second: args.rpc_compute_units_per_second,
133158
health_port: args.health_port,
159+
dependence_cache_size: args.dependence_cache_size,
160+
dependence_by_connexity: args.dependence_by_connexity,
161+
dependence_cross_block: args.dependence_cross_block,
134162
};
135163

136164
run_poller(config).await

coprocessor/fhevm-engine/host-listener/src/cmd/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ const REORG_RETRY_GET_BLOCK: u64 = 10; // retry 10 times to get logs for a block
3636
const RETRY_GET_BLOCK_DELAY_IN_MS: u64 = 100;
3737

3838
const DEFAULT_BLOCK_TIME: u64 = 12;
39+
pub const DEFAULT_DEPENDENCE_CACHE_SIZE: u16 = 10_000;
40+
pub const DEFAULT_DEPENDENCE_BY_CONNEXITY: bool = false;
41+
pub const DEFAULT_DEPENDENCE_CROSS_BLOCK: bool = false;
3942

4043
#[derive(Parser, Debug, Clone)]
4144
#[command(version, about, long_about = None)]
@@ -101,21 +104,21 @@ pub struct Args {
101104

102105
#[arg(
103106
long,
104-
default_value = "10000",
107+
default_value_t = DEFAULT_DEPENDENCE_CACHE_SIZE,
105108
help = "Pre-computation dependence chain cache size"
106109
)]
107110
pub dependence_cache_size: u16,
108111

109112
#[arg(
110113
long,
111-
default_value_t = false,
114+
default_value_t = DEFAULT_DEPENDENCE_BY_CONNEXITY,
112115
help = "Dependence chain are connected components"
113116
)]
114117
pub dependence_by_connexity: bool,
115118

116119
#[arg(
117120
long,
118-
default_value_t = false,
121+
default_value_t = DEFAULT_DEPENDENCE_CROSS_BLOCK,
119122
help = "Dependence chain are across blocks"
120123
)]
121124
pub dependence_cross_block: bool,

coprocessor/fhevm-engine/host-listener/src/poller/mod.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use crate::poller::metrics::{
2828
inc_blocks_processed, inc_db_errors, inc_rpc_errors,
2929
};
3030

31-
const DEFAULT_DEPENDENCE_CACHE_SIZE: u16 = 128;
3231
const MAX_DB_RETRIES: u64 = 10;
3332
/// Exit after this many consecutive RPC failures (after retries exhausted).
3433
/// Orchestrator will restart with fresh state.
@@ -84,6 +83,10 @@ pub struct PollerConfig {
8483
/// Higher values = less throttling.
8584
pub rpc_compute_units_per_second: u64,
8685
pub health_port: u16,
86+
// Dependence chain settings
87+
pub dependence_cache_size: u16,
88+
pub dependence_by_connexity: bool,
89+
pub dependence_cross_block: bool,
8790
}
8891

8992
pub async fn run_poller(config: PollerConfig) -> Result<()> {
@@ -133,7 +136,7 @@ pub async fn run_poller(config: PollerConfig) -> Result<()> {
133136
let mut db = Database::new(
134137
&config.database_url,
135138
&config.coprocessor_api_key,
136-
DEFAULT_DEPENDENCE_CACHE_SIZE,
139+
config.dependence_cache_size,
137140
)
138141
.await?;
139142

@@ -293,6 +296,8 @@ pub async fn run_poller(config: PollerConfig) -> Result<()> {
293296
acl_address,
294297
tfhe_address,
295298
config.retry_interval,
299+
config.dependence_by_connexity,
300+
config.dependence_cross_block,
296301
)
297302
.await
298303
{
@@ -356,20 +361,29 @@ pub async fn run_poller(config: PollerConfig) -> Result<()> {
356361
}
357362
}
358363

364+
#[allow(clippy::too_many_arguments)]
359365
async fn ingest_with_retry(
360366
chain_id: u64,
361367
db: &mut Database,
362368
block_logs: &BlockLogs<Log>,
363369
acl_address: Address,
364370
tfhe_address: Address,
365371
retry_interval: Duration,
372+
dependency_by_connexity: bool,
373+
dependency_cross_block: bool,
366374
) -> Result<u64, (sqlx::Error, u64)> {
367375
let mut errors = 0;
368376
let acl = Some(acl_address);
369377
let tfhe = Some(tfhe_address);
370378
loop {
371379
match ingest_block_logs(
372-
chain_id, db, block_logs, &acl, &tfhe, false, false,
380+
chain_id,
381+
db,
382+
block_logs,
383+
&acl,
384+
&tfhe,
385+
dependency_by_connexity,
386+
dependency_cross_block,
373387
)
374388
.await
375389
{

coprocessor/fhevm-engine/host-listener/tests/poller_integration_tests.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ async fn poller_catches_up_to_safe_tip(
197197
max_http_retries: 0,
198198
rpc_compute_units_per_second: 1000,
199199
health_port: 18081,
200+
dependence_cache_size: 10_000,
201+
dependence_by_connexity: false,
202+
dependence_cross_block: false,
200203
};
201204

202205
let poller_handle = tokio::spawn(run_poller(config));

0 commit comments

Comments
 (0)