Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
166ba06b
Unverified
Commit
166ba06b
authored
Aug 19, 2023
by
Ethen Pociask
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[indexer.l1height-param] Updated mocks
parent
7eb17ec9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
35 deletions
+34
-35
config.go
indexer/config/config.go
+14
-14
mocks.go
indexer/database/mocks.go
+4
-7
etl.go
indexer/etl/etl.go
+4
-1
l1_etl_test.go
indexer/etl/l1_etl_test.go
+12
-13
No files found.
indexer/config/config.go
View file @
166ba06b
...
@@ -15,11 +15,11 @@ import (
...
@@ -15,11 +15,11 @@ import (
// Config represents the `indexer.toml` file used to configure the indexer
// Config represents the `indexer.toml` file used to configure the indexer
type
Config
struct
{
type
Config
struct
{
Chain
ChainConfig
Chain
ChainConfig
`toml:"chain"`
RPCs
RPCsConfig
`toml:"rpcs"`
RPCs
RPCsConfig
`toml:"rpcs"`
DB
DBConfig
DB
DBConfig
`toml:"db"`
API
APIConfig
API
APIConfig
`toml:"api"`
Metrics
MetricsConfig
Metrics
MetricsConfig
`toml:"metrics"`
}
}
// fetch this via onchain config from RPCsConfig and remove from config in future
// fetch this via onchain config from RPCsConfig and remove from config in future
...
@@ -78,23 +78,23 @@ type RPCsConfig struct {
...
@@ -78,23 +78,23 @@ type RPCsConfig struct {
// DBConfig configures the postgres database
// DBConfig configures the postgres database
type
DBConfig
struct
{
type
DBConfig
struct
{
Host
string
Host
string
`toml:"host"`
Port
int
Port
int
`toml:"port"`
Name
string
Name
string
`toml:"name"`
User
string
User
string
`toml:"user"`
Password
string
Password
string
`toml:"password"`
}
}
// APIConfig configures the API server
// APIConfig configures the API server
type
APIConfig
struct
{
type
APIConfig
struct
{
Host
string
Host
string
`toml:"host"`
Port
int
Port
int
`toml:"port"`
}
}
// MetricsConfig configures the metrics server
// MetricsConfig configures the metrics server
type
MetricsConfig
struct
{
type
MetricsConfig
struct
{
Host
string
Host
string
`toml:"host"`
Port
int
Port
int
`toml:"port"`
}
}
// LoadConfig loads the `indexer.toml` config file from a given path
// LoadConfig loads the `indexer.toml` config file from a given path
...
...
indexer/database/mocks.go
View file @
166ba06b
...
@@ -67,8 +67,6 @@ func (m *MockBlocksView) LatestEpoch() (*Epoch, error) {
...
@@ -67,8 +67,6 @@ func (m *MockBlocksView) LatestEpoch() (*Epoch, error) {
return
args
.
Get
(
0
)
.
(
*
Epoch
),
args
.
Error
(
1
)
return
args
.
Get
(
0
)
.
(
*
Epoch
),
args
.
Error
(
1
)
}
}
var
_
BlocksDB
=
(
*
MockBlocksDB
)(
nil
)
type
MockBlocksDB
struct
{
type
MockBlocksDB
struct
{
MockBlocksView
MockBlocksView
}
}
...
@@ -92,8 +90,8 @@ func (m *MockBlocksDB) StoreOutputProposals(headers []OutputProposal) error {
...
@@ -92,8 +90,8 @@ func (m *MockBlocksDB) StoreOutputProposals(headers []OutputProposal) error {
return
args
.
Error
(
1
)
return
args
.
Error
(
1
)
}
}
// MockDB is a mock database that can be used for testing
type
MockDB
struct
{
type
MockDB
struct
{
MockBlockView
*
MockBlocksView
MockBlocks
*
MockBlocksDB
MockBlocks
*
MockBlocksDB
DB
*
DB
DB
*
DB
}
}
...
@@ -105,6 +103,5 @@ func NewMockDB() *MockDB {
...
@@ -105,6 +103,5 @@ func NewMockDB() *MockDB {
mockBlocks
:=
new
(
MockBlocksDB
)
mockBlocks
:=
new
(
MockBlocksDB
)
db
:=
&
DB
{
Blocks
:
mockBlocks
}
db
:=
&
DB
{
Blocks
:
mockBlocks
}
return
&
MockDB
{
MockBlocks
:
mockBlocks
,
DB
:
db
,
return
&
MockDB
{
MockBlocks
:
mockBlocks
,
DB
:
db
}
MockBlockView
:
new
(
MockBlocksView
)}
}
}
indexer/etl/etl.go
View file @
166ba06b
...
@@ -14,6 +14,9 @@ import (
...
@@ -14,6 +14,9 @@ import (
)
)
const
(
const
(
// NOTE - These values can be made configurable to allow for more fine grained control
// Additionally a default interval of 5 seconds may be too slow for reading L2 blocks provided
// the current rate of L2 block production on OP Stack chains (2 seconds per block)
defaultLoopInterval
=
5
*
time
.
Second
defaultLoopInterval
=
5
*
time
.
Second
defaultHeaderBufferSize
=
500
defaultHeaderBufferSize
=
500
)
)
...
@@ -90,7 +93,7 @@ func (etl *ETL) Start(ctx context.Context) error {
...
@@ -90,7 +93,7 @@ func (etl *ETL) Start(ctx context.Context) error {
for
i
:=
range
logs
{
for
i
:=
range
logs
{
if
_
,
ok
:=
headerMap
[
logs
[
i
]
.
BlockHash
];
!
ok
{
if
_
,
ok
:=
headerMap
[
logs
[
i
]
.
BlockHash
];
!
ok
{
// NOTE. Definitely an error state if the none of the headers were re-orged out in between
// NOTE. Definitely an error state if the none of the headers were re-orged out in between
// the blocks and logs retr
ei
val operations. However, we need to gracefully handle reorgs
// the blocks and logs retr
ie
val operations. However, we need to gracefully handle reorgs
batchLog
.
Error
(
"log found with block hash not in the batch"
,
"block_hash"
,
logs
[
i
]
.
BlockHash
,
"log_index"
,
logs
[
i
]
.
Index
)
batchLog
.
Error
(
"log found with block hash not in the batch"
,
"block_hash"
,
logs
[
i
]
.
BlockHash
,
"log_index"
,
logs
[
i
]
.
Index
)
return
errors
.
New
(
"parsed log with a block hash not in the fetched batch"
)
return
errors
.
New
(
"parsed log with a block hash not in the fetched batch"
)
}
}
...
...
indexer/etl/l1_etl_test.go
View file @
166ba06b
...
@@ -16,23 +16,22 @@ import (
...
@@ -16,23 +16,22 @@ import (
"testing"
"testing"
)
)
// test suite
func
Test_L1ETL_Construction
(
t
*
testing
.
T
)
{
type
l1EtlTs
struct
{
type
testSuite
struct
{
db
*
database
.
MockDB
db
*
database
.
MockDB
client
*
node
.
MockEthClient
client
*
node
.
MockEthClient
start
*
big
.
Int
start
*
big
.
Int
contracts
config
.
L1Contracts
contracts
config
.
L1Contracts
}
}
func
Test_L1ETL_Construction
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
var
tests
=
[]
struct
{
name
string
name
string
construction
func
()
*
l1EtlTs
construction
func
()
*
testSuite
assertion
func
(
*
L1ETL
,
error
)
assertion
func
(
*
L1ETL
,
error
)
}{
}{
{
{
name
:
"Start from L1 config height"
,
name
:
"Start from L1 config height"
,
construction
:
func
()
*
l1EtlTs
{
construction
:
func
()
*
testSuite
{
client
:=
new
(
node
.
MockEthClient
)
client
:=
new
(
node
.
MockEthClient
)
db
:=
database
.
NewMockDB
()
db
:=
database
.
NewMockDB
()
...
@@ -48,7 +47,7 @@ func Test_L1ETL_Construction(t *testing.T) {
...
@@ -48,7 +47,7 @@ func Test_L1ETL_Construction(t *testing.T) {
client
.
On
(
"GethEthClient"
)
.
Return
(
nil
)
client
.
On
(
"GethEthClient"
)
.
Return
(
nil
)
return
&
l1EtlTs
{
return
&
testSuite
{
db
:
db
,
db
:
db
,
client
:
client
,
client
:
client
,
start
:
testStart
,
start
:
testStart
,
...
@@ -62,7 +61,7 @@ func Test_L1ETL_Construction(t *testing.T) {
...
@@ -62,7 +61,7 @@ func Test_L1ETL_Construction(t *testing.T) {
},
},
{
{
name
:
"Start from recent height stored in DB"
,
name
:
"Start from recent height stored in DB"
,
construction
:
func
()
*
l1EtlTs
{
construction
:
func
()
*
testSuite
{
client
:=
new
(
node
.
MockEthClient
)
client
:=
new
(
node
.
MockEthClient
)
db
:=
database
.
NewMockDB
()
db
:=
database
.
NewMockDB
()
...
@@ -78,7 +77,7 @@ func Test_L1ETL_Construction(t *testing.T) {
...
@@ -78,7 +77,7 @@ func Test_L1ETL_Construction(t *testing.T) {
client
.
On
(
"GethEthClient"
)
.
Return
(
nil
)
client
.
On
(
"GethEthClient"
)
.
Return
(
nil
)
return
&
l1EtlTs
{
return
&
testSuite
{
db
:
db
,
db
:
db
,
client
:
client
,
client
:
client
,
start
:
testStart
,
start
:
testStart
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment