Skip to content

Commit

Permalink
Add 10% to the fee we're fixup up the transactions with
Browse files Browse the repository at this point in the history
in order to cover the things fixed up after the fee was fixed up
  • Loading branch information
teodanciu committed Dec 6, 2024
1 parent d33d3bc commit addc986
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ spec = describe "Invalid transactions" $ do
let scriptHash = alwaysSucceedsWithDatumHash
scriptInput <- produceScript scriptHash
(collateralHash, collateralAddr) <- freshKeyAddr
collateralInput <- sendCoinTo collateralAddr $ Coin 1_000_000
collateralInput <- sendCoinTo collateralAddr $ Coin 3_000_000
let
tx =
mkBasicTx mkBasicTxBody
Expand Down Expand Up @@ -275,7 +275,7 @@ spec = describe "Invalid transactions" $ do
, mkDelegStakeTxCert cred poolId -- 1: Needs a redeemer
, mkDelegStakeTxCert cred poolId -- 2: Duplicate, ignored, no redeemer needed
]
redeemer = (Data (P.I 32), ExUnits 5000 5000)
redeemer = (Data (P.I 32), ExUnits 5000 1_000_000)
redeemers = Map.fromList [(mkCertifyingPurpose (AsIx i), redeemer) | i <- [1 .. 2]]
tx =
mkBasicTx mkBasicTxBody
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class
makeCollateralInput :: ShelleyEraImp era => ImpTestM era (TxIn (EraCrypto era))
makeCollateralInput = do
-- TODO: make more accurate
let collateral = Coin 10_000_000
let collateral = Coin 30_000_000
addr <- freshKeyAddr_
withFixup fixupTx $ sendCoinTo addr collateral

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ spec = describe "BBODY" $ do
mkTxIn :: ImpTestM era (TxIn (EraCrypto era))
mkTxIn = do
addr <- freshKeyAddr_
sendCoinTo addr (Coin 7_000_000)
sendCoinTo addr (Coin 8_000_000)

largeScript :: Maybe (Script era)
largeScript = do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ import Cardano.Ledger.BaseTypes
import Cardano.Ledger.Binary (DecCBOR, EncCBOR)
import Cardano.Ledger.Block (Block)
import Cardano.Ledger.CertState (certDStateL, dsUnifiedL)
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Coin
import Cardano.Ledger.Credential (Credential (..), StakeReference (..), credToText)
import Cardano.Ledger.Crypto (Crypto (..))
import Cardano.Ledger.Genesis (EraGenesis (..), NoGenesis (..))
Expand Down Expand Up @@ -252,6 +252,7 @@ import Data.List.NonEmpty (NonEmpty)
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import Data.Maybe (catMaybes, mapMaybe)
import Data.Ratio ((%))
import Data.Sequence.Strict (StrictSeq (..))
import qualified Data.Sequence.Strict as SSeq
import qualified Data.Set as Set
Expand Down Expand Up @@ -1010,9 +1011,10 @@ fixupFees txOriginal = impAnn "fixupFees" $ do
txNoWits = tx & bodyTxL . outputsTxBodyL %~ (:|> changeBeforeFeeTxOut)
outsBeforeFee = tx ^. bodyTxL . outputsTxBodyL
suppliedFee = txOriginal ^. bodyTxL . feeTxBodyL
fee
fee0
| suppliedFee == zero = calcMinFeeTxNativeScriptWits utxo pp txNoWits nativeScriptKeyWits
| otherwise = suppliedFee
fee = rationalToCoinViaCeiling $ coinToRational fee0 * (11 % 10)
logString "Validating change"
change <- ensureNonNegativeCoin $ changeBeforeFeeTxOut ^. coinTxOutL <-> fee
logToExpr change
Expand Down

0 comments on commit addc986

Please sign in to comment.