forked from okx/xlayer-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
133 lines (101 loc) · 4.84 KB
/
config.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package jsonrpc
import (
"github.com/0xPolygonHermez/zkevm-node/config/types"
"github.com/ethereum/go-ethereum/common"
)
// Config represents the configuration of the json rpc
type Config struct {
// Host defines the network adapter that will be used to serve the HTTP requests
Host string `mapstructure:"Host"`
// Port defines the port to serve the endpoints via HTTP
Port int `mapstructure:"Port"`
// ReadTimeout is the HTTP server read timeout
// check net/http.server.ReadTimeout and net/http.server.ReadHeaderTimeout
ReadTimeout types.Duration `mapstructure:"ReadTimeout"`
// WriteTimeout is the HTTP server write timeout
// check net/http.server.WriteTimeout
WriteTimeout types.Duration `mapstructure:"WriteTimeout"`
// MaxRequestsPerIPAndSecond defines how much requests a single IP can
// send within a single second
MaxRequestsPerIPAndSecond float64 `mapstructure:"MaxRequestsPerIPAndSecond"`
// SequencerNodeURI is used allow Non-Sequencer nodes
// to relay transactions to the Sequencer node
SequencerNodeURI string `mapstructure:"SequencerNodeURI"`
// MaxCumulativeGasUsed is the max gas allowed per batch
MaxCumulativeGasUsed uint64
// WebSockets configuration
WebSockets WebSocketsConfig `mapstructure:"WebSockets"`
// EnableL2SuggestedGasPricePolling enables polling of the L2 gas price to block tx in the RPC with lower gas price.
EnableL2SuggestedGasPricePolling bool `mapstructure:"EnableL2SuggestedGasPricePolling"`
// BatchRequestsEnabled defines if the Batch requests are enabled or disabled
BatchRequestsEnabled bool `mapstructure:"BatchRequestsEnabled"`
// BatchRequestsLimit defines the limit of requests that can be incorporated into each batch request
BatchRequestsLimit uint `mapstructure:"BatchRequestsLimit"`
// L2Coinbase defines which address is going to receive the fees
L2Coinbase common.Address
// MaxLogsCount is a configuration to set the max number of logs that can be returned
// in a single call to the state, if zero it means no limit
MaxLogsCount uint64 `mapstructure:"MaxLogsCount"`
// MaxLogsBlockRange is a configuration to set the max range for block number when querying TXs
// logs in a single call to the state, if zero it means no limit
MaxLogsBlockRange uint64 `mapstructure:"MaxLogsBlockRange"`
// MaxNativeBlockHashBlockRange is a configuration to set the max range for block number when querying
// native block hashes in a single call to the state, if zero it means no limit
MaxNativeBlockHashBlockRange uint64 `mapstructure:"MaxNativeBlockHashBlockRange"`
// EnableHttpLog allows the user to enable or disable the logs related to the HTTP
// requests to be captured by the server.
EnableHttpLog bool `mapstructure:"EnableHttpLog"`
// ZKCountersLimits defines the ZK Counter limits
ZKCountersLimits ZKCountersLimits
// XLayer config
// EnablePendingTransactionFilter enables pending transaction filter that can support query L2 pending transaction
EnablePendingTransactionFilter bool `mapstructure:"EnablePendingTransactionFilter"`
// Nacos configuration
Nacos NacosConfig `mapstructure:"Nacos"`
// NacosWs configuration
NacosWs NacosConfig `mapstructure:"NacosWs"`
// GasLimitFactor is used to multiply the suggested gas provided by the network
// in order to allow a enough gas to be set for all the transactions default value is 1.
//
// ex:
// suggested gas limit: 100
// GasLimitFactor: 1
// gas limit = 100
//
// suggested gas limit: 100
// GasLimitFactor: 1.1
// gas limit = 110
GasLimitFactor float64 `mapstructure:"GasLimitFactor"`
// DisableAPIs disable some API
DisableAPIs []string `mapstructure:"DisableAPIs"`
// RateLimit enable rate limit
RateLimit RateLimitConfig `mapstructure:"RateLimit"`
// DynamicGP defines the config of dynamic gas price
DynamicGP DynamicGPConfig `mapstructure:"DynamicGP"`
// EnableInnerTxCacheDB enables the inner tx cache db
EnableInnerTxCacheDB bool `mapstructure:"EnableInnerTxCacheDB"`
// BridgeAddress is the address of the bridge contract
BridgeAddress common.Address `mapstructure:"BridgeAddress"`
}
// ZKCountersLimits defines the ZK Counter limits
type ZKCountersLimits struct {
MaxKeccakHashes uint32
MaxPoseidonHashes uint32
MaxPoseidonPaddings uint32
MaxMemAligns uint32
MaxArithmetics uint32
MaxBinaries uint32
MaxSteps uint32
MaxSHA256Hashes uint32
}
// WebSocketsConfig has parameters to config the rpc websocket support
type WebSocketsConfig struct {
// Enabled defines if the WebSocket requests are enabled or disabled
Enabled bool `mapstructure:"Enabled"`
// Host defines the network adapter that will be used to serve the WS requests
Host string `mapstructure:"Host"`
// Port defines the port to serve the endpoints via WS
Port int `mapstructure:"Port"`
// ReadLimit defines the maximum size of a message read from the client (in bytes)
ReadLimit int64 `mapstructure:"ReadLimit"`
}