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

Missing access to transaction input Datums in on-chain code #3119

Closed
mputz86 opened this issue May 5, 2021 · 2 comments
Closed

Missing access to transaction input Datums in on-chain code #3119

mputz86 opened this issue May 5, 2021 · 2 comments
Labels

Comments

@mputz86
Copy link

mputz86 commented May 5, 2021

Area

[X] Plutus Foundation Related to the GHC plugin, Haskell-to-Plutus compiler, on-chain code
[] Plutus Application Framework Related to the Plutus application backend (PAB), emulator, Plutus libraries
[] Marlowe Related to Marlowe
[] Other Any other topic (Playgrounds, etc.)

Summary

When validating a spending transaction, the Datums of the spent inputs are not available via ScriptContext.
Precisely:

  • The txOutDatumHash in the txInfoInputs (from ScriptContext) gives back a hash, so Just ...
  • But using findDatum in Plutus.V1.Ledger.Contexts returns Nothing
  • So the data was not added to txInfoData
    • Can be verified by viewing the Tx returned by submiTx...

Steps to reproduce

(see attachments for an example demonstrating the issue)

  • Build a contract which creates two UTxO with a Datum
  • Create another transaction which spends both UTxO and
  • try to access all Datum of all input UTxO via the ScriptContext

Expected behavior

  1. According to a discussion with @brunjlar (pioneer discord), all input Datum should be available per default via the ScriptContext in on-chain validation.
  2. Maybe it would be worth to update the documentation on txInfoData in TxInfo (there is none at the moment)

System info (please complete the following information):

  • OS: macOS Big Sur
  • Version: 11.2.3
  • Plutus version or commit hash: master branch, commit, 2087467

Screenshots and attachments

  • See InputTxDatumsIssue.hs for an example which
    • Reproduces the error
    • Note: Latest version of this file already applies the workaround from the next section

Additional context

  • Workaround: By using mustIncludeDatum, the Datum of the inputs can be made available to the transaction and be validated on-chain (by using the findDatum). See latest InputTxDatumsIssue.hs
@mputz86 mputz86 added the bug label May 5, 2021
ghost pushed a commit that referenced this issue May 5, 2021
@ghost
Copy link

ghost commented May 5, 2021

@mputz86 Thanks for reporting this! Especially for prodiving the repository with code. :)

You can already test the fix in 965aa32 as it will take some time to land into master.

@mputz86
Copy link
Author

mputz86 commented May 5, 2021

@ak3n Thanks for the fast fix, works like a charm 😊 👍 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant