Plutonomicon / cardano-transaction-lib

A Purescript library for building smart contract transactions on Cardano
https://plutonomicon.github.io/cardano-transaction-lib/
MIT License
91 stars 52 forks source link

Non-determinism in tests [Meta-task] #1174

Open klntsky opened 1 year ago

klntsky commented 1 year ago

We have some sort of non-determinism in the balancer (?) that leads to errors, but only sometimes.

Let's use this issue to collect failing logs that hopefully can help us pin down the issue eventually.

Grouped by type of error:

submit call failed. Error from Ogmios: [{"valueNotConserved...

log1.txt commit, PR

Tests affected:

Could not find unspent output locked at script address

log2.txt commit PR

Test affected:

(ClientHttpError There was a problem making the request: request failed)

  Error: (ClientHttpError There was a problem making the request: request failed)
    at Object.exports.error (/home/me/c/cardano-browser-tx/output/Effect.Exception/foreign.js:8:10)
    at Object.$$throw [as throw] (/home/me/c/cardano-browser-tx/output/Effect.Exception/index.js:18:45)
    at /home/me/c/cardano-browser-tx/output/Ctl.Internal.Plutip.Server/index.js:149:57
    at /home/me/c/cardano-browser-tx/output/Data.Either/index.js:203:24
    at /home/me/c/cardano-browser-tx/output/Ctl.Internal.Plutip.Server/index.js:151:71
    at run (/home/me/c/cardano-browser-tx/output/Effect.Aff/foreign.js:278:22)
    at /home/me/c/cardano-browser-tx/output/Effect.Aff/foreign.js:348:19
    at drain (/home/me/c/cardano-browser-tx/output/Effect.Aff/foreign.js:120:9)
    at Object.enqueue (/home/me/c/cardano-browser-tx/output/Effect.Aff/foreign.js:141:11)
    at /home/me/c/cardano-browser-tx/output/Effect.Aff/foreign.js:339:27

Happens on develop, looks like all tests are affected (very low chance)

(Right unit) doesn't satisfy predicate

log3.txt PR

Test affected:

ownStakePubKeyHash: failed to convert to base address

Fixed in https://github.com/Plutonomicon/cardano-transaction-lib/commit/37d9d41e3b8377dbbe726540e8c4495c766a44c6

Error: Error: (TxOutRefWrongType

  ✗ gero:http://localhost:4008/?gero:ECDSA:

  Error: Error: (TxOutRefWrongType (TransactionInput { index: 0u, transactionId: (TransactionHash (hexToByteArrayUnsafe "3ca8852ff76537383dded28f3d65249b76b605890193ee306f7e0584b2e5d19a")) }))
    at exports.error (webpack-internal:///./output.js:2367:12)
    at Object.$$throw [as throw] (webpack-internal:///./output.js:2415:47)
    at eval (webpack-internal:///./output.js:33552:47)
    at eval (webpack-internal:///./output.js:2215:26)
    at eval (webpack-internal:///./output.js:9248:36)
    at run (webpack-internal:///./output.js:11927:24)
    at eval (webpack-internal:///./output.js:11997:21)
    at drain (webpack-internal:///./output.js:11769:11)
    at Object.enqueue (webpack-internal:///./output.js:11790:13)
    at eval (webpack-internal:///./output.js:11988:29)

wallet missing collateral in E2E

  ✗ plutip:http://localhost:4008/?plutip-nami-mock:OneShotMinting:
  Error: Error: Nami wallet missing collateral

This is normal. Please set up the collateral manually in npm run e2e-browser and save the settings with npm run e2e-pack-settings immediately after (do not re-run the test suite in between, it will overwrite the settings)

missingRequiredRedeemers (gero, E2E, Schnorr example)

  ✗ gero:http://localhost:4008/?gero:Schnorr:

  Error: Error: `submit` call failed. Error from Ogmios: [{"missingRequiredRedeemers":{"missing":[{"e444749abd19e49f4c0e78b21ad4a4fe77e323856e12fa0d4b72bacb":{"spend":{"txId":"91735ecbfb66a6df75b5b93e4f226ac99785f8a5d4512f055fb83383d4f2f313","index":0}}}]}},{"collectErrors":[{"noRedeemer":{"spend":{"txId":"91735ecbfb66a6df75b5b93e4f226ac99785f8a5d4512f055fb83383d4f2f313","index":0}}}]}]

e2e-cip-49-gero-log.txt

pb99u069 commented 1 year ago

Evaluation with additional UTxOs with native scripts gets skipped, for the moment, in this PR

uhbif19 commented 1 year ago

Looks like example of the last problem: https://ci.staging.mlabs.city/build/121841/nixlog/2

jy14898 commented 1 year ago

submit call failed. Error from Ogmios: [{"valueNotConserved... this time for Evaluation with additional UTxOs

https://ci.staging.mlabs.city/build/134166/log

makes sense

klntsky commented 1 year ago

I think the valueNotConserved + badInputs in AdditionalUtxoSet* tests happens because when we make two subsequent submit calls there's no guarantee that ogmios will see the outputs of the first transaction when we send the second one. We should probably ask upstream if it is possible to provide an additional UTxO set for submit endpoint as well, just like it is done for evaluteTx.

uhbif19 commented 1 year ago

@klntsky

https://github.com/Plutonomicon/cardano-transaction-lib/pull/1267 says it covers ClientHttpError case. If so it seems like this issue solved?

klntsky commented 1 year ago

@uhbif19 as it always is with race condition issues, remains to be seen.

uhbif19 commented 1 year ago

@klntsky I mean the PR is merged for more than a week. And as far as I understand, ClientHttpError was quite frequent in CIs. So if there were no fails for the last days, then the bug is probably fixed, no?

Luis-omega commented 1 year ago

I think I got the insights of this error:

  ✗ gero:http://localhost:4008/?gero:ECDSA:

  Error: Error: (TxOutRefWrongType (TransactionInput { index: 0u, transactionId: (TransactionHash (hexToByteArrayUnsafe "3ca8852ff76537383dded28f3d65249b76b605890193ee306f7e0584b2e5d19a")) }))
    at exports.error (webpack-internal:///./output.js:2367:12)
    at Object.$$throw [as throw] (webpack-internal:///./output.js:2415:47)
    at eval (webpack-internal:///./output.js:33552:47)
    at eval (webpack-internal:///./output.js:2215:26)
    at eval (webpack-internal:///./output.js:9248:36)
    at run (webpack-internal:///./output.js:11927:24)
    at eval (webpack-internal:///./output.js:11997:21)
    at drain (webpack-internal:///./output.js:11769:11)
    at Object.enqueue (webpack-internal:///./output.js:11790:13)
    at eval (webpack-internal:///./output.js:11988:29)

in this pr : #1326

Basically, the failure on eternl made it an error that always happens in one of the commits from the beginning, which allow me to trace the error.

Basically, the test,

Currently this make the test to bypass this error but broke the assertions.

I also got in this kind of error in Schnorr but it seems that the change solved it for this test.