Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Cargo Build & Test

on:
push:
branches:
- main
pull_request:
branches:
- main

env:
CARGO_TERM_COLOR: always

jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- run: rustup component add clippy
- run: cargo clippy --all-targets -- -D warnings
test:
name: Cargo Test
runs-on: ubuntu-latest
environment:
GATE_CHAIN_ADAPTOR_GOAT_RPC_URL=https://rpc.testnet3.goat.network
GATEWAY_CHAIN_ADAPTOR_GOAT_GATE_ADDRESS=0xeD8AeeD334fA446FA03Aa00B28aFf02FA8aC02df
GATE_CHAIN_ADAPTOR_GOAT_GATE_CREATION=0
GATE_CHAIN_ADAPTOR_GOAT_CHAIN_ID=48816
strategy:
matrix:
toolchain:
- nightly
steps:
- uses: actions/checkout@v2
- run: cargo test -r
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ members = [
"crates/store", "crates/identity", "node", "crates/spv", "crates/client",
]

default-members = ["node"]

[workspace.dependencies]
bitvm = { git = "https://github.com/GOATNetwork/BitVM.git", branch = "goat-test" }
goat = { git = "https://github.com/GOATNetwork/BitVM.git", branch = "goat-test" }
Expand Down
14 changes: 0 additions & 14 deletions crates/bitvm2/src/challenger/mod.rs

This file was deleted.

