Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Don't take collateral if validation doesn't fail in phase 2 #510

Merged

Conversation

MaximilianAlgehed
Copy link
Contributor

Pre-submit checklist:

  • Branch
    • Tests are provided (if possible)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
    • Formatting, PNG optimization, etc. are updated
  • PR
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested

@MaximilianAlgehed
Copy link
Contributor Author

@sjoerdvisscher here is a PR with that fix. I think we might need a bit of help debugging the PAB issue. Should we make an issue with this too?

@MaximilianAlgehed MaximilianAlgehed changed the title on't take collateral if validation doesn't fail in phase 2 Don't take collateral if validation doesn't fail in phase 2 Jun 10, 2022
@@ -178,8 +178,7 @@ validateTransactionOffChain t = do

idx <- vctxIndex <$> ask
pure (Nothing, insert t idx)
)
`catchError` payCollateral
) `catchError` payCollateral
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how this actually changed the result of PAB testing? Isn't this a code format change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, just saw your comment on the other PR: "because of how do and infix notation interact"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I guess I don't see the difference...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is super subtle, the old code would do catchError on the whole do-block, not just the bits in the brackets (the phase 2 validation).

@sjoerdvisscher
Copy link
Contributor

I have looked at this a bit. The problem seems to be that the test was not ok to begin with. The 3rd test does not fail if you comment out the second test. So there's some state transfer between tests. @koslambrou it seems you wrote these tests, does that sound plausible?

@koslambrou
Copy link
Contributor

koslambrou commented Jun 13, 2022

Found the error, but I don't know why your fix triggered it.

It's in the test case "PingPong contract state is maintained across PAB instances" in CliSpec.

Change

let newConfig = bumpConfig 50 "db1" pabConfig

to

 let newConfig = bumpConfig 50 "db1" defaultPabConfig

That solved it locally.

Edit:

@sjoerdvisscher Mentionned that a better solution would be let newConfig = bumpConfig 10 "db1" pabConfig so the second test runs with bumps of 50 and 60, and the third runs with bumps of 100 and 110?

P.S. I would create a commit with the fix, but I don't have permission access for your fork.

@UlfNorell UlfNorell force-pushed the PR-fix-phase2-validation-problem branch from 43babac to 7c6a1b8 Compare June 17, 2022 08:37
@UlfNorell
Copy link
Contributor

@koslambrou if the test failure is unrelated to this fix, maybe it makes more sense to fix the test in a separate PR and hold this PR until that has landed? If you want it here you can always make a PR to this branch.

@koslambrou
Copy link
Contributor

@MaximilianAlgehed The fix is on main. You can rebase.

@UlfNorell UlfNorell force-pushed the PR-fix-phase2-validation-problem branch from 7c6a1b8 to dfbb809 Compare June 20, 2022 08:39
@UlfNorell
Copy link
Contributor

@koslambrou Rebased and tests are passing.

@koslambrou koslambrou merged commit ae81022 into IntersectMBO:main Jun 20, 2022
@UlfNorell UlfNorell deleted the PR-fix-phase2-validation-problem branch June 20, 2022 11:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants