1
1
-- editorconfig-checker-disable-file
2
- {-# LANGUAGE GADTs #-}
3
- {-# LANGUAGE LambdaCase #-}
4
- {-# LANGUAGE RecordWildCards #-}
5
- {-# LANGUAGE TemplateHaskell #-}
6
- {-# LANGUAGE TupleSections #-}
7
- {-# LANGUAGE TypeApplications #-}
2
+ {-# LANGUAGE GADTs #-}
3
+ {-# LANGUAGE LambdaCase #-}
4
+ {-# LANGUAGE NumericUnderscores #-}
5
+ {-# LANGUAGE RecordWildCards #-}
6
+ {-# LANGUAGE TemplateHaskell #-}
7
+ {-# LANGUAGE TupleSections #-}
8
+ {-# LANGUAGE TypeApplications #-}
8
9
9
10
-- | Various analyses of events in mainnet script dumps.
10
11
-- This only deals with PlutusV1 and PlutusV2 script events because
@@ -352,6 +353,30 @@ analyseOneFile analyse eventFile = do
352
353
Just (ctx, params) -> analyse ctx params event
353
354
Nothing -> putStrLn " *** ctxV2 missing ***"
354
355
356
+
357
+ max_tx_ex_steps :: Double
358
+ max_tx_ex_steps = 10_000_000_000
359
+
360
+ max_tx_ex_mem :: Double
361
+ max_tx_ex_mem = 14_000_000
362
+
363
+ -- Print out the CPU and memory budgets of each script event. These are the costs
364
+ -- paid for by the submitters, not the actual costs consumed during execution.
365
+ -- TODO: add a version that tells us the actual execution costs.
366
+ getBudgets :: EventAnalyser
367
+ getBudgets _ctx _params ev =
368
+ let printFractions d =
369
+ let ExBudget (V2. ExCPU cpu) (V2. ExMemory mem) = dataBudget d
370
+ in printf " %15d %10.8f %15d %10.8f\n "
371
+ (fromSatInt cpu :: Int )
372
+ ((fromSatInt cpu) / max_tx_ex_steps)
373
+ (fromSatInt mem :: Int )
374
+ ((fromSatInt mem) / max_tx_ex_mem)
375
+
376
+ in case ev of
377
+ PlutusV1Event evdata _expected -> printFractions evdata
378
+ PlutusV2Event evdata _expected -> printFractions evdata
379
+
355
380
main :: IO ()
356
381
main =
357
382
let analyses =
@@ -375,6 +400,11 @@ main =
375
400
, " count the total number of occurrences of each builtin in validator scripts"
376
401
, countBuiltins
377
402
)
403
+ , ( " budgets"
404
+ , " print (claimed) budgets of scripts"
405
+ , putStrLn " cpu cpuFraction mem memFraction"
406
+ `thenDoAnalysis` getBudgets
407
+ )
378
408
]
379
409
380
410
doAnalysis analyser = mapM_ (analyseOneFile analyser)
0 commit comments