make some adjustments

This commit is contained in:
Alfredo Garcia 2024-04-16 15:21:22 -03:00
parent d041410ce2
commit a458065366
5 changed files with 43 additions and 25 deletions

View File

@ -1349,6 +1349,8 @@ dependencies = [
[[package]]
name = "equihash"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab579d7cf78477773b03e80bc2f89702ef02d7112c711d54ca93dcdce68533d5"
dependencies = [
"blake2b_simd",
"byteorder",
@ -1357,8 +1359,7 @@ dependencies = [
[[package]]
name = "equihash"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab579d7cf78477773b03e80bc2f89702ef02d7112c711d54ca93dcdce68533d5"
source = "git+https://github.com/oxarbitrage/librustzcash?branch=put-block-zebra#62d8055aa44f96ca58cb609d09953e89a04dda26"
dependencies = [
"blake2b_simd",
"byteorder",
@ -1393,6 +1394,8 @@ dependencies = [
[[package]]
name = "f4jumble"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a83e8d7fd0c526af4aad893b7c9fe41e2699ed8a776a6c74aecdeafe05afc75"
dependencies = [
"blake2b_simd",
]
@ -1400,8 +1403,7 @@ dependencies = [
[[package]]
name = "f4jumble"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a83e8d7fd0c526af4aad893b7c9fe41e2699ed8a776a6c74aecdeafe05afc75"
source = "git+https://github.com/oxarbitrage/librustzcash?branch=put-block-zebra#62d8055aa44f96ca58cb609d09953e89a04dda26"
dependencies = [
"blake2b_simd",
]
@ -3806,8 +3808,9 @@ dependencies = [
[[package]]
name = "sapling-crypto"
version = "0.1.2"
source = "git+https://github.com/zcash/sapling-crypto?rev=54fc7d3d9c8eeb8e6ef6f64619deed43b0b681a6#54fc7d3d9c8eeb8e6ef6f64619deed43b0b681a6"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02f4270033afcb0c74c5c7d59c73cfd1040367f67f224fe7ed9a919ae618f1b7"
dependencies = [
"aes",
"bellman",
@ -5656,11 +5659,12 @@ dependencies = [
[[package]]
name = "zcash_address"
version = "0.3.2"
source = "git+https://github.com/oxarbitrage/librustzcash?branch=put-block-zebra#62d8055aa44f96ca58cb609d09953e89a04dda26"
dependencies = [
"bech32",
"bs58",
"f4jumble 0.1.0",
"zcash_encoding 0.2.0",
"f4jumble 0.1.0 (git+https://github.com/oxarbitrage/librustzcash?branch=put-block-zebra)",
"zcash_encoding 0.2.0 (git+https://github.com/oxarbitrage/librustzcash?branch=put-block-zebra)",
"zcash_protocol",
]
@ -5700,6 +5704,7 @@ dependencies = [
[[package]]
name = "zcash_client_backend"
version = "0.11.1"
source = "git+https://github.com/oxarbitrage/librustzcash?branch=put-block-zebra#62d8055aa44f96ca58cb609d09953e89a04dda26"
dependencies = [
"base64 0.21.7",
"bech32",
@ -5728,7 +5733,7 @@ dependencies = [
"tracing",
"which",
"zcash_address 0.3.2",
"zcash_encoding 0.2.0",
"zcash_encoding 0.2.0 (git+https://github.com/oxarbitrage/librustzcash?branch=put-block-zebra)",
"zcash_keys",
"zcash_note_encryption",
"zcash_primitives 0.14.0",
@ -5739,6 +5744,8 @@ dependencies = [
[[package]]
name = "zcash_encoding"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f03391b81727875efa6ac0661a20883022b6fba92365dc121c48fa9b00c5aac0"
dependencies = [
"byteorder",
"nonempty",
@ -5747,8 +5754,7 @@ dependencies = [
[[package]]
name = "zcash_encoding"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f03391b81727875efa6ac0661a20883022b6fba92365dc121c48fa9b00c5aac0"
source = "git+https://github.com/oxarbitrage/librustzcash?branch=put-block-zebra#62d8055aa44f96ca58cb609d09953e89a04dda26"
dependencies = [
"byteorder",
"nonempty",
@ -5768,6 +5774,7 @@ dependencies = [
[[package]]
name = "zcash_keys"
version = "0.1.1"
source = "git+https://github.com/oxarbitrage/librustzcash?branch=put-block-zebra#62d8055aa44f96ca58cb609d09953e89a04dda26"
dependencies = [
"bech32",
"blake2b_simd",
@ -5785,7 +5792,7 @@ dependencies = [
"subtle",
"tracing",
"zcash_address 0.3.2",
"zcash_encoding 0.2.0",
"zcash_encoding 0.2.0 (git+https://github.com/oxarbitrage/librustzcash?branch=put-block-zebra)",
"zcash_primitives 0.14.0",
"zcash_protocol",
"zip32",
@ -5843,13 +5850,14 @@ dependencies = [
[[package]]
name = "zcash_primitives"
version = "0.14.0"
source = "git+https://github.com/oxarbitrage/librustzcash?branch=put-block-zebra#62d8055aa44f96ca58cb609d09953e89a04dda26"
dependencies = [
"aes",
"bip0039",
"blake2b_simd",
"byteorder",
"document-features",
"equihash 0.2.0",
"equihash 0.2.0 (git+https://github.com/oxarbitrage/librustzcash?branch=put-block-zebra)",
"ff",
"fpe",
"group",
@ -5868,7 +5876,7 @@ dependencies = [
"subtle",
"tracing",
"zcash_address 0.3.2",
"zcash_encoding 0.2.0",
"zcash_encoding 0.2.0 (git+https://github.com/oxarbitrage/librustzcash?branch=put-block-zebra)",
"zcash_note_encryption",
"zcash_protocol",
"zcash_spec",
@ -5899,6 +5907,7 @@ dependencies = [
[[package]]
name = "zcash_protocol"
version = "0.1.0"
source = "git+https://github.com/oxarbitrage/librustzcash?branch=put-block-zebra#62d8055aa44f96ca58cb609d09953e89a04dda26"
dependencies = [
"document-features",
"incrementalmerkletree",

View File

@ -54,9 +54,9 @@ futures = "0.3.30"
zcash_client_backend = "0.10.0-rc.1"
zcash_primitives = "0.13.0-rc.1"
# Wallet integration
zcash_client_backend2 = { package = "zcash_client_backend", path = "/home/alfredo/librustzcash/pr1293/librustzcash/zcash_client_backend", features = ["test-dependencies"] }
zcash_primitives2 = { package = "zcash_primitives", path = "/home/alfredo/librustzcash/pr1293/librustzcash/zcash_primitives" }
# Memory wallet integration
zcash_client_backend2 = { package = "zcash_client_backend", git = "https://github.com/oxarbitrage/librustzcash", branch = "put-block-zebra", features = ["test-dependencies"] }
zcash_primitives2 = { package = "zcash_primitives", git = "https://github.com/oxarbitrage/librustzcash", branch = "put-block-zebra" }
secrecy = "0.8.0"
zebra-chain = { path = "../zebra-chain", version = "1.0.0-beta.35", features = ["shielded-scan"] }

View File

@ -12,7 +12,7 @@ use crate::storage::Storage;
mod commands;
mod executor;
pub mod scan;
pub mod wallet;
pub mod external_client;
pub use commands::ScanTaskCommand;

View File

@ -8,9 +8,9 @@ use zcash_client_backend2::{
encoding::encode_extended_full_viewing_key,
};
use zcash_primitives2::{
consensus::Network, constants::mainnet::HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY,
consensus::{BlockHeight, Network}, constants::mainnet::HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY,
};
use zebra_chain::block::Height;
use zebra_chain::block::{Hash, Height};
/// Create a new, empty `MemoryWalletDb`.
pub fn init() -> MemoryWalletDb {
@ -57,3 +57,11 @@ pub fn get_wallet_chain_tip(database: &MemoryWalletDb) -> Result<Option<Height>,
None => Ok(None),
})?
}
/// Get a block hash from a given height.
pub fn get_memory_wallet_block_hash(database: &MemoryWalletDb, height: Height) -> Result<Option<Hash>, WalletError> {
database.get_block_hash(BlockHeight::from_u32(height.0)).map(|hash| match hash {
Some(h) => Ok(Some(Hash::from(h.0))),
None => Ok(None),
})?
}

View File

@ -202,12 +202,12 @@ fn scanning_fake_blocks_store_key_and_results() -> Result<()> {
}
#[tokio::test]
async fn wallet_fake_generated_blocks() -> Result<()> {
async fn memory_wallet_integration_test() -> Result<()> {
use zcash_client_backend2::data_api::{ScannedBlock, ScannedBundles};
use zcash_primitives2::{block::BlockHash, consensus::BlockHeight};
use crate::service::scan_task::wallet::{
create_account, get_wallet_chain_tip, init, insert_block,
use crate::service::scan_task::external_client::{
create_account, get_memory_wallet_block_hash, init, insert_block,
};
let extsk = ExtendedSpendingKey::master(&[]);
@ -235,9 +235,10 @@ async fn wallet_fake_generated_blocks() -> Result<()> {
// Insert a block
let _ = insert_block(&mut database, scanned_block_converted);
// Check inserted block
let chain_tip = get_wallet_chain_tip(&database).unwrap();
assert_eq!(chain_tip, block.coinbase_height());
let chain_hash = get_memory_wallet_block_hash(&database, Height(1)).unwrap().unwrap();
assert_eq!(chain_hash, block.hash());
// Create an account
let seed = [0u8; 32];