From c434bccc03bd5ee85ca57ccc2bf12194836fee64 Mon Sep 17 00:00:00 2001 From: sveitser Date: Wed, 29 Jun 2022 16:43:58 +0200 Subject: [PATCH 1/4] atomicstore: 0.1.1 -> 0.1.3 --- Cargo.lock | 5 ++--- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 07de3525..12d3b168 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -605,12 +605,11 @@ checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" [[package]] name = "atomic_store" -version = "0.1.1" -source = "git+https://github.com/EspressoSystems/atomicstore.git?tag=0.1.1#e116cea2de934fd315f690d07d45b3bb7a213654" +version = "0.1.3" +source = "git+https://github.com/EspressoSystems/atomicstore.git?tag=0.1.3#9da9998dd8d92f61c5b78a8f0676d415e6fafe92" dependencies = [ "ark-serialize", "bincode", - "chrono", "glob", "serde", "snafu", diff --git a/Cargo.toml b/Cargo.toml index 17572fd7..476d005b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ tracing = "0.1.35" zeroize = "1.3" # local dependencies -atomic_store = { git = "https://github.com/EspressoSystems/atomicstore.git", tag = "0.1.1" } +atomic_store = { git = "https://github.com/EspressoSystems/atomicstore.git", tag = "0.1.3" } commit = { git = "https://github.com/EspressoSystems/commit.git", tag = "0.1.0" } key-set = { git = "https://github.com/EspressoSystems/key-set.git", tag = "0.2.3" } espresso-macros = { git = "https://github.com/EspressoSystems/espresso-macros.git", tag = "0.1.0" } From 6d19b528565581111e53b7bfa27e12aa778ee5c3 Mon Sep 17 00:00:00 2001 From: sveitser Date: Wed, 29 Jun 2022 18:39:35 +0200 Subject: [PATCH 2/4] Add flake.nix from main --- flake.lock | 111 +++++++++++++++++++++++++++++++++++++++++ flake.nix | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 252 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..0ebb66e8 --- /dev/null +++ b/flake.lock @@ -0,0 +1,111 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1652776076, + "narHash": "sha256-gzTw/v1vj4dOVbpBSJX4J0DwUR6LIyXo7/SuuTJp1kM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "04c1b180862888302ddfb2e3ad9eaa63afc60cf8", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1637014545, + "narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "bba5dcc8e0b20ab664967ad83d24d64cb64ec4f4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1653060744, + "narHash": "sha256-kfRusllRumpt33J1hPV+CeCCylCXEU7e0gn2/cIM7cY=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "dfd82985c273aac6eced03625f454b334daae2e8", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1637453606, + "narHash": "sha256-Gy6cwUswft9xqsjWxFYEnx/63/qzaFUwatcbV5GF/GQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "8afc4e543663ca0a6a4f496262cd05233737e732", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1653446633, + "narHash": "sha256-oJ1i9yaQdZb1DOqWi5qIm4HRtpT9B44NBNoULFz8q/c=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "77c13b096bdd5f39b9017f75d3b98dcc64b893e8", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..c41a05cc --- /dev/null +++ b/flake.nix @@ -0,0 +1,141 @@ +{ + description = "A devShell example"; + + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + + inputs.flake-utils.url = "github:numtide/flake-utils"; + + inputs.flake-compat.url = "github:edolstra/flake-compat"; + inputs.flake-compat.flake = false; + + inputs.rust-overlay.url = "github:oxalica/rust-overlay"; + + outputs = { self, nixpkgs, flake-utils, flake-compat, rust-overlay, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { inherit system overlays; }; + stableToolchain = pkgs.rust-bin.stable."1.59.0".minimal.override { + extensions = [ "rustfmt" "clippy" "llvm-tools-preview" "rust-src" ]; + }; + sixtyStableToolchain = pkgs.rust-bin.stable."1.60.0".minimal.override { + extensions = [ "rustfmt" "clippy" "llvm-tools-preview" "rust-src" ]; + }; + stableMuslRustToolchain = + pkgs.rust-bin.stable."1.59.0".minimal.override { + extensions = [ "rustfmt" "clippy" "llvm-tools-preview" "rust-src" ]; + targets = [ "x86_64-unknown-linux-musl" ]; + }; + rustDeps = with pkgs; + [ + pkgconfig + openssl + bash + + curl + + cargo-edit + cargo-udeps + cargo-sort + ] ++ lib.optionals stdenv.isDarwin [ + # required to compile ethers-rs + darwin.apple_sdk.frameworks.Security + darwin.apple_sdk.frameworks.CoreFoundation + + # https://github.com/NixOS/nixpkgs/issues/126182 + libiconv + ] ++ lib.optionals (stdenv.system != "aarch64-darwin") [ + cargo-watch # broken: https://github.com/NixOS/nixpkgs/issues/146349 + ]; + # nixWithFlakes allows pre v2.4 nix installations to use + # flake commands (like `nix flake update`) + nixWithFlakes = pkgs.writeShellScriptBin "nix" '' + exec ${pkgs.nixFlakes}/bin/nix --experimental-features "nix-command flakes" "$@" + ''; + cargo-llvm-cov = pkgs.rustPlatform.buildRustPackage rec { + pname = "cargo-llvm-cov"; + version = "0.3.0"; + + doCheck = false; + + buildInputs = [ pkgs.libllvm ]; + + src = builtins.fetchTarball { + url = + "https://crates.io/api/v1/crates/${pname}/${version}/download"; + sha256 = + "sha256:0iswa2cdaf2123vfc42yj9l8jx53k5jm2y51d4xqc1672hi4620l"; + }; + + cargoSha256 = "sha256-RzIkW/eytU8ZdZ18x0sGriJ2xvjVW+8hB85In12dXMg="; + meta = with pkgs.lib; { + description = "Cargo llvm cov generates code coverage via llvm."; + homepage = "https://github.com/taiki-e/cargo-llvm-cov"; + + license = with licenses; [ mit asl20 ]; + }; + }; + opensslMusl = muslPkgs.openssl.override { static = true; }; + curlMusl = (muslPkgs.pkgsStatic.curl.override { + http2Support = false; + libssh2 = muslPkgs.pkgsStatic.libssh2.dev; + zstdSupport = false; + idnSupport = false; + }).overrideAttrs (oldAttrs: + let confFlags = oldAttrs.configureFlags; + in { + configureFlags = (muslPkgs.lib.take 13 confFlags) + ++ (muslPkgs.lib.drop 14 confFlags) + ++ [ (muslPkgs.lib.withFeature true "libssh2") ]; + }); + # MUSL pkgs + muslPkgs = import nixpkgs { + localSystem = "x86_64-linux"; + crossSystem = { config = "x86_64-unknown-linux-musl"; }; + }; + muslRustDeps = with muslPkgs.pkgsStatic; [ + pkgconfig + opensslMusl.dev + opensslMusl.out + ]; + in { + devShell = pkgs.mkShell { + buildInputs = with pkgs; + [ + nixWithFlakes + nixpkgs-fmt + git + mdbook # make-doc, documentation generation + stableToolchain + ] ++ rustDeps; + + RUST_SRC_PATH = "${stableToolchain}/lib/rustlib/src/rust/library"; + RUST_BACKTRACE = 1; + RUST_LOG = "info"; + }; + devShells = { + perfShell = pkgs.mkShell { + buildInputs = with pkgs; + [ cargo-llvm-cov sixtyStableToolchain ] ++ rustDeps; + }; + staticShell = pkgs.mkShell { + shellHook = '' + export PATH=${pkgs.xdot}/bin:$PATH + ''; + DEP_CURL_STATIC = "y"; + CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER = + "${pkgs.llvmPackages_latest.lld}/bin/lld"; + RUSTFLAGS = + "-C target-feature=+crt-static -L${opensslMusl.out}/lib/ -L${curlMusl.out}/lib -L${muslPkgs.pkgsStatic.zstd.out}/lib -L${muslPkgs.pkgsStatic.libssh2}/lib -L${muslPkgs.pkgsStatic.openssl}/lib -lssh2"; + OPENSSL_STATIC = "true"; + OPENSSL_DIR = "-L${muslPkgs.pkgsStatic.openssl}"; + OPENSSL_INCLUDE_DIR = "${opensslMusl.dev}/include/"; + OPENSSL_LIB_DIR = "${opensslMusl.dev}/lib/"; + CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl"; + buildInputs = with pkgs; + [ stableMuslRustToolchain fd ] ++ muslRustDeps; + }; + }; + + }); +} From e0d6ed726fe8027d08fd247b1e3bee7988340f3a Mon Sep 17 00:00:00 2001 From: sveitser Date: Wed, 29 Jun 2022 18:47:54 +0200 Subject: [PATCH 3/4] Prune atomic store file entries --- src/persistence.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/persistence.rs b/src/persistence.rs index 96d67cba..bb9de3e9 100644 --- a/src/persistence.rs +++ b/src/persistence.rs @@ -31,6 +31,8 @@ use reef::*; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use snafu::ResultExt; +const ATOMIC_STORE_RETAINED_ENTRIES: u32 = 5; + // Serialization intermediate for the static part of a WalletState. #[derive(Deserialize, Serialize)] struct WalletStaticState<'a> { @@ -242,13 +244,16 @@ impl<'a, L: Ledger, Meta: Send + Serialize + DeserializeOwned + Clone + PartialE file_fill_size, ) .context(crate::PersistenceSnafu)?; - let dynamic_state = RollingLog::load( + let mut dynamic_state = RollingLog::load( &mut atomic_loader, adaptor.cast(), "wallet_dyn", file_fill_size, ) .context(crate::PersistenceSnafu)?; + + dynamic_state.set_retained_entries(ATOMIC_STORE_RETAINED_ENTRIES); + let assets = AppendLog::load( &mut atomic_loader, adaptor.cast(), @@ -452,6 +457,7 @@ impl<'a, L: Ledger, Meta: Send + Serialize + DeserializeOwned> WalletStorage<'a, } self.store.commit_version().unwrap(); + self.dynamic_state.prune_file_entries().unwrap(); self.meta_dirty = false; self.static_dirty = false; From cc92f1d38c1907ce522183f3504fba2e715ae1f2 Mon Sep 17 00:00:00 2001 From: sveitser Date: Wed, 29 Jun 2022 16:45:57 +0200 Subject: [PATCH 4/4] Release 0.2.6 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 12d3b168..1d87854b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3450,7 +3450,7 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "seahorse" -version = "0.2.4" +version = "0.2.6" dependencies = [ "arbitrary", "arbitrary-wrappers", diff --git a/Cargo.toml b/Cargo.toml index 476d005b..ed8ba8aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "seahorse" description = "A generic cap-style cryptocurrency wallet." authors = ["Espresso Systems "] -version = "0.2.5" +version = "0.2.6" edition = "2018" license = "GPL-3.0-or-later"