Skip to content

Commit

Permalink
Bump MSRV to 1.63.0 and update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
romanz committed Jun 10, 2023
1 parent 46881ed commit d2c794c
Show file tree
Hide file tree
Showing 8 changed files with 380 additions and 271 deletions.
596 changes: 351 additions & 245 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 7 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repository = "https://github.com/romanz/electrs"
keywords = ["bitcoin", "electrum", "server", "index", "database"]
documentation = "https://docs.rs/electrs/"
readme = "README.md"
edition = "2018"
edition = "2021"
build = "build.rs"

[features]
Expand All @@ -27,29 +27,27 @@ bitcoincore-rpc = "0.17.0"
configure_me = "0.4"
crossbeam-channel = "0.5"
dirs-next = "2.0"
env_logger = "0.9"
env_logger = "0.10"
log = "0.4"
parking_lot = "0.11"
parking_lot = "0.12"
prometheus = { version = "0.13", optional = true }
rayon = "1.5"
rayon = "1.7"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
signal-hook = "0.3"
tiny_http = { version = "0.12", optional = true }

[dependencies.electrs-rocksdb]
# Workaround the following issues:
# - https://github.com/romanz/electrs/issues/403 (support building on ARM 32-bit)
# - https://github.com/romanz/electrs/issues/469 (dynamic linking on Debian 11)
version = "0.15.0-e3"
version = "0.19.0-e2"

default-features = false
# ZSTD is used for data compression
# Snappy is only for checking old DB
features = ["zstd", "snappy"]

[build-dependencies]
configure_me_codegen = { version = "0.4.3", default-features = false }
configure_me_codegen = { version = "0.4.4", default-features = false }

[dev-dependencies]
hex_lit = "0.1.1"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# The maintainers of electrs are not deeply familiar with Docker, so you should DYOR.
# If you are not familiar with Docker either it's probably be safer to NOT use it.

FROM debian:bullseye-slim as base
FROM debian:bookworm-slim as base
RUN apt-get update -qqy
RUN apt-get install -qqy librocksdb-dev curl

Expand Down
8 changes: 5 additions & 3 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# The maintainers of electrs are not deeply familiar with Docker, so you should DYOR.
# If you are not familiar with Docker either it's probably be safer to NOT use it.

FROM debian:bullseye-slim as base
FROM debian:bookworm-slim as base
RUN apt-get update -qqy
RUN apt-get install -qqy librocksdb-dev wget

Expand Down Expand Up @@ -36,9 +36,11 @@ RUN bitcoind -version && bitcoin-cli -version
### Electrum ###
# Clone latest Electrum wallet and a few test tools
WORKDIR /build/
RUN apt-get install -qqy git libsecp256k1-0 python3-cryptography python3-setuptools python3-pip jq curl
RUN apt-get install -qqy git libsecp256k1-1 python3-cryptography python3-setuptools python3-venv python3-pip jq curl
RUN git clone --recurse-submodules https://github.com/spesmilo/electrum/ && cd electrum/ && git log -1
RUN python3 -m pip install -e electrum/
RUN python3 -m venv --system-site-packages venv && \
venv/bin/pip install -e electrum/ && \
ln /build/venv/bin/electrum /usr/bin/electrum

