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
4d22eb44
Commit
4d22eb44
authored
Nov 29, 2023
by
Baptiste Oueriagli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nit(op-node): export DataSourceConfig and make its usage more consistent
parent
698b6406
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
calldata_source.go
op-node/rollup/derive/calldata_source.go
+14
-14
calldata_source_test.go
op-node/rollup/derive/calldata_source_test.go
+1
-1
No files found.
op-node/rollup/derive/calldata_source.go
View file @
4d22eb44
...
@@ -41,8 +41,8 @@ func (ds *DataSourceFactory) OpenData(ctx context.Context, id eth.BlockID, batch
...
@@ -41,8 +41,8 @@ func (ds *DataSourceFactory) OpenData(ctx context.Context, id eth.BlockID, batch
return
NewDataSource
(
ctx
,
ds
.
log
,
ds
.
cfg
,
ds
.
fetcher
,
id
,
batcherAddr
)
return
NewDataSource
(
ctx
,
ds
.
log
,
ds
.
cfg
,
ds
.
fetcher
,
id
,
batcherAddr
)
}
}
//
d
ataSourceConfig regroups the mandatory rollup.Config fields needed for DataFromEVMTransactions.
//
D
ataSourceConfig regroups the mandatory rollup.Config fields needed for DataFromEVMTransactions.
type
d
ataSourceConfig
struct
{
type
D
ataSourceConfig
struct
{
l1Signer
types
.
Signer
l1Signer
types
.
Signer
batchInboxAddress
common
.
Address
batchInboxAddress
common
.
Address
}
}
...
@@ -56,7 +56,7 @@ type DataSource struct {
...
@@ -56,7 +56,7 @@ type DataSource struct {
data
[]
eth
.
Data
data
[]
eth
.
Data
// Required to re-attempt fetching
// Required to re-attempt fetching
id
eth
.
BlockID
id
eth
.
BlockID
cfg
d
ataSourceConfig
dsCfg
D
ataSourceConfig
fetcher
L1TransactionFetcher
fetcher
L1TransactionFetcher
log
log
.
Logger
log
log
.
Logger
...
@@ -67,14 +67,14 @@ type DataSource struct {
...
@@ -67,14 +67,14 @@ type DataSource struct {
// If there is an error, it will attempt to fetch the result on the next call to `Next`.
// If there is an error, it will attempt to fetch the result on the next call to `Next`.
func
NewDataSource
(
ctx
context
.
Context
,
log
log
.
Logger
,
cfg
*
rollup
.
Config
,
fetcher
L1TransactionFetcher
,
block
eth
.
BlockID
,
batcherAddr
common
.
Address
)
DataIter
{
func
NewDataSource
(
ctx
context
.
Context
,
log
log
.
Logger
,
cfg
*
rollup
.
Config
,
fetcher
L1TransactionFetcher
,
block
eth
.
BlockID
,
batcherAddr
common
.
Address
)
DataIter
{
_
,
txs
,
err
:=
fetcher
.
InfoAndTxsByHash
(
ctx
,
block
.
Hash
)
_
,
txs
,
err
:=
fetcher
.
InfoAndTxsByHash
(
ctx
,
block
.
Hash
)
dsCfg
:=
DataSourceConfig
{
cfg
.
L1Signer
(),
cfg
.
BatchInboxAddress
}
if
err
!=
nil
{
if
err
!=
nil
{
return
&
DataSource
{
return
&
DataSource
{
open
:
false
,
open
:
false
,
id
:
block
,
id
:
block
,
cfg
:
dataSourceConfig
{
dsCfg
:
dsCfg
,
l1Signer
:
cfg
.
L1Signer
(),
batchInboxAddress
:
cfg
.
BatchInboxAddress
,
},
fetcher
:
fetcher
,
fetcher
:
fetcher
,
log
:
log
,
log
:
log
,
batcherAddr
:
batcherAddr
,
batcherAddr
:
batcherAddr
,
...
@@ -82,7 +82,7 @@ func NewDataSource(ctx context.Context, log log.Logger, cfg *rollup.Config, fetc
...
@@ -82,7 +82,7 @@ func NewDataSource(ctx context.Context, log log.Logger, cfg *rollup.Config, fetc
}
else
{
}
else
{
return
&
DataSource
{
return
&
DataSource
{
open
:
true
,
open
:
true
,
data
:
DataFromEVMTransactions
(
cfg
.
L1Signer
(),
cfg
.
BatchInboxAddress
,
batcherAddr
,
txs
,
log
.
New
(
"origin"
,
block
)),
data
:
DataFromEVMTransactions
(
dsCfg
,
batcherAddr
,
txs
,
log
.
New
(
"origin"
,
block
)),
}
}
}
}
}
}
...
@@ -94,7 +94,7 @@ func (ds *DataSource) Next(ctx context.Context) (eth.Data, error) {
...
@@ -94,7 +94,7 @@ func (ds *DataSource) Next(ctx context.Context) (eth.Data, error) {
if
!
ds
.
open
{
if
!
ds
.
open
{
if
_
,
txs
,
err
:=
ds
.
fetcher
.
InfoAndTxsByHash
(
ctx
,
ds
.
id
.
Hash
);
err
==
nil
{
if
_
,
txs
,
err
:=
ds
.
fetcher
.
InfoAndTxsByHash
(
ctx
,
ds
.
id
.
Hash
);
err
==
nil
{
ds
.
open
=
true
ds
.
open
=
true
ds
.
data
=
DataFromEVMTransactions
(
ds
.
cfg
.
l1Signer
,
ds
.
cfg
.
batchInboxAddress
,
ds
.
batcherAddr
,
txs
,
log
.
New
(
"origin"
,
ds
.
id
))
ds
.
data
=
DataFromEVMTransactions
(
ds
.
dsCfg
,
ds
.
batcherAddr
,
txs
,
log
.
New
(
"origin"
,
ds
.
id
))
}
else
if
errors
.
Is
(
err
,
ethereum
.
NotFound
)
{
}
else
if
errors
.
Is
(
err
,
ethereum
.
NotFound
)
{
return
nil
,
NewResetError
(
fmt
.
Errorf
(
"failed to open calldata source: %w"
,
err
))
return
nil
,
NewResetError
(
fmt
.
Errorf
(
"failed to open calldata source: %w"
,
err
))
}
else
{
}
else
{
...
@@ -113,11 +113,11 @@ func (ds *DataSource) Next(ctx context.Context) (eth.Data, error) {
...
@@ -113,11 +113,11 @@ func (ds *DataSource) Next(ctx context.Context) (eth.Data, error) {
// DataFromEVMTransactions filters all of the transactions and returns the calldata from transactions
// DataFromEVMTransactions filters all of the transactions and returns the calldata from transactions
// that are sent to the batch inbox address from the batch sender address.
// that are sent to the batch inbox address from the batch sender address.
// This will return an empty array if no valid transactions are found.
// This will return an empty array if no valid transactions are found.
func
DataFromEVMTransactions
(
l1Signer
types
.
Signer
,
batchInboxAddress
common
.
Address
,
batcherAddr
common
.
Address
,
txs
types
.
Transactions
,
log
log
.
Logger
)
[]
eth
.
Data
{
func
DataFromEVMTransactions
(
dsCfg
DataSourceConfig
,
batcherAddr
common
.
Address
,
txs
types
.
Transactions
,
log
log
.
Logger
)
[]
eth
.
Data
{
var
out
[]
eth
.
Data
var
out
[]
eth
.
Data
for
j
,
tx
:=
range
txs
{
for
j
,
tx
:=
range
txs
{
if
to
:=
tx
.
To
();
to
!=
nil
&&
*
to
==
batchInboxAddress
{
if
to
:=
tx
.
To
();
to
!=
nil
&&
*
to
==
dsCfg
.
batchInboxAddress
{
seqDataSubmitter
,
err
:=
l1Signer
.
Sender
(
tx
)
// optimization: only derive sender if To is correct
seqDataSubmitter
,
err
:=
dsCfg
.
l1Signer
.
Sender
(
tx
)
// optimization: only derive sender if To is correct
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Warn
(
"tx in inbox with invalid signature"
,
"index"
,
j
,
"err"
,
err
)
log
.
Warn
(
"tx in inbox with invalid signature"
,
"index"
,
j
,
"err"
,
err
)
continue
// bad signature, ignore
continue
// bad signature, ignore
...
...
op-node/rollup/derive/calldata_source_test.go
View file @
4d22eb44
...
@@ -121,7 +121,7 @@ func TestDataFromEVMTransactions(t *testing.T) {
...
@@ -121,7 +121,7 @@ func TestDataFromEVMTransactions(t *testing.T) {
}
}
}
}
out
:=
DataFromEVMTransactions
(
cfg
.
L1Signer
(),
cfg
.
BatchInboxAddress
,
batcherAddr
,
txs
,
testlog
.
Logger
(
t
,
log
.
LvlCrit
))
out
:=
DataFromEVMTransactions
(
DataSourceConfig
{
cfg
.
L1Signer
(),
cfg
.
BatchInboxAddress
}
,
batcherAddr
,
txs
,
testlog
.
Logger
(
t
,
log
.
LvlCrit
))
require
.
ElementsMatch
(
t
,
expectedData
,
out
)
require
.
ElementsMatch
(
t
,
expectedData
,
out
)
}
}
...
...
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