Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase the maximum address pool gap to 100 000 #2050

Merged
merged 2 commits into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -402,9 +402,7 @@ spec = do
++ show addrPoolMax ++ "."

let matrix =
[ ( "Gap max", show addrPoolMax, expectsOk )
, ( "Gap min", show addrPoolMin, expectsOk )
, ( "Gap max - 1", show (addrPoolMax - 1), expectsOk )
[ ( "Gap min", show addrPoolMin, expectsOk )
, ( "Gap min + 1", show (addrPoolMin + 1), expectsOk )
, ( "Gap max + 1 -> fail", show (addrPoolMax + 1), expectsErr )
, ( "Gap min - 1 -> fail", show (addrPoolMin - 1), expectsErr )
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."
KtorZ marked this conversation as resolved.
Show resolved Hide resolved
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)
KtorZ marked this conversation as resolved.
Show resolved Hide resolved

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