From 793de1c2def5a7cce4cfce727e1445d424368807 Mon Sep 17 00:00:00 2001 From: KtorZ Date: Wed, 26 Aug 2020 15:43:45 +0200 Subject: [PATCH] extend restoration benchmarks with a special 1% random wallet This wallet is very analogous to the existing any% wallet scheme we designed a while ago, with a subtle difference: it is built __on top of__ the 'RndState' and, as a result, does perform the same database operation and addresses management as the standard random wallets. So the benchmark results obtained from this are much closer to what an actual random wallet of the same size would look like. --- .../Primitive/AddressDiscovery/Random.hs | 10 +++---- lib/shelley/bench/Restore.hs | 26 +++---------------- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/lib/core/src/Cardano/Wallet/Primitive/AddressDiscovery/Random.hs b/lib/core/src/Cardano/Wallet/Primitive/AddressDiscovery/Random.hs index cbaf21651ea..d359c2d79e7 100644 --- a/lib/core/src/Cardano/Wallet/Primitive/AddressDiscovery/Random.hs +++ b/lib/core/src/Cardano/Wallet/Primitive/AddressDiscovery/Random.hs @@ -292,9 +292,9 @@ instance KnownAddresses (RndState n) where -- it discover addresses based on an arbitrary ratio instead of decrypting the -- derivation path. -- --- The proportion is stored as a type-level parameter so that we don't have to --- alter the database schema to store it. It simply exists and depends on the --- caller creating the wallet to define it. +-- The type parameter is expected to be a ratio (between 0 and 100) of addresses +-- we ought to simply recognize as ours. So, giving @5 means that 5% of the +-- entire address space of the network will be considered ours, picked randomly. newtype RndAnyState (network :: NetworkDiscriminant) (p :: Nat) = RndAnyState { innerState :: RndState network } deriving (Generic, Show) @@ -304,8 +304,8 @@ instance NFData (RndAnyState n p) -- | Initialize the HD random address discovery state from a root key and RNG -- seed. -- --- The type parameter is expected to be a ratio (between 0 and 100) of addresses --- we ought to simply recognize as ours. So, giving @5 means that 5% of the +-- The first argument is expected to be a ratio (between 0 and 1) of addresses +-- we ought to simply recognize as ours. So, giving .5 means that 50% of the -- entire address space of the network will be considered ours, picked randomly. mkRndAnyState :: forall (p :: Nat) n. () diff --git a/lib/shelley/bench/Restore.hs b/lib/shelley/bench/Restore.hs index 8814e8908cd..8083538fb80 100644 --- a/lib/shelley/bench/Restore.hs +++ b/lib/shelley/bench/Restore.hs @@ -208,34 +208,14 @@ cardanoRestoreBench tr c socketFile = do "1-percent-rnd.timelog" (walletRnd $ mkRndAnyState @1)) - , bench ("restore " <> network <> " 0.1% any") - (bench_restoration @_ @ShelleyKey + , bench ("restore " <> network <> " 1% naked") + (bench_restoration @_ @IcarusKey networkProxy tr socketFile np vData - "0.1-percent-any.timelog" - (initAnyState "Benchmark 0.1% Wallet" 0.001)) - - , bench ("restore " <> network <> " 0.5% any") - (bench_restoration @_ @ShelleyKey - networkProxy - tr - socketFile - np - vData - "0.5-percent-any.timelog" - (initAnyState "Benchmark 0.5% Wallet" 0.005)) - - , bench ("restore " <> network <> " 1% any") - (bench_restoration @_ @ShelleyKey - networkProxy - tr - socketFile - np - vData - "1-percent-any.timelog" + "1-percent-naked.timelog" (initAnyState "Benchmark 1% Wallet" 0.01)) ] where