OpShin/opshin

Builtin Function to check integrity of Datums

nielstron opened this issue · 2 comments

Is your feature request related to a problem? Please describe.
OpShin does currently not care whether a datum is structurally intact - this is intentional because this check is extremely expensive and usually unnecessary. Other tools like PlutusTx and aiken perform the check automatically when type casting. This is not the way opshin should go.

Instead I propose a builtin function integrity_check that checks that a plutus datum has all fields and no further fields than defined in the respective PlutusData definition. This is necessary if (and only if) the datum/redeemer is going to be included in future transactions where they may cause issues for users other than the person who set the datum/redeemer. A builtin function would allow to perform the check more efficiently and remove potential sources for errors in case the function would have to be hand-written.

Describe the solution you'd like
integrity_check checks whether the constructor ID is correct and all fields are present and no further fields are present. it recursively checks this for all fields of the datum (excluding atomic types)

Describe alternatives you've considered
None

Additional context
None

Potential extension: Allow passing in parameters for maximum integer and bytestring sizes in the datum / a maximum datum size.

(excluding atomic types)

Note on this: the current implementation in #246 also checks that the atomic types have the proper type.