Skip to content
Open
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
1 change: 1 addition & 0 deletions plutus-ledger-api/plutus-ledger-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ library
build-depends:
, aeson
, aeson-pretty
, array
, base >=4.9 && <5
, base16-bytestring >=1
, bytestring
Expand Down
13 changes: 9 additions & 4 deletions plutus-ledger-api/src/PlutusLedgerApi/Common/SerialisedScript.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ import Control.Monad.Except (MonadError)
import Data.ByteString.Lazy qualified as BSL
import Data.ByteString.Short
import Data.Coerce
import Data.Set as Set
import Data.Array.ST (newArray, runSTUArray, writeArray)
import Data.Array.Unboxed (UArray, (!))
import GHC.Generics
import NoThunks.Class
import Prettyprinter
Expand Down Expand Up @@ -197,10 +198,14 @@ scriptCBORDecoder
-> CBOR.Decoder s ScriptNamedDeBruijn
scriptCBORDecoder ll pv =
-- See Note [New builtins/language versions and protocol versions]
let availableBuiltins = builtinsAvailableIn ll pv
let available = builtinsAvailableIn ll pv
availableArr :: UArray DefaultFun Bool
availableArr = runSTUArray $ do
arr <- newArray (minBound, maxBound) False
mapM_ (\f -> writeArray arr f True) available
return arr
flatDecoder = UPLC.decodeProgram checkBuiltin
-- TODO: optimize this by using a better datastructure e.g. 'IntSet'
checkBuiltin f | f `Set.member` availableBuiltins = Nothing
checkBuiltin f | availableArr ! f = Nothing
checkBuiltin f =
Just $
"Builtin function "
Expand Down
Loading