Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #219 from EspressoSystems/mathis-atomicstore-0.1.3
Browse files Browse the repository at this point in the history
Release 0.2.6
  • Loading branch information
sveitser authored Jun 30, 2022
2 parents 613d1e6 + cc92f1d commit 9c99d79
Show file tree
Hide file tree
Showing 5 changed files with 264 additions and 7 deletions.
7 changes: 3 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "seahorse"
description = "A generic cap-style cryptocurrency wallet."
authors = ["Espresso Systems <[email protected]>"]
version = "0.2.5"
version = "0.2.6"
edition = "2018"
license = "GPL-3.0-or-later"

Expand Down Expand Up @@ -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" }
Expand Down
111 changes: 111 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

141 changes: 141 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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;
};
};

});
}
8 changes: 7 additions & 1 deletion src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9c99d79

Please sign in to comment.