-
Notifications
You must be signed in to change notification settings - Fork 720
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 #5851 from IntersectMBO/bench-master
bench: PlutusV3 BLST workload; DRep injection; UTxO-HD tracing config
- Loading branch information
Showing
43 changed files
with
1,386 additions
and
567 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
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 |
---|---|---|
@@ -1,40 +1,51 @@ | ||
{-# LANGUAGE LambdaCase #-} | ||
{-# LANGUAGE RecordWildCards #-} | ||
|
||
import Cardano.Benchmarking.PlutusScripts (findPlutusScript, encodePlutusScript) | ||
import Cardano.Benchmarking.PlutusScripts | ||
|
||
import qualified Data.ByteString.Lazy as LBS (hPut) | ||
import Options.Applicative | ||
import System.Exit (die) | ||
import System.IO (IOMode(..), openFile, stdout) | ||
import Data.List (sort) | ||
import Options.Applicative | ||
import System.Exit (die) | ||
import System.IO (IOMode (..), openFile, stdout, hClose) | ||
|
||
data Options = Options | ||
{ optOut :: Maybe FilePath | ||
, optMod :: String | ||
} deriving (Eq, Read, Show) | ||
data Options = | ||
List | ||
{ optOut :: Maybe FilePath | ||
, optMod :: String | ||
} deriving (Eq, Show) | ||
|
||
opts :: Parser Options | ||
opts = Options | ||
<$> | ||
optional (strOption | ||
( long "output" | ||
<> short 'o' | ||
<> metavar "FILE" | ||
<> help "Write output to FILE" | ||
) | ||
) | ||
<*> | ||
strArgument | ||
( metavar "SCRIPT" | ||
<> help "Write SCRIPT to output" | ||
) | ||
opts = | ||
subparser $ listParser <> printParser | ||
where | ||
listParser = command "list" $ info (p <**> helper) $ progDesc "list available scripts" | ||
where p = pure List | ||
|
||
printParser = command "print" $ info (p <**> helper) $ progDesc "serialize script" | ||
where | ||
p = Print | ||
<$> optional (strOption | ||
( long "output" | ||
<> short 'o' | ||
<> metavar "FILE" | ||
<> help "Write output to FILE" | ||
)) | ||
<*> strArgument (metavar "SCRIPT" <> help "Write SCRIPT to output") | ||
|
||
pref :: ParserPrefs | ||
pref = prefs showHelpOnEmpty | ||
|
||
main :: IO () | ||
main = | ||
do | ||
Options {..} <- execParser (info opts fullDesc) | ||
main = customExecParser pref (info opts fullDesc) >>= \case | ||
List -> mapM_ putStrLn (sort listPlutusScripts) | ||
Print{..} -> do | ||
s <- case findPlutusScript optMod of | ||
Just s -> pure s | ||
Nothing -> die $ "unable to find plutus script for `" ++ optMod ++ "'" | ||
h <- case optOut of | ||
Just file -> openFile file WriteMode | ||
Nothing -> pure stdout | ||
LBS.hPut h $ encodePlutusScript s | ||
hClose h |
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
61 changes: 61 additions & 0 deletions
61
bench/plutus-scripts-bench/src/Cardano/Benchmarking/PlutusScripts/HashOntoG2AndAdd.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,61 @@ | ||
{-# LANGUAGE BangPatterns #-} | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
|
||
-- | This validator script is based on the Plutus benchmark | ||
-- 'Hash n bytestrings onto G2 and add points' | ||
-- cf. https://github.com/IntersectMBO/plutus/blob/master/plutus-benchmark/bls12-381-costs/test/9.6/bls12-381-costs.golden | ||
|
||
module Cardano.Benchmarking.PlutusScripts.HashOntoG2AndAdd (script) where | ||
|
||
import Cardano.Api.Shelley (PlutusScript (..), PlutusScriptV3, PlutusScriptVersion (..), | ||
Script (..), toScriptInAnyLang) | ||
|
||
import Cardano.Benchmarking.ScriptAPI | ||
import qualified PlutusLedgerApi.V3 as PlutusV3 | ||
|
||
import Prelude as Haskell (String, (.), (<$>)) | ||
|
||
import qualified Data.ByteString.Short as SBS | ||
import GHC.ByteOrder (ByteOrder(LittleEndian)) | ||
|
||
import Language.Haskell.TH | ||
import Language.Haskell.TH.Syntax | ||
import qualified PlutusTx | ||
import PlutusTx.Prelude as Tx hiding (Semigroup (..), (.), (<$>)) | ||
|
||
|
||
scriptName :: Haskell.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 red _txContext = | ||
case PlutusV3.fromBuiltinData red of | ||
Nothing -> Tx.traceError "invalid redeemer" | ||
Just (n, l) -> | ||
if n < (1000000 :: Integer) -- large number ensures same bitsize for all counter values | ||
then traceError "redeemer is < 1000000" | ||
else loop n l | ||
where | ||
hashAndAddG2 :: [BuiltinByteString] -> Integer -> BuiltinBLS12_381_G2_Element | ||
hashAndAddG2 l i = | ||
go l (Tx.bls12_381_G2_uncompress Tx.bls12_381_G2_compressed_zero) | ||
where go [] !acc = acc | ||
go (q:qs) !acc = go qs $ Tx.bls12_381_G2_add (Tx.bls12_381_G2_hashToGroup q (integerToByteString LittleEndian 0 i)) acc | ||
loop i l | ||
| i == 1000000 = () | ||
| otherwise = let !_ = hashAndAddG2 l i in loop (pred i) l | ||
|
||
hashAndAddG2ShortBs :: SBS.ShortByteString | ||
hashAndAddG2ShortBs = PlutusV3.serialiseCompiledCode $$(PlutusTx.compile [|| mkValidator ||]) | ||
|
||
scriptSerialized :: PlutusScript PlutusScriptV3 | ||
scriptSerialized = PlutusScriptSerialised hashAndAddG2ShortBs |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"constructor": 0, | ||
"fields": [ | ||
{ | ||
"int": 1000000 | ||
}, | ||
{ | ||
"bytes": "0392d7b94bc6a11c335a043ee1ff326b6eacee6230d3685861cd62bce350a172e0" | ||
}, | ||
{ | ||
"bytes": "16e0bf1f85594a11e75030981c0b670370b3ad83a43f49ae58a2fd6f6513cde9" | ||
}, | ||
{ | ||
"bytes": "5fb12954b28be6456feb080cfb8467b6f5677f62eb9ad231de7a575f4b6857512754fb5ef7e0e60e270832e7bb0e2f0dc271012fa9c46c02504aa0e798be6295" | ||
} | ||
] | ||
} |
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,24 @@ | ||
{ | ||
"constructor": 0, | ||
"fields": [ | ||
{ | ||
"int": 1000000 | ||
}, | ||
{ | ||
"list": [ | ||
{ | ||
"bytes": "714805c6" | ||
}, | ||
{ | ||
"bytes": "c413111e" | ||
}, | ||
{ | ||
"bytes": "2d7eb870" | ||
}, | ||
{ | ||
"bytes": "4ecbd6a1" | ||
} | ||
] | ||
} | ||
] | ||
} |
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,3 @@ | ||
{ | ||
"int": 1000000 | ||
} |
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,3 @@ | ||
{ | ||
"int": 1000000 | ||
} |
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,3 @@ | ||
{ | ||
"int": 1000000 | ||
} |
17 changes: 17 additions & 0 deletions
17
bench/tx-generator/data/SchnorrSecp256k1Loop.redeemer.json
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,17 @@ | ||
{ | ||
"constructor": 0, | ||
"fields": [ | ||
{ | ||
"int": 1000000 | ||
}, | ||
{ | ||
"bytes": "599de3e582e2a3779208a210dfeae8f330b9af00a47a7fb22e9bb8ef596f301b" | ||
}, | ||
{ | ||
"bytes": "30303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030" | ||
}, | ||
{ | ||
"bytes": "5a56da88e6fd8419181dec4d3dd6997bab953d2fc71ab65e23cfc9e7e3d1a310613454a60f6703819a39fdac2a410a094442afd1fc083354443e8d8bb4461a9b" | ||
} | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.