Skip to content

Commit d394fa7

Browse files
chore: bump rustreexo
1 parent 378f826 commit d394fa7

File tree

19 files changed

+138
-52
lines changed

19 files changed

+138
-52
lines changed

Cargo.lock

Lines changed: 74 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ kv = "0.24"
5656
miniscript = { version = "12.3", default-features = false }
5757
rand = "0.8"
5858
rcgen = { version = "0.14", default-features = false, features = ["aws_lc_rs", "pem"] }
59-
rustreexo = "0.4"
59+
rustreexo = { git = "https://github.com/mit-dci/rustreexo", rev = "b1080e0cca54e99213cd92e4bcb7743840802a1a" }
6060
serde = { version = "1.0", features = ["derive"] }
6161
serde_json = "1.0"
6262
sha2 = { version = "0.10", default-features = false }

crates/floresta-chain/benches/chain_state_bench.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use floresta_chain::AssumeValidArg;
2121
use floresta_chain::ChainState;
2222
use floresta_chain::FlatChainStore;
2323
use floresta_chain::FlatChainStoreConfig;
24-
use rustreexo::accumulator::proof::Proof;
24+
use rustreexo::proof::Proof;
2525

2626
/// Reads the first 151 blocks (or 150 blocks on top of genesis) from blocks.txt, which are regtest
2727
fn read_blocks_txt() -> Vec<Block> {

crates/floresta-chain/src/extensions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ mod tests {
284284
use bitcoin::OutPoint;
285285
use bitcoin::Transaction;
286286
use bitcoin::Txid;
287-
use rustreexo::accumulator::proof::Proof;
288-
use rustreexo::accumulator::stump::Stump;
287+
use rustreexo::proof::Proof;
288+
use rustreexo::stump::Stump;
289289

290290
use super::*;
291291
use crate::BlockConsumer;

crates/floresta-chain/src/pruned_utreexo/chain_state.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use core::cell::UnsafeCell;
2626
use bitcoin::block::Header as BlockHeader;
2727
use bitcoin::blockdata::constants::genesis_block;
2828
use bitcoin::hashes::sha256;
29+
use bitcoin::hashes::Hash;
2930
use bitcoin::Block;
3031
use bitcoin::BlockHash;
3132
use bitcoin::Network;
@@ -37,9 +38,9 @@ use bitcoin::Work;
3738
use floresta_common::Channel;
3839
#[cfg(feature = "metrics")]
3940
use metrics;
40-
use rustreexo::accumulator::node_hash::BitcoinNodeHash;
41-
use rustreexo::accumulator::proof::Proof;
42-
use rustreexo::accumulator::stump::Stump;
41+
use rustreexo::node_hash::BitcoinNodeHash;
42+
use rustreexo::proof::Proof;
43+
use rustreexo::stump::Stump;
4344
use spin::RwLock;
4445
use tracing::debug;
4546
use tracing::info;
@@ -576,7 +577,7 @@ impl<PersistedState: ChainStore> ChainState<PersistedState> {
576577
};
577578

578579
let mut acc = acc.as_slice();
579-
let acc = Stump::deserialize(&mut acc).map_err(BlockchainError::UtreexoError)?;
580+
let acc = Stump::deserialize(&mut acc)?;
580581
Ok(Some(acc))
581582
}
582583

@@ -1000,7 +1001,10 @@ impl<PersistedState: ChainStore> BlockchainInterface for ChainState<PersistedSta
10001001
acc: Stump,
10011002
) -> Result<(), Self::Error> {
10021003
// Convert to BitcoinNodeHashes, from rustreexo
1003-
let del_hashes: Vec<_> = del_hashes.into_iter().map(Into::into).collect();
1004+
let del_hashes: Vec<_> = del_hashes
1005+
.into_iter()
1006+
.map(|hash| BitcoinNodeHash::Some(hash.to_byte_array()))
1007+
.collect();
10041008

10051009
if !acc.verify(&proof, &del_hashes)? {
10061010
return Err(BlockValidationErrors::InvalidProof)?;
@@ -1452,8 +1456,8 @@ mod test {
14521456
use floresta_common::assert_ok;
14531457
use floresta_common::bhash;
14541458
use rand::Rng;
1455-
use rustreexo::accumulator::proof::Proof;
1456-
use rustreexo::accumulator::stump::Stump;
1459+
use rustreexo::proof::Proof;
1460+
use rustreexo::stump::Stump;
14571461

14581462
use super::BlockchainInterface;
14591463
use super::ChainParams;

crates/floresta-chain/src/pruned_utreexo/chain_state_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use bitcoin::block::Header as BlockHeader;
1212
use bitcoin::BlockHash;
1313
use bitcoin::Network;
14-
use rustreexo::accumulator::stump::Stump;
14+
use rustreexo::stump::Stump;
1515

1616
use super::chain_state::ChainState;
1717
use super::chainparams::ChainParams;

crates/floresta-chain/src/pruned_utreexo/chainparams.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use bitcoin::Network;
2323
use floresta_common::acchashes;
2424
use floresta_common::bhash;
2525
use floresta_common::service_flags;
26-
use rustreexo::accumulator::node_hash::BitcoinNodeHash;
26+
use rustreexo::node_hash::BitcoinNodeHash;
2727

2828
use crate::prelude::*;
2929
use crate::AssumeValidArg;

crates/floresta-chain/src/pruned_utreexo/consensus.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use bitcoin::blockdata::Weight;
1111
#[cfg(feature = "bitcoinkernel")]
1212
use bitcoin::consensus::serialize;
1313
use bitcoin::hashes::sha256;
14+
use bitcoin::hashes::Hash;
1415
use bitcoin::merkle_tree;
1516
use bitcoin::script;
1617
use bitcoin::Amount;
@@ -25,8 +26,9 @@ use bitcoin::Txid;
2526
#[cfg(feature = "bitcoinkernel")]
2627
use bitcoinkernel::PrecomputedTransactionData;
2728
use floresta_common::prelude::*;
28-
use rustreexo::accumulator::proof::Proof;
29-
use rustreexo::accumulator::stump::Stump;
29+
use rustreexo::node_hash::BitcoinNodeHash;
30+
use rustreexo::proof::Proof;
31+
use rustreexo::stump::Stump;
3032

3133
use super::chainparams::ChainParams;
3234
use super::error::BlockValidationErrors;
@@ -498,7 +500,10 @@ impl Consensus {
498500
}
499501

500502
// Convert to BitcoinNodeHash, from rustreexo
501-
let del_hashes: Vec<_> = del_hashes.into_iter().map(Into::into).collect();
503+
let del_hashes: Vec<_> = del_hashes
504+
.into_iter()
505+
.map(|hash| BitcoinNodeHash::Some(hash.to_byte_array()))
506+
.collect();
502507

503508
let adds = udata::proof_util::get_block_adds(block, height, block_hash);
504509

crates/floresta-chain/src/pruned_utreexo/error.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use bitcoin::OutPoint;
2020
use bitcoin::Txid;
2121
use floresta_common::impl_error_from;
2222
use floresta_common::prelude::*;
23+
use rustreexo::stump::StumpError;
2324

2425
use crate::proof_util::UtreexoLeafError;
2526
use crate::pruned_utreexo::chain_state_builder::BlockchainBuilderError;
@@ -35,7 +36,7 @@ pub enum BlockchainError {
3536
BlockValidation(BlockValidationErrors),
3637
TransactionError(TransactionError),
3738
InvalidProof,
38-
UtreexoError(String),
39+
UtreexoError(StumpError),
3940
UtreexoLeaf(UtreexoLeafError),
4041
Database(Box<dyn DatabaseError>),
4142
ConsensusDecode(bitcoin::consensus::encode::Error),
@@ -196,7 +197,7 @@ impl_error_from!(
196197
ConsensusDecode
197198
);
198199
impl_error_from!(BlockchainError, BlockValidationErrors, BlockValidation);
199-
impl_error_from!(BlockchainError, String, UtreexoError);
200+
impl_error_from!(BlockchainError, StumpError, UtreexoError);
200201

201202
impl Display for BlockchainError {
202203
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {

crates/floresta-chain/src/pruned_utreexo/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ use bitcoin::hashes::sha256;
2828
use bitcoin::Block;
2929
use bitcoin::BlockHash;
3030
use bitcoin::OutPoint;
31-
use rustreexo::accumulator::node_hash::BitcoinNodeHash;
32-
use rustreexo::accumulator::proof::Proof;
33-
use rustreexo::accumulator::stump::Stump;
31+
use rustreexo::node_hash::BitcoinNodeHash;
32+
use rustreexo::proof::Proof;
33+
use rustreexo::stump::Stump;
3434

3535
use self::partial_chain::PartialChainState;
3636
use crate::prelude::*;

0 commit comments

Comments
 (0)