Skip to content

Commit

Permalink
Merge branch 'main' into third_pary_repo
Browse files Browse the repository at this point in the history
  • Loading branch information
steelgeek091 authored Nov 27, 2024
2 parents 6a0c2ab + b70ff13 commit 45a4a72
Show file tree
Hide file tree
Showing 29 changed files with 393 additions and 246 deletions.
207 changes: 118 additions & 89 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ members = [
"moveos/smt",
"moveos/moveos-eventbus",
"moveos/moveos-gas-profiling",
"crates/bitcoin-client",
"crates/data_verify",
"crates/rooch",
"crates/rooch-benchmarks",
Expand Down Expand Up @@ -59,7 +60,7 @@ members = [
"frameworks/framework-types",
"frameworks/moveos-stdlib",
"frameworks/rooch-framework",
"frameworks/rooch-nursery",
"frameworks/rooch-nursery", "crates/bitcoin-client",
"third_party/move/language/move-compiler-v2"
]

Expand All @@ -85,7 +86,7 @@ license = "Apache-2.0"
publish = false
repository = "https://github.com/rooch-network/rooch"
rust-version = "1.82.0"
version = "0.8.0"
version = "0.8.1"

[workspace.dependencies]
# Internal crate dependencies.
Expand All @@ -109,6 +110,8 @@ accumulator = { path = "moveos/moveos-commons/accumulator" }
moveos-gas-profiling = { path = "moveos/moveos-gas-profiling" }

# crates for Rooch
bitcoin-client = { path = "crates/bitcoin-client" }
data-verify = { path = "crates/data_verify" }
rooch = { path = "crates/rooch" }
rooch-common = { path = "crates/rooch-common" }
rooch-key = { path = "crates/rooch-key" }
Expand Down Expand Up @@ -136,7 +139,6 @@ rooch-da = { path = "crates/rooch-da" }
rooch-benchmarks = { path = "crates/rooch-benchmarks" }
rooch-faucet = { path = "crates/rooch-faucet" }
rooch-test-transaction-builder = { path = "crates/rooch-test-transaction-builder" }
data-verify = { path = "crates/data_verify" }
rooch-db = { path = "crates/rooch-db" }
rooch-event = { path = "crates/rooch-event" }
rooch-ord = { path = "crates/rooch-ord" }
Expand Down Expand Up @@ -267,6 +269,7 @@ tower_governor = { version = "0.4.3", features = ["tracing"] }
pin-project = "1.1.7"
mirai-annotations = "1.12.0"
lru = "0.11.0"
quick_cache = "0.6.9"
bs58 = "0.5.1"
dirs-next = "2.0.0"
anstream = { version = "0.3" }
Expand Down Expand Up @@ -351,7 +354,7 @@ function_name = { version = "0.3.0" }
rustc-hash = { version = "2.0.0" }
xorf = { version = "0.11.0" }
vergen-git2 = { version = "1.0.0", features = ["build", "cargo", "rustc"] }
vergen-pretty = "0.3.5"
vergen-pretty = "0.3.6"
crossbeam-channel = "0.5.13"
inferno = "0.11.21"
handlebars = "4.2.2"
Expand Down
21 changes: 21 additions & 0 deletions crates/bitcoin-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "bitcoin-client"
authors.workspace = true
edition.workspace = true
homepage.workspace = true
license.workspace = true
publish.workspace = true
repository.workspace = true
rust-version.workspace = true
version.workspace = true

[dependencies]
anyhow = { workspace = true }
async-trait = { workspace = true }
bitcoin = { workspace = true }
bitcoincore-rpc = { workspace = true }
coerce = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
tokio = { features = ["full"], workspace = true }
tracing = { workspace = true }
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use super::messages::{GetChainTipsMessage, GetRawTransactionMessage, GetTxOutMessage};
use crate::actor::messages::{
BroadcastTransactionMessage, GetBestBlockHashMessage, GetBlockHashMessage,
GetBlockHeaderInfoMessage, GetBlockMessage,
GetBlockHeaderInfoMessage, GetBlockMessage, GetChainTipsMessage, GetRawTransactionMessage,
GetTxOutMessage,
};
use anyhow::Result;
use async_trait::async_trait;
Expand All @@ -20,6 +20,22 @@ pub struct BitcoinClientActor {
retry_delay: Duration,
}

pub struct BitcoinClientConfig {
pub btc_rpc_url: String,
pub btc_rpc_user_name: String,
pub btc_rpc_password: String,
}

impl BitcoinClientConfig {
pub fn build(&self) -> Result<BitcoinClientActor> {
BitcoinClientActor::new(
&self.btc_rpc_url,
&self.btc_rpc_user_name,
&self.btc_rpc_password,
)
}
}

impl BitcoinClientActor {
pub fn new(btc_rpc_url: &str, btc_rpc_user_name: &str, btc_rpc_password: &str) -> Result<Self> {
let rpc_client = Client::new(
Expand Down
91 changes: 91 additions & 0 deletions crates/bitcoin-client/src/actor/messages.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use anyhow::Result;
use bitcoin::Transaction;
use bitcoincore_rpc::bitcoin::Txid;
use bitcoincore_rpc::json;
use coerce::actor::message::Message;
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize)]
pub struct GetBlockMessage {
pub hash: bitcoin::BlockHash,
}

impl Message for GetBlockMessage {
type Result = Result<bitcoin::Block>;
}

#[derive(Debug, Serialize, Deserialize)]
pub struct GetBestBlockHashMessage {}

impl Message for GetBestBlockHashMessage {
type Result = Result<bitcoin::BlockHash>;
}

#[derive(Debug, Serialize, Deserialize)]
pub struct GetBlockHashMessage {
pub height: u64,
}

impl Message for GetBlockHashMessage {
type Result = Result<bitcoin::BlockHash>;
}

#[derive(Debug, Serialize, Deserialize)]
pub struct GetBlockHeaderInfoMessage {
pub hash: bitcoin::BlockHash,
}

impl Message for GetBlockHeaderInfoMessage {
type Result = Result<json::GetBlockHeaderResult>;
}

#[derive(Debug, Serialize, Deserialize)]
pub struct GetChainTipsMessage {}

impl Message for GetChainTipsMessage {
type Result = Result<json::GetChainTipsResult>;
}

#[derive(Debug, Serialize, Deserialize)]
pub struct BroadcastTransactionMessage {
pub hex: String,
pub maxfeerate: Option<f64>,
pub maxburnamount: Option<f64>,
}

impl Message for BroadcastTransactionMessage {
type Result = Result<Txid>;
}

#[derive(Debug, Serialize, Deserialize)]
pub struct GetTxOutMessage {
pub txid: Txid,
pub vout: u32,
pub include_mempool: Option<bool>,
}

impl GetTxOutMessage {
pub fn new(txid: Txid, vout: u32) -> Self {
Self {
txid,
vout,
include_mempool: Some(false),
}
}
}

impl Message for GetTxOutMessage {
type Result = Result<Option<json::GetTxOutResult>>;
}

#[derive(Debug, Serialize, Deserialize)]
pub struct GetRawTransactionMessage {
pub txid: Txid,
}

impl Message for GetRawTransactionMessage {
type Result = Result<Transaction>;
}
5 changes: 5 additions & 0 deletions crates/bitcoin-client/src/actor/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

pub mod client;
pub mod messages;
5 changes: 5 additions & 0 deletions crates/bitcoin-client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

pub mod actor;
pub mod proxy;
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use crate::actor::bitcoin_client::BitcoinClientActor;
use crate::actor::client::BitcoinClientActor;
use crate::actor::messages::{
BroadcastTransactionMessage, GetBestBlockHashMessage, GetBlockHashMessage,
GetBlockHeaderInfoMessage, GetBlockMessage,
GetBlockHeaderInfoMessage, GetBlockMessage, GetChainTipsMessage, GetRawTransactionMessage,
GetTxOutMessage,
};
use anyhow::Result;
use bitcoin::Transaction;
use bitcoincore_rpc::bitcoin::Txid;
use bitcoincore_rpc::json;
use coerce::actor::ActorRef;

use super::messages::{GetChainTipsMessage, GetRawTransactionMessage, GetTxOutMessage};

#[derive(Clone)]
pub struct BitcoinClientProxy {
pub actor: ActorRef<BitcoinClientActor>,
Expand Down
2 changes: 1 addition & 1 deletion crates/rooch-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ repository = { workspace = true }
rust-version = { workspace = true }

[dependencies]
libc = { workspace = true }
libc = { workspace = true }
2 changes: 1 addition & 1 deletion crates/rooch-framework-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ moveos-store = { workspace = true }
moveos-config = { workspace = true }
metrics = { workspace = true }

bitcoin-client = { workspace = true }
rooch-genesis = { workspace = true }
rooch-types = { workspace = true }
rooch-key = { workspace = true }
rooch-executor = { workspace = true }
rooch-config = { workspace = true }
rooch-db = { workspace = true }
rooch-relayer = { workspace = true }
rooch-ord = { workspace = true }

framework-builder = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/rooch-framework-tests/src/bitcoin_block_tester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use crate::{bbn_tx_loader::BBNStakingTxRecord, binding_test::RustBindingTest};
use anyhow::{anyhow, bail, ensure, Result};
use bitcoin::{hashes::Hash, Block, OutPoint, TxOut, Txid};
use bitcoin_client::proxy::BitcoinClientProxy;
use framework_builder::stdlib_version::StdlibVersion;
use move_core_types::{account_address::AccountAddress, u256::U256, vm_status::KeptVMStatus};
use moveos_types::{
Expand All @@ -16,7 +17,6 @@ use moveos_types::{
state_resolver::StateResolver,
};
use rooch_ord::ord_client::Charm;
use rooch_relayer::actor::bitcoin_client_proxy::BitcoinClientProxy;
use rooch_types::{
bitcoin::{
bbn::{
Expand Down
5 changes: 2 additions & 3 deletions crates/rooch-framework-tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
use std::path::PathBuf;

use anyhow::Result;
use bitcoin_client::actor::client::BitcoinClientActor;
use bitcoin_client::proxy::BitcoinClientProxy;
use clap::Parser;
use coerce::actor::{system::ActorSystem, IntoActor};
use rooch_framework_tests::bitcoin_block_tester::TesterGenesisBuilder;
use rooch_relayer::actor::{
bitcoin_client::BitcoinClientActor, bitcoin_client_proxy::BitcoinClientProxy,
};

#[derive(Parser)]
#[clap(name = "test_builder", author = "The Rooch Core Contributors")]
Expand Down
2 changes: 1 addition & 1 deletion crates/rooch-open-rpc-spec/schemas/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"name": "Apache-2.0",
"url": "https://raw.githubusercontent.com/rooch-network/rooch/main/LICENSE"
},
"version": "0.8.0"
"version": "0.8.1"
},
"methods": [
{
Expand Down
10 changes: 6 additions & 4 deletions crates/rooch-pipeline-processor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ rust-version = { workspace = true }
anyhow = { workspace = true }
async-trait = { workspace = true }
bcs = { workspace = true }
bitcoin = { workspace = true }
coerce = { workspace = true }
function_name = { workspace = true }
hex = { workspace = true }
Expand All @@ -25,10 +26,11 @@ moveos = { workspace = true }
metrics = { workspace = true }
moveos-types = { workspace = true }

bitcoin-client = { workspace = true }
rooch-da = { workspace = true }
rooch-types = { workspace = true }
rooch-sequencer = { workspace = true }
rooch-db = { workspace = true }
rooch-executor = { workspace = true }
rooch-indexer = { workspace = true }
rooch-event = { workspace = true }
rooch-db = { workspace = true }
rooch-indexer = { workspace = true }
rooch-sequencer = { workspace = true }
rooch-types = { workspace = true }
Loading

0 comments on commit 45a4a72

Please sign in to comment.