depolymerization

wire gateway for Bitcoin/Ethereum
Log | Files | Refs | Submodules | README | LICENSE

commit 1e5bae6f56c6c63ff4af09a29e289b4f36520ca1
parent 575ef8fc155fcf650ac0c7b0764d74bc056990fe
Author: Antoine A <>
Date:   Sat, 10 Oct 2026 11:41:25 +0200

common: set rust version and improve boostrap & config

Diffstat:
M.gitmodules | 3---
MCargo.lock | 79+++++++++++++++++++++++++++++++++++++++++++------------------------------------
MCargo.toml | 5+++++
Mbootstrap | 4++--
Mbuild-system/configure.py | 122++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
Dbuild-system/taler-build-scripts | 1-
Mcontrib/ci/Containerfile | 14++++++++++----
Mdebian/control | 3++-
Mdebian/rules | 4++--
Mdepolymerizer-bitcoin/Cargo.toml | 1+
Mdepolymerizer-bitcoin/src/bin/btc-harness.rs | 14++++++++------
Mdepolymerizer-common/Cargo.toml | 1+
Mmakefile | 26++++++++++++++++----------
Muri-pack/Cargo.toml | 1+
14 files changed, 206 insertions(+), 72 deletions(-)

diff --git a/.gitmodules b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "build-system/taler-build-scripts"] - path = build-system/taler-build-scripts - url = ../build-common.git [submodule "doc/prebuilt"] path = doc/prebuilt url = ../taler-docs.git diff --git a/Cargo.lock b/Cargo.lock @@ -228,6 +228,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + +[[package]] name = "bech32" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -362,9 +368,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f74872d07caf508b30a21f6836e7d7016a2eaf7d9ff4f48deaa58cd8a0407630" +checksum = "50a649af8a827553c29fb0cb4bd4a6f1a0dd695bd3232b9bc98bd9c8a3ffbb8b" dependencies = [ "find-msvc-tools", "jobserver", @@ -459,7 +465,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 3.0.6", + "syn 3.0.7", ] [[package]] @@ -713,7 +719,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 3.0.6", + "syn 3.0.7", ] [[package]] @@ -724,7 +730,7 @@ checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785" dependencies = [ "darling_core", "quote", - "syn 3.0.6", + "syn 3.0.7", ] [[package]] @@ -872,7 +878,7 @@ checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" dependencies = [ "proc-macro2", "quote", - "syn 3.0.6", + "syn 3.0.7", ] [[package]] @@ -971,7 +977,7 @@ dependencies = [ [[package]] name = "failure-injection" version = "1.5.0" -source = "git+git://git.taler.net/taler-rust.git/#412bfed5e688c3bdfd1f1e9ae00b306a899395bb" +source = "git+git://git.taler.net/taler-rust.git/#91ff47a5fc84ee85c8c54eab7e03b649d9608ef8" dependencies = [ "thiserror", ] @@ -1891,7 +1897,7 @@ checksum = "01e34894696ff94f64a20c2c373a6440903e9c2789a303d68ec6e6f953f890e4" dependencies = [ "proc-macro2", "quote", - "syn 3.0.6", + "syn 3.0.7", ] [[package]] @@ -2276,7 +2282,7 @@ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", - "syn 3.0.6", + "syn 3.0.7", ] [[package]] @@ -2311,7 +2317,7 @@ checksum = "8d3b1629de253c70a0508c3899572da79ca359fdab27c7920ff00406df418906" dependencies = [ "proc-macro2", "quote", - "syn 3.0.6", + "syn 3.0.7", ] [[package]] @@ -2345,7 +2351,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 3.0.6", + "syn 3.0.7", ] [[package]] @@ -2413,9 +2419,9 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "smallvec" -version = "1.16.2" +version = "1.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9395f0f0eee849a9b707b2f06bb92a6a422090e2123bb2ef8e87a0e61892a8e" +checksum = "5b3dc8af474f516a851ff4bd12db780f948b9250ad37211e4eec0bccea54e01b" dependencies = [ "serde", ] @@ -2447,7 +2453,7 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee6798b1838b6a0f69c007c133b8df5866302197e404e8b6ee8ed3e3a5e68dc6" dependencies = [ - "base64", + "base64 0.22.1", "bytes", "crc", "crossbeam-queue", @@ -2521,7 +2527,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db58fcd5a53cf07c184b154801ff91347e4c30d17a3562a635ff028ad5deda46" dependencies = [ "atoi", - "base64", + "base64 0.22.1", "bitflags 2.13.2", "byteorder", "crc", @@ -2630,9 +2636,9 @@ dependencies = [ [[package]] name = "syn" -version = "3.0.6" +version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee" +checksum = "d62a2e0561533f2ca2561d0cf27fd9fedb640a1bf2616ff5d5c80d99017faadc" dependencies = [ "proc-macro2", "quote", @@ -2653,13 +2659,13 @@ checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" dependencies = [ "proc-macro2", "quote", - "syn 3.0.6", + "syn 3.0.7", ] [[package]] name = "taler-api" version = "1.5.0" -source = "git+git://git.taler.net/taler-rust.git/#412bfed5e688c3bdfd1f1e9ae00b306a899395bb" +source = "git+git://git.taler.net/taler-rust.git/#91ff47a5fc84ee85c8c54eab7e03b649d9608ef8" dependencies = [ "aws-lc-rs", "axum", @@ -2689,15 +2695,16 @@ dependencies = [ [[package]] name = "taler-build" version = "1.5.0" -source = "git+git://git.taler.net/taler-rust.git/#412bfed5e688c3bdfd1f1e9ae00b306a899395bb" +source = "git+git://git.taler.net/taler-rust.git/#91ff47a5fc84ee85c8c54eab7e03b649d9608ef8" [[package]] name = "taler-common" version = "1.5.0" -source = "git+git://git.taler.net/taler-rust.git/#412bfed5e688c3bdfd1f1e9ae00b306a899395bb" +source = "git+git://git.taler.net/taler-rust.git/#91ff47a5fc84ee85c8c54eab7e03b649d9608ef8" dependencies = [ "anyhow", "aws-lc-rs", + "base64 0.23.1", "clap", "compact_str", "glob", @@ -2724,17 +2731,17 @@ dependencies = [ [[package]] name = "taler-macros" version = "1.5.0" -source = "git+git://git.taler.net/taler-rust.git/#412bfed5e688c3bdfd1f1e9ae00b306a899395bb" +source = "git+git://git.taler.net/taler-rust.git/#91ff47a5fc84ee85c8c54eab7e03b649d9608ef8" dependencies = [ "proc-macro2", "quote", - "syn 3.0.6", + "syn 3.0.7", ] [[package]] name = "taler-test-utils" version = "1.5.0" -source = "git+git://git.taler.net/taler-rust.git/#412bfed5e688c3bdfd1f1e9ae00b306a899395bb" +source = "git+git://git.taler.net/taler-rust.git/#91ff47a5fc84ee85c8c54eab7e03b649d9608ef8" dependencies = [ "aws-lc-rs", "axum", @@ -2789,7 +2796,7 @@ checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" dependencies = [ "proc-macro2", "quote", - "syn 3.0.6", + "syn 3.0.7", ] [[package]] @@ -2881,7 +2888,7 @@ checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e" dependencies = [ "proc-macro2", "quote", - "syn 3.0.6", + "syn 3.0.7", ] [[package]] @@ -3105,9 +3112,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.27.0" +version = "1.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97277d36b9c3ace13e58fa6e753f8b0bbbf302a18dd193240d70f9e29681059a" +checksum = "7cc1186384beb7dd8eedea376413fd654937285ea6c9cfbb928dc3043ea4b606" dependencies = [ "js-sys", "wasm-bindgen", @@ -3197,7 +3204,7 @@ dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 3.0.6", + "syn 3.0.7", "wasm-bindgen-shared", ] @@ -3532,24 +3539,24 @@ checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" dependencies = [ "proc-macro2", "quote", - "syn 3.0.6", + "syn 3.0.7", "synstructure", ] [[package]] name = "zerocopy" -version = "0.8.61" +version = "0.8.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879fb705ce98c32e41ebdb970fbe1204f8492423b314c6ab0354c3e7b5542866" +checksum = "86502bf56ac7c77571a32e2647bb2a15894565e981fb2a48d7bde2d91c965a9d" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.61" +version = "0.8.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "708882a28301d604fa039cc7727607a98d04c4b86dc76ec9cc683f805d709759" +checksum = "5457206954b06561e2608c7e19cf58b1926586d999c246eebe4502f7e2039d1a" dependencies = [ "proc-macro2", "quote", @@ -3573,7 +3580,7 @@ checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" dependencies = [ "proc-macro2", "quote", - "syn 3.0.6", + "syn 3.0.7", "synstructure", ] @@ -3613,7 +3620,7 @@ checksum = "34df6fc39dbd26ddc9c10e6a2984476e13acce22e64e4487636ef494369225da" dependencies = [ "proc-macro2", "quote", - "syn 3.0.6", + "syn 3.0.7", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml @@ -5,6 +5,7 @@ members = ["depolymerizer-bitcoin", "depolymerizer-common", "uri-pack"] [workspace.package] version = "0.0.1" edition = "2024" +rust-version = "1.93" authors = ["Taler Systems SA <deb@taler.net>"] homepage = "https://taler.net/" repository = "https://git.taler.net/depolymerization.git" @@ -13,6 +14,10 @@ license-file = "LICENSE" [profile.dev] debug = true +[profile.release] +lto = "fat" +codegen-units = 1 + [workspace.dependencies] thiserror = "2.0.4" serde_json = "1.0" diff --git a/bootstrap b/bootstrap @@ -22,4 +22,4 @@ git config --local submodule.recurse true git submodule sync git submodule update --init rm -f ./configure -cp build-system/taler-build-scripts/configure ./configure -\ No newline at end of file +cp build-system/configure.py ./configure +\ No newline at end of file diff --git a/build-system/configure.py b/build-system/configure.py @@ -1,9 +1,117 @@ -# This configure.py.template file is in the public domain. +#!/usr/bin/env python3 -from talerbuildconfig import * +"""Configure the depolymerization installation prefix and Rust toolchain.""" -b = BuildConfig() -b.enable_prefix() -b.enable_configmk() -b.add_tool(PosixTool("find")) -b.run() +from __future__ import annotations + +import argparse +import os +from pathlib import Path +import re +import shutil +import subprocess +import sys + + +# Oldest Rust release that can build this tree. Keep the reason for the number +# next to it -- the point of the check is to report an unusable toolchain here, +# once, instead of as a wall of parse errors in the middle of the build. +# +# 1.85 edition 2024 / resolver "3" (Cargo.toml) +# 1.86 Vec::pop_if (common/failure-injection) +# 1.88 let chains (used throughout) +# 1.93 std::fmt::from_fn (taler-common, taler-api, taler-wise) +# +# Debian trixie ships 1.85, which is too old; trixie-backports and testing both +# ship a new enough rustc. Keep this in step with `rust-version` in Cargo.toml. +RUST_MIN_VERSION = "1.93" +BUILD_VARIABLE = re.compile(r"[A-Za-z_][A-Za-z0-9_]*=.*", re.DOTALL) + + +def version_tuple(version: str) -> tuple[int, int, int]: + parts = [int(part) for part in version.split(".")[:3]] + return tuple(parts + [0] * (3 - len(parts))) + + +def tool_version(path: str) -> str | None: + try: + output = subprocess.run( + [path, "--version"], + check=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True, + ).stdout + except (OSError, subprocess.SubprocessError): + return None + found = re.search(r"\d+(?:\.\d+)+", output) + return found.group(0) if found else None + + +def find_tool(name: str) -> tuple[str, str | None]: + requested = os.environ.get(name.upper()) or name + path = shutil.which(requested) + if path is None: + print(f"configure: error: tool '{name}' not available", file=sys.stderr) + print( + f"configure: hint: install '{name}' or point {name.upper()}= at it", + file=sys.stderr, + ) + raise SystemExit(1) + return path, tool_version(path) + + +def parse_args() -> argparse.Namespace: + parser = argparse.ArgumentParser( + usage="./configure [--prefix=DIR] [VARIABLE=VALUE]...", + description="Configure the installation prefix and Rust toolchain.", + ) + parser.add_argument("--prefix", default="/usr/local", help="installation prefix") + parser.add_argument("build_variables", nargs="*", metavar="VARIABLE=VALUE") + args = parser.parse_args() + if not args.prefix: + parser.error("installation prefix must not be empty") + for argument in args.build_variables: + if not BUILD_VARIABLE.fullmatch(argument): + parser.error(f"unrecognized argument: {argument}") + variable = argument.partition("=")[0] + print( + f"configure: WARNING: unsupported variable '{variable}' is ignored", + file=sys.stderr, + ) + return args + + +def main() -> int: + args = parse_args() + cargo_path, cargo_version = find_tool("cargo") + rustc_path, rustc_version = find_tool("rustc") + + for name, path, version in ( + ("cargo", cargo_path, cargo_version), + ("rustc", rustc_path, rustc_version), + ): + suffix = f" (version {version})" if version else "" + print(f"found {name} as {path}{suffix}") + + if rustc_version and version_tuple(rustc_version) < version_tuple(RUST_MIN_VERSION): + print( + f"configure: WARNING: rustc {rustc_version} is older than" + f" {RUST_MIN_VERSION}; this tree will not compile with it." + " On Debian stable: apt install -t trixie-backports rustc cargo", + file=sys.stderr, + ) + + config = ( + "# This makefile fragment is generated by configure.\n" + f"prefix = {args.prefix}\n" + f"cargo = {cargo_path}\n" + f"rustc = {rustc_path}\n" + ) + Path(".config.mk").write_text(config, encoding="utf-8") + print("writing .config.mk") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/build-system/taler-build-scripts b/build-system/taler-build-scripts @@ -1 +0,0 @@ -Subproject commit 884e13fe65b584f63d4cf92348fab1136af4bd69 diff --git a/contrib/ci/Containerfile b/contrib/ci/Containerfile @@ -1,13 +1,12 @@ FROM docker.io/library/debian:trixie ENV DEBIAN_FRONTEND=noninteractive - + # Apt sync RUN apt-get update -yq && \ apt-get upgrade -yq && \ # Install build & test dependencies apt-get install -yq \ - rustup \ git \ python3 \ sudo \ @@ -17,8 +16,15 @@ RUN apt-get update -yq && \ debhelper \ build-essential \ git-buildpackage && \ - # Install rustup toolchain - rustup default stable + # Rust from trixie-backports: trixie itself ships 1.85, this tree needs + # >= 1.93 (std::fmt::from_fn). Backports keeps the base image -- and + # therefore the glibc the .deb is linked against -- on stable, which + # matters because the artifacts are published to a trixie repository. + echo 'deb http://deb.debian.org/debian trixie-backports main' \ + > /etc/apt/sources.list.d/backports.list && \ + apt-get update -yq && \ + apt-get install -yq -t trixie-backports rustc cargo rust-clippy && \ + rm -rf /var/lib/apt/lists/* WORKDIR /workdir diff --git a/debian/control b/debian/control @@ -6,7 +6,8 @@ Uploaders: Christian Grothoff <grothoff@gnu.org>, Florian Dold <dold@taler.net> Rules-Requires-Root: no Build-Depends: debhelper-compat (= 13), - rustup + cargo | rustup, + rustc (>= 1.93) | rustup Standards-Version: 4.7.2 Vcs-Git: https://git.taler.net/depolymerization.git Homepage: https://taler.net/ diff --git a/debian/rules b/debian/rules @@ -4,10 +4,10 @@ dh $@ --no-parallel override_dh_auto_configure: - rustup default stable + true override_dh_auto_build: - cargo build --release --bin depolymerizer-bitcoin + make build override_dh_auto_test: true diff --git a/depolymerizer-bitcoin/Cargo.toml b/depolymerizer-bitcoin/Cargo.toml @@ -3,6 +3,7 @@ name = "depolymerizer-bitcoin" description = "Bitcoin depolymerizer" license = "AGPL-3.0-or-later" version.workspace = true +rust-version.workspace = true edition.workspace = true authors.workspace = true homepage.workspace = true diff --git a/depolymerizer-bitcoin/src/bin/btc-harness.rs b/depolymerizer-bitcoin/src/bin/btc-harness.rs @@ -15,7 +15,6 @@ */ use std::{ - assert_matches, collections::BTreeSet, net::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpListener}, process::{Child, Stdio}, @@ -312,15 +311,18 @@ impl<'a> Ctx<'a> { /// Run the worker once and fail on an injected error async fn w_injected_err(&mut self) { - assert_matches!(self.run_worker().await, Err(LoopError::Injected(_))); + assert!(matches!( + self.run_worker().await, + Err(LoopError::Injected(_)) + )); } /// Run the worker once and fail on a rpc error async fn w_rpc_err(&mut self) { - assert_matches!( + assert!(matches!( self.run_worker().await, Err(LoopError::Rpc(Error::RPC { .. })) - ); + )); } async fn restart_node(&mut self, args: &[&str]) { @@ -529,10 +531,10 @@ impl<'a> Ctx<'a> { ) .await .unwrap(); - assert_matches!( + assert!(matches!( transfer.first().unwrap(), IncomingBankTransaction::Reserve { reserve_pub, .. } if *reserve_pub == key, - ); + )); } async fn expect_transfer_status(&self, id: u64, status: TransferState) { diff --git a/depolymerizer-common/Cargo.toml b/depolymerizer-common/Cargo.toml @@ -3,6 +3,7 @@ name = "depolymerizer-common" license = "GPL-3.0-or-later" version.workspace = true edition.workspace = true +rust-version.workspace = true authors.workspace = true homepage.workspace = true repository.workspace = true diff --git a/makefile b/makefile @@ -1,5 +1,11 @@ # This Makefile has been placed under the public domain --include build-system/config.mk +-include .config.mk + +# Defaults for an unconfigured tree. .config.mk is included above, so whatever +# ./configure resolved wins over these; a plain `make` without ./configure still +# works and uses whichever cargo is on $PATH. No rustup required either way. +cargo ?= cargo +prefix ?= /usr/local # Absolute DESTDIR or empty string if DESTDIR unset/empty abs_destdir=$(abspath $(DESTDIR)) @@ -13,7 +19,7 @@ all: build .PHONY: build build: - cargo build --release + $(cargo) build --release --bin depolymerizer-bitcoin .PHONY: install-files install-files: @@ -30,15 +36,15 @@ install: build install-files .PHONY: check check: install-files - cargo test + $(cargo) test .PHONY: test test: install-files - RUST_BACKTRACE=true cargo run --profile dev --bin testbench -- instrumentation + RUST_BACKTRACE=true $(cargo) run --profile dev --bin testbench -- instrumentation .PHONY: doc doc: - cargo doc + $(cargo) doc .PHONY: deb deb: @@ -55,7 +61,7 @@ fmt: .PHONY: coverage-cyclos coverage: - cargo llvm-cov clean --workspace - cargo llvm-cov test --no-clean - cargo llvm-cov run --bin btc-harness --no-clean -- logic - cargo llvm-cov report --html -\ No newline at end of file + $(cargo) llvm-cov clean --workspace + $(cargo) llvm-cov test --no-clean + $(cargo) llvm-cov run --bin btc-harness --no-clean -- logic + $(cargo) llvm-cov report --html +\ No newline at end of file diff --git a/uri-pack/Cargo.toml b/uri-pack/Cargo.toml @@ -3,6 +3,7 @@ name = "uri-pack" version = "0.1.0" license = "GPL-3.0-or-later" edition.workspace = true +rust-version.workspace = true authors.workspace = true homepage.workspace = true repository.workspace = true