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
503515ec
Unverified
Commit
503515ec
authored
Jun 09, 2023
by
mergify[bot]
Committed by
GitHub
Jun 09, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into aj/update-op-geth
parents
b8993827
a8138864
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
118 additions
and
19 deletions
+118
-19
README.md
README.md
+31
-12
channel_manager.go
op-batcher/batcher/channel_manager.go
+3
-0
metrics.go
op-batcher/metrics/metrics.go
+43
-2
noop.go
op-batcher/metrics/noop.go
+3
-0
receipts.go
op-node/sources/receipts.go
+24
-4
receipts_test.go
op-node/sources/receipts_test.go
+14
-1
No files found.
README.md
View file @
503515ec
...
@@ -51,6 +51,36 @@ Refer to the Directory Structure section below to understand which packages are
...
@@ -51,6 +51,36 @@ Refer to the Directory Structure section below to understand which packages are
~~ Production ~~
~~ Production ~~
├──
<a
href=
"./packages"
>
packages
</a>
├──
<a
href=
"./packages"
>
packages
</a>
│ ├──
<a
href=
"./packages/common-ts"
>
common-ts
</a>
: Common tools for building apps in TypeScript
│ ├──
<a
href=
"./packages/common-ts"
>
common-ts
</a>
: Common tools for building apps in TypeScript
│ ├──
<a
href=
"./packages/contracts-bedrock"
>
contracts-bedrock
</a>
: Bedrock smart contracts.
│ ├──
<a
href=
"./packages/contracts-periphery"
>
contracts-periphery
</a>
: Peripheral contracts for Optimism
│ ├──
<a
href=
"./packages/core-utils"
>
core-utils
</a>
: Low-level utilities that make building Optimism easier
│ ├──
<a
href=
"./packages/data-transport-layer"
>
data-transport-layer
</a>
: Service for indexing Optimism-related L1 data
│ ├──
<a
href=
"./packages/chain-mon"
>
chain-mon
</a>
: Chain monitoring services
│ ├──
<a
href=
"./packages/fault-detector"
>
fault-detector
</a>
: Service for detecting Sequencer faults
│ ├──
<a
href=
"./packages/message-relayer"
>
message-relayer
</a>
: Tool for automatically relaying L1
<>
L2 messages in development
│ ├──
<a
href=
"./packages/replica-healthcheck"
>
replica-healthcheck
</a>
: Service for monitoring the health of a replica node
│ └──
<a
href=
"./packages/sdk"
>
sdk
</a>
: provides a set of tools for interacting with Optimism
├──
<a
href=
"./op-bindings"
>
op-bindings
</a>
: Go bindings for Bedrock smart contracts.
├──
<a
href=
"./op-batcher"
>
op-batcher
</a>
: L2-Batch Submitter, submits bundles of batches to L1
├──
<a
href=
"./op-bootnode"
>
op-bootnode
</a>
: Standalone op-node discovery bootnode
├──
<a
href=
"./op-chain-ops"
>
op-chain-ops
</a>
: State surgery utilities
├──
<a
href=
"./op-challenger"
>
op-challenger
</a>
: Dispute game challenge agent
├──
<a
href=
"./op-e2e"
>
op-e2e
</a>
: End-to-End testing of all bedrock components in Go
├──
<a
href=
"./op-exporter"
>
op-exporter
</a>
: Prometheus exporter client
├──
<a
href=
"./op-heartbeat"
>
op-heartbeat
</a>
: Heartbeat monitor service
├──
<a
href=
"./op-node"
>
op-node
</a>
: rollup consensus-layer client
├──
<a
href=
"./op-program"
>
op-program
</a>
: Fault proof program
├──
<a
href=
"./op-proposer"
>
op-proposer
</a>
: L2-Output Submitter, submits proposals to L1
├──
<a
href=
"./op-service"
>
op-service
</a>
: Common codebase utilities
├──
<a
href=
"./op-signer"
>
op-signer
</a>
: Client signer
├──
<a
href=
"./op-wheel"
>
op-wheel
</a>
: Database utilities
├──
<a
href=
"./ops-bedrock"
>
ops-bedrock
</a>
: Bedrock devnet work
├──
<a
href=
"./proxyd"
>
proxyd
</a>
: Configurable RPC request router and proxy
└──
<a
href=
"./specs"
>
specs
</a>
: Specs of the rollup starting at the Bedrock upgrade
~~ Pre-BEDROCK ~~
├──
<a
href=
"./packages"
>
packages
</a>
│ ├──
<a
href=
"./packages/common-ts"
>
common-ts
</a>
: Common tools for building apps in TypeScript
│ ├──
<a
href=
"./packages/contracts"
>
contracts
</a>
: L1 and L2 smart contracts for Optimism
│ ├──
<a
href=
"./packages/contracts"
>
contracts
</a>
: L1 and L2 smart contracts for Optimism
│ ├──
<a
href=
"./packages/contracts-periphery"
>
contracts-periphery
</a>
: Peripheral contracts for Optimism
│ ├──
<a
href=
"./packages/contracts-periphery"
>
contracts-periphery
</a>
: Peripheral contracts for Optimism
│ ├──
<a
href=
"./packages/core-utils"
>
core-utils
</a>
: Low-level utilities that make building Optimism easier
│ ├──
<a
href=
"./packages/core-utils"
>
core-utils
</a>
: Low-level utilities that make building Optimism easier
...
@@ -69,18 +99,7 @@ Refer to the Directory Structure section below to understand which packages are
...
@@ -69,18 +99,7 @@ Refer to the Directory Structure section below to understand which packages are
├──
<a
href=
"./l2geth-exporter"
>
l2geth-exporter
</a>
: A prometheus exporter to collect/serve metrics from an L2 geth node
├──
<a
href=
"./l2geth-exporter"
>
l2geth-exporter
</a>
: A prometheus exporter to collect/serve metrics from an L2 geth node
├──
<a
href=
"./op-exporter"
>
op-exporter
</a>
: A prometheus exporter to collect/serve metrics from an Optimism node
├──
<a
href=
"./op-exporter"
>
op-exporter
</a>
: A prometheus exporter to collect/serve metrics from an Optimism node
├──
<a
href=
"./proxyd"
>
proxyd
</a>
: Configurable RPC request router and proxy
├──
<a
href=
"./proxyd"
>
proxyd
</a>
: Configurable RPC request router and proxy
├──
<a
href=
"./technical-documents"
>
technical-documents
</a>
: audits and post-mortem documents
└──
<a
href=
"./technical-documents"
>
technical-documents
</a>
: audits and post-mortem documents
~~ BEDROCK upgrade - Not production-ready yet, part of next major upgrade ~~
├──
<a
href=
"./packages"
>
packages
</a>
│ └──
<a
href=
"./packages/contracts-bedrock"
>
contracts-bedrock
</a>
: Bedrock smart contracts. To be merged with ./packages/contracts.
├──
<a
href=
"./op-bindings"
>
op-bindings
</a>
: Go bindings for Bedrock smart contracts.
├──
<a
href=
"./op-batcher"
>
op-batcher
</a>
: L2-Batch Submitter, submits bundles of batches to L1
├──
<a
href=
"./op-e2e"
>
op-e2e
</a>
: End-to-End testing of all bedrock components in Go
├──
<a
href=
"./op-node"
>
op-node
</a>
: rollup consensus-layer client.
├──
<a
href=
"./op-proposer"
>
op-proposer
</a>
: L2-Output Submitter, submits proposals to L1
├──
<a
href=
"./ops-bedrock"
>
ops-bedrock
</a>
: Bedrock devnet work
└──
<a
href=
"./specs"
>
specs
</a>
: Specs of the rollup starting at the Bedrock upgrade
</pre>
</pre>
## Branching Model
## Branching Model
...
...
op-batcher/batcher/channel_manager.go
View file @
503515ec
...
@@ -228,6 +228,7 @@ func (s *channelManager) processBlocks() error {
...
@@ -228,6 +228,7 @@ func (s *channelManager) processBlocks() error {
}
}
blocksAdded
+=
1
blocksAdded
+=
1
latestL2ref
=
l2BlockRefFromBlockAndL1Info
(
block
,
l1info
)
latestL2ref
=
l2BlockRefFromBlockAndL1Info
(
block
,
l1info
)
s
.
metr
.
RecordL2BlockInChannel
(
block
)
// current block got added but channel is now full
// current block got added but channel is now full
if
s
.
currentChannel
.
IsFull
()
{
if
s
.
currentChannel
.
IsFull
()
{
break
break
...
@@ -298,6 +299,8 @@ func (s *channelManager) AddL2Block(block *types.Block) error {
...
@@ -298,6 +299,8 @@ func (s *channelManager) AddL2Block(block *types.Block) error {
if
s
.
tip
!=
(
common
.
Hash
{})
&&
s
.
tip
!=
block
.
ParentHash
()
{
if
s
.
tip
!=
(
common
.
Hash
{})
&&
s
.
tip
!=
block
.
ParentHash
()
{
return
ErrReorg
return
ErrReorg
}
}
s
.
metr
.
RecordL2BlockInPendingQueue
(
block
)
s
.
blocks
=
append
(
s
.
blocks
,
block
)
s
.
blocks
=
append
(
s
.
blocks
,
block
)
s
.
tip
=
block
.
Hash
()
s
.
tip
=
block
.
Hash
()
...
...
op-batcher/metrics/metrics.go
View file @
503515ec
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"context"
"context"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus"
...
@@ -30,6 +31,8 @@ type Metricer interface {
...
@@ -30,6 +31,8 @@ type Metricer interface {
RecordL2BlocksLoaded
(
l2ref
eth
.
L2BlockRef
)
RecordL2BlocksLoaded
(
l2ref
eth
.
L2BlockRef
)
RecordChannelOpened
(
id
derive
.
ChannelID
,
numPendingBlocks
int
)
RecordChannelOpened
(
id
derive
.
ChannelID
,
numPendingBlocks
int
)
RecordL2BlocksAdded
(
l2ref
eth
.
L2BlockRef
,
numBlocksAdded
,
numPendingBlocks
,
inputBytes
,
outputComprBytes
int
)
RecordL2BlocksAdded
(
l2ref
eth
.
L2BlockRef
,
numBlocksAdded
,
numPendingBlocks
,
inputBytes
,
outputComprBytes
int
)
RecordL2BlockInPendingQueue
(
block
*
types
.
Block
)
RecordL2BlockInChannel
(
block
*
types
.
Block
)
RecordChannelClosed
(
id
derive
.
ChannelID
,
numPendingBlocks
int
,
numFrames
int
,
inputBytes
int
,
outputComprBytes
int
,
reason
error
)
RecordChannelClosed
(
id
derive
.
ChannelID
,
numPendingBlocks
int
,
numFrames
int
,
inputBytes
int
,
outputComprBytes
int
,
reason
error
)
RecordChannelFullySubmitted
(
id
derive
.
ChannelID
)
RecordChannelFullySubmitted
(
id
derive
.
ChannelID
)
RecordChannelTimedOut
(
id
derive
.
ChannelID
)
RecordChannelTimedOut
(
id
derive
.
ChannelID
)
...
@@ -55,8 +58,10 @@ type Metrics struct {
...
@@ -55,8 +58,10 @@ type Metrics struct {
// label by openend, closed, fully_submitted, timed_out
// label by openend, closed, fully_submitted, timed_out
channelEvs
opmetrics
.
EventVec
channelEvs
opmetrics
.
EventVec
pendingBlocksCount
prometheus
.
GaugeVec
pendingBlocksCount
prometheus
.
GaugeVec
blocksAddedCount
prometheus
.
Gauge
pendingBlocksBytesTotal
prometheus
.
Counter
pendingBlocksBytesCurrent
prometheus
.
Gauge
blocksAddedCount
prometheus
.
Gauge
channelInputBytes
prometheus
.
GaugeVec
channelInputBytes
prometheus
.
GaugeVec
channelReadyBytes
prometheus
.
Gauge
channelReadyBytes
prometheus
.
Gauge
...
@@ -109,6 +114,16 @@ func NewMetrics(procName string) *Metrics {
...
@@ -109,6 +114,16 @@ func NewMetrics(procName string) *Metrics {
Name
:
"pending_blocks_count"
,
Name
:
"pending_blocks_count"
,
Help
:
"Number of pending blocks, not added to a channel yet."
,
Help
:
"Number of pending blocks, not added to a channel yet."
,
},
[]
string
{
"stage"
}),
},
[]
string
{
"stage"
}),
pendingBlocksBytesTotal
:
factory
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
ns
,
Name
:
"pending_blocks_bytes_total"
,
Help
:
"Total size of transactions in pending blocks as they are fetched from L2"
,
}),
pendingBlocksBytesCurrent
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Name
:
"pending_blocks_bytes_current"
,
Help
:
"Current size of transactions in the pending (fetched from L2 but not in a channel) stage."
,
}),
blocksAddedCount
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
blocksAddedCount
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Namespace
:
ns
,
Name
:
"blocks_added_count"
,
Name
:
"blocks_added_count"
,
...
@@ -243,6 +258,18 @@ func (m *Metrics) RecordChannelClosed(id derive.ChannelID, numPendingBlocks int,
...
@@ -243,6 +258,18 @@ func (m *Metrics) RecordChannelClosed(id derive.ChannelID, numPendingBlocks int,
m
.
channelClosedReason
.
Set
(
float64
(
ClosedReasonToNum
(
reason
)))
m
.
channelClosedReason
.
Set
(
float64
(
ClosedReasonToNum
(
reason
)))
}
}
func
(
m
*
Metrics
)
RecordL2BlockInPendingQueue
(
block
*
types
.
Block
)
{
size
:=
float64
(
estimateBatchSize
(
block
))
m
.
pendingBlocksBytesTotal
.
Add
(
size
)
m
.
pendingBlocksBytesCurrent
.
Add
(
size
)
}
func
(
m
*
Metrics
)
RecordL2BlockInChannel
(
block
*
types
.
Block
)
{
size
:=
float64
(
estimateBatchSize
(
block
))
m
.
pendingBlocksBytesCurrent
.
Add
(
-
1
*
size
)
// Refer to RecordL2BlocksAdded to see the current + count of bytes added to a channel
}
func
ClosedReasonToNum
(
reason
error
)
int
{
func
ClosedReasonToNum
(
reason
error
)
int
{
// CLI-3640
// CLI-3640
return
0
return
0
...
@@ -267,3 +294,17 @@ func (m *Metrics) RecordBatchTxSuccess() {
...
@@ -267,3 +294,17 @@ func (m *Metrics) RecordBatchTxSuccess() {
func
(
m
*
Metrics
)
RecordBatchTxFailed
()
{
func
(
m
*
Metrics
)
RecordBatchTxFailed
()
{
m
.
batcherTxEvs
.
Record
(
TxStageFailed
)
m
.
batcherTxEvs
.
Record
(
TxStageFailed
)
}
}
// estimateBatchSize estimates the size of the batch
func
estimateBatchSize
(
block
*
types
.
Block
)
uint64
{
size
:=
uint64
(
70
)
// estimated overhead of batch metadata
for
_
,
tx
:=
range
block
.
Transactions
()
{
// Don't include deposit transactions in the batch.
if
tx
.
IsDepositTx
()
{
continue
}
// Add 2 for the overhead of encoding the tx bytes in a RLP list
size
+=
tx
.
Size
()
+
2
}
return
size
}
op-batcher/metrics/noop.go
View file @
503515ec
...
@@ -5,6 +5,7 @@ import (
...
@@ -5,6 +5,7 @@ import (
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
opmetrics
"github.com/ethereum-optimism/optimism/op-service/metrics"
opmetrics
"github.com/ethereum-optimism/optimism/op-service/metrics"
txmetrics
"github.com/ethereum-optimism/optimism/op-service/txmgr/metrics"
txmetrics
"github.com/ethereum-optimism/optimism/op-service/txmgr/metrics"
"github.com/ethereum/go-ethereum/core/types"
)
)
type
noopMetrics
struct
{
type
noopMetrics
struct
{
...
@@ -23,6 +24,8 @@ func (*noopMetrics) RecordLatestL1Block(l1ref eth.L1BlockRef) {}
...
@@ -23,6 +24,8 @@ func (*noopMetrics) RecordLatestL1Block(l1ref eth.L1BlockRef) {}
func
(
*
noopMetrics
)
RecordL2BlocksLoaded
(
eth
.
L2BlockRef
)
{}
func
(
*
noopMetrics
)
RecordL2BlocksLoaded
(
eth
.
L2BlockRef
)
{}
func
(
*
noopMetrics
)
RecordChannelOpened
(
derive
.
ChannelID
,
int
)
{}
func
(
*
noopMetrics
)
RecordChannelOpened
(
derive
.
ChannelID
,
int
)
{}
func
(
*
noopMetrics
)
RecordL2BlocksAdded
(
eth
.
L2BlockRef
,
int
,
int
,
int
,
int
)
{}
func
(
*
noopMetrics
)
RecordL2BlocksAdded
(
eth
.
L2BlockRef
,
int
,
int
,
int
,
int
)
{}
func
(
*
noopMetrics
)
RecordL2BlockInPendingQueue
(
*
types
.
Block
)
{}
func
(
*
noopMetrics
)
RecordL2BlockInChannel
(
*
types
.
Block
)
{}
func
(
*
noopMetrics
)
RecordChannelClosed
(
derive
.
ChannelID
,
int
,
int
,
int
,
int
,
error
)
{}
func
(
*
noopMetrics
)
RecordChannelClosed
(
derive
.
ChannelID
,
int
,
int
,
int
,
int
,
error
)
{}
...
...
op-node/sources/receipts.go
View file @
503515ec
...
@@ -179,6 +179,7 @@ func (r ReceiptsFetchingMethod) String() string {
...
@@ -179,6 +179,7 @@ func (r ReceiptsFetchingMethod) String() string {
addMaybe
(
DebugGetRawReceipts
,
"debug_getRawReceipts"
)
addMaybe
(
DebugGetRawReceipts
,
"debug_getRawReceipts"
)
addMaybe
(
ParityGetBlockReceipts
,
"parity_getBlockReceipts"
)
addMaybe
(
ParityGetBlockReceipts
,
"parity_getBlockReceipts"
)
addMaybe
(
EthGetBlockReceipts
,
"eth_getBlockReceipts"
)
addMaybe
(
EthGetBlockReceipts
,
"eth_getBlockReceipts"
)
addMaybe
(
ErigonGetBlockReceiptsByBlockHash
,
"erigon_getBlockReceiptsByBlockHash"
)
addMaybe
(
^
ReceiptsFetchingMethod
(
0
),
"unknown"
)
// if anything is left, describe it as unknown
addMaybe
(
^
ReceiptsFetchingMethod
(
0
),
"unknown"
)
// if anything is left, describe it as unknown
return
out
return
out
}
}
...
@@ -230,10 +231,9 @@ const (
...
@@ -230,10 +231,9 @@ const (
// - Nethermind: https://docs.nethermind.io/nethermind/ethereum-client/json-rpc/parity#parity_getblockreceipts
// - Nethermind: https://docs.nethermind.io/nethermind/ethereum-client/json-rpc/parity#parity_getblockreceipts
ParityGetBlockReceipts
ParityGetBlockReceipts
// EthGetBlockReceipts is a non-standard receipt fetching method in the eth namespace,
// EthGetBlockReceipts is a non-standard receipt fetching method in the eth namespace,
// supported by some RPC platforms
and Erigon
.
// supported by some RPC platforms.
// Available in:
// Available in:
// - Alchemy: 500 CU total (and deprecated)
// - Alchemy: 500 CU total (and deprecated)
// - Erigon: free
// - QuickNode: 59 credits total (does not seem to work with block hash arg, inaccurate docs)
// - QuickNode: 59 credits total (does not seem to work with block hash arg, inaccurate docs)
// Method: eth_getBlockReceipts
// Method: eth_getBlockReceipts
// Params:
// Params:
...
@@ -243,7 +243,21 @@ const (
...
@@ -243,7 +243,21 @@ const (
// See:
// See:
// - QuickNode: https://www.quicknode.com/docs/ethereum/eth_getBlockReceipts
// - QuickNode: https://www.quicknode.com/docs/ethereum/eth_getBlockReceipts
// - Alchemy: https://docs.alchemy.com/reference/eth-getblockreceipts
// - Alchemy: https://docs.alchemy.com/reference/eth-getblockreceipts
// Erigon has this available, but does not support block-hash argument to the method:
// https://github.com/ledgerwatch/erigon/blob/287a3d1d6c90fc6a7a088b5ae320f93600d5a167/cmd/rpcdaemon/commands/eth_receipts.go#L571
EthGetBlockReceipts
EthGetBlockReceipts
// ErigonGetBlockReceiptsByBlockHash is an Erigon-specific receipt fetching method,
// the same as EthGetBlockReceipts but supporting a block-hash argument.
// Available in:
// - Erigon
// Method: erigon_getBlockReceiptsByBlockHash
// Params:
// - Erigon: string, hex-encoded block hash
// Returns:
// - Erigon: array of json-ified receipts
// See:
// https://github.com/ledgerwatch/erigon/blob/287a3d1d6c90fc6a7a088b5ae320f93600d5a167/cmd/rpcdaemon/commands/erigon_receipts.go#LL391C24-L391C51
ErigonGetBlockReceiptsByBlockHash
// Other:
// Other:
// - 250 credits, not supported, strictly worse than other options. In quicknode price-table.
// - 250 credits, not supported, strictly worse than other options. In quicknode price-table.
...
@@ -269,13 +283,14 @@ func AvailableReceiptsFetchingMethods(kind RPCProviderKind) ReceiptsFetchingMeth
...
@@ -269,13 +283,14 @@ func AvailableReceiptsFetchingMethods(kind RPCProviderKind) ReceiptsFetchingMeth
case
RPCKindDebugGeth
:
case
RPCKindDebugGeth
:
return
DebugGetRawReceipts
|
EthGetTransactionReceiptBatch
return
DebugGetRawReceipts
|
EthGetTransactionReceiptBatch
case
RPCKindErigon
:
case
RPCKindErigon
:
return
E
thGetBlockReceipts
|
EthGetTransactionReceiptBatch
return
E
rigonGetBlockReceiptsByBlockHash
|
EthGetTransactionReceiptBatch
case
RPCKindBasic
:
case
RPCKindBasic
:
return
EthGetTransactionReceiptBatch
return
EthGetTransactionReceiptBatch
case
RPCKindAny
:
case
RPCKindAny
:
// if it's any kind of RPC provider, then try all methods
// if it's any kind of RPC provider, then try all methods
return
AlchemyGetTransactionReceipts
|
EthGetBlockReceipts
|
return
AlchemyGetTransactionReceipts
|
EthGetBlockReceipts
|
DebugGetRawReceipts
|
ParityGetBlockReceipts
|
EthGetTransactionReceiptBatch
DebugGetRawReceipts
|
ErigonGetBlockReceiptsByBlockHash
|
ParityGetBlockReceipts
|
EthGetTransactionReceiptBatch
default
:
default
:
return
EthGetTransactionReceiptBatch
return
EthGetTransactionReceiptBatch
}
}
...
@@ -310,6 +325,9 @@ func PickBestReceiptsFetchingMethod(kind RPCProviderKind, available ReceiptsFetc
...
@@ -310,6 +325,9 @@ func PickBestReceiptsFetchingMethod(kind RPCProviderKind, available ReceiptsFetc
if
available
&
DebugGetRawReceipts
!=
0
{
if
available
&
DebugGetRawReceipts
!=
0
{
return
DebugGetRawReceipts
return
DebugGetRawReceipts
}
}
if
available
&
ErigonGetBlockReceiptsByBlockHash
!=
0
{
return
ErigonGetBlockReceiptsByBlockHash
}
if
available
&
EthGetBlockReceipts
!=
0
{
if
available
&
EthGetBlockReceipts
!=
0
{
return
EthGetBlockReceipts
return
EthGetBlockReceipts
}
}
...
@@ -428,6 +446,8 @@ func (job *receiptsFetchingJob) runAltMethod(ctx context.Context, m ReceiptsFetc
...
@@ -428,6 +446,8 @@ func (job *receiptsFetchingJob) runAltMethod(ctx context.Context, m ReceiptsFetc
err
=
job
.
client
.
CallContext
(
ctx
,
&
result
,
"parity_getBlockReceipts"
,
job
.
block
.
Hash
)
err
=
job
.
client
.
CallContext
(
ctx
,
&
result
,
"parity_getBlockReceipts"
,
job
.
block
.
Hash
)
case
EthGetBlockReceipts
:
case
EthGetBlockReceipts
:
err
=
job
.
client
.
CallContext
(
ctx
,
&
result
,
"eth_getBlockReceipts"
,
job
.
block
.
Hash
)
err
=
job
.
client
.
CallContext
(
ctx
,
&
result
,
"eth_getBlockReceipts"
,
job
.
block
.
Hash
)
case
ErigonGetBlockReceiptsByBlockHash
:
err
=
job
.
client
.
CallContext
(
ctx
,
&
result
,
"erigon_getBlockReceiptsByBlockHash"
,
job
.
block
.
Hash
)
default
:
default
:
err
=
fmt
.
Errorf
(
"unknown receipt fetching method: %d"
,
uint64
(
m
))
err
=
fmt
.
Errorf
(
"unknown receipt fetching method: %d"
,
uint64
(
m
))
}
}
...
...
op-node/sources/receipts_test.go
View file @
503515ec
...
@@ -40,6 +40,15 @@ func (b *ethBackend) GetBlockReceipts(id string) ([]*types.Receipt, error) {
...
@@ -40,6 +40,15 @@ func (b *ethBackend) GetBlockReceipts(id string) ([]*types.Receipt, error) {
return
out
[
0
]
.
([]
*
types
.
Receipt
),
*
out
[
1
]
.
(
*
error
)
return
out
[
0
]
.
([]
*
types
.
Receipt
),
*
out
[
1
]
.
(
*
error
)
}
}
type
erigonBackend
struct
{
*
mock
.
Mock
}
func
(
b
*
erigonBackend
)
GetBlockReceiptsByBlockHash
(
id
string
)
([]
*
types
.
Receipt
,
error
)
{
out
:=
b
.
Mock
.
MethodCalled
(
"erigon_getBlockReceiptsByBlockHash"
,
id
)
return
out
[
0
]
.
([]
*
types
.
Receipt
),
*
out
[
1
]
.
(
*
error
)
}
type
alchemyBackend
struct
{
type
alchemyBackend
struct
{
*
mock
.
Mock
*
mock
.
Mock
}
}
...
@@ -99,6 +108,7 @@ func (tc *ReceiptsTestCase) Run(t *testing.T) {
...
@@ -99,6 +108,7 @@ func (tc *ReceiptsTestCase) Run(t *testing.T) {
require
.
NoError
(
t
,
srv
.
RegisterName
(
"alchemy"
,
&
alchemyBackend
{
Mock
:
m
}))
require
.
NoError
(
t
,
srv
.
RegisterName
(
"alchemy"
,
&
alchemyBackend
{
Mock
:
m
}))
require
.
NoError
(
t
,
srv
.
RegisterName
(
"debug"
,
&
debugBackend
{
Mock
:
m
}))
require
.
NoError
(
t
,
srv
.
RegisterName
(
"debug"
,
&
debugBackend
{
Mock
:
m
}))
require
.
NoError
(
t
,
srv
.
RegisterName
(
"parity"
,
&
parityBackend
{
Mock
:
m
}))
require
.
NoError
(
t
,
srv
.
RegisterName
(
"parity"
,
&
parityBackend
{
Mock
:
m
}))
require
.
NoError
(
t
,
srv
.
RegisterName
(
"erigon"
,
&
erigonBackend
{
Mock
:
m
}))
block
,
requests
:=
tc
.
setup
(
t
)
block
,
requests
:=
tc
.
setup
(
t
)
...
@@ -127,6 +137,8 @@ func (tc *ReceiptsTestCase) Run(t *testing.T) {
...
@@ -127,6 +137,8 @@ func (tc *ReceiptsTestCase) Run(t *testing.T) {
m
.
On
(
"parity_getBlockReceipts"
,
block
.
Hash
.
String
())
.
Once
()
.
Return
(
req
.
result
,
&
req
.
err
)
m
.
On
(
"parity_getBlockReceipts"
,
block
.
Hash
.
String
())
.
Once
()
.
Return
(
req
.
result
,
&
req
.
err
)
case
EthGetBlockReceipts
:
case
EthGetBlockReceipts
:
m
.
On
(
"eth_getBlockReceipts"
,
block
.
Hash
.
String
())
.
Once
()
.
Return
(
req
.
result
,
&
req
.
err
)
m
.
On
(
"eth_getBlockReceipts"
,
block
.
Hash
.
String
())
.
Once
()
.
Return
(
req
.
result
,
&
req
.
err
)
case
ErigonGetBlockReceiptsByBlockHash
:
m
.
On
(
"erigon_getBlockReceiptsByBlockHash"
,
block
.
Hash
.
String
())
.
Once
()
.
Return
(
req
.
result
,
&
req
.
err
)
default
:
default
:
t
.
Fatalf
(
"unrecognized request method: %d"
,
uint64
(
req
.
method
))
t
.
Fatalf
(
"unrecognized request method: %d"
,
uint64
(
req
.
method
))
}
}
...
@@ -286,7 +298,7 @@ func TestEthClient_FetchReceipts(t *testing.T) {
...
@@ -286,7 +298,7 @@ func TestEthClient_FetchReceipts(t *testing.T) {
{
{
name
:
"erigon"
,
name
:
"erigon"
,
providerKind
:
RPCKindErigon
,
providerKind
:
RPCKindErigon
,
setup
:
fallbackCase
(
4
,
E
thGetBlockReceipts
),
setup
:
fallbackCase
(
4
,
E
rigonGetBlockReceiptsByBlockHash
),
},
},
{
{
name
:
"basic"
,
name
:
"basic"
,
...
@@ -305,6 +317,7 @@ func TestEthClient_FetchReceipts(t *testing.T) {
...
@@ -305,6 +317,7 @@ func TestEthClient_FetchReceipts(t *testing.T) {
setup
:
fallbackCase
(
4
,
setup
:
fallbackCase
(
4
,
AlchemyGetTransactionReceipts
,
AlchemyGetTransactionReceipts
,
DebugGetRawReceipts
,
DebugGetRawReceipts
,
ErigonGetBlockReceiptsByBlockHash
,
EthGetBlockReceipts
,
EthGetBlockReceipts
,
ParityGetBlockReceipts
,
ParityGetBlockReceipts
,
),
),
...
...
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