diff --git a/lib/core-integration/src/Test/Integration/Framework/DSL.hs b/lib/core-integration/src/Test/Integration/Framework/DSL.hs index 8f3d3f0e9f0..f71ea44a032 100644 --- a/lib/core-integration/src/Test/Integration/Framework/DSL.hs +++ b/lib/core-integration/src/Test/Integration/Framework/DSL.hs @@ -674,7 +674,8 @@ walletId = -- | Min UTxO parameter for the test cluster. minUTxOValue :: ApiEra -> Natural minUTxOValue e - | e >= ApiBabbage = 999_920 + | e >= ApiBabbage = 1_107_670 -- needs to be overestimated for the sake of + -- long byron addresses | e >= ApiAlonzo = 999_978 -- From 34482 lovelace per word | otherwise = 1_000_000 diff --git a/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs b/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs index 62da40a1868..e217baf18fa 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs @@ -2697,7 +2697,7 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do it "TRANS_NEW_JOIN_02 - Can join stakepool in case I have many UTxOs on 1 address" $ \ctx -> runResourceT $ do - let amt = 1_000_000 + let amt = minUTxOValue (_mainEra ctx) src <- emptyWallet ctx wa <- fixtureWallet ctx diff --git a/lib/shelley/src/Cardano/Wallet/Shelley/Compatibility.hs b/lib/shelley/src/Cardano/Wallet/Shelley/Compatibility.hs index ff34e90bce0..3afea0ccdf3 100644 --- a/lib/shelley/src/Cardano/Wallet/Shelley/Compatibility.hs +++ b/lib/shelley/src/Cardano/Wallet/Shelley/Compatibility.hs @@ -24,9 +24,6 @@ -- Jörmungandr dual support. {-# OPTIONS_GHC -fno-warn-orphans #-} --- We have to use it until 'BabbageEra' appears in 'Cardano.Api'. -{-# OPTIONS_GHC -Wno-partial-type-signatures #-} - -- | -- Copyright: © 2020 IOHK -- License: Apache-2.0 @@ -280,8 +277,6 @@ import Data.ByteString.Short ( fromShort, toShort ) import Data.Coerce ( coerce ) -import Data.Default - ( Default (..) ) import Data.Foldable ( toList ) import Data.Function @@ -918,19 +913,7 @@ fromBabbagePParams eraInfo currentNodeProtocolParameters pp = , desiredNumberOfStakePools = desiredNumberOfStakePoolsFromPParams pp , minimumUTxO = - -- FIXME [ADP-1978] need to fix for final Babbage support ⚠️ - -- - -- We unexpectedly needed to increase @maxLengthAddress@ causing - -- tests to break in Babbage. Using the Alonzo calculation even in - -- Babbage is correct enough to make the integration tests to pass - -- in Babbage, and for us to be able to merge the Babbage - -- integration cluster support to master. This is not waterproof - -- though, and we should definitely use the babbage-specific - -- calculation. - minimumUTxOForShelleyBasedEra ShelleyBasedEraAlonzo $ - def { Alonzo._coinsPerUTxOWord = - multiplyCoinBy 8 $ Babbage._coinsPerUTxOByte pp - } + minimumUTxOForShelleyBasedEra ShelleyBasedEraBabbage pp , stakeKeyDeposit = stakeKeyDepositFromPParams pp , eras = fromBoundToEpochNo <$> eraInfo , maximumCollateralInputCount = unsafeIntToWord $ @@ -941,8 +924,6 @@ fromBabbagePParams eraInfo currentNodeProtocolParameters pp = Just $ executionUnitPricesFromPParams pp , currentNodeProtocolParameters } - where - multiplyCoinBy a (SL.Coin c) = SL.Coin (a * c) -- | Extract the current network decentralization level from the given set of -- protocol parameters. diff --git a/lib/shelley/src/Cardano/Wallet/Shelley/MinimumUTxO.hs b/lib/shelley/src/Cardano/Wallet/Shelley/MinimumUTxO.hs index d911f90a3da..1dfe981f197 100644 --- a/lib/shelley/src/Cardano/Wallet/Shelley/MinimumUTxO.hs +++ b/lib/shelley/src/Cardano/Wallet/Shelley/MinimumUTxO.hs @@ -18,10 +18,10 @@ module Cardano.Wallet.Shelley.MinimumUTxO import Prelude -import Cardano.Wallet.Api.Types - ( DecodeAddress (..) ) -import Cardano.Wallet.Primitive.AddressDerivation - ( NetworkDiscriminant (..) ) +import Cardano.Wallet.Primitive.Passphrase + ( Passphrase (..) ) +import Cardano.Wallet.Primitive.Types + ( ProtocolMagic (..) ) import Cardano.Wallet.Primitive.Types.Address ( Address (..) ) import Cardano.Wallet.Primitive.Types.Coin @@ -48,6 +48,11 @@ import Numeric.Natural ( Natural ) import qualified Cardano.Api.Shelley as Cardano +import qualified Cardano.Byron.Codec.Cbor as Byron +import qualified Cardano.Crypto.Wallet as CC +import qualified Codec.CBOR.Write as CBOR +import qualified Data.ByteArray as BA +import qualified Data.ByteString as BS -- | Computes a minimum 'Coin' value for a 'TokenMap' that is destined for -- inclusion in a transaction output. @@ -145,17 +150,29 @@ embedTokenMapWithinPaddedTxOut era m = -- for inclusion in a transaction output. -- maxLengthAddress :: Address -maxLengthAddress = largeByronAddress +maxLengthAddress = longestByronAddrGeneratedByWallet where - -- FIXME: It's imperative to return the largest possible address, which is a - -- byron address. The following is /a/ large one, but not necessarily /the - -- largest/: - largeByronAddress :: Address - largeByronAddress = unsafeDecodeAddr - "DdzFFzCqrht74rkP7eNhMp9iaQ79JQZzHX6QxjoFoie4qAn5D2MESx3Rzpqtc9zX6ASEdDT\ - \hwJyqjc2kjqHMFnoUnC79GmmNCB9Vfe6a" + -- This should be the longest possible address the wallet can generate, + -- with a length of 86 bytes. (We can look at the callsites to encodeAddress + -- to confirm) + -- + -- With 4310 lovelace/byte, the minimum utxo value for a pure-ada output is + -- now 1.107670 ada (according to /v2/network/information). The largest + -- possible overestimation should be (86-29) bytes, or 0.245670 ada. + longestByronAddrGeneratedByWallet = Address + $ CBOR.toStrictByteString + $ Byron.encodeAddress xpub + [ Byron.encodeDerivationPathAttr pwd maxBound maxBound + , Byron.encodeProtocolMagicAttr (ProtocolMagic maxBound) + ] where - unsafeDecodeAddr = either (error . show) id . decodeAddress @'Mainnet + -- Must apparently always be 32 bytes + pwd :: Passphrase "addr-derivation-payload" + pwd = Passphrase $ BA.convert $ BS.replicate 32 0 + + xpub = CC.toXPub $ CC.generate (BS.replicate 32 0) xprvPass + where + xprvPass = mempty :: BS.ByteString -- | A 'Coin' value that is maximal in length when serialized to bytes. -- diff --git a/lib/shelley/test/unit/Cardano/Wallet/Shelley/MinimumUTxOSpec.hs b/lib/shelley/test/unit/Cardano/Wallet/Shelley/MinimumUTxOSpec.hs index 5823949b8ef..6a2aa90c9a5 100644 --- a/lib/shelley/test/unit/Cardano/Wallet/Shelley/MinimumUTxOSpec.hs +++ b/lib/shelley/test/unit/Cardano/Wallet/Shelley/MinimumUTxOSpec.hs @@ -134,11 +134,9 @@ spec = do goldenTests_computeMinimumCoinForUTxO "Alonzo" goldenMinimumUTxO_Alonzo goldenMinimumCoins_Alonzo - - -- FIXME [ADP-1978] Re-enable - --goldenTests_computeMinimumCoinForUTxO "Babbage" - -- goldenMinimumUTxO_Babbage - -- goldenMinimumCoins_Babbage + goldenTests_computeMinimumCoinForUTxO "Babbage" + goldenMinimumUTxO_Babbage + goldenMinimumCoins_Babbage -- Check that it's possible to evaluate 'computeMinimumCoinForUTxO' without -- any run-time error. @@ -346,9 +344,8 @@ goldenMinimumUTxO_Alonzo = minimumUTxOForShelleyBasedEra ShelleyBasedEraAlonzo def {Alonzo._coinsPerUTxOWord = testParameter_coinsPerUTxOWord_Alonzo} --- FIXME [ADP-1978] Re-enable -_goldenMinimumUTxO_Babbage :: MinimumUTxO -_goldenMinimumUTxO_Babbage = +goldenMinimumUTxO_Babbage :: MinimumUTxO +goldenMinimumUTxO_Babbage = minimumUTxOForShelleyBasedEra ShelleyBasedEraBabbage def {Babbage._coinsPerUTxOByte = testParameter_coinsPerUTxOByte_Babbage} @@ -392,9 +389,8 @@ goldenMinimumCoins_Alonzo = , (goldenTokenMap_4, Coin 1_862_028) ] --- FIXME [ADP-1978] Re-enable -_goldenMinimumCoins_Babbage :: [(TokenMap, Coin)] -_goldenMinimumCoins_Babbage = +goldenMinimumCoins_Babbage :: [(TokenMap, Coin)] +goldenMinimumCoins_Babbage = [ (goldenTokenMap_0, Coin 995_610) , (goldenTokenMap_1, Coin 1_150_770) , (goldenTokenMap_2, Coin 1_323_170)