This repository was archived by the owner on Dec 2, 2024. It is now read-only.
PAB: More consistent slot configs#77
Merged
sjoerdvisscher merged 2 commits intoIntersectMBO:mainfrom Nov 8, 2021
Merged
Conversation
8 tasks
0ff7559 to
a0da9a2
Compare
a7a2068 to
7e9e0bd
Compare
7e9e0bd to
ab091b8
Compare
ab091b8 to
d44bc27
Compare
Contributor
|
@kk-hainq This fix looks good! Is it ready? |
sjoerdvisscher
approved these changes
Nov 8, 2021
Contributor
Author
|
@sjoerdvisscher It is, thanks! The recent force pushes were only rebase(s) to make sure it wouldn't break the recent major changes. |
Contributor
|
Thanks @kk-hainq! |
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR attempts to fix a misconfigured slot config issue we found while working with PAB. It started with a wrong Shelley launch time in
plutus-pab/plutus-pab.yaml.sample, which leads to weird off-chain validation errors when we usemustValidateInconstraints.The quick fix was to update the config file with the "correct" Shelley launch date, but this PR provides the general fix that removes the bug for good.
The flow starts with
mustValidateIn, which adds the validity range to theUnbalancedTx:https://github.com/input-output-hk/plutus-apps/blob/942bd8c6de6a2d5981d91c704b0258bddd9d9d7c/plutus-ledger/src/Ledger/Constraints/OffChain.hs#L505-L506
Which is eventually balanced here:
https://github.com/input-output-hk/plutus-apps/blob/942bd8c6de6a2d5981d91c704b0258bddd9d9d7c/plutus-contract/src/Wallet/Emulator/Wallet.hs#L202-L208
We can see that the original validity interval is translated to a slot range using the PAB's slot config before being set to
UnbalancedTx's internaltx's validity range.Fast forward through
validateTxAndAddFees, thenvalidateTransactionOffChain, thencheckMintingScripts, thenmkTxInfowe end up re-converting the slot range, but with the default slot config!https://github.com/input-output-hk/plutus-apps/blob/ecc528ec38f42dee056ccb072abd41a64b640425/plutus-ledger/src/Ledger/Index.hs#L396
When the PAB's slot config does not match the default, this mismatch modifies the intended validity interval, and off-chain validates the transaction with it, which effectively makes the config not configurable.
https://github.com/input-output-hk/plutus-apps/blob/f4893f8713d299020d9e6d059dd956f30c11dca1/plutus-ledger/src/Ledger/TimeSlot.hs#L54-L56
Luckily the addition of
SlotConfigto the existing API is pretty natural and matches previous works.Pre-submit checklist: