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
1029095c
Unverified
Commit
1029095c
authored
Apr 12, 2023
by
mergify[bot]
Committed by
GitHub
Apr 12, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into aj/fpp-engine-unknown-block
parents
7742c972
52779a2b
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
127 additions
and
23 deletions
+127
-23
config.yml
.circleci/config.yml
+1
-1
channel_manager.go
op-batcher/batcher/channel_manager.go
+1
-1
driver.go
op-batcher/batcher/driver.go
+1
-1
metrics.go
op-batcher/metrics/metrics.go
+20
-6
batching.go
op-node/sources/batching.go
+19
-4
batching_test.go
op-node/sources/batching_test.go
+80
-6
receipts.go
op-node/sources/receipts.go
+1
-0
txmgr.go
op-service/txmgr/txmgr.go
+3
-3
proposals.md
specs/proposals.md
+1
-1
No files found.
.circleci/config.yml
View file @
1029095c
...
...
@@ -600,7 +600,7 @@ jobs:
-
run
:
name
:
run lint
command
:
|
golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout
2
m -e "errors.As" -e "errors.Is" ./...
golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout
5
m -e "errors.As" -e "errors.Is" ./...
working_directory
:
<<parameters.module>>
go-test
:
...
...
op-batcher/batcher/channel_manager.go
View file @
1029095c
...
...
@@ -82,7 +82,7 @@ func (s *channelManager) TxFailed(id txID) {
}
s
.
metr
.
RecordBatchTxFailed
()
if
s
.
closed
&&
len
(
s
.
confirmedTransactions
)
==
0
&&
len
(
s
.
pendingTransactions
)
==
0
{
if
s
.
closed
&&
len
(
s
.
confirmedTransactions
)
==
0
&&
len
(
s
.
pendingTransactions
)
==
0
&&
s
.
pendingChannel
!=
nil
{
s
.
log
.
Info
(
"Channel has no submitted transactions, clearing for shutdown"
,
"chID"
,
s
.
pendingChannel
.
ID
())
s
.
clearPendingChannel
()
}
...
...
op-batcher/batcher/driver.go
View file @
1029095c
...
...
@@ -191,7 +191,7 @@ func (l *BatchSubmitter) loadBlocksIntoState(ctx context.Context) {
if
err
!=
nil
{
l
.
log
.
Warn
(
"Error calculating L2 block range"
,
"err"
,
err
)
return
}
else
if
start
.
Number
=
=
end
.
Number
{
}
else
if
start
.
Number
>
=
end
.
Number
{
return
}
...
...
op-batcher/metrics/metrics.go
View file @
1029095c
...
...
@@ -58,12 +58,14 @@ type Metrics struct {
PendingBlocksCount
prometheus
.
GaugeVec
BlocksAddedCount
prometheus
.
Gauge
ChannelInputBytes
prometheus
.
GaugeVec
ChannelReadyBytes
prometheus
.
Gauge
ChannelOutputBytes
prometheus
.
Gauge
ChannelClosedReason
prometheus
.
Gauge
ChannelNumFrames
prometheus
.
Gauge
ChannelComprRatio
prometheus
.
Histogram
ChannelInputBytes
prometheus
.
GaugeVec
ChannelReadyBytes
prometheus
.
Gauge
ChannelOutputBytes
prometheus
.
Gauge
ChannelClosedReason
prometheus
.
Gauge
ChannelNumFrames
prometheus
.
Gauge
ChannelComprRatio
prometheus
.
Histogram
ChannelInputBytesTotal
prometheus
.
Counter
ChannelOutputBytesTotal
prometheus
.
Counter
BatcherTxEvs
opmetrics
.
EventVec
}
...
...
@@ -144,6 +146,16 @@ func NewMetrics(procName string) *Metrics {
Help
:
"Compression ratios of closed channel."
,
Buckets
:
append
([]
float64
{
0.1
,
0.2
},
prometheus
.
LinearBuckets
(
0.3
,
0.05
,
14
)
...
),
}),
ChannelInputBytesTotal
:
factory
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
ns
,
Name
:
"input_bytes_total"
,
Help
:
"Total number of bytes to a channel."
,
}),
ChannelOutputBytesTotal
:
factory
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
ns
,
Name
:
"output_bytes_total"
,
Help
:
"Total number of compressed output bytes from a channel."
,
}),
BatcherTxEvs
:
opmetrics
.
NewEventVec
(
factory
,
ns
,
""
,
"batcher_tx"
,
"BatcherTx"
,
[]
string
{
"stage"
}),
}
...
...
@@ -219,6 +231,8 @@ func (m *Metrics) RecordChannelClosed(id derive.ChannelID, numPendingBlocks int,
m
.
ChannelNumFrames
.
Set
(
float64
(
numFrames
))
m
.
ChannelInputBytes
.
WithLabelValues
(
StageClosed
)
.
Set
(
float64
(
inputBytes
))
m
.
ChannelOutputBytes
.
Set
(
float64
(
outputComprBytes
))
m
.
ChannelInputBytesTotal
.
Add
(
float64
(
inputBytes
))
m
.
ChannelOutputBytesTotal
.
Add
(
float64
(
outputComprBytes
))
var
comprRatio
float64
if
inputBytes
>
0
{
...
...
op-node/sources/batching.go
View file @
1029095c
...
...
@@ -24,6 +24,7 @@ type IterativeBatchCall[K any, V any] struct {
makeRequest
func
(
K
)
(
V
,
rpc
.
BatchElem
)
getBatch
BatchCallContextFn
getSingle
CallContextFn
requestsValues
[]
V
scheduled
chan
rpc
.
BatchElem
...
...
@@ -35,6 +36,7 @@ func NewIterativeBatchCall[K any, V any](
requestsKeys
[]
K
,
makeRequest
func
(
K
)
(
V
,
rpc
.
BatchElem
),
getBatch
BatchCallContextFn
,
getSingle
CallContextFn
,
batchSize
int
)
*
IterativeBatchCall
[
K
,
V
]
{
if
len
(
requestsKeys
)
<
batchSize
{
...
...
@@ -47,6 +49,7 @@ func NewIterativeBatchCall[K any, V any](
out
:=
&
IterativeBatchCall
[
K
,
V
]{
completed
:
0
,
getBatch
:
getBatch
,
getSingle
:
getSingle
,
requestsKeys
:
requestsKeys
,
batchSize
:
batchSize
,
makeRequest
:
makeRequest
,
...
...
@@ -119,11 +122,23 @@ func (ibc *IterativeBatchCall[K, V]) Fetch(ctx context.Context) error {
break
}
if
err
:=
ibc
.
getBatch
(
ctx
,
batch
);
err
!=
nil
{
for
_
,
r
:=
range
batch
{
ibc
.
scheduled
<-
r
if
len
(
batch
)
==
0
{
return
nil
}
if
ibc
.
batchSize
==
1
{
first
:=
batch
[
0
]
if
err
:=
ibc
.
getSingle
(
ctx
,
&
first
.
Result
,
first
.
Method
,
first
.
Args
...
);
err
!=
nil
{
ibc
.
scheduled
<-
first
return
err
}
}
else
{
if
err
:=
ibc
.
getBatch
(
ctx
,
batch
);
err
!=
nil
{
for
_
,
r
:=
range
batch
{
ibc
.
scheduled
<-
r
}
return
fmt
.
Errorf
(
"failed batch-retrieval: %w"
,
err
)
}
return
fmt
.
Errorf
(
"failed batch-retrieval: %w"
,
err
)
}
var
result
error
for
_
,
elem
:=
range
batch
{
...
...
op-node/sources/batching_test.go
View file @
1029095c
...
...
@@ -34,7 +34,8 @@ type batchTestCase struct {
batchSize
int
batchCalls
[]
batchCall
batchCalls
[]
batchCall
singleCalls
[]
elemCall
mock
.
Mock
}
...
...
@@ -53,7 +54,14 @@ func (tc *batchTestCase) GetBatch(ctx context.Context, b []rpc.BatchElem) error
if
ctx
.
Err
()
!=
nil
{
return
ctx
.
Err
()
}
return
tc
.
Mock
.
MethodCalled
(
"get"
,
b
)
.
Get
(
0
)
.
([]
error
)[
0
]
return
tc
.
Mock
.
MethodCalled
(
"getBatch"
,
b
)
.
Get
(
0
)
.
([]
error
)[
0
]
}
func
(
tc
*
batchTestCase
)
GetSingle
(
ctx
context
.
Context
,
result
any
,
method
string
,
args
...
any
)
error
{
if
ctx
.
Err
()
!=
nil
{
return
ctx
.
Err
()
}
return
tc
.
Mock
.
MethodCalled
(
"getSingle"
,
(
*
(
result
.
(
*
interface
{})))
.
(
*
string
),
method
,
args
[
0
])
.
Get
(
0
)
.
([]
error
)[
0
]
}
var
mockErr
=
errors
.
New
(
"mockErr"
)
...
...
@@ -64,7 +72,7 @@ func (tc *batchTestCase) Run(t *testing.T) {
keys
[
i
]
=
i
}
makeMock
:=
func
(
bci
int
,
bc
batchCall
)
func
(
args
mock
.
Arguments
)
{
make
Batch
Mock
:=
func
(
bci
int
,
bc
batchCall
)
func
(
args
mock
.
Arguments
)
{
return
func
(
args
mock
.
Arguments
)
{
batch
:=
args
[
0
]
.
([]
rpc
.
BatchElem
)
for
i
,
elem
:=
range
batch
{
...
...
@@ -94,10 +102,30 @@ func (tc *batchTestCase) Run(t *testing.T) {
})
}
if
len
(
bc
.
elems
)
>
0
{
tc
.
On
(
"get"
,
batch
)
.
Once
()
.
Run
(
makeMock
(
bci
,
bc
))
.
Return
([]
error
{
bc
.
rpcErr
})
// wrap to preserve nil as type of error
tc
.
On
(
"getBatch"
,
batch
)
.
Once
()
.
Run
(
makeBatchMock
(
bci
,
bc
))
.
Return
([]
error
{
bc
.
rpcErr
})
// wrap to preserve nil as type of error
}
}
makeSingleMock
:=
func
(
eci
int
,
ec
elemCall
)
func
(
args
mock
.
Arguments
)
{
return
func
(
args
mock
.
Arguments
)
{
result
:=
args
[
0
]
.
(
*
string
)
id
:=
args
[
2
]
.
(
int
)
require
.
Equal
(
t
,
ec
.
id
,
id
,
"element should match expected element"
)
if
ec
.
err
{
*
result
=
""
}
else
{
*
result
=
fmt
.
Sprintf
(
"mock result id %d"
,
id
)
}
}
}
iter
:=
NewIterativeBatchCall
[
int
,
*
string
](
keys
,
makeTestRequest
,
tc
.
GetBatch
,
tc
.
batchSize
)
// mock the results of unbatched calls
for
eci
,
ec
:=
range
tc
.
singleCalls
{
var
ret
error
if
ec
.
err
{
ret
=
mockErr
}
tc
.
On
(
"getSingle"
,
new
(
string
),
"testing_foobar"
,
ec
.
id
)
.
Once
()
.
Run
(
makeSingleMock
(
eci
,
ec
))
.
Return
([]
error
{
ret
})
}
iter
:=
NewIterativeBatchCall
[
int
,
*
string
](
keys
,
makeTestRequest
,
tc
.
GetBatch
,
tc
.
GetSingle
,
tc
.
batchSize
)
for
i
,
bc
:=
range
tc
.
batchCalls
{
ctx
:=
context
.
Background
()
if
bc
.
makeCtx
!=
nil
{
...
...
@@ -116,6 +144,20 @@ func (tc *batchTestCase) Run(t *testing.T) {
}
}
}
for
i
,
ec
:=
range
tc
.
singleCalls
{
ctx
:=
context
.
Background
()
err
:=
iter
.
Fetch
(
ctx
)
if
err
==
io
.
EOF
{
require
.
Equal
(
t
,
i
,
len
(
tc
.
singleCalls
)
-
1
,
"EOF only on last call"
)
}
else
{
require
.
False
(
t
,
iter
.
Complete
())
if
ec
.
err
{
require
.
Error
(
t
,
err
)
}
else
{
require
.
NoError
(
t
,
err
)
}
}
}
require
.
True
(
t
,
iter
.
Complete
(),
"batch iter should be complete after the expected calls"
)
out
,
err
:=
iter
.
Result
()
require
.
NoError
(
t
,
err
)
...
...
@@ -154,6 +196,37 @@ func TestFetchBatched(t *testing.T) {
},
},
},
{
name
:
"single element"
,
items
:
1
,
batchSize
:
4
,
singleCalls
:
[]
elemCall
{
{
id
:
0
,
err
:
false
},
},
},
{
name
:
"unbatched"
,
items
:
4
,
batchSize
:
1
,
singleCalls
:
[]
elemCall
{
{
id
:
0
,
err
:
false
},
{
id
:
1
,
err
:
false
},
{
id
:
2
,
err
:
false
},
{
id
:
3
,
err
:
false
},
},
},
{
name
:
"unbatched with retry"
,
items
:
4
,
batchSize
:
1
,
singleCalls
:
[]
elemCall
{
{
id
:
0
,
err
:
false
},
{
id
:
1
,
err
:
true
},
{
id
:
2
,
err
:
false
},
{
id
:
3
,
err
:
false
},
{
id
:
1
,
err
:
false
},
},
},
{
name
:
"split"
,
items
:
5
,
...
...
@@ -240,7 +313,7 @@ func TestFetchBatched(t *testing.T) {
},
{
name
:
"context timeout"
,
items
:
1
,
items
:
2
,
batchSize
:
3
,
batchCalls
:
[]
batchCall
{
{
...
...
@@ -255,6 +328,7 @@ func TestFetchBatched(t *testing.T) {
{
elems
:
[]
elemCall
{
{
id
:
0
,
err
:
false
},
{
id
:
1
,
err
:
false
},
},
err
:
""
,
},
...
...
op-node/sources/receipts.go
View file @
1029095c
...
...
@@ -373,6 +373,7 @@ func (job *receiptsFetchingJob) runFetcher(ctx context.Context) error {
job
.
txHashes
,
makeReceiptRequest
,
job
.
client
.
BatchCallContext
,
job
.
client
.
CallContext
,
job
.
maxBatchSize
,
)
}
...
...
op-service/txmgr/txmgr.go
View file @
1029095c
...
...
@@ -67,10 +67,10 @@ type ETHBackend interface {
// NonceAt returns the account nonce of the given account.
// The block number can be nil, in which case the nonce is taken from the latest known block.
NonceAt
(
ctx
context
.
Context
,
account
common
.
Address
,
blockNumber
*
big
.
Int
)
(
uint64
,
error
)
// PendingNonce returns the pending nonce.
// PendingNonce
At
returns the pending nonce.
PendingNonceAt
(
ctx
context
.
Context
,
account
common
.
Address
)
(
uint64
,
error
)
//
/
EstimateGas returns an estimate of the amount of gas needed to execute the given
//
/
transaction against the current pending block.
// EstimateGas returns an estimate of the amount of gas needed to execute the given
// transaction against the current pending block.
EstimateGas
(
ctx
context
.
Context
,
msg
ethereum
.
CallMsg
)
(
uint64
,
error
)
}
...
...
specs/proposals.md
View file @
1029095c
...
...
@@ -207,7 +207,7 @@ function deleteL2Outputs(uint256 _l2OutputIndex) external
/**
* @notice Computes the block number of the next L2 block that needs to be checkpointed.
*/
function
getN
extBlockNumber() public view returns (uint256)
function
n
extBlockNumber() public view returns (uint256)
```
### Configuration
...
...
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