Follow up work after #5791
This ticket is about actually using memoized PlutusWithContext and using all of memoization for transactions leaving the mempool.
Here is a lay down of steps necessary
- First and foremost
newtype Validated tx will be deprecated and a different type will be added as its replacement, which will contain StAnnTx, instead of arbitrary tx. Point of this is that we don't even want to leak StAnnTx as a publicly usable type family, it must remain an implementation detail:
data ValidatedTx era = ValidatedTx
{ vtStAnnTx :: !(StAnnTx TopTx era)
-- ^ State annotated transaction that went through full validation
, vtProtocolVersion :: !ProtVer
-- ^ Protocol version in which transaction was fully validated
, vtSlotNo :: !SlotNo
-- ^ Slot number in which transaction was fully validated
}
We want to record the SlotNo for book keeping, as well as for one edge case in Alonzo era, which will be mentioned later below. Protocol version will be needed to properly handle revalidation on the hard fork boundary
applyTxValidation will be responsible for creating StAnnTx and in the end producing ValidatedTx
applyValidatedTx will need to be added into ApplyTx type class. It will accept ValidatedTx era instead of plain old Tx.
applyTx and reapplyTx should have retain their previous type signature and DEPRECATED
applyTxWithFullValidation and applyTxWithReValidation need to be added as their new replacements with same type signatures, except using new ValidatedTx data type
- Alonzo era will have to retain previous weird behavior where construction of plutus context actually depends on the
SlotNo. Therefore, for AlonzoEra:
- in
applyTxValidation we will pass extended epochInfo:
mkStAnnTx (unsafeLinearExtendEpochInfo slot ei) sysStart pp utxo tx
- in
applyValidatedTx we will have to guard against revalidation in a different slot number. So if vtSlotNo doesn't equal the supplied slotNo in the MempoolEnv then StAnnTx will have to be reconstructed as above.
- Alonzo era will need new definition of
LEDGERS rule, which will construct StAnnTx in the same way as in ApplyTx, using unsafeLinearExtendEpochInfo slot ei.
asatProtocolVersion and dsattProtocolVersion can be removed in favor of vtProtocolVersion
- in
applyTxWithReValidation for all eras, if major protocol version in vtProtocolVersion does not match ppProtocolVersionL . curPParamsGovStateL, then StAnnTx needs to be reconstructed from scratch.
ueUtxo can be removed from UtxosEnv
Follow up work after #5791
This ticket is about actually using memoized PlutusWithContext and using all of memoization for transactions leaving the mempool.
Here is a lay down of steps necessary
newtype Validated txwill be deprecated and a different type will be added as its replacement, which will containStAnnTx, instead of arbitrarytx. Point of this is that we don't even want to leakStAnnTxas a publicly usable type family, it must remain an implementation detail:We want to record the
SlotNofor book keeping, as well as for one edge case in Alonzo era, which will be mentioned later below. Protocol version will be needed to properly handle revalidation on the hard fork boundaryapplyTxValidationwill be responsible for creatingStAnnTxand in the end producingValidatedTxapplyValidatedTxwill need to be added intoApplyTxtype class. It will acceptValidatedTx erainstead of plain oldTx.applyTxandreapplyTxshould have retain their previous type signature andDEPRECATEDapplyTxWithFullValidationandapplyTxWithReValidationneed to be added as their new replacements with same type signatures, except using newValidatedTxdata typeSlotNo. Therefore, for AlonzoEra:applyTxValidationwe will pass extended epochInfo:applyValidatedTxwe will have to guard against revalidation in a different slot number. So ifvtSlotNodoesn't equal the suppliedslotNoin theMempoolEnvthenStAnnTxwill have to be reconstructed as above.LEDGERSrule, which will constructStAnnTxin the same way as inApplyTx, usingunsafeLinearExtendEpochInfo slot ei.asatProtocolVersionanddsattProtocolVersioncan be removed in favor ofvtProtocolVersionapplyTxWithReValidationfor all eras, if major protocol version invtProtocolVersiondoes not matchppProtocolVersionL . curPParamsGovStateL, thenStAnnTxneeds to be reconstructed from scratch.ueUtxocan be removed fromUtxosEnv