mesh icon indicating copy to clipboard operation
mesh copied to clipboard

Incorrect datum for fetchUtxos() with Koios provider

Open mpizenberg opened this issue 8 months ago • 0 comments

Summary

I was facing a missing required datum in the UPLC offline evaluator for a datum this IS present inline by value in the corresponding spent UTxO. So I’ve looked for the reason and it seems this error only happens when I use Koios as the provider for the offline evaluator:

new MeshTxBuilder({
  evaluator: new OfflineEvaluator(koios, "preview"),
  ...

If I change the provider by blockfrost inside the OfflineEvaluator constructor, then everything works.

So I’ve dig a little in the code, and it seems the faulty function is fetchUTxOs(), called inside the evaluateTx() function of offline-evaluator.ts:

...
const txHashesSet = new Set(inputsToResolve.map((input) => input.txHash));
for (const txHash of txHashesSet) {
  const utxos = await this.fetcher.fetchUTxOs(txHash);            // HERE
  for (const utxo of utxos) {
    if (utxo)
      if (
        inputsToResolve.find(
          (input) =>
            input.txHash === txHash &&
            input.outputIndex === utxo.input.outputIndex,
        )
      ) {
        additionalUtxos.push(utxo);
        foundUtxos.add(`${utxo.input.txHash}:${utxo.input.outputIndex}`);
      }
  }
}
...

Steps to reproduce the bug

Create a Tx spending a utxo with an inline datum, and use the offline evaluator, with Koios configured as a fetcher.

Actual Result

The offline uplc vm says that the inline datum does not exist.

Expected Result

The fetched and decoded utxos should contain the inline datum, so that the offline uplc vm is aware of it.

SDK version

1.9.0-beta.37 with the fix in #608

Environment type

  • [ ] Node.js
  • [x] Browser
  • [ ] Browser Extension
  • [ ] Other

Environment details

No response

mpizenberg avatar Apr 21 '25 18:04 mpizenberg