Skip to content

Commit

Permalink
Remove unused ErrAssignRedeemersPastHorizon for now
Browse files Browse the repository at this point in the history
It seems we can no longer construct this error as the ledger no longer
returns the actual `PastHorizon`. This commit removes it, with the
intention that we can re-add it being explicitly rendered in our API
instead of being lumped under TranslationErrors. It would probably also
be nice to render all the other TranslationErrors explicitly.
  • Loading branch information
Anviking committed Jun 14, 2022
1 parent 745af3b commit 4f62922
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
2 changes: 0 additions & 2 deletions lib/core/src/Cardano/Wallet/Api/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5052,8 +5052,6 @@ instance IsServerError ErrAssignRedeemers where
, "part of the API request. The unknown inputs are:\n\n"
, pretty ins
]
ErrAssignRedeemersPastHorizon e ->
toServerError e
ErrAssignRedeemersTranslationError e ->
apiError err400 TranslationError $ T.unwords
[ "The transaction I was given contains bits that cannot "
Expand Down
2 changes: 0 additions & 2 deletions lib/core/src/Cardano/Wallet/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,6 @@ data ErrAssignRedeemers
-- ^ The given redeemer target couldn't be located in the transaction.
| ErrAssignRedeemersInvalidData Redeemer String
-- ^ Redeemer's data isn't a valid Plutus' data.
| ErrAssignRedeemersPastHorizon PastHorizonException
-- ^ Evaluating the Plutus script failed past the visible horizon.
| ErrAssignRedeemersUnresolvedTxIns [TxIn]
-- ^ The transaction contains inputs which couldn't be resolved.
| ErrAssignRedeemersTranslationError String
Expand Down
27 changes: 18 additions & 9 deletions lib/shelley/src/Cardano/Wallet/Shelley/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ import Cardano.Ledger.Era
( Crypto, Era, ValidateScript (..) )
import Cardano.Ledger.Shelley.API
( StrictMaybe (..) )
import Cardano.Slotting.EpochInfo
( EpochInfo )
import Cardano.Slotting.EpochInfo.API
( hoistEpochInfo )
import Cardano.Wallet.CoinSelection
Expand Down Expand Up @@ -208,6 +210,8 @@ import Control.Monad.Trans.State.Strict
( StateT (..), execStateT, get, modify' )
import Data.Bifunctor
( bimap )
import Data.Either
( fromRight )
import Data.Function
( (&) )
import Data.Functor
Expand Down Expand Up @@ -1170,6 +1174,20 @@ _assignScriptRedeemers pparams ti resolveInput redeemers tx =
modify' addScriptIntegrityHashBabbage
pure $ Cardano.ShelleyTx ShelleyBasedEraBabbage babbageTx'
where
epochInfo :: EpochInfo (Either T.Text)
epochInfo = hoistEpochInfo (left (T.pack . show) . runIdentity . runExceptT)
-- Because `TimeInterpreter` conflates the monad for fetching the
-- interpreter with the possibility of errors, we cope with this `error`
-- call for now. A nicer solution would be exposing either
-- `EpochInfo` or `Cardano.EraHistory` in the `NetworkLayer` directly,
-- or - perhaps at some point - reimagining the `TimeInterpreter`
-- abstraction.
$ fromRight
(error "`toEpochInfo ti` can never fail")
(toEpochInfo ti)

systemStart = getSystemStart ti

-- | Assign redeemers with null execution units to the input transaction.
--
-- Redeemers are determined from the context given to the caller via the
Expand Down Expand Up @@ -1276,11 +1294,6 @@ _assignScriptRedeemers pparams ti resolveInput redeemers tx =
let utxo = utxoFromAlonzoTx alonzoTx
let pparams' = Cardano.toLedgerPParams Cardano.ShelleyBasedEraAlonzo pparams
let costs = toCostModelsAsArray (Alonzo.unCostModels $ Alonzo._costmdls pparams')
let systemStart = getSystemStart ti

epochInfo <- hoistEpochInfo (left (T.pack . show . ErrAssignRedeemersPastHorizon) . runIdentity . runExceptT)
<$> left ErrAssignRedeemersPastHorizon (toEpochInfo ti)

let res = evaluateTransactionExecutionUnits
pparams'
alonzoTx
Expand All @@ -1305,10 +1318,6 @@ _assignScriptRedeemers pparams ti resolveInput redeemers tx =
let utxo = utxoFromBabbageTx babbageTx
let pparams' = Cardano.toLedgerPParams Cardano.ShelleyBasedEraBabbage pparams
let costs = toCostModelsAsArray (Alonzo.unCostModels $ Babbage._costmdls pparams')
let systemStart = getSystemStart ti

epochInfo <- hoistEpochInfo (left (T.pack . show . ErrAssignRedeemersPastHorizon) . runIdentity . runExceptT)
<$> left ErrAssignRedeemersPastHorizon (toEpochInfo ti)

let res = evaluateTransactionExecutionUnits
pparams'
Expand Down
2 changes: 1 addition & 1 deletion specifications/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3287,7 +3287,7 @@ components:
- new_passphrase
properties:
mnemonic_second_factor: *walletSecondFactor
mnemonic_sentence:
mnemonic_sentence:
<<: *walletMnemonicSentence
description: The mnemonic list of words to restore the wallet
new_passphrase:
Expand Down

0 comments on commit 4f62922

Please sign in to comment.