Skip to content

Commit f4e042d

Browse files
committed
Merge branch 'tomas/fix-all-features-build' (#2457)
* origin/tomas/fix-all-features-build: use forked rocksdb that doesn't use jemalloc on windows sdk: fix unused import (in conditional compilation) warn core/token: add `#[must_use]` on token checked arith
2 parents 065ac1a + f4c030a commit f4e042d

File tree

9 files changed

+27
-44
lines changed

9 files changed

+27
-44
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ regex = "1.4.5"
137137
reqwest = "0.11.4"
138138
ripemd = "0.1"
139139
rlimit = "0.5.4"
140-
rocksdb = {version = "0.21.0", features = ['zstd'], default-features = false}
140+
# rocksdb = {version = "0.21.0", features = ['zstd'], default-features = false}
141+
# TEMP branch "tomas/no-jemalloc-win", replace once upstreamed
142+
rocksdb = {git = "https://github.com/heliaxdev/rust-rocksdb", rev = "20f158ade557eea2d62baece0a5b5b55a34f4915", features = ['zstd'], default-features = false}
141143
rpassword = "5.0.1"
142144
serde = {version = "1.0.125", features = ["derive"]}
143145
serde_bytes = "0.11.5"

crates/apps/Cargo.toml

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,15 @@ name = "namadar"
5050
path = "src/bin/namada-relayer/main.rs"
5151

5252
[features]
53-
default = ["no_jemalloc"]
53+
default = []
5454
mainnet = [
5555
"namada/mainnet",
5656
]
5757
# for integration tests and test utilities
5858
testing = ["namada_test_utils"]
5959
benches = ["testing", "namada_test_utils"]
6060
integration = []
61-
62-
# RocksDB's "jemalloc" disabled by default as it takes a long time to build.
63-
# Note that only exactly one of these features has to be enabled at a time.
64-
# Jemalloc is enabled in `make build-release`.
65-
no_jemalloc = ["dep:rocksdb"]
66-
jemalloc = ["rocksdb_with_jemalloc"]
61+
jemalloc = ["rocksdb/jemalloc"]
6762

6863
[dependencies]
6964
namada = {path = "../namada", features = ["multicore", "http-client", "tendermint-rpc", "std"]}
@@ -121,6 +116,7 @@ regex.workspace = true
121116
reqwest.workspace = true
122117
ripemd.workspace = true
123118
rlimit.workspace = true
119+
rocksdb.workspace = true
124120
rpassword.workspace = true
125121
serde_bytes.workspace = true
126122
serde_json = {workspace = true, features = ["raw_value"]}
@@ -146,15 +142,6 @@ zeroize.workspace = true
146142
warp = "0.3.2"
147143
bytes = "1.1.0"
148144

149-
[target.'cfg(not(windows))'.dependencies]
150-
rocksdb = { workspace = true, optional = true }
151-
rocksdb_with_jemalloc = { package = "rocksdb", version = "0.21.0", default-features = false, features = ['zstd', 'jemalloc'], optional = true }
152-
153-
[target.'cfg(windows)'.dependencies]
154-
rocksdb = { workspace = true, optional = true }
155-
# jemalloc is not supported on windows
156-
rocksdb_with_jemalloc = { package = "rocksdb", version = "0.21.0", default-features = false, features = ['zstd'], optional = true }
157-
158145
[dev-dependencies]
159146
assert_matches = "1.5.0"
160147
namada = {path = "../namada", default-features = false, features = ["testing", "wasm-runtime"]}

crates/apps/src/lib/mod.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,3 @@ pub mod facade {
2929
pub use tower_abci::BoxError;
3030
}
3131
}
32-
33-
#[cfg(all(feature = "no_jemalloc", feature = "jemalloc"))]
34-
compile_error!("`jemalloc` and `no_jemalloc` may not be used at the same time");
35-
#[cfg(feature = "no_jemalloc")]
36-
pub use rocksdb;
37-
#[cfg(feature = "jemalloc")]
38-
pub use rocksdb_with_jemalloc as rocksdb;

crates/apps/src/lib/node/ledger/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,8 @@ fn start_abci_broadcaster_shell(
469469
};
470470

471471
// Setup DB cache, it must outlive the DB instance that's in the shell
472-
let db_cache = crate::rocksdb::Cache::new_lru_cache(
473-
db_block_cache_size_bytes as usize,
474-
);
472+
let db_cache =
473+
rocksdb::Cache::new_lru_cache(db_block_cache_size_bytes as usize);
475474

476475
// Construct our ABCI application.
477476
let tendermint_mode = config.shell.tendermint_mode.clone();

