Skip to content
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
858 changes: 592 additions & 266 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async-trait = "0.1.81"
suppaftp = { version = "6.0.1", features = ["async", "async-native-tls"] }
openssh-sftp-client = { version = "0.14.6", features = ["openssh"] }
openssh = { version = "0.10.4", features = ["native-mux"] }
alloy = { version = "0.2.1", features = ["full"] }
alloy = { version = "1.0.9", features = ["full"] }
clap = { version = "4.5.23", features = ["derive", "cargo", "env"] }
toml = "0.5.11"
colored = "2.0.0"
Expand Down
2 changes: 1 addition & 1 deletion bitvm/src/chunk/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,6 @@ mod test {
index_of_bitcommitted_msg.push(seg.id);
}
println!("script {i} bitcoms: {:?}", index_of_bitcommitted_msg);
};
}
}
}
12 changes: 9 additions & 3 deletions bridge/src/client/chain/ethereum_adaptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ use alloy::rpc::types::Log;
use super::{
chain::PegInEvent, chain::PegOutBurntEvent, chain::PegOutEvent, chain_adaptor::ChainAdaptor,
};
use alloy::network::Ethereum;
use alloy::providers::fillers::{FillProvider, JoinFill, RecommendedFillers};
use alloy::providers::Identity;
use alloy::sol_types::SolEvent;
use alloy::{
eips::BlockNumberOrTag,
primitives::Address as EvmAddress,
providers::{Provider, ProviderBuilder, RootProvider},
rpc::types::Filter,
sol,
transports::http::{reqwest::Url, Client, Http},
transports::http::reqwest::Url,
};
use async_trait::async_trait;
use bitcoin::hashes::Hash;
Expand Down Expand Up @@ -52,7 +55,10 @@ sol!(
pub struct EthereumAdaptor {
bridge_address: EvmAddress,
bridge_creation_block: u64,
provider: RootProvider<Http<Client>>,
provider: FillProvider<
JoinFill<Identity, <Ethereum as RecommendedFillers>::RecommendedFillers>,
RootProvider,
>,
to_block: Option<BlockNumberOrTag>,
}

Expand Down Expand Up @@ -236,7 +242,7 @@ impl EthereumAdaptor {
Self {
bridge_address: config.bridge_address,
bridge_creation_block: config.bridge_creation_block,
provider: ProviderBuilder::new().on_http(config.rpc_url),
provider: ProviderBuilder::new().connect_http(config.rpc_url),
to_block: config.to_block,
}
}
Expand Down
52 changes: 23 additions & 29 deletions goat/src/bin/goat-bridge/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,63 @@ use clap::Subcommand;

#[derive(Subcommand)]
pub(crate) enum Commands {
/// -GENERAL----: generate disprove scripts
GenerateDisproveScripts{
},
/// -GENERAL----: generate disprove scripts
GenerateDisproveScripts {},

/// -GENERAL----: generate all necessary bitvm2 transactions (unsigned)
GenerateBitvmInstanace {
},
GenerateBitvmInstanace {},

/// -DEPOSITOR--: generate pegin-prepare, pegin-comfirm & pegin-refund txns
GeneratePeginTx {
/// (sats) deposit amount of pegin tx
#[arg(long="amount")]
#[arg(long = "amount")]
deposit_amount: u64,

/// (sats) fee amount of pegin tx
#[arg(long="fee")]
#[arg(long = "fee")]
fee_amount: u64,

/// (Address) address to receive change
#[arg(long="change")]
#[arg(long = "change")]
change_address: String,

/// (array of strings) input utxos for pegin tx
/// format: "txid:vout:amount"
/// format: "txid:vout:amount"
/// example: "f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16:0:10000000000"
#[arg(long="inputs", num_args = 1.., value_delimiter = ',', required = true)]
tx_inputs: Vec<String>,
},

/// -FEDERATION-: push federation members' pre-signature for necessary txns, include: pegin_comfirm, take_1, take_2, assert_final, disprove
FederationPresign {
},
FederationPresign {},

/// -OPERATOR---: generate winternitz public-keys & secret-keys
/// -OPERATOR---: generate winternitz public-keys & secret-keys
/// (⚠ Warning: This feature is for testing and development purposes only. It may not be secure enough for production use.)
GenerateWotsKeys {
/// (String) a random seed used to generate wots keypairs
// #[arg(short = 's', long = "seed")]
secret_seed: String,
},
},

/// -OPERATOR---: generate winternitz signatures for groth16-proof & intermediate-values
/// -OPERATOR---: generate winternitz signatures for groth16-proof & intermediate-values
SignProof {
/// skip verifying the correctness of generated sigs
#[arg(long)]
skip_validation: bool,
},

/// -OPERATOR---: generate pre-kickoff(pegout-confirm) tx
GeneratePrekickoffTx { /// (sats) stake amount of pre-kickof tx
#[arg(long="amount")]
GeneratePrekickoffTx {
/// (sats) stake amount of pre-kickof tx
#[arg(long = "amount")]
stake_amount: u64,

/// (sats) fee amount of pre-kickof tx
#[arg(long="fee")]
#[arg(long = "fee")]
fee_amount: u64,

/// (Address) address to receive change
#[arg(long="change")]
#[arg(long = "change")]
change_address: String,

/// (array of formatted strings) input utxos for prekickoff tx
Expand All @@ -71,8 +69,7 @@ pub(crate) enum Commands {
},

/// -OPERATOR---: push operator's pre-signature necessary txns, include: challenge
OperatorPresign {
},
OperatorPresign {},

/// -OPERATOR---: operator sign txns: include: kickoff, take-1, assert, take-2
OperatorSign {
Expand All @@ -97,25 +94,22 @@ pub(crate) enum Commands {
take_2: bool,
},

/// -CHALLENGER-: check if the groth16-proof(bitcommitments) is valid
VerifyProof {
},
/// -CHALLENGER-: check if the groth16-proof(bitcommitments) is valid
VerifyProof {},

/// -CHALLENGER-: send disprove tx
Disprove {
/// address that will receive challenger success reward
reward_address: String,
},


/*
/*
/// -FEDERATION-: generate psbt for federation members
GenerateFederationPsbt {
/// (hex String) federation member's public-key
// #[arg(long)]
pubkey: String,
},

/// -OPERATOR---: generate psbt for operator
GenerateOperatorPsbt {
// #[arg(long)]
Expand All @@ -135,8 +129,8 @@ pub(crate) enum Commands {
ValidateKickoff {
},

/// -CHALLENGER-: check if the groth16-proof(bitcommitments) submitted by operator in assert-tx is valid
/// -CHALLENGER-: check if the groth16-proof(bitcommitments) submitted by operator in assert-tx is valid
ValidateAssert {
},
*/
}
}
33 changes: 15 additions & 18 deletions goat/src/bin/goat-bridge/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use serde::Deserialize;
use bitcoin::Network;
use serde::Deserialize;

pub const DEFAULT_WOTS_SECRET_FILE: &str = "data/private/wots_sec.json";
pub const DEFAULT_WOTS_PUBKEY_FILE: &str = "data/public/wots_pub.json";
Expand Down Expand Up @@ -30,31 +30,29 @@ pub const ASSERT_FINAL_FILE_NAME: &str = "assert-final.json";
pub const TAKE2_FILE_NAME: &str = "take-2.json";
pub const DISPROVE_FILE_NAME: &str = "disprove.json";


#[derive(Deserialize, Debug, Clone)]
pub struct Config {
#[serde(default)]
#[serde(default)]
pub general: GeneralConfig,
#[serde(default)]
#[serde(default)]
pub depositor: DepositorConfig,
#[serde(default)]
#[serde(default)]
pub operator: OperatorConfig,
#[serde(default)]
#[serde(default)]
pub federation: FederationConfig,
#[serde(default)]
#[serde(default)]
pub challenger: ChallengerConfig,
}

#[derive(Deserialize, Debug, Clone)]
pub struct GeneralConfig {
pub struct GeneralConfig {
#[serde(default = "default_network")]
pub network: String,

pub federation_pubkeys: Option<Vec<String>>,
pub federation_taproot_pubkey: Option<String>,
pub operator_pubkey: Option<String>,
// pub operator_taproot_pubkey: Option<String>,

#[serde(default = "default_txns_dir")]
pub txns_dir: String,
#[serde(default = "default_signed_txns_dir")]
Expand All @@ -79,29 +77,29 @@ pub struct GeneralConfig {
}

#[derive(Deserialize, Debug, Default, Clone)]
pub struct DepositorConfig {
pub struct DepositorConfig {
pub depositor_evm_address: Option<String>,
// pub depositor_taproot_public_key: Option<String>,
pub depositor_pubkey: Option<String>,
pub depositor_seckey: Option<String>,
pub depositor_seckey: Option<String>,
}

#[derive(Deserialize, Debug, Clone)]
pub struct OperatorConfig {
pub struct OperatorConfig {
#[serde(default = "default_operator_wots_secret_file")]
pub operator_wots_seckey_file: String,
pub operator_seckey: Option<String>,
pub operator_seckey: Option<String>,
}

#[derive(Deserialize, Debug, Default, Clone)]
pub struct FederationConfig {
pub federation_seckeys: Option<Vec<String>>,
pub struct FederationConfig {
pub federation_seckeys: Option<Vec<String>>,
}

#[derive(Deserialize, Debug, Clone)]
pub struct ChallengerConfig {
pub struct ChallengerConfig {
#[serde(default = "default_disprove_witness_file")]
pub disprove_witness_file: String,
pub disprove_witness_file: String,
}

pub fn load_config(file: &str) -> Config {
Expand Down Expand Up @@ -202,4 +200,3 @@ fn default_signed_assertions_file() -> String {
fn default_disprove_witness_file() -> String {
DFFAULT_DISPROVE_WITNESS_FILE.to_string()
}

Loading
Loading