6 changes: 3 additions & 3 deletions crates/bitvm2/src/committee/api.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::types::Bitvm2Graph;
use anyhow::{bail, Result};
use anyhow::{Result, bail};
use bitcoin::PublicKey;
use bitcoin::{hex::FromHex, key::Keypair, TapSighashType, Witness};
use bitcoin::{TapSighashType, Witness, hex::FromHex, key::Keypair};
use goat::connectors::{connector_0::Connector0, connector_5::Connector5, connector_d::ConnectorD};
use goat::contexts::base::generate_n_of_n_public_key;
use goat::transactions::signing_musig2::{
Expand All @@ -11,7 +11,7 @@ use goat::transactions::{
base::BaseTransaction, pre_signed::PreSignedTransaction, pre_signed_musig2::get_nonce_message,
signing_musig2::generate_taproot_partial_signature,
};
use musig2::{secp256k1::schnorr::Signature, AggNonce, PartialSignature, PubNonce, SecNonce};
use musig2::{AggNonce, PartialSignature, PubNonce, SecNonce, secp256k1::schnorr::Signature};
use sha2::{Digest, Sha256};

pub const COMMITTEE_PRE_SIGN_NUM: usize = 5;
Expand Down
6 changes: 3 additions & 3 deletions crates/bitvm2/src/committee/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod api;

pub use api::{
committee_pre_sign, generate_keypair_from_seed, generate_nonce_from_seed, key_aggregation,
nonce_aggregation, nonces_aggregation, push_committee_pre_signatures,
signature_aggregation_and_push, COMMITTEE_PRE_SIGN_NUM,
COMMITTEE_PRE_SIGN_NUM, committee_pre_sign, generate_keypair_from_seed,
generate_nonce_from_seed, key_aggregation, nonce_aggregation, nonces_aggregation,
push_committee_pre_signatures, signature_aggregation_and_push,
};
4 changes: 2 additions & 2 deletions crates/bitvm2/src/keys.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use super::{
committee::{generate_keypair_from_seed, generate_nonce_from_seed, COMMITTEE_PRE_SIGN_NUM},
committee::{COMMITTEE_PRE_SIGN_NUM, generate_keypair_from_seed, generate_nonce_from_seed},
operator::generate_wots_keys,
types::{WotsPublicKeys, WotsSecretKeys},
};
use bitcoin::key::Keypair;
use musig2::{secp256k1::schnorr::Signature, PubNonce, SecNonce};
use musig2::{PubNonce, SecNonce, secp256k1::schnorr::Signature};
use sha2::{Digest, Sha256};
use uuid::Uuid;

Expand Down
1 change: 0 additions & 1 deletion crates/bitvm2/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub mod challenger;
pub mod committee;
pub mod operator;
pub mod verifier;
Expand Down
22 changes: 11 additions & 11 deletions crates/bitvm2/src/operator/api.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use crate::types::{
get_magic_bytes, Bitvm2Graph, Bitvm2Parameters, CustomInputs, Groth16Proof,
Groth16WotsPublicKeys, Groth16WotsSignatures, PublicInputs, VerifyingKey, WotsPublicKeys,
WotsSecretKeys,
Bitvm2Graph, Bitvm2Parameters, CustomInputs, Groth16Proof, Groth16WotsPublicKeys,
Groth16WotsSignatures, PublicInputs, VerifyingKey, WotsPublicKeys, WotsSecretKeys,
get_magic_bytes,
};
use anyhow::{bail, Result};
use anyhow::{Result, bail};
use bitcoin::Transaction;
use bitcoin::{key::Keypair, Amount, OutPoint, Witness, XOnlyPublicKey};
use bitcoin::{Amount, OutPoint, Witness, XOnlyPublicKey, key::Keypair};
use bitvm::chunk::api::{
api_generate_full_tapscripts, api_generate_partial_script, generate_signatures_lit,
type_conversion_utils::utils_raw_witnesses_from_signatures, NUM_HASH, NUM_PUBS, NUM_U256,
NUM_HASH, NUM_PUBS, NUM_U256, api_generate_full_tapscripts, api_generate_partial_script,
generate_signatures_lit, type_conversion_utils::utils_raw_witnesses_from_signatures,
};
use bitvm::signatures::{
signing_winternitz::{WinternitzPublicKey, WinternitzSecret, WinternitzSigningInputs, LOG_D},
signing_winternitz::{LOG_D, WinternitzPublicKey, WinternitzSecret, WinternitzSigningInputs},
winternitz::Parameters,
wots_api::{wots256, wots_hash},
wots_api::{wots_hash, wots256},
};
use bitvm::treepp::*;
use goat::commitments::{CommitmentMessageId, KICKOFF_MSG_SIZE, NUM_KICKOFF};
Expand All @@ -28,8 +28,8 @@ use goat::transactions::{
assert::assert_final::AssertFinalTransaction,
assert::assert_initial::AssertInitialTransaction,
assert::utils::{
convert_to_connector_c_commits_public_key, AllCommitConnectorsE, AssertCommitConnectorsF,
COMMIT_TX_NUM,
AllCommitConnectorsE, AssertCommitConnectorsF, COMMIT_TX_NUM,
convert_to_connector_c_commits_public_key,
},
base::Input,
challenge::ChallengeTransaction,
Expand Down
2 changes: 1 addition & 1 deletion crates/bitvm2/src/pegin.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bitcoin::opcodes::all::OP_RETURN;
use bitcoin::script::Instruction;
use bitcoin::{script, Network, Script};
use bitcoin::{Network, Script, script};

use crate::types::get_magic_bytes;

Expand Down
22 changes: 11 additions & 11 deletions crates/bitvm2/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bitcoin::TapNodeHash;
use bitcoin::{key::Keypair, Address, Amount, Network, PrivateKey, PublicKey, XOnlyPublicKey};
use bitcoin::{Address, Amount, Network, PrivateKey, PublicKey, XOnlyPublicKey, key::Keypair};
use bitvm::chunk::api::{
PublicKeys as ApiWotsPublicKeys, Signatures as ApiWotsSignatures, NUM_HASH, NUM_PUBS, NUM_U256,
NUM_HASH, NUM_PUBS, NUM_U256, PublicKeys as ApiWotsPublicKeys, Signatures as ApiWotsSignatures,
};
use bitvm::signatures::signing_winternitz::{WinternitzPublicKey, WinternitzSecret};
use goat::commitments::NUM_KICKOFF;
Expand All @@ -15,7 +15,7 @@ use goat::transactions::{
kick_off::KickOffTransaction, peg_in::peg_in::PegInTransaction,
peg_out_confirm::PreKickoffTransaction, take_1::Take1Transaction, take_2::Take2Transaction,
};
use rand::{distributions::Alphanumeric, Rng};
use rand::{Rng, distributions::Alphanumeric};
use secp256k1::SECP256K1;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -172,7 +172,7 @@ pub fn get_magic_bytes(net: &Network) -> Vec<u8> {
}

pub mod node_serializer {
use serde::{self, ser::Error, Deserialize, Deserializer, Serializer};
use serde::{self, Deserialize, Deserializer, Serializer, ser::Error};
use std::str::FromStr;

pub mod address {
Expand Down Expand Up @@ -203,7 +203,7 @@ pub mod node_serializer {
use crate::types::WotsPublicKeys;
use bitvm::chunk::api::{NUM_HASH, NUM_PUBS, NUM_U256};
use bitvm::signatures::signing_winternitz::WinternitzPublicKey;
use bitvm::signatures::wots_api::{wots256, wots_hash};
use bitvm::signatures::wots_api::{wots_hash, wots256};
use goat::commitments::NUM_KICKOFF;
use std::collections::HashMap;

Expand All @@ -214,17 +214,17 @@ pub mod node_serializer {
let mut pubkeys_map: HashMap<u32, Vec<Vec<u8>>> = HashMap::new();
let mut index = 0;
// wots pk for groth16 proof
for pk in pubkeys.1 .0 {
for pk in pubkeys.1.0 {
let v: Vec<Vec<u8>> = pk.iter().map(|x| x.to_vec()).collect();
pubkeys_map.insert(index, v);
index += 1;
}
for pk in pubkeys.1 .1 {
for pk in pubkeys.1.1 {
let v: Vec<Vec<u8>> = pk.iter().map(|x| x.to_vec()).collect();
pubkeys_map.insert(index, v);
index += 1;
}
for pk in pubkeys.1 .2 {
for pk in pubkeys.1.2 {
let v: Vec<Vec<u8>> = pk.iter().map(|x| x.to_vec()).collect();
pubkeys_map.insert(index, v);
index += 1;
Expand Down Expand Up @@ -359,11 +359,11 @@ pub mod node_serializer {
pub mod wots_seckeys {
use serde::de::{SeqAccess, Visitor};
use serde::ser::SerializeTuple;
use serde::{de::Error as DeError, ser::Error, Deserializer, Serializer};
use serde::{Deserializer, Serializer, de::Error as DeError, ser::Error};
use std::fmt;

use crate::types::{
Groth16WotsSecretKeys, KickoffWotsSecretKeys, WotsSecretKeys, NUM_KICKOFF, NUM_SIGS,
Groth16WotsSecretKeys, KickoffWotsSecretKeys, NUM_KICKOFF, NUM_SIGS, WotsSecretKeys,
};

pub fn serialize<S>(keys: &WotsSecretKeys, serializer: S) -> Result<S::Ok, S::Error>
Expand Down Expand Up @@ -445,7 +445,7 @@ pub mod node_serializer {
#[cfg(test)]
mod tests {
use crate::operator::generate_wots_keys;
use crate::types::{node_serializer, WotsPublicKeys, WotsSecretKeys};
use crate::types::{WotsPublicKeys, WotsSecretKeys, node_serializer};
use serde::{Deserialize, Serialize};
use std::fmt::Debug;

Expand Down
9 changes: 5 additions & 4 deletions crates/bitvm2/src/verifier/api.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use crate::types::{
Bitvm2Graph, Groth16WotsPublicKeys, Groth16WotsSignatures, VerifyingKey, WotsPublicKeys,
};
use anyhow::{bail, Result};
use anyhow::{Result, bail};
use bitcoin::{Address, Amount, Transaction};
use bitvm::chunk::api::{
type_conversion_utils::{script_to_witness, utils_signatures_from_raw_witnesses, RawWitness},
validate_assertions, NUM_TAPS,
NUM_TAPS,
type_conversion_utils::{RawWitness, script_to_witness, utils_signatures_from_raw_witnesses},
validate_assertions,
};
use bitvm::treepp::*;
use goat::connectors::connector_c::{get_commit_from_assert_commit_tx, ConnectorC};
use goat::connectors::connector_c::{ConnectorC, get_commit_from_assert_commit_tx};
use goat::transactions::assert::utils::*;
use goat::transactions::{base::BaseTransaction, pre_signed::PreSignedTransaction};

Expand Down
10 changes: 5 additions & 5 deletions crates/client/src/chain/goat_adaptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ use alloy::primitives::TxHash;
use alloy::{
eips::BlockNumberOrTag,
network::{
eip2718::Encodable2718, Ethereum, EthereumWallet, NetworkWallet, TransactionBuilder,
TxSigner, TxSignerSync,
Ethereum, EthereumWallet, NetworkWallet, TransactionBuilder, TxSigner, TxSignerSync,
eip2718::Encodable2718,
},
primitives::{Address as EvmAddress, Bytes, ChainId, FixedBytes, U256},
providers::{Provider, ProviderBuilder, RootProvider},
rpc::types::TransactionRequest,
signers::{local::PrivateKeySigner, Signer},
signers::{Signer, local::PrivateKeySigner},
sol,
sol_types::SolEvent,
transports::http::{reqwest::Url, Client, Http},
transports::http::{Client, Http, reqwest::Url},
};
use anyhow::format_err;
use async_trait::async_trait;
Expand Down Expand Up @@ -287,7 +287,7 @@ impl ChainAdaptor for GoatAdaptor {
.await?;
Ok(WithdrawData {
pegin_txid: res._0.0,
operator_address: res._1.0 .0,
operator_address: res._1.0.0,
status: res._2.into(),
instance_id: Uuid::from_slice(res._3.as_slice())?,
lock_amount: res._4,
Expand Down
2 changes: 1 addition & 1 deletion crates/client/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::chain::chain::Chain;
use crate::chain::chain_adaptor::{
get_chain_adaptor, ChainAdaptor, GoatNetwork, OperatorData, PeginData, WithdrawData,
ChainAdaptor, GoatNetwork, OperatorData, PeginData, WithdrawData, get_chain_adaptor,
};
use crate::chain::goat_adaptor::GoatInitConfig;
use crate::esplora::get_esplora_url;
Expand Down
4 changes: 2 additions & 2 deletions crates/identity/src/musig2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ use std::{
use tokio::sync::mpsc::{self, Receiver, Sender};

use libp2p::{
core::{multiaddr::Protocol, Multiaddr},
core::{Multiaddr, multiaddr::Protocol},
identify, identity, noise,
swarm::{NetworkBehaviour, SwarmEvent},
tcp, yamux,
};
use musig2::KeyAggContext;
use musig2::k256::PublicKey;
use musig2::secp::Scalar;
use musig2::KeyAggContext;
use musig2::{
AggNonce, CompactSignature, FirstRound, PartialSignature, PubNonce, SecNonce, SecNonceSpices,
SecondRound,
Expand Down
2 changes: 1 addition & 1 deletion crates/spv/src/header_chain.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bitcoin::{
BlockHash, CompactTarget, TxMerkleNode,
block::{Header, Version},
hashes::Hash,
BlockHash, CompactTarget, TxMerkleNode,
};
use borsh::{BorshDeserialize, BorshSerialize};
use serde::{Deserialize, Serialize};
Expand Down
2 changes: 1 addition & 1 deletion crates/spv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ mod tests {
];
#[test]
fn test_spv() {
let mut mmr_native = MMRNative::new();
let mut mmr_native = MMRHost::new();
let mut mmr_guest = MMRGuest::new();
let block_headers = MAINNET_BLOCK_HEADERS
.iter()
Expand Down
2 changes: 1 addition & 1 deletion crates/spv/src/merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ pub fn verify_merkle_proof(
mod tests {

use crate::transaction::CircuitTransaction;
use bitcoin::Block;
use bitcoin::hashes::Hash;
use bitcoin::hex::FromHex;
use bitcoin::Block;

use super::*;

Expand Down
4 changes: 2 additions & 2 deletions crates/store/src/ipfs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::{bail, Result};
use anyhow::{Result, bail};
use futures::TryStreamExt;
use reqwest::multipart::{Form, Part};
use reqwest::Client;
use reqwest::multipart::{Form, Part};
use serde::Deserialize;
use std::path::Path;
use tokio::fs::File;
Expand Down
6 changes: 3 additions & 3 deletions crates/store/src/localdb.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use crate::schema::NODE_STATUS_OFFLINE;
use crate::schema::NODE_STATUS_ONLINE;
use crate::{
GrapRpcQueryData, Graph, Instance, Message, Node, NodesOverview, NonceCollect,
NonceCollectMetaData, PubKeyCollect, PubKeyCollectMetaData, COMMITTEE_PRE_SIGN_NUM,
COMMITTEE_PRE_SIGN_NUM, GrapRpcQueryData, Graph, Instance, Message, Node, NodesOverview,
NonceCollect, NonceCollectMetaData, PubKeyCollect, PubKeyCollectMetaData,
};
use futures::future::ok;
use sqlx::migrate::Migrator;
use sqlx::pool::PoolConnection;
use sqlx::types::Uuid;
use sqlx::{migrate::MigrateDatabase, Row, Sqlite, SqliteConnection, SqlitePool, Transaction};
use sqlx::{Row, Sqlite, SqliteConnection, SqlitePool, Transaction, migrate::MigrateDatabase};
use std::time::{SystemTime, UNIX_EPOCH};

#[derive(Clone)]
Expand Down
Loading
Loading