IntersectMBO / IntersectMBO/plutus

Remove `PlutusTx.Builtins` and replace with `PlutusTx.Builtins.Internal` or fix the design

Open
#7,013 1 comment 1 reaction 0 assignees View on GitHub
Internal status: triaged
Dominant language
Haskell
Stars
1.6k
Forks
508
Avg merge
3d 10h
Merged PRs (30d)
22

Description

https://github.com/IntersectMBO/plutus/blob/2596b5b93c100dc9c33c2848b37155cbb8503a21/plutus-tx/src/PlutusTx/Builtins.hs#L515

The name of this module and its functions leads a reasonable developer to expect that `PlutusTx.Builtins` exposes the interfaces for invoking PlutusCore builtins.

Thus the user of this module naturally expects `unsafeDataAsList` to be the public interface for the PlutusCore builtin function `UnListData` and to have the type signature:
```haskell
unsafeDataAsList :: BuiltinData -> BuiltinList BuiltinData
```
compiling to:
```haskell
PLC.UnListData
```

Instead `unsafeDataAsList` does not correspond to a PlutusCore builtin at all. This is a standard library concept that translates a `BuiltinList` to a SOP encoded list. It compiles to a function that applies `UnDataAsList` to `BuiltinData` and then recursively traverses the `BuiltinList` and constructs an SOP encoded equivalent which it returns.

It's not just `unsafeDataAsList` a huge portion of the functions exported by `PlutusTx.Builtins` are not builtins, and are instead standard library concepts that do things that are completely unrelated to the underlying builtin.

Please rename all such functions and move them into a different module or get rid of them entirely, or if that is too much work, at-least rename them so they don't have identical names to the ones exposed by `PlutusTx.Builtins.Internal` and entirely different behavior. The only thing this public module should be doing is calling `fromOpaque`/`toOpaque` on simple types for which it translates to a no-op (ie. for `Integer` to or `Bool`) and then directly calling the underlying builtin. It should not be using `fromOpaque` / `toOpaque` on containers like list, pair or map, where it translates to a recursive function or other work that is not just directly converting the type to call the underlying builtin.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.