diff --git a/Cargo.lock b/Cargo.lock index 37196f2fb..149c2b2b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6492,9 +6492,9 @@ dependencies = [ [[package]] name = "sled-overlay" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad42f44feda8a0f1697d6608bd34999ec40a3894915ca826bb3df66ac9247e75" +checksum = "4c33dea88a6fcef15045db58735976a75488268751fa4574ca6d95a3f612a0da" dependencies = [ "darkfi-serial", "sled", diff --git a/Cargo.toml b/Cargo.toml index 40b5accd3..7cd9c6f74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -122,7 +122,7 @@ wasmer-compiler-singlepass = {version = "4.4.0", optional = true} wasmer-middlewares = {version = "4.4.0", optional = true} # Blockchain store -sled-overlay = {version = "0.1.5", optional = true} +sled-overlay = {version = "0.1.6", optional = true} # Miner randomx = {git = "https://github.com/darkrenaissance/RandomX", optional = true} diff --git a/bin/darkfid/Cargo.toml b/bin/darkfid/Cargo.toml index 226118caa..4fc9cd4c6 100644 --- a/bin/darkfid/Cargo.toml +++ b/bin/darkfid/Cargo.toml @@ -22,7 +22,7 @@ bs58 = "0.5.1" log = "0.4.22" num-bigint = "0.4.6" rand = "0.8.5" -sled-overlay = "0.1.5" +sled-overlay = "0.1.6" toml = "0.8.19" # JSON-RPC diff --git a/bin/darkirc/Cargo.toml b/bin/darkirc/Cargo.toml index d5ff75ab5..511e52394 100644 --- a/bin/darkirc/Cargo.toml +++ b/bin/darkirc/Cargo.toml @@ -24,7 +24,7 @@ darkfi-serial = {version = "0.4.2", features = ["async"]} libc = "0.2.159" # Event Graph DB -sled-overlay = "0.1.5" +sled-overlay = "0.1.6" # TLS async-trait = "0.1.83" diff --git a/bin/darkwallet/Cargo.toml b/bin/darkwallet/Cargo.toml index e9f21f73a..4682c2921 100644 --- a/bin/darkwallet/Cargo.toml +++ b/bin/darkwallet/Cargo.toml @@ -42,7 +42,7 @@ futures = "0.3.31" async-recursion = "1.1.1" colored = "2.1.0" #rustpython-vm = "0.3.1" -sled-overlay = "0.1.5" +sled-overlay = "0.1.6" url = "2.5.2" semver = "1.0.23" chrono = "0.4.38" diff --git a/bin/genev/genevd/Cargo.toml b/bin/genev/genevd/Cargo.toml index 38f578990..dec55732a 100644 --- a/bin/genev/genevd/Cargo.toml +++ b/bin/genev/genevd/Cargo.toml @@ -28,7 +28,7 @@ darkfi-serial = "0.4.2" blake3 = "1.5.4" # Event Graph DB -sled-overlay = "0.1.5" +sled-overlay = "0.1.6" # Misc async-trait = "0.1.83" diff --git a/bin/tau/taud/Cargo.toml b/bin/tau/taud/Cargo.toml index 4f77bf004..3b0c855d0 100644 --- a/bin/tau/taud/Cargo.toml +++ b/bin/tau/taud/Cargo.toml @@ -27,7 +27,7 @@ darkfi = { path = "../../../", features = [ darkfi-serial = "0.4.2" # Event Graph DB -sled-overlay = "0.1.5" +sled-overlay = "0.1.6" # Crypto blake3 = "1.5.4" diff --git a/script/evgrd/Cargo.toml b/script/evgrd/Cargo.toml index 0ba6f51bd..76cd155a2 100644 --- a/script/evgrd/Cargo.toml +++ b/script/evgrd/Cargo.toml @@ -26,7 +26,7 @@ darkfi = {path = "../../", features = ["event-graph"]} darkfi-serial = {version = "0.4.2", features = ["async"]} # Event Graph DB -sled-overlay = "0.1.5" +sled-overlay = "0.1.6" # Crypto blake3 = "1.5.4" diff --git a/script/research/blockchain-explorer/Cargo.toml b/script/research/blockchain-explorer/Cargo.toml index 2941ee6ec..2a33284c5 100644 --- a/script/research/blockchain-explorer/Cargo.toml +++ b/script/research/blockchain-explorer/Cargo.toml @@ -18,7 +18,7 @@ drk = {path = "../../../bin/drk"} # Misc log = "0.4.22" -sled-overlay = "0.1.5" +sled-overlay = "0.1.6" # JSON-RPC async-trait = "0.1.83" diff --git a/script/research/gg/Cargo.toml b/script/research/gg/Cargo.toml index cbd972828..c3ad37c8d 100644 --- a/script/research/gg/Cargo.toml +++ b/script/research/gg/Cargo.toml @@ -18,13 +18,13 @@ darkfi = {path = "../../../", features = ["bs58", "validator"]} darkfi_money_contract = {path = "../../../src/contract/money", features = ["no-entrypoint", "client"]} darkfi-contract-test-harness = {path = "../../../src/contract/test-harness"} darkfi-sdk = {path = "../../../src/sdk"} -darkfi-serial = {path = "../../../src/serial"} +darkfi-serial = "0.4.2" # Misc async-std = {version = "1.13.0", features = ["attributes"]} bs58 = "0.5.1" clap = {version = "4.4.11", features = ["derive"]} -sled-overlay = "0.1.5" +sled-overlay = "0.1.6" [patch.crates-io] halo2_proofs = {git="https://github.com/parazyd/halo2", branch="v4"} diff --git a/src/blockchain/block_store.rs b/src/blockchain/block_store.rs index 3c935ff9e..e9d30a57a 100644 --- a/src/blockchain/block_store.rs +++ b/src/blockchain/block_store.rs @@ -28,11 +28,14 @@ use darkfi_sdk::{ use darkfi_serial::async_trait; use darkfi_serial::{deserialize, serialize, SerialDecodable, SerialEncodable}; use num_bigint::BigUint; -use sled_overlay::{sled, SledDbOverlayStateDiff}; +use sled_overlay::{ + serial::{parse_record, parse_u32_key_record}, + sled, SledDbOverlayStateDiff, +}; use crate::{tx::Transaction, util::time::Timestamp, Error, Result}; -use super::{parse_record, parse_u32_key_record, Header, HeaderHash, SledDbOverlayPtr}; +use super::{Header, HeaderHash, SledDbOverlayPtr}; /// This struct represents a tuple of the form (`header`, `txs`, `signature`). /// diff --git a/src/blockchain/contract_store.rs b/src/blockchain/contract_store.rs index fafbda1a7..3b5fa62d7 100644 --- a/src/blockchain/contract_store.rs +++ b/src/blockchain/contract_store.rs @@ -21,7 +21,7 @@ use std::io::Cursor; use darkfi_sdk::crypto::ContractId; use darkfi_serial::{deserialize, serialize}; use log::{debug, error}; -use sled_overlay::sled; +use sled_overlay::{serial::parse_record, sled}; use crate::{ zk::{empty_witnesses, VerifyingKey, ZkCircuit}, @@ -29,7 +29,7 @@ use crate::{ Error, Result, }; -use super::{parse_record, SledDbOverlayPtr}; +use super::SledDbOverlayPtr; pub const SLED_CONTRACTS_TREE: &[u8] = b"_contracts"; pub const SLED_BINCODE_TREE: &[u8] = b"_wasm_bincode"; diff --git a/src/blockchain/header_store.rs b/src/blockchain/header_store.rs index eb5721cb7..5d00ae5c1 100644 --- a/src/blockchain/header_store.rs +++ b/src/blockchain/header_store.rs @@ -27,11 +27,14 @@ use darkfi_sdk::{ #[cfg(feature = "async-serial")] use darkfi_serial::async_trait; use darkfi_serial::{deserialize, serialize, Encodable, SerialDecodable, SerialEncodable}; -use sled_overlay::sled; +use sled_overlay::{ + serial::{parse_record, parse_u32_key_record}, + sled, +}; use crate::{util::time::Timestamp, Error, Result}; -use super::{parse_record, parse_u32_key_record, SledDbOverlayPtr}; +use super::SledDbOverlayPtr; #[derive(Copy, Clone, Debug, Eq, PartialEq, SerialEncodable, SerialDecodable)] // We have to introduce a type rather than using an alias so we can restrict API access diff --git a/src/blockchain/mod.rs b/src/blockchain/mod.rs index e8e3af7b7..72fb4fb5b 100644 --- a/src/blockchain/mod.rs +++ b/src/blockchain/mod.rs @@ -19,7 +19,6 @@ use std::sync::{Arc, Mutex}; use darkfi_sdk::tx::TransactionHash; -use darkfi_serial::{deserialize, Decodable}; use log::debug; use sled_overlay::{sled, sled::Transactional}; @@ -585,31 +584,3 @@ impl BlockchainOverlay { Ok(Arc::new(Mutex::new(Self { overlay, headers, blocks, transactions, contracts }))) } } - -/// Parse a sled record with a u32 key in the form of a tuple (`key`, `value`). -pub fn parse_u32_key_record(record: (sled::IVec, sled::IVec)) -> Result<(u32, T)> { - let key_bytes: [u8; 4] = record.0.as_ref().try_into().unwrap(); - let key = u32::from_be_bytes(key_bytes); - let value = deserialize(&record.1)?; - - Ok((key, value)) -} - -/// Parse a sled record with a u64 key in the form of a tuple (`key`, `value`). -pub fn parse_u64_key_record(record: (sled::IVec, sled::IVec)) -> Result<(u64, T)> { - let key_bytes: [u8; 8] = record.0.as_ref().try_into().unwrap(); - let key = u64::from_be_bytes(key_bytes); - let value = deserialize(&record.1)?; - - Ok((key, value)) -} - -/// Parse a sled record in the form of a tuple (`key`, `value`). -pub fn parse_record( - record: (sled::IVec, sled::IVec), -) -> Result<(T1, T2)> { - let key = deserialize(&record.0)?; - let value = deserialize(&record.1)?; - - Ok((key, value)) -} diff --git a/src/blockchain/tx_store.rs b/src/blockchain/tx_store.rs index 8a8b64abf..4ce2b8641 100644 --- a/src/blockchain/tx_store.rs +++ b/src/blockchain/tx_store.rs @@ -20,11 +20,14 @@ use std::collections::HashMap; use darkfi_sdk::tx::TransactionHash; use darkfi_serial::{deserialize, serialize}; -use sled_overlay::sled; +use sled_overlay::{ + serial::{parse_record, parse_u64_key_record}, + sled, +}; use crate::{tx::Transaction, Error, Result}; -use super::{parse_record, parse_u64_key_record, SledDbOverlayPtr}; +use super::SledDbOverlayPtr; pub const SLED_TX_TREE: &[u8] = b"_transactions"; pub const SLED_TX_LOCATION_TREE: &[u8] = b"_transaction_location"; diff --git a/src/contract/test-harness/Cargo.toml b/src/contract/test-harness/Cargo.toml index 38dfbf493..339dd41a8 100644 --- a/src/contract/test-harness/Cargo.toml +++ b/src/contract/test-harness/Cargo.toml @@ -19,7 +19,7 @@ blake3 = "1.5.4" log = "0.4.22" rand = "0.8.5" simplelog = "0.12.2" -sled-overlay = "0.1.5" +sled-overlay = "0.1.6" [lints] workspace = true