RUN electrum version --offline
WORKDIR /
10 changes: 5 additions & 5 deletions doc/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $ ./target/release/electrs --version # should print the latest version
Note for Raspberry Pi 4 owners: the old versions of OS/toolchains produce broken binaries.
Make sure to use latest OS! (see #226)

Install [recent Rust](https://rustup.rs/) (1.48.0+, `apt install cargo` is preferred for Debian 11),
Install [recent Rust](https://rustup.rs/) (1.63.0+, `apt install cargo` is preferred for Debian 12),
[latest Bitcoin Core](https://bitcoincore.org/en/download/) (0.21+)
and [latest Electrum wallet](https://electrum.org/#download) (4.0+).

Expand All @@ -52,18 +52,18 @@ The advantages of dynamic linking:
* Cross compilation is more reliable
* If another application is also using `rocksdb`, you don't store it on disk and in RAM twice

If you decided to use dynamic linking, you will also need to install the library ([6.11.4 release](https://github.com/facebook/rocksdb/releases/tag/v6.11.4) is required).
On [Debian 11 (bullseye)](https://packages.debian.org/bullseye/librocksdb-dev) and [Ubuntu 21.04 (hirsute)](https://packages.ubuntu.com/hirsute/librocksdb-dev):
If you decided to use dynamic linking, you will also need to install the library ([7.8.3 release](https://github.com/facebook/rocksdb/releases/tag/v7.8.3) is required).
On [Debian 12 (bookworm)](https://packages.debian.org/bookworm/librocksdb-dev) and [Ubuntu 23.04 (lunar)](https://packages.ubuntu.com/lunar/librocksdb-dev):

```bash
$ sudo apt install librocksdb-dev=6.11.4-3
$ sudo apt install librocksdb-dev=7.8.3-2
```

For other versions of Debian or Ubuntu, you can build librocksdb and install inside `/usr/local` directory using following command.

```bash
$ sudo apt install -y libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev
$ git clone -b v6.11.4 --depth 1 https://github.com/facebook/rocksdb && cd rocksdb
$ git clone -b v7.8.3 --depth 1 https://github.com/facebook/rocksdb && cd rocksdb
$ make shared_lib -j $(nproc) && sudo make install-shared
$ cd .. && rm -r rocksdb
```
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.48.0
1.63.0
10 changes: 7 additions & 3 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ impl Default for Config {
}

fn default_opts() -> rocksdb::Options {
let mut block_opts = rocksdb::BlockBasedOptions::default();
block_opts.set_checksum_type(rocksdb::ChecksumType::CRC32c);

let mut opts = rocksdb::Options::default();
opts.set_keep_log_file_num(10);
opts.set_max_open_files(16);
Expand All @@ -106,6 +109,7 @@ fn default_opts() -> rocksdb::Options {
opts.set_disable_auto_compactions(true); // for initial bulk load
opts.set_advise_random_on_open(false); // bulk load uses sequential I/O
opts.set_prefix_extractor(rocksdb::SliceTransform::create_fixed_prefix(8));
opts.set_block_based_table_factory(&block_opts);
opts
}

Expand Down Expand Up @@ -233,15 +237,15 @@ impl DBStore {
opts.set_prefix_same_as_start(true); // requires .set_prefix_extractor() above.
self.db
.iterator_cf_opt(cf, opts, mode)
.map(|(key, _value)| key) // values are empty in prefix-scanned CFs
.map(|row| row.expect("prefix iterator failed").0) // values are empty in prefix-scanned CFs
}

pub(crate) fn read_headers(&self) -> Vec<Row> {
let mut opts = rocksdb::ReadOptions::default();
opts.fill_cache(false);
self.db
.iterator_cf_opt(self.headers_cf(), opts, rocksdb::IteratorMode::Start)
.map(|(key, _)| key)
.map(|row| row.expect("header iterator failed").0) // extract key from row
.filter(|key| &key[..] != TIP_KEY) // headers' rows are longer than TIP_KEY
.collect()
}
Expand Down Expand Up @@ -310,7 +314,7 @@ impl DBStore {
DB_PROPERIES.iter().filter_map(move |property_name| {
let value = self
.db
.property_int_value_cf(cf, property_name)
.property_int_value_cf(cf, *property_name)
.expect("failed to get property");
Some((*cf_name, *property_name, value?))
})
Expand Down
7 changes: 3 additions & 4 deletions src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,8 @@ impl ScriptHashStatus {
let sorted_entries = entries_map
.into_iter()
.collect::<BTreeMap<usize, TxEntry>>()
.into_iter()
.map(|(_pos, entry)| entry)
.collect::<Vec<TxEntry>>();
.into_values()
.collect();
(blockhash, sorted_entries)
})
.collect())
Expand Down Expand Up @@ -415,7 +414,7 @@ impl ScriptHashStatus {
.spent = spent_outpoints;
cache.add_tx(entry.txid, || entry.tx.clone());
}
result.into_iter().map(|(_txid, entry)| entry).collect()
result.into_values().collect()
}

/// Sync with currently confirmed txs and mempool, downloading non-cached transactions via p2p protocol.
Expand Down

0 comments on commit d2c794c

Please sign in to comment.