-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathgas_data.go
82 lines (70 loc) · 1.96 KB
/
gas_data.go
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
78
79
80
81
82
package types
const (
gasDataOffsetGasPrice = 0
gasDataOffsetDataPrice = 2
gasDataOffsetExecBuffer = 4
gasDataOffsetAmortAttCost = 6
gasDataOffsetEtherPrice = 8
gasDataOffsetMarkup = 10
gasDataSize = 12
)
// GasData is the GasData interface.
type GasData interface {
// GasPrice is the gas price for the chain (in Wei per gas unit).
GasPrice() uint16
// DataPrice is the calldata price (in Wei per byte of content).
DataPrice() uint16
// ExecBuffer is the tx fee safety buffer for message execution (in Wei).
ExecBuffer() uint16
// AmortAttCost is the amortized cost for attestation submission (in Wei).
AmortAttCost() uint16
// EtherPrice is the chain's Ether Price / Mainnet Ether Price (in BWAD).
EtherPrice() uint16
// Markup is the markup for the message execution (in BWAD).
Markup() uint16
}
type gasData struct {
gasPrice uint16
dataPrice uint16
execBuffer uint16
amortAttCost uint16
etherPrice uint16
markup uint16
}
// NewGasData creates a new gasdata.
func NewGasData(gasPrice, dataPrice, execBuffer, amortAttCost, etherPrice, markup uint16) GasData {
return &gasData{
gasPrice: gasPrice,
dataPrice: dataPrice,
execBuffer: execBuffer,
amortAttCost: amortAttCost,
etherPrice: etherPrice,
markup: markup,
}
}
func (g gasData) GasPrice() uint16 {
return g.gasPrice
}
func (g gasData) DataPrice() uint16 {
return g.dataPrice
}
func (g gasData) ExecBuffer() uint16 {
return g.execBuffer
}
func (g gasData) AmortAttCost() uint16 {
return g.amortAttCost
}
func (g gasData) EtherPrice() uint16 {
return g.etherPrice
}
func (g gasData) Markup() uint16 {
return g.markup
}
var _ GasData = gasData{}
// GasDataFromSnapGas takes the raw snapGas and returns a map keyed by domain id to the gas data of that chain
// func GasDataFromSnapGas(snapGas []*big.Int) (map[uint32]GasData, error) {
// for _, rawGasAsBigInt := range snapGas {
// rawGasAsBytes := rawGasAsBigInt.Bytes()
//
// }
//}