-
Notifications
You must be signed in to change notification settings - Fork 396
Expand file tree
/
Copy pathmod.rs
More file actions
104 lines (91 loc) · 3.18 KB
/
mod.rs
File metadata and controls
104 lines (91 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
use ethers::{core::k256::ecdsa::SigningKey, signers::Wallet, types::Address};
use serde::Deserialize;
#[derive(Clone, Debug, Deserialize)]
pub struct ECDSAConfig {
pub private_key_store_path: String,
pub private_key_store_password: String,
}
#[derive(Debug)]
pub struct NonPayingConfig {
pub address: Address,
pub replacement: Wallet<SigningKey>,
}
#[derive(Debug, Deserialize)]
pub struct NonPayingConfigFromYaml {
pub address: Address,
pub replacement_private_key: String,
}
impl NonPayingConfig {
pub async fn from_yaml_config(config: NonPayingConfigFromYaml) -> Self {
let replacement = Wallet::from_bytes(
hex::decode(config.replacement_private_key)
.expect("Failed to decode replacement private key")
.as_slice(),
)
.expect("Failed to create replacement wallet");
NonPayingConfig {
address: config.address,
replacement,
}
}
}
#[derive(Debug, Deserialize)]
pub struct BatcherConfigFromYaml {
#[serde(default = "default_aggregator_fee_percentage_multiplier")]
pub aggregator_fee_percentage_multiplier: u128,
#[serde(default = "default_aggregator_gas_cost")]
pub aggregator_gas_cost: u128,
pub block_interval: u64,
pub transaction_wait_timeout: u64,
pub max_proof_size: usize,
pub max_batch_byte_size: usize,
pub max_batch_proof_qty: usize,
pub max_queue_size: usize,
pub pre_verification_is_enabled: bool,
pub metrics_port: u16,
pub telemetry_ip_port_address: String,
pub non_paying: Option<NonPayingConfigFromYaml>,
pub amount_of_proofs_for_min_max_fee: usize,
pub min_bump_percentage: u64,
pub balance_unlock_polling_interval_seconds: u64,
}
#[derive(Debug, Deserialize)]
pub struct ConfigFromYaml {
pub eth_rpc_url: String,
pub eth_rpc_url_fallback: String,
pub eth_ws_url: String,
pub eth_ws_url_fallback: String,
pub ecdsa: ECDSAConfig,
pub aligned_layer_deployment_config_file_path: String,
pub batcher: BatcherConfigFromYaml,
}
impl ConfigFromYaml {
pub fn new(config_file: String) -> Self {
let config_file = std::fs::read_to_string(config_file).expect("Failed to read config file");
serde_yaml::from_str(&config_file).expect("Failed to parse config file")
}
}
#[derive(Debug, Deserialize)]
pub struct Addresses {
#[serde(rename = "batcherPaymentService")]
pub batcher_payment_service: String,
#[serde(rename = "alignedLayerServiceManager")]
pub service_manager: String,
}
#[derive(Debug, Deserialize)]
pub struct ContractDeploymentOutput {
pub addresses: Addresses,
}
impl ContractDeploymentOutput {
pub fn new(deployment_output: String) -> Self {
let deployment_output = std::fs::read_to_string(deployment_output)
.expect("Failed to read deployment output file");
serde_json::from_str(&deployment_output).expect("Failed to parse deployment output file")
}
}
fn default_aggregator_fee_percentage_multiplier() -> u128 {
aligned_sdk::common::constants::DEFAULT_AGGREGATOR_FEE_PERCENTAGE_MULTIPLIER
}
fn default_aggregator_gas_cost() -> u128 {
aligned_sdk::common::constants::DEFAULT_AGGREGATOR_GAS_COST
}