forked from IntersectMBO/cardano-node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request IntersectMBO#5550 from input-output-hk/nadia.chamb…
…ers/plutus-v3-tx-gen-01 tx-generator PlutusV3 testcase
- Loading branch information
Showing
11 changed files
with
849 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
bench/plutus-scripts-bench/src/Cardano/Benchmarking/PlutusScripts/LoopV3.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
|
||
module Cardano.Benchmarking.PlutusScripts.LoopV3 (script) where | ||
|
||
import Language.Haskell.TH | ||
import Language.Haskell.TH.Syntax | ||
import Prelude hiding (pred, ($), (&&), (<), (==)) | ||
|
||
import Cardano.Api.Shelley (PlutusScript (..), PlutusScriptV3, PlutusScriptVersion (..), | ||
Script (..), toScriptInAnyLang) | ||
import Cardano.Benchmarking.ScriptAPI | ||
import qualified Data.ByteString.Short as SBS | ||
|
||
import qualified PlutusLedgerApi.V3 as PlutusV3 | ||
import PlutusTx | ||
import PlutusTx.Builtins (unsafeDataAsI) | ||
import PlutusTx.Prelude hiding (Semigroup (..), unless, (.), (<$>)) | ||
|
||
|
||
scriptName :: String | ||
scriptName | ||
= prepareScriptName $(LitE . StringL . loc_module <$> qLocation) | ||
|
||
script :: PlutusBenchScript | ||
script = mkPlutusBenchScript scriptName (toScriptInAnyLang (PlutusScript PlutusScriptV3 scriptSerialized)) | ||
|
||
|
||
{-# INLINABLE mkValidator #-} | ||
mkValidator :: BuiltinData -> BuiltinData -> BuiltinData -> () | ||
mkValidator _datum redeemer _txContext | ||
= if n < 1000000 | ||
then traceError "redeemer is < 1000000" | ||
else loop n | ||
where | ||
n = unsafeDataAsI redeemer | ||
loop i = if i == 1000000 then () else loop $ pred i | ||
|
||
loopScriptShortBs :: SBS.ShortByteString | ||
loopScriptShortBs = PlutusV3.serialiseCompiledCode $$(PlutusTx.compile [|| mkValidator ||]) | ||
|
||
scriptSerialized :: PlutusScript PlutusScriptV3 | ||
scriptSerialized = PlutusScriptSerialised loopScriptShortBs |
Oops, something went wrong.