Skip to content

Commit 5844e61

Browse files
chore(batcher): add disabled verifiers to the batcher config (#2169)
Co-authored-by: JuArce <[email protected]>
1 parent 47aaa56 commit 5844e61

File tree

6 files changed

+47
-3
lines changed

6 files changed

+47
-3
lines changed

config-files/config-batcher-docker.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ batcher:
2828
pre_verification_is_enabled: true
2929
metrics_port: 9093
3030
telemetry_ip_port_address: localhost:4001
31+
# The specific name for each verifier should match the ProvingSystemId string representation
32+
# Possible values: GnarkPlonkBls12_381, GnarkPlonkBn254, GnarkGroth16Bn254, SP1, Risc0, CircomGroth16Bn256, Mina, MinaAccount
33+
disabled_verifiers: []
3134
non_paying:
3235
address: '0xa0Ee7A142d267C1f36714E4a8F75612F20a79720' # Anvil address 9
3336
replacement_private_key: ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 # Anvil address 1

config-files/config-batcher-ethereum-package.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ batcher:
2626
pre_verification_is_enabled: true
2727
metrics_port: 9093
2828
telemetry_ip_port_address: localhost:4001
29+
# The specific name for each verifier should match the ProvingSystemId string representation
30+
# Possible values: GnarkPlonkBls12_381, GnarkPlonkBn254, GnarkGroth16Bn254, SP1, Risc0, CircomGroth16Bn256, Mina, MinaAccount
31+
disabled_verifiers: []
2932
non_paying:
3033
address: '0xa0Ee7A142d267C1f36714E4a8F75612F20a79720' # Anvil address 9
3134
replacement_private_key: ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 # Anvil address 1

config-files/config-batcher.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ batcher:
2828
pre_verification_is_enabled: true
2929
metrics_port: 9093
3030
telemetry_ip_port_address: localhost:4001
31+
# The specific name for each verifier should match the ProvingSystemId string representation
32+
# Possible values: GnarkPlonkBls12_381, GnarkPlonkBn254, GnarkGroth16Bn254, SP1, Risc0, CircomGroth16Bn256, Mina, MinaAccount
33+
disabled_verifiers: []
3134
non_paying:
3235
address: '0xa0Ee7A142d267C1f36714E4a8F75612F20a79720' # Anvil address 9
3336
replacement_private_key: ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 # Anvil address 1

crates/batcher/src/config/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use aligned_sdk::common::types::ProvingSystemId;
12
use ethers::{core::k256::ecdsa::SigningKey, signers::Wallet, types::Address};
23
use serde::Deserialize;
34

@@ -54,6 +55,7 @@ pub struct BatcherConfigFromYaml {
5455
pub amount_of_proofs_for_min_max_fee: usize,
5556
pub min_bump_percentage: u64,
5657
pub balance_unlock_polling_interval_seconds: u64,
58+
pub disabled_verifiers: Vec<ProvingSystemId>,
5759
}
5860

5961
#[derive(Debug, Deserialize)]

crates/batcher/src/lib.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ pub struct Batcher {
134134

135135
disabled_verifiers: Mutex<U256>,
136136

137+
// The list of disabled verifiers from the config file. Note that this is separate from the
138+
// contract's disabled verifiers, and is updated only when the batcher is restarted.
139+
config_disabled_verifiers: Vec<ProvingSystemId>,
140+
137141
// Observability and monitoring
138142
pub metrics: metrics::BatcherMetrics,
139143
pub telemetry: TelemetrySender,
@@ -298,12 +302,18 @@ impl Batcher {
298302
None
299303
};
300304

301-
let disabled_verifiers = match service_manager.disabled_verifiers().call().await {
302-
Ok(disabled_verifiers) => Ok(disabled_verifiers),
305+
let contract_disabled_verifiers = match service_manager.disabled_verifiers().call().await {
306+
Ok(contract_disabled_verifiers) => Ok(contract_disabled_verifiers),
303307
Err(_) => service_manager_fallback.disabled_verifiers().call().await,
304308
}
305309
.expect("Failed to get disabled verifiers");
306310

311+
let config_disabled_verifiers = config.batcher.disabled_verifiers.clone();
312+
info!(
313+
"Disabled verifiers from config: {:?}",
314+
config_disabled_verifiers
315+
);
316+
307317
let telemetry = TelemetrySender::new(format!(
308318
"http://{}",
309319
config.batcher.telemetry_ip_port_address
@@ -347,7 +357,8 @@ impl Batcher {
347357
posting_batch: Mutex::new(false),
348358
batch_state: Mutex::new(batch_state),
349359
user_states,
350-
disabled_verifiers: Mutex::new(disabled_verifiers),
360+
disabled_verifiers: Mutex::new(contract_disabled_verifiers),
361+
config_disabled_verifiers,
351362
current_min_max_fee: RwLock::new(U256::zero()),
352363
metrics,
353364
telemetry,
@@ -1484,6 +1495,10 @@ impl Batcher {
14841495
}
14851496

14861497
async fn is_verifier_disabled(&self, verifier: ProvingSystemId) -> bool {
1498+
// Check if the verifier is disabled in the configuration first
1499+
if self.config_disabled_verifiers.contains(&verifier) {
1500+
return true;
1501+
}
14871502
let disabled_verifiers = self.disabled_verifiers.lock().await;
14881503
zk_utils::is_verifier_disabled(*disabled_verifiers, verifier)
14891504
}

crates/sdk/src/common/types.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,24 @@ impl Display for ProvingSystemId {
7070
}
7171
}
7272

73+
impl FromStr for ProvingSystemId {
74+
type Err = String;
75+
76+
fn from_str(s: &str) -> Result<Self, Self::Err> {
77+
match s {
78+
"GnarkPlonkBls12_381" => Ok(ProvingSystemId::GnarkPlonkBls12_381),
79+
"GnarkPlonkBn254" => Ok(ProvingSystemId::GnarkPlonkBn254),
80+
"GnarkGroth16Bn254" => Ok(ProvingSystemId::GnarkGroth16Bn254),
81+
"SP1" => Ok(ProvingSystemId::SP1),
82+
"Risc0" => Ok(ProvingSystemId::Risc0),
83+
"CircomGroth16Bn256" => Ok(ProvingSystemId::CircomGroth16Bn256),
84+
"Mina" => Ok(ProvingSystemId::Mina),
85+
"MinaAccount" => Ok(ProvingSystemId::MinaAccount),
86+
_ => Err(format!("Invalid ProvingSystemId: {}", s)),
87+
}
88+
}
89+
}
90+
7391
#[derive(Debug, Serialize, Deserialize, Clone)]
7492
pub struct VerificationData {
7593
pub proving_system: ProvingSystemId,

0 commit comments

Comments
 (0)