Skip to content

Commit

Permalink
Merge #2050
Browse files Browse the repository at this point in the history
2050: Increase the maximum address pool gap to 100 000 r=KtorZ a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

N/A

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have increased the maximum address pool gap to 100 000

# Comments

<!-- Additional comments or screenshots to attach if any -->

- NOTE 1: This was done originally when exploring options to help exchanges with large Byron wallets, discarded, but now resurrected as needed by other exchanges who wants to leverage Shelley wallets NOW. I still think that we should work on a dedicated wallet scheme for exchange, but in the meantime, this would do. 

- NOTE 2: I originally tested to restore a Shelley wallet with a gap of 100k on Mainnet, it took a bit less than 8 hours BUT, this was before we find and fix the issue with the logger so I'd like to re-conduct such test with the fix on to see. 

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Assign the PR to a corresponding milestone
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: KtorZ <[email protected]>
  • Loading branch information
iohk-bors[bot] and KtorZ authored Aug 24, 2020
2 parents 77eae59 + cd0878f commit 7697581
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 26 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 @@ -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."
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 7697581

Please sign in to comment.