1

I need to make VALUES comparisons on chain.

I realized that if a use the (==) operator from Plutus it is very inefficient in matter of memory and cpu steps needed to compute. (https://github.com/input-output-hk/plutus/issues/5135)

I wrote another way of equality compare and I got better results.

But the best results I got was with the proposal here: https://github.com/input-output-hk/hydra/pull/709

The problem is that this way of comparing is UNSAFE, witch means that it only work when VALUES are NORMALIZED (always with some ADA value, sorted lists, not repeated currency symbols or token names). That is why they call it exact equality operator.

Since memory in transactions executions is so limited, I really will be happy using the UNSAFE equality on my contracts, but... I really need to understand when and how VALUES that are not normalized can end up in the on-chain validation code.

Im building the transactions and creating the VALUES they are using (the off-chain code), in React with Lucid and Cardano Serialization Lib.

Then on chain, Im taking some of the INPUT VALUES, adding or deleting tokens in them with the built in operator <>, and comparing the resulting VALUES with the VALUES in the OUTPUT UTXOS.

In summary, I need to know...

  • Could Lucid and Cardano Serialization Lib build a transaction with a VALUE that is not NORMALIZED?
  • Could the <> operator on chain des-normalize a VALUE?

Can someone put some light here for me?

I need to feel safe using this UNSAFE operations.

Thank you so much

0

Browse other questions tagged or ask your own question.