Skip to content

Commit

Permalink
increase the maximum address pool gap to 100 000
Browse files Browse the repository at this point in the history
  This is probably _unsound_ and will revert if it turns out to be a bad experiment.
  • Loading branch information
KtorZ committed Aug 24, 2020
1 parent 90c1e59 commit b418744
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ spec = do
c `shouldBe` ExitFailure 1
e `shouldContain`
"option --address-pool-gap: An address pool gap must be a\
\ natural number between 10 and 100."
\ natural number between 10 and 100000."
o `shouldBe` mempty

emptyWalletFromPubKeyViaCLI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TupleSections #-}
Expand Down Expand Up @@ -152,7 +153,7 @@ instance ToText (AddressPoolGap) where

instance Bounded AddressPoolGap where
minBound = AddressPoolGap 10
maxBound = AddressPoolGap 100
maxBound = AddressPoolGap 100_000

instance Enum AddressPoolGap where
fromEnum (AddressPoolGap g) = fromEnum g
Expand Down
22 changes: 7 additions & 15 deletions lib/core/test/unit/Cardano/Wallet/Api/Malformed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -556,55 +556,47 @@ instance Malformed (BodyParam WalletOrAccountPostData) where
, "passphrase" : #{wPassphrase}
, "address_pool_gap" : 0
}|]
, "Error in $['address_pool_gap']: An address pool gap must be a natural number between 10 and 100."
, "Error in $['address_pool_gap']: An address pool gap must be a natural number between 10 and 100000."
)
, ( [aesonQQ|
{ "name": #{wName}
, "mnemonic_sentence": #{mnemonics15}
, "passphrase" : #{wPassphrase}
, "address_pool_gap" : -1000
}|]
, "Error in $['address_pool_gap']: An address pool gap must be a natural number between 10 and 100."
, "Error in $['address_pool_gap']: An address pool gap must be a natural number between 10 and 100000."
)
, ( [aesonQQ|
{ "name": #{wName}
, "mnemonic_sentence": #{mnemonics15}
, "passphrase" : #{wPassphrase}
, "address_pool_gap" : -132323000
}|]
, "Error in $['address_pool_gap']: An address pool gap must be a natural number between 10 and 100."
, "Error in $['address_pool_gap']: An address pool gap must be a natural number between 10 and 100000."
)
, ( [aesonQQ|
{ "name": #{wName}
, "mnemonic_sentence": #{mnemonics15}
, "passphrase" : #{wPassphrase}
, "address_pool_gap" : 9
}|]
, "Error in $['address_pool_gap']: An address pool gap must be a natural number between 10 and 100."
, "Error in $['address_pool_gap']: An address pool gap must be a natural number between 10 and 100000."
)
, ( [aesonQQ|
{ "name": #{wName}
, "mnemonic_sentence": #{mnemonics15}
, "passphrase" : #{wPassphrase}
, "address_pool_gap" : 101
, "address_pool_gap" : 100001
}|]
, "Error in $['address_pool_gap']: An address pool gap must be a natural number between 10 and 100."
)
, ( [aesonQQ|
{ "name": #{wName}
, "mnemonic_sentence": #{mnemonics15}
, "passphrase" : #{wPassphrase}
, "address_pool_gap" : 1000
}|]
, "Error in $['address_pool_gap']: An address pool gap must be a natural number between 10 and 100."
, "Error in $['address_pool_gap']: An address pool gap must be a natural number between 10 and 100000."
)
, ( [aesonQQ|
{ "name": #{wName}
, "mnemonic_sentence": #{mnemonics15}
, "passphrase" : #{wPassphrase}
, "address_pool_gap" : 132323000
}|]
, "Error in $['address_pool_gap']: An address pool gap must be a natural number between 10 and 100."
, "Error in $['address_pool_gap']: An address pool gap must be a natural number between 10 and 100000."
)
-- passphrase
, ( [aesonQQ|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import Cardano.Wallet.Primitive.AddressDiscovery.Sequential
, mkAddressPoolGap
, mkSeqStateFromAccountXPub
, mkSeqStateFromRootXPrv
, mkUnboundedAddressPoolGap
, shrinkPool
)
import Cardano.Wallet.Primitive.Types
Expand Down Expand Up @@ -166,15 +167,15 @@ spec = do

describe "AddressPoolGap - Text Roundtrip" $ do
textRoundtrip $ Proxy @AddressPoolGap
let err = "An address pool gap must be a natural number between 10 and 100."
let err = "An address pool gap must be a natural number between 10 and 100000."
it "fail fromText @AddressPoolGap \"-10\"" $
fromText @AddressPoolGap "-10" === Left (TextDecodingError err)
it "fail fromText @AddressPoolGap \"0\"" $
fromText @AddressPoolGap "0" === Left (TextDecodingError err)
it "fail fromText @AddressPoolGap \"9\"" $
fromText @AddressPoolGap "9" === Left (TextDecodingError err)
it "fail fromText @AddressPoolGap \"101\"" $
fromText @AddressPoolGap "101" === Left (TextDecodingError err)
it "fail fromText @AddressPoolGap \"100001\"" $
fromText @AddressPoolGap "100001" === Left (TextDecodingError err)
it "fail fromText @AddressPoolGap \"20eiei\"" $
fromText @AddressPoolGap "20eiei" === Left (TextDecodingError err)
it "fail fromText @AddressPoolGap \"raczej nie\"" $
Expand Down Expand Up @@ -616,7 +617,7 @@ deriving instance Arbitrary a => Arbitrary (ShowFmt a)

instance Arbitrary AddressPoolGap where
shrink _ = []
arbitrary = arbitraryBoundedEnum
arbitrary = mkUnboundedAddressPoolGap <$> choose (10, 20)

instance Arbitrary AccountingStyle where
shrink _ = []
Expand Down
11 changes: 9 additions & 2 deletions specifications/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,17 @@ x-walletEncryptedRootPrivateKey: &walletEncryptedRootPrivateKey
maxLength: 256

x-walletAddressPoolGap: &walletAddressPoolGap
description: Number of consecutive unused addresses allowed
description: |
Number of consecutive unused addresses allowed.
**IMPORTANT DISCLAIMER:** Using values other than `20` automatically makes your wallet invalid with regards to BIP-44 address discovery. It means that you **will not** be able to fully restore
your wallet in a different software which is strictly following BIP-44.
Beside, using large gaps is **not recommended** as it may induce important performance degradations. Use at your own risks.
type: integer
minimum: 10
maximum: 100
maximum: 100000
example: 20
default: 20

Expand Down

0 comments on commit b418744

Please sign in to comment.