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
bc5e060e
Commit
bc5e060e
authored
Oct 26, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add flag to `op-node`
parent
80d619ab
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
7 deletions
+39
-7
flags.go
op-node/flags/flags.go
+7
-0
config.go
op-node/node/config.go
+3
-0
node.go
op-node/node/node.go
+2
-0
service.go
op-node/service.go
+6
-0
eth_client.go
op-service/sources/eth_client.go
+8
-1
receipts.go
op-service/sources/receipts.go
+13
-6
No files found.
op-node/flags/flags.go
View file @
bc5e060e
...
...
@@ -82,6 +82,12 @@ var (
return
&
out
}(),
}
L1RethDBPath
=
&
cli
.
StringFlag
{
Name
:
"l1.rethdb"
,
Usage
:
"The L1 RethDB path, used to fetch receipts for L1 blocks. Only applicable when using the `reth_db` RPC kind with `l1.rpckind`."
,
EnvVars
:
prefixEnvVars
(
"L1_RETHDB"
),
Required
:
false
,
}
L1RPCRateLimit
=
&
cli
.
Float64Flag
{
Name
:
"l1.rpc-rate-limit"
,
Usage
:
"Optional self-imposed global rate-limit on L1 RPC requests, specified in requests / second. Disabled if set to 0."
,
...
...
@@ -304,6 +310,7 @@ var optionalFlags = []cli.Flag{
RollupHalt
,
RollupLoadProtocolVersions
,
CanyonOverrideFlag
,
L1RethDBPath
,
}
// Flags contains the list of configuration options available to the binary.
...
...
op-node/node/config.go
View file @
bc5e060e
...
...
@@ -60,6 +60,9 @@ type Config struct {
// Cancel to request a premature shutdown of the node itself, e.g. when halting. This may be nil.
Cancel
context
.
CancelCauseFunc
// [OPTIONAL] The reth DB path to read receipts from
RethDBPath
*
string
}
type
RPCConfig
struct
{
...
...
op-node/node/node.go
View file @
bc5e060e
...
...
@@ -156,6 +156,8 @@ func (n *OpNode) initL1(ctx context.Context, cfg *Config) error {
return
fmt
.
Errorf
(
"failed to get L1 RPC client: %w"
,
err
)
}
rpcCfg
.
EthClientConfig
.
RethDBPath
=
cfg
.
RethDBPath
n
.
l1Source
,
err
=
sources
.
NewL1Client
(
client
.
NewInstrumentedRPC
(
l1Node
,
n
.
metrics
),
n
.
log
,
n
.
metrics
.
L1SourceCache
,
rpcCfg
)
if
err
!=
nil
{
...
...
op-node/service.go
View file @
bc5e060e
...
...
@@ -71,6 +71,11 @@ func NewConfig(ctx *cli.Context, log log.Logger) (*node.Config, error) {
haltOption
=
""
}
var
rethDBPath
*
string
if
rdb
:=
ctx
.
String
(
flags
.
L1RethDBPath
.
Name
);
rdb
!=
""
{
rethDBPath
=
&
rdb
}
cfg
:=
&
node
.
Config
{
L1
:
l1Endpoint
,
L2
:
l2Endpoint
,
...
...
@@ -104,6 +109,7 @@ func NewConfig(ctx *cli.Context, log log.Logger) (*node.Config, error) {
ConfigPersistence
:
configPersistence
,
Sync
:
*
syncConfig
,
RollupHalt
:
haltOption
,
RethDBPath
:
rethDBPath
,
}
if
err
:=
cfg
.
LoadPersisted
(
log
);
err
!=
nil
{
...
...
op-service/sources/eth_client.go
View file @
bc5e060e
...
...
@@ -62,6 +62,9 @@ type EthClientConfig struct {
// till we re-attempt the user-preferred methods.
// If this is 0 then the client does not fall back to less optimal but available methods.
MethodResetDuration
time
.
Duration
// [OPTIONAL] The reth DB path to fetch receipts from
RethDBPath
*
string
}
func
(
c
*
EthClientConfig
)
Check
()
error
{
...
...
@@ -132,6 +135,9 @@ type EthClient struct {
// methodResetDuration defines how long we take till we reset lastMethodsReset
methodResetDuration
time
.
Duration
// [OPTIONAL] The reth DB path to fetch receipts from
rethDbPath
*
string
}
func
(
s
*
EthClient
)
PickReceiptsMethod
(
txCount
uint64
)
ReceiptsFetchingMethod
{
...
...
@@ -179,6 +185,7 @@ func NewEthClient(client client.RPC, log log.Logger, metrics caching.Metrics, co
availableReceiptMethods
:
AvailableReceiptsFetchingMethods
(
config
.
RPCProviderKind
),
lastMethodsReset
:
time
.
Now
(),
methodResetDuration
:
config
.
MethodResetDuration
,
rethDbPath
:
config
.
RethDBPath
,
},
nil
}
...
...
@@ -357,7 +364,7 @@ func (s *EthClient) FetchReceipts(ctx context.Context, blockHash common.Hash) (e
job
=
v
}
else
{
txHashes
:=
eth
.
TransactionsToHashes
(
txs
)
job
=
NewReceiptsFetchingJob
(
s
,
s
.
client
,
s
.
maxBatchSize
,
eth
.
ToBlockID
(
info
),
info
.
ReceiptHash
(),
txHashes
)
job
=
NewReceiptsFetchingJob
(
s
,
s
.
client
,
s
.
maxBatchSize
,
eth
.
ToBlockID
(
info
),
info
.
ReceiptHash
(),
txHashes
,
s
.
rethDbPath
)
s
.
receiptsCache
.
Add
(
blockHash
,
job
)
}
receipts
,
err
:=
job
.
Fetch
(
ctx
)
...
...
op-service/sources/receipts.go
View file @
bc5e060e
...
...
@@ -281,7 +281,7 @@ const (
// - Reth: array of RLP-encoded receipts
// See:
// - reth's DB crate documentation: https://github.com/paradigmxyz/reth/blob/main/docs/crates/db.md
RethGetBlockReceipts
MDBX
RethGetBlockReceipts
// Other:
// - 250 credits, not supported, strictly worse than other options. In quicknode price-table.
...
...
@@ -318,7 +318,7 @@ func AvailableReceiptsFetchingMethods(kind RPCProviderKind) ReceiptsFetchingMeth
case
RPCKindStandard
:
return
EthGetBlockReceipts
|
EthGetTransactionReceiptBatch
case
RPCKindRethDB
:
return
RethGetBlockReceipts
MDBX
return
RethGetBlockReceipts
default
:
return
EthGetTransactionReceiptBatch
}
...
...
@@ -330,7 +330,7 @@ func PickBestReceiptsFetchingMethod(kind RPCProviderKind, available ReceiptsFetc
// If we have optimized methods available, it makes sense to use them, but only if the cost is
// lower than fetching transactions one by one with the standard receipts RPC method.
if
kind
==
RPCKindRethDB
{
return
RethGetBlockReceipts
MDBX
return
RethGetBlockReceipts
}
else
if
kind
==
RPCKindAlchemy
{
if
available
&
AlchemyGetTransactionReceipts
!=
0
&&
txCount
>
250
/
15
{
return
AlchemyGetTransactionReceipts
...
...
@@ -389,11 +389,14 @@ type receiptsFetchingJob struct {
fetcher
*
IterativeBatchCall
[
common
.
Hash
,
*
types
.
Receipt
]
// [OPTIONAL] RethDB path to fetch receipts from
rethDbPath
*
string
result
types
.
Receipts
}
func
NewReceiptsFetchingJob
(
requester
ReceiptsRequester
,
client
rpcClient
,
maxBatchSize
int
,
block
eth
.
BlockID
,
receiptHash
common
.
Hash
,
txHashes
[]
common
.
Hash
)
*
receiptsFetchingJob
{
receiptHash
common
.
Hash
,
txHashes
[]
common
.
Hash
,
rethDb
*
string
)
*
receiptsFetchingJob
{
return
&
receiptsFetchingJob
{
requester
:
requester
,
client
:
client
,
...
...
@@ -401,6 +404,7 @@ func NewReceiptsFetchingJob(requester ReceiptsRequester, client rpcClient, maxBa
block
:
block
,
receiptHash
:
receiptHash
,
txHashes
:
txHashes
,
rethDbPath
:
rethDb
,
}
}
...
...
@@ -478,8 +482,11 @@ func (job *receiptsFetchingJob) runAltMethod(ctx context.Context, m ReceiptsFetc
err
=
job
.
client
.
CallContext
(
ctx
,
&
result
,
"eth_getBlockReceipts"
,
job
.
block
.
Hash
)
case
ErigonGetBlockReceiptsByBlockHash
:
err
=
job
.
client
.
CallContext
(
ctx
,
&
result
,
"erigon_getBlockReceiptsByBlockHash"
,
job
.
block
.
Hash
)
case
RethGetBlockReceiptsMDBX
:
res
,
err
:=
FetchRethReceipts
(
"placeholder"
,
&
job
.
block
.
Hash
)
case
RethGetBlockReceipts
:
if
job
.
rethDbPath
==
nil
{
return
fmt
.
Errorf
(
"reth_db path not set"
)
}
res
,
err
:=
FetchRethReceipts
(
*
job
.
rethDbPath
,
&
job
.
block
.
Hash
)
if
err
!=
nil
{
return
err
}
...
...
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