This repository has been archived by the owner on Dec 2, 2024. It is now read-only.
Non-normalized Value
s can get to the ScriptContext
when in the emulator
#671
Labels
bug
Something isn't working
Summary
IIUC, the
cardano
ledger usesData.Map
for values, hence, all the values in aScriptContext
are sorted and normalized by the time the validator gets them. It seems like the emulator doesn't perform this normalization/sorting and some library functions will actively generate "bad" values. One such example isadjustUnbalancedTx
, which usesadjustTxOut
, which in turn might return atxOut { txOutValue = txOutValue txOut <> Ada.toValue missingLovelace }
. Note how themissingLovelace
is added at the tail of the value, where it should have been added at the head or the values should be sorted to conform to how the ledger creates script contexts.This is related to:
plutus-apps
andcardano-ledger
on handling values. #604Steps to reproduce the behavior
Value
is sorted; that script is equivalent toconst True
in the actual chain.adjustUnbalancedTx
and submit it through the emulator, said script will now fail to validate.Actual Result
see above
Expected Result
The validator shouldn't be able to distinguish if it is running from the emulator or from the ledger.
Describe the approach you would take to fix this
At this point, it would be good to have a concrete list of assumptions on the invariants that the different datatypes defined by
plutus-apps
need to respect and how these should be enforced. Is it up to us to sort these off-chain? Which of those invariantsare actually a specification? Is the validator even supposed to assume that values are sorted?
System info
n/a
The text was updated successfully, but these errors were encountered: