forked from kadena-io/chainweb-node
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInitialGasModel.hs
More file actions
77 lines (66 loc) · 2.06 KB
/
InitialGasModel.hs
File metadata and controls
77 lines (66 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE BangPatterns #-}
module Chainweb.Pact5.InitialGasModel
( InitialGasModel(..)
, pre31GasModel
, post31GasModel
, post32GasModel
-- Lenses
, feePerByte
, rawPayloadSizeFactor
, proofSizeFactor
, signatureSizeFactor
, sizePenalty
, signatureCost
) where
import Control.DeepSeq
import Pact.Core.Scheme
import Control.Lens
data InitialGasModel = InitialGasModel
{ _feePerByte :: Rational
-- ^ Base Price charged per byte
, _rawPayloadSizeFactor :: Rational
-- ^ Multiplier for the raw payload (without continuation proof) size
, _proofSizeFactor :: Rational
-- ^ Multiplier for the proof size
, _signatureSizeFactor :: Rational
-- ^ Multiplier for signatures size
, _sizePenalty :: Rational -> Rational
-- ^ Function used to compute a penalty for big transactions
, _signatureCost :: PPKScheme -> Rational
-- ^ Function used to compute a fixed amount of gas per signature
}
-- Required to be used as a rule
instance NFData InitialGasModel where
rnf (InitialGasModel {}) = ()
makeLenses ''InitialGasModel
pre31GasModel :: InitialGasModel
pre31GasModel = InitialGasModel
{ _feePerByte = 0.01
, _rawPayloadSizeFactor = 1.0
, _proofSizeFactor = 0.0
, _signatureSizeFactor = 0.0
, _sizePenalty = \x -> (x / 512) ^ (7 :: Integer)
, _signatureCost = const 0.0
}
post31GasModel :: InitialGasModel
post31GasModel = InitialGasModel
{ _feePerByte = 0.01
, _rawPayloadSizeFactor = 1.0
, _proofSizeFactor = 1.0
, _signatureSizeFactor = 0.0
, _sizePenalty = \x -> (x / 512) ^ (7 :: Integer)
, _signatureCost = const 0.0
}
post32GasModel :: InitialGasModel
post32GasModel = InitialGasModel
{ _feePerByte = 0.01
, _rawPayloadSizeFactor = 1.0
, _proofSizeFactor = 1.0
, _signatureSizeFactor = 1.0
, _sizePenalty = \x -> (x / 512) ^ (7 :: Integer)
, _signatureCost = \case
ED25519 -> 21.0 -- | Benchmarked at 52 ns
WebAuthn -> 526.0 -- | Benchmarked at 1.315 ms (worst case)
}