diff --git a/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs b/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs index a2d0ea18515..cdc4421eb00 100644 --- a/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs +++ b/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs @@ -215,7 +215,6 @@ import Cardano.Wallet.Transaction , WitnessCount (..) , WitnessCountCtx (..) , mapTxFeeAndChange - , withdrawalToCoin ) import Cardano.Wallet.TxWitnessTag ( TxWitnessTag (..), TxWitnessTagFor (..) ) @@ -1433,7 +1432,6 @@ txConstraints protocolParams witnessTag = TxConstraints data TxSkeleton = TxSkeleton { txMetadata :: !(Maybe TxMetadata) , txDelegationAction :: !(Maybe DelegationAction) - , txRewardWithdrawal :: !Coin , txWitnessTag :: !TxWitnessTag , txInputCount :: !Int , txOutputs :: ![TxOut] @@ -1453,7 +1451,6 @@ emptyTxSkeleton :: TxWitnessTag -> TxSkeleton emptyTxSkeleton txWitnessTag = TxSkeleton { txMetadata = Nothing , txDelegationAction = Nothing - , txRewardWithdrawal = Coin 0 , txWitnessTag , txInputCount = 0 , txOutputs = [] @@ -1476,7 +1473,6 @@ mkTxSkeleton mkTxSkeleton witness context skeleton = TxSkeleton { txMetadata = view #txMetadata context , txDelegationAction = view #txDelegationAction context - , txRewardWithdrawal = withdrawalToCoin $ view #txWithdrawal context , txWitnessTag = witness , txInputCount = view #skeletonInputCount skeleton , txOutputs = view #skeletonOutputs skeleton @@ -1721,7 +1717,6 @@ estimateTxSize skeleton = TxSkeleton { txMetadata , txDelegationAction - , txRewardWithdrawal , txWitnessTag , txInputCount , txOutputs @@ -1737,9 +1732,6 @@ estimateTxSize skeleton = numberOf_CertificateSignatures = maybe 0 (const 1) txDelegationAction - numberOf_Withdrawals - = if txRewardWithdrawal > Coin 0 then 1 else 0 - -- Total number of signatures the scripts require numberOf_MintingWitnesses = intCast $ sumVia estimateMaxWitnessRequiredPerInput txMintOrBurnScripts @@ -1753,12 +1745,10 @@ estimateTxSize skeleton = TxWitnessShelleyUTxO -> if numberOf_ScriptVkeyWitnesses == 0 then numberOf_Inputs - + numberOf_Withdrawals + numberOf_CertificateSignatures + numberOf_MintingWitnesses else (numberOf_Inputs * numberOf_ScriptVkeyWitnesses) - + numberOf_Withdrawals + numberOf_CertificateSignatures + numberOf_MintingWitnesses @@ -1797,7 +1787,6 @@ estimateTxSize skeleton = + sizeOf_Fee + sizeOf_Ttl + sizeOf_Certificates - + sizeOf_Withdrawals + sizeOf_Update + sizeOf_MetadataHash + sizeOf_ValidityIntervalStart @@ -1845,13 +1834,6 @@ estimateTxSize skeleton = + sizeOf_SmallArray + sizeOf_StakeDeregistration - -- ?5 => withdrawals - sizeOf_Withdrawals - = (if numberOf_Withdrawals > 0 - then sizeOf_SmallUInt + sizeOf_SmallMap - else 0) - + intCast sizeOfSignedWithdrawal * numberOf_Withdrawals - -- ?6 => update sizeOf_Update = 0 -- Assuming no updates is running through cardano-wallet diff --git a/lib/wallet/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs b/lib/wallet/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs index 7b2cece68b8..db26b7746ff 100644 --- a/lib/wallet/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs +++ b/lib/wallet/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs @@ -343,7 +343,7 @@ import Data.Quantity import Data.Ratio ( (%) ) import Data.Semigroup - ( Sum (Sum), getSum, mtimesDefault ) + ( Sum (Sum), getSum ) import Data.Set ( Set ) import Data.Text @@ -1747,8 +1747,6 @@ binaryCalculationsSpec' era = describe ("calculateBinary - "+||era||+"") $ do transactionConstraintsSpec :: Spec transactionConstraintsSpec = describe "Transaction constraints" $ do it "size of empty transaction" prop_txConstraints_txBaseSize - it "size of non-empty transaction" $ - property prop_txConstraints_txSize it "maximum size of output" $ property prop_txConstraints_txOutputMaximumSize @@ -2070,34 +2068,6 @@ prop_txConstraints_txBaseSize :: Property prop_txConstraints_txBaseSize = txBaseSize mockTxConstraints === estimateTxSize emptyTxSkeleton --- Tests that using 'txConstraints' to estimate the size of a non-empty --- selection produces a result that is consistent with the result of using --- 'estimateTxSize'. --- -prop_txConstraints_txSize :: MockSelection -> Property -prop_txConstraints_txSize mock = - counterexample ("result: " <> show result) $ - counterexample ("lower bound: " <> show lowerBound) $ - counterexample ("upper bound: " <> show upperBound) $ - conjoin - [ result >= lowerBound - , result <= upperBound - ] - where - MockSelection {txInputCount, txOutputs, txRewardWithdrawal} = mock - result :: TxSize - result = mconcat - [ txBaseSize mockTxConstraints - , txInputCount `mtimesDefault` txInputSize mockTxConstraints - , F.foldMap (txOutputSize mockTxConstraints . tokens) txOutputs - , txRewardWithdrawalSize mockTxConstraints txRewardWithdrawal - ] - lowerBound = estimateTxSize emptyTxSkeleton - {txInputCount, txOutputs, txRewardWithdrawal} - -- We allow a small amount of overestimation due to the slight variation in - -- the marginal size of an input: - upperBound = lowerBound <> txInputCount `mtimesDefault` TxSize 4 - newtype Large a = Large { unLarge :: a } deriving (Eq, Show)