Skip to content

Commit 28c212f

Browse files
feat: use op receiptsFetcher on BlocksReceiptsByNumbers (#12)
1 parent 1c2b151 commit 28c212f

30 files changed

+664
-505
lines changed

.github/workflows/golangci-lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
#
4343
# Note: By default, the `.golangci.yaml` file should be at the root of the repository.
4444
# The location of the configuration file can be changed by using `--config=`
45-
args: --timeout=10m --config=.golangci.yaml --allow-parallel-runners
45+
args: --timeout=10m --config=../.golangci.yaml --allow-parallel-runners
4646

4747
# Optional: show only new issues if it's a pull request. The default value is `false`.
4848
# only-new-issues: true
File renamed without changes.

go.mod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ require (
4848
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
4949
github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 // indirect
5050
github.com/fsnotify/fsnotify v1.7.0 // indirect
51+
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect
5152
github.com/getsentry/sentry-go v0.27.0 // indirect
5253
github.com/go-ole/go-ole v1.3.0 // indirect
5354
github.com/go-viper/mapstructure/v2 v2.1.0 // indirect
@@ -59,6 +60,8 @@ require (
5960
github.com/gorilla/websocket v1.5.3 // indirect
6061
github.com/hashicorp/errwrap v1.1.0 // indirect
6162
github.com/hashicorp/go-bexpr v0.1.11 // indirect
63+
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
64+
github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 // indirect
6265
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
6366
github.com/holiman/uint256 v1.3.1 // indirect
6467
github.com/huin/goupnp v1.3.0 // indirect
@@ -89,6 +92,7 @@ require (
8992
github.com/rs/cors v1.11.0 // indirect
9093
github.com/russross/blackfriday/v2 v2.1.0 // indirect
9194
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
95+
github.com/status-im/keycard-go v0.2.0 // indirect
9296
github.com/stretchr/objx v0.5.2 // indirect
9397
github.com/supranational/blst v0.3.11 // indirect
9498
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect

go.sum

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ github.com/hashicorp/go-bexpr v0.1.11 h1:6DqdA/KBjurGby9yTY0bmkathya0lfwF2SeuubC
162162
github.com/hashicorp/go-bexpr v0.1.11/go.mod h1:f03lAo0duBlDIUMGCuad8oLcgejw4m7U+N8T+6Kz1AE=
163163
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
164164
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
165-
github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo=
166165
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
167166
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
168167
github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4=

op-translator/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,11 @@ test:
3232
go test -v ./...
3333
.PHONY: test
3434

35+
lint:
36+
golangci-lint run --timeout=10m --config=../.golangci.yaml --allow-parallel-runners
37+
.PHONY: lint
38+
39+
lint-fix:
40+
golangci-lint run --timeout=10m --config=../.golangci.yaml --allow-parallel-runners --fix
41+
.PHONY: lint-fix
42+

op-translator/internal/config/config.go

Lines changed: 52 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,21 @@ var (
2828
)
2929

3030
type Config struct {
31-
settlementChainAddr string `koanf:"settlement_chain_addr"`
32-
sequencingChainAddr string `koanf:"sequencing_chain_addr"`
33-
metaBasedChainAddr string `koanf:"meta_based_chain_addr"`
34-
sequencingContractAddress string `koanf:"sequencing_contract_address"`
35-
batcherAddress string `koanf:"batcher_address"`
36-
batchInboxAddress string `koanf:"batch_inbox_address"`
37-
batcherPrivateKey string `koanf:"batcher_private_key"`
38-
logLevel string `koanf:"log_level"`
39-
settlementChainID int64 `koanf:"settlement_chain_id"`
40-
settlementStartBlock int `koanf:"settlement_start_block"`
41-
sequencingStartBlock int `koanf:"sequencing_start_block"`
42-
sequencePerSettlementBlock int `koanf:"sequence_per_settlement_block"`
43-
port int `koanf:"port"`
44-
frameSize int `koanf:"frame_size"`
45-
pretty bool `koanf:"pretty"`
46-
}
47-
48-
type IConfig interface {
49-
SettlementChainAddr() string
50-
SequencingChainAddr() string
51-
MetaBasedChainAddr() string
52-
LogLevel() string
53-
Port() int
54-
FrameSize() int
55-
Pretty() bool
56-
57-
SequencingContractAddress() string
58-
BatcherAddress() string
59-
BatchInboxAddress() string
60-
BatcherPrivateKey() string
61-
SettlementChainID() int64
62-
SettlementStartBlock() int
63-
SequencingStartBlock() int
64-
SequencePerSettlementBlock() int
31+
SettlementChainAddr string `koanf:"settlement_chain_addr"`
32+
SequencingChainAddr string `koanf:"sequencing_chain_addr"`
33+
MetaBasedChainAddr string `koanf:"meta_based_chain_addr"`
34+
SequencingContractAddress string `koanf:"sequencing_contract_address"`
35+
BatcherAddress string `koanf:"batcher_address"`
36+
BatchInboxAddress string `koanf:"batch_inbox_address"`
37+
BatcherPrivateKey string `koanf:"batcher_private_key"`
38+
LogLevel string `koanf:"log_level"`
39+
SettlementChainID int64 `koanf:"settlement_chain_id"`
40+
SettlementStartBlock int `koanf:"settlement_start_block"`
41+
SequencingStartBlock int `koanf:"sequencing_start_block"`
42+
SequencePerSettlementBlock int `koanf:"sequence_per_settlement_block"`
43+
Port int `koanf:"port"`
44+
FrameSize int `koanf:"frame_size"`
45+
Pretty bool `koanf:"pretty"`
6546
}
6647

6748
// setCLIFlags sets all valid CLI flags for the app
@@ -85,22 +66,22 @@ func setCLIFlags(f *pflag.FlagSet) {
8566

8667
// hydrateFromConfMap sets the Config values from the koanf conf map
8768
func hydrateFromConfMap(config *Config) {
88-
config.port = k.Int("port")
89-
config.settlementChainAddr = k.String("settlement_chain_addr")
90-
config.sequencingChainAddr = k.String("sequencing_chain_addr")
91-
config.metaBasedChainAddr = k.String("meta_based_chain_addr")
92-
config.frameSize = k.Int("frame_size")
93-
config.logLevel = k.String("log_level")
94-
config.pretty = k.Bool("pretty")
95-
96-
config.sequencingContractAddress = k.String("sequencing_contract_address")
97-
config.batcherAddress = k.String("batcher_address")
98-
config.batchInboxAddress = k.String("batch_inbox_address")
99-
config.settlementStartBlock = k.Int("settlement_start_block")
100-
config.sequencingStartBlock = k.Int("sequencing_start_block")
101-
config.sequencePerSettlementBlock = k.Int("sequence_per_settlement_block")
102-
config.batcherPrivateKey = k.String("batcher_private_key")
103-
config.settlementChainID = k.Int64("settlement_chain_id")
69+
config.Port = k.Int("port")
70+
config.SettlementChainAddr = k.String("settlement_chain_addr")
71+
config.SequencingChainAddr = k.String("sequencing_chain_addr")
72+
config.MetaBasedChainAddr = k.String("meta_based_chain_addr")
73+
config.FrameSize = k.Int("frame_size")
74+
config.LogLevel = k.String("log_level")
75+
config.Pretty = k.Bool("pretty")
76+
77+
config.SequencingContractAddress = k.String("sequencing_contract_address")
78+
config.BatcherAddress = k.String("batcher_address")
79+
config.BatchInboxAddress = k.String("batch_inbox_address")
80+
config.SettlementStartBlock = k.Int("settlement_start_block")
81+
config.SequencingStartBlock = k.Int("sequencing_start_block")
82+
config.SequencePerSettlementBlock = k.Int("sequence_per_settlement_block")
83+
config.BatcherPrivateKey = k.String("batcher_private_key")
84+
config.SettlementChainID = k.Int64("settlement_chain_id")
10485
}
10586

10687
func Init() *Config {
@@ -136,135 +117,75 @@ func Init() *Config {
136117
hydrateFromConfMap(&config)
137118

138119
// Validate config
139-
if err = validateConfigValues(&config); err != nil {
120+
if err = ValidateConfigValues(&config); err != nil {
140121
log.Panic().Err(err).Msg("error validating config")
141122
}
142123
return &config
143124
}
144125

145-
func validateConfigValues(config *Config) (result error) {
146-
if config.port <= 0 {
126+
func ValidateConfigValues(config *Config) (result error) {
127+
if config.Port <= 0 {
147128
result = multierror.Append(result, errors.New("port must be a positive number"))
148129
}
149130

150-
if config.frameSize <= 0 {
131+
if config.FrameSize <= 0 {
151132
result = multierror.Append(result, errors.New("frameSize must be a positive number"))
152133
}
153134

154-
if config.frameSize > MaxFrameSize {
135+
if config.FrameSize > MaxFrameSize {
155136
result = multierror.Append(result, errors.New("frameSize must be less than maximum"))
156137
}
157138

158-
_, err := url.ParseRequestURI(config.sequencingChainAddr)
139+
_, err := url.ParseRequestURI(config.SequencingChainAddr)
159140
if err != nil {
160141
result = multierror.Append(result, fmt.Errorf("invalid URL for sequencing chain address: %w", err))
161142
}
162143

163-
_, err = url.ParseRequestURI(config.settlementChainAddr)
144+
_, err = url.ParseRequestURI(config.SettlementChainAddr)
164145
if err != nil {
165146
result = multierror.Append(result, fmt.Errorf("invalid URL for settlement chain address: %w", err))
166147
}
167148

168-
_, err = url.ParseRequestURI(config.metaBasedChainAddr)
149+
_, err = url.ParseRequestURI(config.MetaBasedChainAddr)
169150
if err != nil {
170151
result = multierror.Append(result, fmt.Errorf("invalid URL for meta based chain address: %w", err))
171152
}
172153

173-
if !constants.IsValidLogLevel(config.logLevel) {
154+
if !constants.IsValidLogLevel(config.LogLevel) {
174155
result = multierror.Append(result, errors.New("invalid log level"))
175156
}
176157

177-
if !common.IsHexAddress(config.sequencingContractAddress) {
158+
if !common.IsHexAddress(config.SequencingContractAddress) {
178159
result = multierror.Append(result, errors.New("sequencingContractAddress must be a valid hex address"))
179160
}
180161

181-
if !common.IsHexAddress(config.batcherAddress) {
162+
if !common.IsHexAddress(config.BatcherAddress) {
182163
result = multierror.Append(result, errors.New("batcherAddress must be a valid hex address"))
183164
}
184165

185-
if !common.IsHexAddress(config.batchInboxAddress) {
166+
if !common.IsHexAddress(config.BatchInboxAddress) {
186167
result = multierror.Append(result, errors.New("batchInboxAddress must be a valid hex address"))
187168
}
188169

189-
if config.sequencePerSettlementBlock <= 0 {
190-
result = multierror.Append(result, fmt.Errorf("sequencePerSettlementBlock must be a positive number: %d", config.sequencePerSettlementBlock))
170+
if config.SequencePerSettlementBlock <= 0 {
171+
result = multierror.Append(result, fmt.Errorf("sequencePerSettlementBlock must be a positive number: %d", config.SequencePerSettlementBlock))
191172
}
192173

193-
if config.settlementStartBlock <= 0 {
194-
result = multierror.Append(result, fmt.Errorf("settlementStartBlock must be a positive number: %d", config.settlementStartBlock))
174+
if config.SettlementStartBlock <= 0 {
175+
result = multierror.Append(result, fmt.Errorf("settlementStartBlock must be a positive number: %d", config.SettlementStartBlock))
195176
}
196177

197-
if config.sequencingStartBlock <= 0 {
198-
result = multierror.Append(result, fmt.Errorf("sequencingStartBlock must be a positive number: %d", config.sequencingStartBlock))
178+
if config.SequencingStartBlock <= 0 {
179+
result = multierror.Append(result, fmt.Errorf("sequencingStartBlock must be a positive number: %d", config.SequencingStartBlock))
199180
}
200181

201-
if config.batcherPrivateKey == "" {
182+
if config.BatcherPrivateKey == "" {
202183
result = multierror.Append(result, fmt.Errorf("batcherPrivateKey cannot be blank"))
203184
}
204185

205-
if config.settlementChainID <= 0 {
206-
result = multierror.Append(result, fmt.Errorf("settlementChainID must be a positive number: %d", config.settlementChainID))
186+
if config.SettlementChainID <= 0 {
187+
result = multierror.Append(result, fmt.Errorf("settlementChainID must be a positive number: %d", config.SettlementChainID))
207188
}
208189

209190
return result
210191
}
211-
212-
func (c *Config) SettlementChainAddr() string {
213-
return c.settlementChainAddr
214-
}
215-
216-
func (c *Config) SequencingChainAddr() string {
217-
return c.sequencingChainAddr
218-
}
219-
220-
func (c *Config) MetaBasedChainAddr() string {
221-
return c.metaBasedChainAddr
222-
}
223-
224-
func (c *Config) Port() int {
225-
return c.port
226-
}
227-
228-
func (c *Config) FrameSize() int {
229-
return c.frameSize
230-
}
231-
232-
func (c *Config) LogLevel() string {
233-
return c.logLevel
234-
}
235-
236-
func (c *Config) Pretty() bool {
237-
return c.pretty
238-
}
239-
240-
func (c *Config) SequencingContractAddress() string {
241-
return c.sequencingContractAddress
242-
}
243-
244-
func (c *Config) BatcherAddress() string {
245-
return c.batcherAddress
246-
}
247-
248-
func (c *Config) BatchInboxAddress() string {
249-
return c.batchInboxAddress
250-
}
251-
252-
func (c *Config) SettlementStartBlock() int {
253-
return c.settlementStartBlock
254-
}
255-
256-
func (c *Config) SequencingStartBlock() int {
257-
return c.sequencingStartBlock
258-
}
259-
260-
func (c *Config) SequencePerSettlementBlock() int {
261-
return c.sequencePerSettlementBlock
262-
}
263-
264-
func (c *Config) BatcherPrivateKey() string {
265-
return c.batcherPrivateKey
266-
}
267-
268-
func (c *Config) SettlementChainID() int64 {
269-
return c.settlementChainID
270-
}

0 commit comments

Comments
 (0)