crates/apps/src/lib/node/ledger/shims/abcipp_shim.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl AbcippShim {
5050
wasm_dir: PathBuf,
5151
broadcast_sender: UnboundedSender<Vec<u8>>,
5252
eth_oracle: Option<EthereumOracleChannels>,
53-
db_cache: &crate::rocksdb::Cache,
53+
db_cache: &rocksdb::Cache,
5454
vp_wasm_compilation_cache: u64,
5555
tx_wasm_compilation_cache: u64,
5656
) -> (Self, AbciService, broadcast::Sender<()>) {

crates/apps/src/lib/node/ledger/storage/rocksdb.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ use namada::types::time::DateTimeUtc;
6767
use namada::types::token::ConversionState;
6868
use namada::types::{ethereum_events, ethereum_structs};
6969
use rayon::prelude::*;
70-
71-
use crate::config::utils::num_of_threads;
72-
use crate::rocksdb::{
70+
use rocksdb::{
7371
BlockBasedOptions, ColumnFamily, ColumnFamilyDescriptor, DBCompactionStyle,
7472
DBCompressionType, Direction, FlushOptions, IteratorMode, Options,
7573
ReadOptions, WriteBatch,
7674
};
7775

76+
use crate::config::utils::num_of_threads;
77+
7878
// TODO the DB schema will probably need some kind of versioning
7979

8080
/// Env. var to set a number of Rayon global worker threads
@@ -93,7 +93,7 @@ const NEW_DIFF_PREFIX: &str = "new";
9393

9494
/// RocksDB handle
9595
#[derive(Debug)]
96-
pub struct RocksDB(crate::rocksdb::DB);
96+
pub struct RocksDB(rocksdb::DB);
9797

9898
/// DB Handle for batch writes.
9999
#[derive(Default)]
@@ -102,7 +102,7 @@ pub struct RocksDBWriteBatch(WriteBatch);
102102
/// Open RocksDB for the DB
103103
pub fn open(
104104
path: impl AsRef<Path>,
105-
cache: Option<&crate::rocksdb::Cache>,
105+
cache: Option<&rocksdb::Cache>,
106106
) -> Result<RocksDB> {
107107
let logical_cores = num_cpus::get();
108108
let compaction_threads = num_of_threads(
@@ -190,7 +190,7 @@ pub fn open(
190190
replay_protection_cf_opts,
191191
));
192192

193-
crate::rocksdb::DB::open_cf_descriptors(&db_opts, path, cfs)
193+
rocksdb::DB::open_cf_descriptors(&db_opts, path, cfs)
194194
.map(RocksDB)
195195
.map_err(|e| Error::DBError(e.into_string()))
196196
}
@@ -636,7 +636,7 @@ impl RocksDB {
636636
}
637637

638638
impl DB for RocksDB {
639-
type Cache = crate::rocksdb::Cache;
639+
type Cache = rocksdb::Cache;
640640
type WriteBatch = RocksDBWriteBatch;
641641

642642
fn open(
@@ -1680,7 +1680,7 @@ fn iter_prefix<'a>(
16801680

16811681
#[derive(Debug)]
16821682
pub struct PersistentPrefixIterator<'a>(
1683-
PrefixIterator<crate::rocksdb::DBIterator<'a>>,
1683+
PrefixIterator<rocksdb::DBIterator<'a>>,
16841684
);
16851685

16861686
impl<'a> Iterator for PersistentPrefixIterator<'a> {
@@ -1755,7 +1755,7 @@ fn unknown_key_error(key: &str) -> Result<()> {
17551755

17561756
/// Try to increase NOFILE limit and set the `max_open_files` limit to it in
17571757
/// RocksDB options.
1758-
fn set_max_open_files(cf_opts: &mut crate::rocksdb::Options) {
1758+
fn set_max_open_files(cf_opts: &mut rocksdb::Options) {
17591759
#[cfg(unix)]
17601760
imp::set_max_open_files(cf_opts);
17611761
// Nothing to do on non-unix
@@ -1771,7 +1771,7 @@ mod imp {
17711771

17721772
const DEFAULT_NOFILE_LIMIT: Rlim = Rlim::from_raw(16384);
17731773

1774-
pub fn set_max_open_files(cf_opts: &mut crate::rocksdb::Options) {
1774+
pub fn set_max_open_files(cf_opts: &mut rocksdb::Options) {
17751775
let max_open_files = match increase_nofile_limit() {
17761776
Ok(max_open_files) => Some(max_open_files),
17771777
Err(err) => {

crates/core/src/types/token.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ impl Amount {
153153

154154
/// Checked addition. Returns `None` on overflow or if
155155
/// the amount exceed [`uint::MAX_VALUE`]
156+
#[must_use]
156157
pub fn checked_add(&self, amount: Amount) -> Option<Self> {
157158
self.raw.checked_add(amount.raw).and_then(|result| {
158159
if result <= uint::MAX_VALUE {
@@ -165,6 +166,7 @@ impl Amount {
165166

166167
/// Checked addition. Returns `None` on overflow or if
167168
/// the amount exceed [`uint::MAX_SIGNED_VALUE`]
169+
#[must_use]
168170
pub fn checked_signed_add(&self, amount: Amount) -> Option<Self> {
169171
self.raw.checked_add(amount.raw).and_then(|result| {
170172
if result <= uint::MAX_SIGNED_VALUE {
@@ -189,13 +191,15 @@ impl Amount {
189191
}
190192

191193
/// Checked division. Returns `None` on underflow.
194+
#[must_use]
192195
pub fn checked_div(&self, amount: Amount) -> Option<Self> {
193196
self.raw
194197
.checked_div(amount.raw)
195198
.map(|result| Self { raw: result })
196199
}
197200

198201
/// Checked multiplication. Returns `None` on overflow.
202+
#[must_use]
199203
pub fn checked_mul(&self, amount: Amount) -> Option<Self> {
200204
self.raw
201205
.checked_mul(amount.raw)

crates/sdk/src/masp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::collections::{btree_map, BTreeMap, BTreeSet, HashMap, HashSet};
55
use std::env;
66
use std::fmt::Debug;
77
use std::ops::Deref;
8-
use std::path::{Path, PathBuf};
8+
use std::path::PathBuf;
99
use std::str::FromStr;
1010

1111
// use async_std::io::prelude::WriteExt;
@@ -2263,7 +2263,7 @@ impl<U: ShieldedUtils + MaybeSend + MaybeSync> ShieldedContext<U> {
22632263
.map_err(|e| Error::Other(e.to_string()))?
22642264
// Two up from "tests" dir to the root dir
22652265
.parent()
2266-
.and_then(Path::parent)
2266+
.and_then(std::path::Path::parent)
22672267
.ok_or_else(|| {
22682268
Error::Other("Can not get root dir".to_string())
22692269
})?

0 commit comments

Comments
 (0)