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

[Plinth] [Builtins] Fix 'writeBits' #6329

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions plutus-tx-plugin/src/PlutusTx/Compiler/Builtins.hs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ builtinNames = [
, 'Builtins.head
, 'Builtins.tail
, 'Builtins.chooseList
, 'Builtins.mkNilInteger
, 'Builtins.mkNilBool
, 'Builtins.mkNilData
, 'Builtins.mkNilPairData
, 'Builtins.mkCons
Expand Down Expand Up @@ -332,6 +334,12 @@ defineBuiltinTerms = do
-- Text constant
defineBuiltinTerm annMayInline 'Builtins.emptyString $ PIR.mkConstant annMayInline ("" :: Text)

-- List constants
defineBuiltinTerm annMayInline 'Builtins.mkNilInteger $
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mkNilInteger and mkNilBool are not builtins, so defineBuiltinTerm is both a misnomer and unnecessary. How about mkNil :: DefaultUni `Contains` a => Proxy a -> BuiltinList a, and handle it in the plugin similar to && and ||?

Copy link
Contributor Author

@effectfully effectfully Jul 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm following the existing convention to a T, you can see that it's the same defineBuiltinTerm for the empty bytestring right above, I've only replicated that for the empty lists.

How about mkNil :: DefaultUni `Contains` a => Proxy a -> BuiltinList a, and handle it in the plugin similar to && and ||?

(see my other comment)

PIR.mkConstant annMayInline ([] @Integer)
defineBuiltinTerm annMayInline 'Builtins.mkNilBool $
PIR.mkConstant annMayInline ([] @Bool)

-- The next two constants are 48 bytes long, so in fact we may not want to inline them.
defineBuiltinTerm annMayInline 'Builtins.bls12_381_G1_compressed_generator $
PIR.mkConstant annMayInline BLS12_381.G1.compressed_generator
Expand Down
Loading
Loading