From 3b6234fb016936c472edea2727ccf2e29168225f Mon Sep 17 00:00:00 2001 From: KtorZ Date: Wed, 12 Aug 2020 08:27:03 +0200 Subject: [PATCH] =?UTF-8?q?generate=20Byron=20addresses=20for=20benchmark?= =?UTF-8?q?=20on=20RndState=20(instead=20of=20J=C3=B6rmungandr=20delegatio?= =?UTF-8?q?n=20addresses...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/core/test/bench/db/Main.hs | 42 ++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/lib/core/test/bench/db/Main.hs b/lib/core/test/bench/db/Main.hs index 62d44f914cc..1f639a62368 100644 --- a/lib/core/test/bench/db/Main.hs +++ b/lib/core/test/bench/db/Main.hs @@ -317,21 +317,24 @@ mkPool numAddrs i = mkAddressPool ourAccount defaultAddressPoolGap addrs ---------------------------------------------------------------------------- -- Wallet State (Random Scheme) Benchmarks -- + + + bgroupWriteRndState :: DBLayerBenchByron -> Benchmark bgroupWriteRndState db = bgroup "RndState" - -- #Checkpoints #Addresses - [ bRndState 1 10 - , bRndState 1 100 - , bRndState 1 1000 - , bRndState 1 10000 - , bRndState 1 100000 - , bRndState 10 1000 - , bRndState 100 1000 + -- #Checkpoints #Addresses #Pending + [ bRndState 1 10 10 + , bRndState 1 100 100 + , bRndState 1 1000 1000 + , bRndState 1 10000 10000 + , bRndState 1 100000 100000 + , bRndState 10 1000 1000 + , bRndState 100 1000 1000 ] where - bRndState n a = bench lbl $ withCleanDB db fixture (uncurry benchPutRndState) + bRndState n a p = bench lbl $ withCleanDB db fixture (uncurry benchPutRndState) where - lbl = n|+" CP x "+|a|+" addr" + lbl = n|+" CP x "+|a|+" addr x "+|p|+" pending" fixture db_ = do walletFixtureByron db_ pure cps @@ -342,7 +345,7 @@ bgroupWriteRndState db = bgroup "RndState" { hdPassphrase = dummyPassphrase , accountIndex = minBound , addresses = mkRndAddresses a i - , pendingAddresses = mempty + , pendingAddresses = mkRndAddresses p (-i) , gen = mkStdGen 42 } | i <- [1..n] @@ -360,7 +363,7 @@ mkRndAddresses mkRndAddresses numAddrs i = Map.fromList addrs where - addrs = [ force ((toEnum i, toEnum j), mkAddress i j) | j <- [1..numAddrs] ] + addrs = [ force ((toEnum i, toEnum j), mkByronAddress i j) | j <- [1..numAddrs] ] ---------------------------------------------------------------------------- -- Tx history Benchmarks @@ -790,3 +793,18 @@ mkAddress i j = -- lead to a satisfactory entropy. seed = 1459*i + 1153*j unsafeXPub = fromMaybe (error "xpubFromBytes error") . xpubFromBytes + +mkByronAddress :: Int -> Int -> Address +mkByronAddress i j = + paymentAddress @'Mainnet + (ByronKey + (unsafeXPub (B8.pack $ take 64 $ randoms g)) + (Index acctIx, Index addrIx) + (Passphrase $ BA.convert $ BS.pack $ replicate 32 0) + ) + where + -- Generate a seed using two prime numbers and a pair of index. This should + -- lead to a satisfactory entropy. + g = mkStdGen $ 1459*i + 1153*j + unsafeXPub = fromMaybe (error "xpubFromBytes error") . xpubFromBytes + [acctIx, addrIx] = take 2 $ randoms g