Skip to content
This repository has been archived by the owner on Dec 9, 2023. It is now read-only.

Bring latest v0.8 changes to the master #230

Merged
merged 12 commits into from
Dec 27, 2022
673 changes: 414 additions & 259 deletions Cargo.lock

Large diffs are not rendered by default.

28 changes: 16 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ members = [".", "rpc", "cli"]
[package]
name = "rgb_node"
description = "RGB node"
version = "0.8.0"
version = "0.8.4"
authors = ["Dr. Maxim Orlovsky <orlovsky@lnp-bp.org>"]
license = "MIT"
keywords = ["bitcoin", "node", "layer-2", "smart-contracts", "rgb"]
Expand All @@ -30,17 +30,17 @@ required-features = ["server"]
[dependencies]
# LNP/BP crates
amplify = "3.13.0"
strict_encoding = "~0.8.1"
strict_encoding = "~0.8.2"
stens = "0.7.1"
commit_verify = "0.8.0"
commit_verify = "~0.8.3"
internet2 = { version = "0.8.3", features = ["keygen", "zmq"] }
microservices = { version = "0.8.10", default-features = false, features = ["node"] }
lnpbp = "0.8.0"
bp-core = { version = "0.8.0", features = ["psbt"] }
lnp-core = { version = "0.8.0", features = ["bifrost"] }
bp-core = { version = "0.8.1", features = ["psbt"] }
lnp-core = { version = "0.8.2", features = ["bifrost"] }
lnp_rpc = "0.8.0"
rgb-std = "0.8.0"
rgb_rpc = { version = "0.8.0", path = "./rpc" }
rgb-std = "0.8.2"
rgb_rpc = { version = "0.8.4", path = "./rpc" }
storm-core = "0.8.0"
storm_ext = "0.8.0"
storm_rpc = "0.8.0"
Expand All @@ -53,7 +53,7 @@ chrono = "0.4"
nix = "0.24"
log = { version = "0.4", features = ["max_level_trace", "release_max_level_debug"] }
env_logger = "0.7"
clap = { version = "~3.1.18", optional = true, features = ["env", "derive"] }
clap = { version = "~3.2.23", optional = true, features = ["env", "derive"] }
settings = { version = "0.10", package = "config", optional = true }
configure_me = { version = "0.4", optional = true }
dotenv = { version = "0.15", optional = true }
Expand All @@ -66,12 +66,12 @@ internet2 = "0.8.0"
microservices = { version = "0.8.0", default-features = false }
lnpbp = "0.8.0"
psbt = "0.8.0"
rgb-std = "0.8.0"
rgb_rpc = { version = "0.8.0", path = "./rpc" }
rgb-std = "0.8.2"
rgb_rpc = { version = "0.8.4", path = "./rpc" }
storm_ext = "0.8.0"
store_rpc = "0.8.0"
clap = { version = "~3.1.18", features = ["env"] }
clap_complete = "~3.1.4"
clap = { version = "~3.2.23", features = ["env"] }
clap_complete = "~3.2.5"
log = { version = "0.4", features = ["max_level_trace", "release_max_level_debug"] }
shellexpand = "2.1"
configure_me_codegen = "0.4"
Expand All @@ -90,3 +90,7 @@ embedded = ["microservices/embedded"]

[package.metadata.configure_me]
spec = "config_spec.toml"

[package.metadata.docs.rs]
all-features = true
rustc-args = ["--cfg", "docsrs"]
20 changes: 11 additions & 9 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// You should have received a copy of the MIT License along with this software.
// If not, see <https://opensource.org/licenses/MIT>.

use std::env;
use std::fs;

use clap::IntoApp;
Expand All @@ -29,16 +30,17 @@ pub mod bucketd {
}

