Skip to content

Commit

Permalink
remove now obsolete random account index override
Browse files Browse the repository at this point in the history
  This was introduced as a hotfix for the Daedalus flight release of April 2019. By now,
  we have got rid of the old cardano-sl implementation for which this was causing an issue
  and can get back to 'normal'. I also removed the associated test.
  • Loading branch information
KtorZ committed Sep 24, 2020
1 parent 3bf5038 commit 98dfd2f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 44 deletions.
17 changes: 1 addition & 16 deletions lib/core/src/Cardano/Wallet/DB/Sqlite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1668,22 +1668,7 @@ instance PersistState (Rnd.RndState t) where
pendingAddresses <- lift $ selectRndStatePending wid
pure $ Rnd.RndState
{ hdPassphrase = pwd
, accountIndex =
-- FIXME
-- In the early days when Daedalus Flight was shipped, the
-- wallet backend was generating addresses indexes across the
-- whole domain which was causing a great deal of issues with
-- the legacy cardano-sl:wallet ...
--
-- We later changed that to instead use "hardened indexes". Yet,
-- for the few wallets which were already created, we revert
-- this dynamically by replacing the index here.
--
-- This ugly hack could / should be removed eventually, in a few
-- releases from 2020-04-06.
if ix == 0
then minBound
else W.Index ix
, accountIndex = W.Index ix
, addresses = addresses
, pendingAddresses = pendingAddresses
, gen = gen
Expand Down
30 changes: 2 additions & 28 deletions lib/core/test/unit/Cardano/Wallet/DB/SqliteSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import Cardano.Wallet.DB
, cleanDB
)
import Cardano.Wallet.DB.Arbitrary
( InitialCheckpoint (..), KeyValPairs (..) )
( KeyValPairs (..) )
import Cardano.Wallet.DB.Properties
( properties, withDB )
import Cardano.Wallet.DB.Sqlite
Expand All @@ -79,8 +79,6 @@ import Cardano.Wallet.Logging
( trMessageText )
import Cardano.Wallet.Primitive.AddressDerivation
( Depth (..)
, DerivationType (..)
, Index (..)
, NetworkDiscriminant (..)
, Passphrase (..)
, PersistPrivateKey
Expand All @@ -106,7 +104,6 @@ import Cardano.Wallet.Primitive.Model
, currentTip
, getState
, initWallet
, updateState
)
import Cardano.Wallet.Primitive.Types
( ActiveSlotCoefficient (..)
Expand Down Expand Up @@ -208,7 +205,7 @@ import Test.Hspec
, xit
)
import Test.QuickCheck
( Property, arbitrary, generate, property, (==>) )
( Property, generate, property, (==>) )
import Test.QuickCheck.Monadic
( monadicIO )
import Test.Utils.Paths
Expand Down Expand Up @@ -245,33 +242,10 @@ sqliteSpecSeq = withDB newMemoryDBLayer $ do

sqliteSpecRnd :: Spec
sqliteSpecRnd = withDB newMemoryDBLayer $ do
describe "Sqlite (RndState)" $ do
it "insertState . selectState (regression account index)"
testRegressionInsertSelectRndState
describe "Sqlite State machine (RndState)" $ do
it "Sequential state machine tests"
(prop_sequential :: TestDBRnd -> Property)

testRegressionInsertSelectRndState
:: DBLayer IO (RndState 'Mainnet) ByronKey
-> IO ()
testRegressionInsertSelectRndState db = do
-- NOTE Abusing the index type here, for the sake of testing.
old <- (\s -> s { accountIndex = Index 0 }) <$> generate arbitraryRndState
wid <- generate arbitrary
cp <- getInitialCheckpoint <$> generate arbitrary
meta <- generate arbitrary

new <- db & \DBLayer{..} -> atomically $ do
unsafeRunExceptT $ initializeWallet wid cp meta mempty pp
unsafeRunExceptT $ putCheckpoint wid (updateState old cp)
(fmap getState) <$> readCheckpoint wid

(accountIndex <$> new) `shouldBe` Just (minBound :: Index 'Hardened 'AccountK)

where
arbitraryRndState = arbitrary @(RndState 'Mainnet)

testMigrationPassphraseScheme
:: forall s k. (k ~ ShelleyKey, s ~ SeqState 'Mainnet k)
=> IO ()
Expand Down

0 comments on commit 98dfd2f

Please sign in to comment.