Skip to content

Commit

Permalink
extend restoration benchmarks with a special 1% random wallet
Browse files Browse the repository at this point in the history
  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.
  • Loading branch information
KtorZ committed Aug 27, 2020
1 parent b35d737 commit 793de1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 28 deletions.
10 changes: 5 additions & 5 deletions lib/core/src/Cardano/Wallet/Primitive/AddressDiscovery/Random.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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. ()
Expand Down
26 changes: 3 additions & 23 deletions lib/shelley/bench/Restore.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 793de1c

Please sign in to comment.