fn main() -> Result<(), configure_me_codegen::Error> {
let outdir = "./shell";

fs::create_dir_all(outdir).expect("failed to create shell dir");
for app in [rgbd::Opts::command(), bucketd::Opts::command()].iter_mut() {
let name = app.get_name().to_string();
generate_to(Bash, app, &name, &outdir)?;
generate_to(PowerShell, app, &name, &outdir)?;
generate_to(Zsh, app, &name, &outdir)?;
if env::var("DOCS_RS").is_err() {
let outdir = "./shell";
fs::create_dir_all(outdir).expect("failed to create shell dir");
for app in [rgbd::Opts::command(), bucketd::Opts::command()].iter_mut() {
let name = app.get_name().to_string();
generate_to(Bash, app, &name, &outdir)?;
generate_to(PowerShell, app, &name, &outdir)?;
generate_to(Zsh, app, &name, &outdir)?;
}
// configure_me_codegen::build_script_auto()
}

// configure_me_codegen::build_script_auto()
Ok(())
}
26 changes: 15 additions & 11 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rgb-cli"
description = "RGB node command-line interface"
version = "0.8.0"
version = "0.8.4"
authors = ["Dr. Maxim Orlovsky <orlovsky@lnp-bp.org>"]
license = "MIT"
keywords = ["bitcoin", "node", "layer-2", "smart-contracts", "rgb"]
Expand All @@ -17,30 +17,34 @@ name = "rgb-cli"

[dependencies]
amplify = "3.13.0"
strict_encoding = "~0.8.0"
strict_encoding = "~0.8.2"
internet2 = "0.8.3"
microservices = { version = "0.8.10", default-features = false, features = ["cli"] }
bitcoin = "0.28.1"
psbt = "0.8.0"
lnpbp = "0.8.0"
rgb-std = { version = "0.8.0", features = ["serde"] }
rgb_rpc = { version = "0.8.0", path = "../rpc" }
clap = { version = "~3.1.18", features = ["derive", "env"] }
rgb-std = { version = "0.8.2", features = ["serde"] }
rgb_rpc = { version = "0.8.4", path = "../rpc" }
clap = { version = "~3.2.23", features = ["derive", "env"] }
serde = "1"
serde_json = "1"
serde_yaml = "0.8"
serde_yaml = "0.9"
log = "0.4.14"
shellexpand = "2.1"
colored = "2"

[build-dependencies]
amplify = "3.12.1"
strict_encoding = "~0.8.0"
strict_encoding = "~0.8.2"
bitcoin = "0.28.1"
lnpbp = "0.8.0"
clap = { version = "~3.1.18", features = ["derive", "env"] }
clap_complete = "~3.1.4"
clap = { version = "~3.2.23", features = ["derive", "env"] }
clap_complete = "~3.2.5"
internet2 = "0.8.0"
rgb-std = "0.8.0"
rgb_rpc = { version = "0.8.0", path = "../rpc" }
rgb-std = "0.8.1"
rgb_rpc = { version = "0.8.2", path = "../rpc" }
configure_me_codegen = "0.4"

[package.metadata.docs.rs]
all-features = true
rustc-args = ["--cfg", "docsrs"]
20 changes: 10 additions & 10 deletions cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extern crate clap;
#[macro_use]
extern crate amplify;

use std::fs;
use std::{env, fs};

use clap::IntoApp;
use clap_complete::generate_to;
Expand All @@ -24,16 +24,16 @@ pub mod cli {
}

fn main() -> Result<(), configure_me_codegen::Error> {
let outdir = "../shell";

fs::create_dir_all(outdir).expect("failed to create shell dir");
for app in [cli::Opts::command()].iter_mut() {
let name = app.get_name().to_string();
generate_to(Bash, app, &name, &outdir)?;
generate_to(PowerShell, app, &name, &outdir)?;
generate_to(Zsh, app, &name, &outdir)?;
if env::var("DOCS_RS").is_err() {
let outdir = "../shell";
fs::create_dir_all(outdir).expect("failed to create shell dir");
for app in [cli::Opts::command()].iter_mut() {
let name = app.get_name().to_string();
generate_to(Bash, app, &name, &outdir)?;
generate_to(PowerShell, app, &name, &outdir)?;
generate_to(Zsh, app, &name, &outdir)?;
}
}

// configure_me_codegen::build_script_auto()
Ok(())
}
18 changes: 11 additions & 7 deletions rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rgb_rpc"
description = "RGB node RPC API"
version = "0.8.0"
version = "0.8.4"
authors = ["Dr. Maxim Orlovsky <orlovsky@lnp-bp.org>"]
license = "MIT"
keywords = ["bitcoin", "node", "layer-2", "smart-contracts", "rgb"]
Expand All @@ -15,18 +15,18 @@ name = "rgb_rpc"

[dependencies]
amplify = "3.13.0"
strict_encoding = "~0.8.1"
rgb-std = "0.8.0"
strict_encoding = "~0.8.2"
rgb-std = "0.8.2"
storm-core = "0.8.0"
lnpbp = "0.8.0"
bitcoin = "0.28.1"
psbt = "0.8.4"
internet2 = "0.8.3"
bp-core = { version = "0.8.0", features = ["psbt"] }
psbt = "0.8.5"
internet2 = "0.8.4"
bp-core = { version = "0.8.1", features = ["psbt"] }
microservices = { version = "0.8.10", default-features = false, features = ["client"] }
serde_crate = { package = "serde", version = "1", features = ["derive"], optional = true }
serde_with = { version = "1.8", optional = true }
serde_yaml = { version = "0.8.23", optional = true }
serde_yaml = { version = "0.9.16", optional = true }
log = "0.4.14"
colored = "2"

Expand All @@ -37,3 +37,7 @@ serde = [
"serde_crate", "serde_with", "serde_yaml", "rgb-std/serde",
"amplify/serde", "internet2/serde", "microservices/serde",
]

[package.metadata.docs.rs]
all-features = true
rustc-args = ["--cfg", "docsrs"]
2 changes: 2 additions & 0 deletions rpc/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ pub enum FailureCode {

Finalize = 0x15,

ElectrumConnectivity = 0x16,

UnexpectedRequest = 0x80,

/// Daemon launcher error
Expand Down
12 changes: 11 additions & 1 deletion rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@
// You should have received a copy of the MIT License along with this software.
// If not, see <https://opensource.org/licenses/MIT>.

#![recursion_limit = "256"]
// Coding conventions
#![deny(
non_upper_case_globals,
non_camel_case_types,
non_snake_case,
unused_mut,
unused_imports,
dead_code,
//missing_docs
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]

#[macro_use]
extern crate amplify;
Expand Down
14 changes: 13 additions & 1 deletion src/bucketd/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use std::io::Write;

use bitcoin::{OutPoint, Txid};
use commit_verify::{lnpbp4, CommitConceal, TaggedHash};
use electrum_client::{Client as ElectrumClient, ConfigBuilder};
use psbt::Psbt;
use rgb::psbt::RgbExt;
use rgb::schema::{OwnedRightType, TransitionType};
Expand All @@ -34,6 +35,8 @@ use crate::amplify::Wrapper;
use crate::db::{self, StoreRpcExt};
use crate::DaemonError;

const ELECTRUM_TIMEOUT: u8 = 4;

#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Display, Error, From)]
#[display(doc_comments)]
pub enum StashError {
Expand Down Expand Up @@ -127,6 +130,15 @@ pub enum FinalizeError {
}

impl Runtime {
fn _new_electrum_client(&self) -> Result<ElectrumClient, DaemonError> {
let electrum_config = ConfigBuilder::new()
.timeout(Some(ELECTRUM_TIMEOUT))
.expect("cannot fail since socks5 is unset")
.build();
ElectrumClient::from_config(&self.electrum_url, electrum_config)
.map_err(|e| DaemonError::ElectrumConnectivity(e.to_string()))
}

/// Processes incoming transfer downloaded as a container locally
pub(super) fn process_container(
&mut self,
Expand Down Expand Up @@ -177,7 +189,7 @@ impl Runtime {
trace!("Starting with contract state {:?}", state);

debug!("Validating consignment {} for contract {}", id, contract_id);
let status = Validator::validate(&consignment, &self.electrum);
let status = Validator::validate(&consignment, &self._new_electrum_client()?);
info!("Consignment validation result is {}", status.validity());

match status.validity() {
Expand Down
8 changes: 2 additions & 6 deletions src/bucketd/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use amplify::num::u24;
use bitcoin::secp256k1::rand::random;
use bitcoin::{OutPoint, Txid};
use commit_verify::ConsensusCommit;
use electrum_client::Client as ElectrumClient;
use internet2::addr::NodeAddr;
use internet2::ZmqSocketType;
use microservices::error::BootstrapError;
Expand Down Expand Up @@ -83,7 +82,7 @@ pub fn run(config: Config) -> Result<(), BootstrapError<LaunchError>> {
pub struct Runtime {
id: DaemonId,

pub(crate) electrum: ElectrumClient,
pub(crate) electrum_url: String,

pub(crate) store: store_rpc::Client,
}
Expand All @@ -96,15 +95,12 @@ impl Runtime {

let id = random();

let electrum = ElectrumClient::new(&config.electrum_url)
.map_err(|_| LaunchError::ElectrumConnectivity)?;

info!("Bucket runtime started successfully");

Ok(Self {
id,
store,
electrum,
electrum_url: config.electrum_url,
})
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ pub(crate) enum DaemonError {
#[from(bp::dbc::anchor::Error)]
Finalize(FinalizeError),

/// electrum connectivity error. Details: {0}
ElectrumConnectivity(String),

/// the container which was requested to be processed is absent in sthe store
NoContainer(ContainerId),

Expand Down Expand Up @@ -98,6 +101,7 @@ impl From<DaemonError> for RpcMsg {
DaemonError::BucketLauncher(_) => FailureCode::Launcher,
DaemonError::Stash(_) => FailureCode::Stash,
DaemonError::Finalize(_) => FailureCode::Finalize,
DaemonError::ElectrumConnectivity(_) => FailureCode::ElectrumConnectivity,
DaemonError::NoContainer(_) => FailureCode::Store,
};
RpcMsg::Failure(rpc::Failure {
Expand Down
12 changes: 12 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
// You should have received a copy of the MIT License along with this software.
// If not, see <https://opensource.org/licenses/MIT>.

// Coding conventions
#![deny(
non_upper_case_globals,
non_camel_case_types,
non_snake_case,
unused_mut,
unused_imports,
dead_code,
//missing_docs
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]

#[macro_use]
extern crate amplify;
#[macro_use]
Expand Down