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
Hide 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 (
// Config represents the `indexer.toml` file used to configure the indexer
type
Config
struct
{
Chain
ChainConfig
RPCs
RPCsConfig
`toml:"rpcs"`
DB
DBConfig
API
APIConfig
Metrics
MetricsConfig
Chain
ChainConfig
`toml:"chain"`
RPCs
RPCsConfig
`toml:"rpcs"`
DB
DBConfig
`toml:"db"`
API
APIConfig
`toml:"api"`
Metrics
MetricsConfig
`toml:"metrics"`
}
// fetch this via onchain config from RPCsConfig and remove from config in future
...
...
@@ -78,23 +78,23 @@ type RPCsConfig struct {
// DBConfig configures the postgres database
type
DBConfig
struct
{
Host
string
Port
int
Name
string
User
string
Password
string
Host
string
`toml:"host"`
Port
int
`toml:"port"`
Name
string
`toml:"name"`
User
string
`toml:"user"`
Password
string
`toml:"password"`
}
// APIConfig configures the API server
type
APIConfig
struct
{
Host
string
Port
int
Host
string
`toml:"host"`
Port
int
`toml:"port"`
}
// MetricsConfig configures the metrics server
type
MetricsConfig
struct
{
Host
string
Port
int
Host
string
`toml:"host"`
Port
int
`toml:"port"`
}
// 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) {
return
args
.
Get
(
0
)
.
(
*
Epoch
),
args
.
Error
(
1
)
}
var
_
BlocksDB
=
(
*
MockBlocksDB
)(
nil
)
type
MockBlocksDB
struct
{
MockBlocksView
}
...
...
@@ -92,10 +90,10 @@ func (m *MockBlocksDB) StoreOutputProposals(headers []OutputProposal) error {
return
args
.
Error
(
1
)
}
// MockDB is a mock database that can be used for testing
type
MockDB
struct
{
MockBlockView
*
MockBlocksView
MockBlocks
*
MockBlocksDB
DB
*
DB
MockBlocks
*
MockBlocksDB
DB
*
DB
}
func
NewMockDB
()
*
MockDB
{
...
...
@@ -105,6 +103,5 @@ func NewMockDB() *MockDB {
mockBlocks
:=
new
(
MockBlocksDB
)
db
:=
&
DB
{
Blocks
:
mockBlocks
}
return
&
MockDB
{
MockBlocks
:
mockBlocks
,
DB
:
db
,
MockBlockView
:
new
(
MockBlocksView
)}
return
&
MockDB
{
MockBlocks
:
mockBlocks
,
DB
:
db
}
}
indexer/etl/etl.go
View file @
166ba06b
...
...
@@ -14,6 +14,9 @@ import (
)
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
defaultHeaderBufferSize
=
500
)
...
...
@@ -90,7 +93,7 @@ func (etl *ETL) Start(ctx context.Context) error {
for
i
:=
range
logs
{
if
_
,
ok
:=
headerMap
[
logs
[
i
]
.
BlockHash
];
!
ok
{
// 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
)
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 (
"testing"
)
// test suite
type
l1EtlTs
struct
{
db
*
database
.
MockDB
client
*
node
.
MockEthClient
start
*
big
.
Int
contracts
config
.
L1Contracts
}
func
Test_L1ETL_Construction
(
t
*
testing
.
T
)
{
type
testSuite
struct
{
db
*
database
.
MockDB
client
*
node
.
MockEthClient
start
*
big
.
Int
contracts
config
.
L1Contracts
}
var
tests
=
[]
struct
{
name
string
construction
func
()
*
l1EtlTs
construction
func
()
*
testSuite
assertion
func
(
*
L1ETL
,
error
)
}{
{
name
:
"Start from L1 config height"
,
construction
:
func
()
*
l1EtlTs
{
construction
:
func
()
*
testSuite
{
client
:=
new
(
node
.
MockEthClient
)
db
:=
database
.
NewMockDB
()
...
...
@@ -48,7 +47,7 @@ func Test_L1ETL_Construction(t *testing.T) {
client
.
On
(
"GethEthClient"
)
.
Return
(
nil
)
return
&
l1EtlTs
{
return
&
testSuite
{
db
:
db
,
client
:
client
,
start
:
testStart
,
...
...
@@ -62,7 +61,7 @@ func Test_L1ETL_Construction(t *testing.T) {
},
{
name
:
"Start from recent height stored in DB"
,
construction
:
func
()
*
l1EtlTs
{
construction
:
func
()
*
testSuite
{
client
:=
new
(
node
.
MockEthClient
)
db
:=
database
.
NewMockDB
()
...
...
@@ -78,7 +77,7 @@ func Test_L1ETL_Construction(t *testing.T) {
client
.
On
(
"GethEthClient"
)
.
Return
(
nil
)
return
&
l1EtlTs
{
return
&
testSuite
{
db
:
db
,
client
:
client
,
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