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

Commit a79f9cd

Browse files
committed
Better debuggin output information
1 parent 51c1607 commit a79f9cd

File tree

9 files changed

+49
-14
lines changed

9 files changed

+49
-14
lines changed

Cargo.lock

+6-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rgb_node"
33
description = "RGB node"
4-
version = "0.3.0-rc.1"
4+
version = "0.3.0"
55
authors = ["Dr. Maxim Orlovsky <[email protected]>"]
66
license = "MIT"
77
keywords = ["bitcoin", "node", "layer-2", "smart-contracts", "rgb"]
@@ -42,7 +42,7 @@ internet2 = { version = "0.3.7", default-features = false, features = ["derive"]
4242
microservices = { version = "0.3.7", default-features = false }
4343
# Bitcoin
4444
bitcoin = "0.26"
45-
electrum-client = { version = "0.5.0-beta.1", optional = true, git = "https://github.com/LNP-BP/rust-electrum-client", branch = "bitcoin-0.26" }
45+
electrum-client = { version = "0.6", optional = true }
4646
# Rust language
4747
lazy_static = "1.4"
4848
nix = { version = "0.19", optional = true }
@@ -55,7 +55,7 @@ serde_with = { version = "1.5", optional = true }
5555
serde_json = { version = "1", optional = true }
5656
serde_yaml = { version = "0.8", optional = true }
5757
toml = { version = "0.5", optional = true }
58-
bech32 = { version = "0.7", optional = true }
58+
bech32 = "0.7"
5959
base64 = { version = "0.12", optional = true }
6060
# Congig & logging
6161
log = { version = "0.4", features = ["max_level_trace", "release_max_level_debug"] }

sample/consignment.rgb

0 Bytes
Binary file not shown.

sample/dest_tx.psbt

0 Bytes
Binary file not shown.

src/cli/fungible.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl Command {
285285
format!("{}", err),
286286
)
287287
})?;
288-
trace!("{:?}", strict_serialize(&consignment));
288+
trace!("{:#?}", consignment);
289289

290290
match &*runtime.validate(consignment)? {
291291
Reply::Failure(failure) => {
@@ -320,7 +320,7 @@ impl Command {
320320
format!("{}", err),
321321
)
322322
})?;
323-
trace!("{:?}", strict_serialize(&consignment));
323+
trace!("{:#?}", consignment);
324324

325325
let api = if let Some((_, outpoint_hash)) = consignment.endpoints.get(0)
326326
{

src/fungibled/runtime.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ use crate::rpc::{
4444
stash::MergeRequest,
4545
Reply,
4646
};
47+
use crate::util::ToBech32Data;
4748

4849
pub struct Runtime {
4950
/// Original configuration object
@@ -174,7 +175,11 @@ impl Runtime {
174175
}
175176

176177
fn rpc_process(&mut self, raw: Vec<u8>) -> Result<Reply, Reply> {
177-
trace!("Got {} bytes over ZMQ RPC: {:?}", raw.len(), raw);
178+
trace!(
179+
"Got {} bytes over ZMQ RPC: {:?}",
180+
raw.len(),
181+
raw.to_bech32data()
182+
);
178183
let message = &*self.unmarshaller.unmarshall(&raw).map_err(|err| {
179184
error!("Error unmarshalling the data: {}", err);
180185
ServiceError::from_rpc(
@@ -516,6 +521,11 @@ impl Runtime {
516521
request: rpc::stash::Request,
517522
) -> Result<Reply, ServiceErrorDomain> {
518523
let data = request.serialize();
524+
trace!(
525+
"Sending {} bytes to stashd: {}",
526+
data.len(),
527+
data.to_bech32data()
528+
);
519529
self.stash_rpc.send_raw_message(data.borrow())?;
520530
let raw = self.stash_rpc.recv_raw_message()?;
521531
let reply = &*self.reply_unmarshaller.unmarshall(&raw)?.clone();

src/stashd/runtime.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ use crate::error::{
3737
use crate::rpc::stash::{ConsignRequest, MergeRequest, Request};
3838
use crate::rpc::{reply, Reply};
3939
use crate::stashd::index::BTreeIndexConfig;
40+
use crate::util::ToBech32Data;
4041

4142
pub struct Runtime {
4243
/// Original configuration object
@@ -149,15 +150,20 @@ impl Runtime {
149150
trace!("Preparing ZMQ RPC reply: {:?}", reply);
150151
let data = reply.serialize();
151152
trace!(
152-
"Sending {} bytes back to the client over ZMQ RPC",
153-
data.len()
153+
"Sending {} bytes back to the client over ZMQ RPC: {}",
154+
data.len(),
155+
data.to_bech32data()
154156
);
155157
self.session_rpc.send_raw_message(&data)?;
156158
Ok(())
157159
}
158160

159161
fn rpc_process(&mut self, raw: Vec<u8>) -> Result<Reply, Reply> {
160-
trace!("Got {} bytes over ZMQ RPC: {:?}", raw.len(), raw);
162+
trace!(
163+
"Got {} bytes over ZMQ RPC: {:?}",
164+
raw.len(),
165+
raw.to_bech32data()
166+
);
161167
let message = &*self.unmarshaller.unmarshall(&raw).map_err(|err| {
162168
ServiceError::from_rpc(ServiceErrorSource::Stash, err)
163169
})?;

src/util/bech32data.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use bech32::ToBase32;
2+
3+
pub trait ToBech32Data {
4+
fn to_bech32data(&self) -> String;
5+
}
6+
7+
pub trait FromBech32Data {
8+
fn from_bech32data(data: String) -> Vec<u8>;
9+
}
10+
11+
impl ToBech32Data for Vec<u8> {
12+
fn to_bech32data(&self) -> String {
13+
::bech32::encode("data", self.to_base32())
14+
.expect("HRP is hardcoded and can't fail")
15+
}
16+
}

src/util/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313

1414
#[macro_use]
1515
mod macros;
16+
mod bech32data;
1617
pub mod file;
1718
mod magic_numbers;
1819
mod seal_spec;
1920

21+
pub use bech32data::{FromBech32Data, ToBech32Data};
2022
pub use magic_numbers::MagicNumber;
2123
pub use seal_spec::SealSpec;

0 commit comments

Comments
 (0)