Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sections to configuration file #306

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,10 @@ sqlx = { version = "0.7.4", default-features = false }
bitcoin-mock-rpc = { git = "https://github.com/chainwayxyz/bitcoin-mock-rpc", tag = "v0.0.11" }
musig2 = { version = "0.0.11", features = ["serde"] }

# Always optimize; building and running the guest takes much longer without optimization.
[profile.dev]
opt-level = 3

[profile.dev.build-override]
opt-level = 3

[profile.release]
debug = 1
lto = true

[profile.release.build-override]
opt-level = 3
strip = true
codegen-units = 1
# TODO: Abort on panic can be enabled to save binary space. But needs a proper
# error management infrastructure to not lose crash report.
# panic = "abort"
34 changes: 17 additions & 17 deletions core/src/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Aggregator {
#[tracing::instrument(err(level = tracing::Level::ERROR), ret(level = tracing::Level::TRACE))]
pub async fn new(config: BridgeConfig) -> Result<Self, BridgeError> {
let nofn_xonly_pk = secp256k1::XOnlyPublicKey::from_musig2_pks(
config.verifiers_public_keys.clone(),
config.verifier.public_keys.clone(),
None,
false,
);
Expand All @@ -62,9 +62,9 @@ impl Aggregator {
&operator_xonly_pk,
operator_idx,
&self.nofn_xonly_pk,
self.config.network,
self.config.bitcoin.network,
self.config.user_takes_after,
self.config.operator_takes_after,
self.config.operator.takes_after,
self.config.bridge_amount_sats,
);
// tracing::debug!("SLASH_OR_TAKE_TX: {:?}", tx);
Expand All @@ -73,7 +73,7 @@ impl Aggregator {
Actor::convert_tx_to_sighash_script_spend(&mut tx, 0, 0)?.to_byte_array();
// tracing::debug!("aggregate SLASH_OR_TAKE_TX message: {:?}", message);
let final_sig: [u8; 64] = aggregate_partial_signatures(
self.config.verifiers_public_keys.clone(),
self.config.verifier.public_keys.clone(),
None,
false,
agg_nonce,
Expand All @@ -83,7 +83,7 @@ impl Aggregator {
// tracing::debug!("aggregate SLASH_OR_TAKE_TX final_sig: {:?}", final_sig);
// tracing::debug!(
// "aggregate SLASH_OR_TAKE_TX for verifiers: {:?}",
// self.config.verifiers_public_keys.clone()
// self.config.verifier.public_keys.clone()
// );
// tracing::debug!(
// "aggregate SLASH_OR_TAKE_TX for operator: {:?}",
Expand All @@ -109,11 +109,11 @@ impl Aggregator {
&utils::SECP,
*utils::UNSPENDABLE_XONLY_PUBKEY,
None,
self.config.network,
self.config.bitcoin.network,
)
.as_unchecked(),
&self.nofn_xonly_pk,
self.config.network,
self.config.bitcoin.network,
self.config.user_takes_after,
self.config.bridge_amount_sats,
);
Expand All @@ -127,9 +127,9 @@ impl Aggregator {
operator_xonly_pk,
operator_idx,
&self.nofn_xonly_pk,
self.config.network,
self.config.bitcoin.network,
self.config.user_takes_after,
self.config.operator_takes_after,
self.config.operator.takes_after,
self.config.bridge_amount_sats,
);
let slash_or_take_utxo = UTXO {
Expand All @@ -149,8 +149,8 @@ impl Aggregator {
slash_or_take_utxo,
operator_xonly_pk,
&self.nofn_xonly_pk,
self.config.network,
self.config.operator_takes_after,
self.config.bitcoin.network,
self.config.operator.takes_after,
self.config.bridge_amount_sats,
self.config.operator_wallet_addresses[operator_idx].clone(),
);
Expand All @@ -164,7 +164,7 @@ impl Aggregator {
let message: [u8; 32] =
Actor::convert_tx_to_sighash_pubkey_spend(&mut tx_handler, 0)?.to_byte_array();
let final_sig: [u8; 64] = aggregate_partial_signatures(
self.config.verifiers_public_keys.clone(),
self.config.verifier.public_keys.clone(),
None,
true,
agg_nonce,
Expand All @@ -189,7 +189,7 @@ impl Aggregator {
evm_address,
recovery_taproot_address,
&self.nofn_xonly_pk,
self.config.network,
self.config.bitcoin.network,
self.config.user_takes_after,
self.config.bridge_amount_sats,
);
Expand All @@ -198,7 +198,7 @@ impl Aggregator {
let message: [u8; 32] =
Actor::convert_tx_to_sighash_script_spend(&mut tx, 0, 0)?.to_byte_array();
let final_sig: [u8; 64] = aggregate_partial_signatures(
self.config.verifiers_public_keys.clone(),
self.config.verifier.public_keys.clone(),
None,
false,
agg_nonce,
Expand Down Expand Up @@ -255,7 +255,7 @@ impl Aggregator {
let agg_sig = self.aggregate_slash_or_take_partial_sigs(
deposit_outpoint,
kickoff_utxos[i].clone(),
self.config.operators_xonly_pks[i],
self.config.operator.xonly_pks[i],
i,
&agg_nonces[i].clone(),
partial_sigs,
Expand All @@ -279,7 +279,7 @@ impl Aggregator {
let agg_sig = self.aggregate_operator_takes_partial_sigs(
deposit_outpoint,
kickoff_utxos[i].clone(),
&self.config.operators_xonly_pks[i].clone(),
&self.config.operator.xonly_pks[i].clone(),
i,
&agg_nonces[i].clone(),
partial_sigs.iter().map(|v| v[i]).collect(),
Expand Down Expand Up @@ -314,7 +314,7 @@ impl Aggregator {
&evm_address,
&recovery_taproot_address,
&self.nofn_xonly_pk,
self.config.network,
self.config.bitcoin.network,
self.config.user_takes_after,
self.config.bridge_amount_sats,
);
Expand Down
2 changes: 1 addition & 1 deletion core/src/bin/all_servers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async fn main() {
.join(",")
);
let xonly =
secp256k1::XOnlyPublicKey::from_musig2_pks(config.verifiers_public_keys, None, false);
secp256k1::XOnlyPublicKey::from_musig2_pks(config.verifier.public_keys, None, false);
println!(
"AGGREGATOR_URL={}",
format!("http://127.0.0.1:{}", aggregator.2.port())
Expand Down
9 changes: 6 additions & 3 deletions core/src/bin/config_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,16 @@ fn main() {
for i in 0..num_verifiers {
let mut new_config = BridgeConfig {
secret_key: secret_keys[i],
verifiers_public_keys: public_keys.clone(),
num_verifiers,
verifier: clementine_core::config::Verifier {
public_keys: public_keys.clone(),
count: num_verifiers,
..cur_config.verifier.clone()
},
port: ports[i],
..cur_config.clone()
};
if i == num_verifiers - 1 {
new_config.verifier_endpoints = Some(
new_config.verifier.endpoints = Some(
ports[0..ports.len() - 1]
.iter()
.map(|p| format!("http://{}:{}", cur_config.host, p))
Expand Down
6 changes: 3 additions & 3 deletions core/src/bin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ async fn main() {
}

let rpc = ExtendedRpc::<bitcoincore_rpc::Client>::new(
config.bitcoin_rpc_url.clone(),
config.bitcoin_rpc_user.clone(),
config.bitcoin_rpc_password.clone(),
config.bitcoin.rpc_url.clone(),
config.bitcoin.rpc_user.clone(),
config.bitcoin.rpc_password.clone(),
);

let database = Database::new(config.clone()).await.unwrap();
Expand Down
Loading
Loading