Skip to content

Commit

Permalink
improve drivechain logging, release
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash-L2L committed Jun 11, 2024
1 parent 0b8339b commit 9e6134c
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 50 deletions.
95 changes: 81 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ authors = [
"Nikita Chashchinskii <[email protected]>"
]
edition = "2021"
version = "0.8.13"
version = "0.8.14"

[workspace.dependencies.bip300301]
git = "https://github.com/Ash-L2L/bip300301.git"
rev = "64568dee7b89fe8c021226f10b17a18fe3386871"
rev = "b74c5bbf6022701cbdfbd9a412327577e115ceda"

[workspace.dependencies.rustreexo]
git = "https://github.com/Ash-L2L/rustreexo.git"
Expand Down
7 changes: 5 additions & 2 deletions app/gui/parent_chain/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ impl Info {
let mainchain_tip = app.runtime.block_on(async {
let mainchain_tip_blockhash = dc.get_mainchain_tip().await?;
dc.client
.getblock(&mainchain_tip_blockhash, None)
.map_err(bip300301::Error::Jsonrpsee)
.getblock(mainchain_tip_blockhash, None)
.map_err(|source| bip300301::Error::Jsonrpsee {
source,
main_addr: dc.main_addr,
})
.await
})?;
let sidechain_wealth = app.node.get_sidechain_wealth()?;
Expand Down
22 changes: 13 additions & 9 deletions lib/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ impl Miner {
}

pub async fn generate(&self) -> Result<(), Error> {
self.drivechain
.client
.generate(1)
.await
.map_err(bip300301::Error::from)?;
self.drivechain.client.generate(1).await.map_err(|source| {
bip300301::Error::Jsonrpsee {
source,
main_addr: self.drivechain.main_addr,
}
})?;
Ok(())
}

Expand All @@ -72,7 +73,10 @@ impl Miner {
prev_bytes,
)
.await
.map_err(bip300301::Error::from)?;
.map_err(|source| bip300301::Error::Jsonrpsee {
source,
main_addr: self.drivechain.main_addr,
})?;
let txid = value["txid"]["txid"]
.as_str()
.map(|s| s.to_owned())
Expand All @@ -93,9 +97,9 @@ impl Miner {
let block_hash = header.hash().into();
tracing::trace!(%block_hash, "verifying bmm...");
self.drivechain
.verify_bmm(
&header.prev_main_hash,
&block_hash,
.verify_bmm_next_block(
header.prev_main_hash,
block_hash,
VERIFY_BMM_POLL_INTERVAL,
)
.await?;
Expand Down
22 changes: 5 additions & 17 deletions lib/node/mainchain_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,30 +111,18 @@ impl MainchainTask {
drivechain: &bip300301::Drivechain,
block_hash: BlockHash,
) -> Result<bool, Error> {
use jsonrpsee::types::error::ErrorCode as JsonrpseeErrorCode;
const VERIFY_BMM_POLL_INTERVAL: Duration = Duration::from_secs(15);
let header = {
let rotxn = env.read_txn()?;
archive.get_header(&rotxn, block_hash)?
};
let res = match drivechain
.verify_bmm(
&header.prev_main_hash,
&block_hash.into(),
let (res, _next_block_hash) = drivechain
.verify_bmm_next_block(
header.prev_main_hash,
block_hash.into(),
VERIFY_BMM_POLL_INTERVAL,
)
.await
{
Ok(()) => true,
Err(bip300301::Error::Jsonrpsee(jsonrpsee::core::Error::Call(
err,
))) if JsonrpseeErrorCode::from(err.code())
== JsonrpseeErrorCode::ServerError(-1) =>
{
false
}
Err(err) => return Err(Error::from(err)),
};
.await?;
let mut rwtxn = env.write_txn()?;
let () = archive.put_bmm_verification(&mut rwtxn, block_hash, res)?;
rwtxn.commit()?;
Expand Down
12 changes: 6 additions & 6 deletions lib/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@ impl Node {
&self,
) -> Result<bitcoin::BlockHash, Error> {
use bip300301::MainClient;
let res = self
.drivechain
.client
.getbestblockhash()
.await
.map_err(bip300301::Error::Jsonrpsee)?;
let res = self.drivechain.client.getbestblockhash().await.map_err(
|source| bip300301::Error::Jsonrpsee {
source,
main_addr: self.drivechain.main_addr,
},
)?;
Ok(res)
}

Expand Down

0 comments on commit 9e6134c

Please sign in to comment.