Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plutus.Contract.Wallet.export ignores unBalancedTxValidityTimeRange info of UnbalancedTx #285

Closed
etiennejf opened this issue Jan 27, 2022 · 0 comments · Fixed by #304
Closed
Labels
bug Something isn't working

Comments

@etiennejf
Copy link
Contributor

etiennejf commented Jan 27, 2022

Summary

Function export defined in Plutus.Contract.Wallet does not update txValidRange of the transaction with unBalancedTxValidityRange before calling mkPartailTx. Script validation may therefore fail when balancing is performed using a local wallet configuration, especially when a restricted txRange is expected. To rectify this bug, export must be parameterized with SlotConfig and txValidRange must be updated as follows before the call to mkPartialTx:

let tx' = unBalancedTxTx { txValidRange = posixTimeRangeToContainedSlotRange slotConfig unBalancedTxValidityTimeRange }
    requiredSigners = fst <$> Map.toList unBalancedTxRequiredSignatories 
in
    ExportTx
        <$> mkPartialTx requiredSigners params networkId tx'
        <*> mkInputs networkId unBalancedTxUtxoIndex
        <*> mkRedeemers unBalancedTxTx

The default slotconfig should be avoided when calling export in Cardano.Wallet.LocalClient and Cardano.Wallet.RemoteClient.

Another more straight forward solution is to directly update txValidRange in mkTxConstraints, but again we need to specify the slotConfig.

This bug may also impact browser-based wallets, especially when exporting a partial tx to be balanced and signed externally.

Steps to reproduce the behavior

  1. A validator script expecting a restricted txValidityRange.
  2. Specify the corresponding off-chain code using Constraints.mustValidateIn
  3. Submit the transaction within a PAB context (e.g., via the invocation of an endpoint) using a local wallet configuration.

Actual Result

The validator script fails during balancing as txValidityRange is unspecified

Expected Result

Validator must evaluate successfully if txValidityRange is properly set.

Describe the approach you would take to fix this

See above.

A current workaround is to call mkTxConstraints and explicitly update txValidityRange of the unBalancedTx (as specified above) before calling submitUnbalancedTx.

System info

plutus-apps commit: 51da951

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant