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
b6152b2f
Commit
b6152b2f
authored
Apr 16, 2025
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug and add log
parent
893bf27b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
22 deletions
+59
-22
binding_test.go
op-proposer/bindings/binding_test.go
+22
-0
driver.go
op-proposer/proposer/driver.go
+6
-6
operator.go
op-proposer/proposer/operator.go
+31
-16
No files found.
op-proposer/bindings/binding_test.go
0 → 100644
View file @
b6152b2f
package
bindings
import
(
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"math/big"
"testing"
)
func
TestL2oo
(
t
*
testing
.
T
)
{
url
:=
"https://achain.bitheart.org"
client
,
_
:=
ethclient
.
Dial
(
url
)
l2ooContract
,
_
:=
NewL2OutputOracle
(
common
.
HexToAddress
(
"0xB90B39722517Fcaa565146Ee3877fF9AEa0C9a85"
),
client
)
callOpts
:=
&
bind
.
CallOpts
{}
index
,
err
:=
l2ooContract
.
GetL2OutputIndexAfter
(
callOpts
,
big
.
NewInt
(
10
))
if
err
!=
nil
{
t
.
Error
(
err
)
}
else
{
t
.
Log
(
"index:"
,
index
)
}
}
op-proposer/proposer/driver.go
View file @
b6152b2f
...
@@ -259,12 +259,12 @@ func (l *L2OutputSubmitter) FetchL2OOOutput(ctx context.Context) (*eth.OutputRes
...
@@ -259,12 +259,12 @@ func (l *L2OutputSubmitter) FetchL2OOOutput(ctx context.Context) (*eth.OutputRes
// Always propose if it's part of the Finalized L2 chain. Or if allowed, if it's part of the safe L2 chain.
// Always propose if it's part of the Finalized L2 chain. Or if allowed, if it's part of the safe L2 chain.
if
output
.
BlockRef
.
Number
>
output
.
Status
.
FinalizedL2
.
Number
&&
(
!
l
.
Cfg
.
AllowNonFinalized
||
output
.
BlockRef
.
Number
>
output
.
Status
.
SafeL2
.
Number
)
{
if
output
.
BlockRef
.
Number
>
output
.
Status
.
FinalizedL2
.
Number
&&
(
!
l
.
Cfg
.
AllowNonFinalized
||
output
.
BlockRef
.
Number
>
output
.
Status
.
SafeL2
.
Number
)
{
l
.
Log
.
Debug
(
"Not proposing yet, L2 block is not ready for proposal"
,
//l.Log.Info
("Not proposing yet, L2 block is not ready for proposal",
"l2_proposal"
,
output
.
BlockRef
,
//
"l2_proposal", output.BlockRef,
"l2_safe"
,
output
.
Status
.
SafeL2
,
//
"l2_safe", output.Status.SafeL2,
"l2_finalized"
,
output
.
Status
.
FinalizedL2
,
//
"l2_finalized", output.Status.FinalizedL2,
"allow_non_finalized"
,
l
.
Cfg
.
AllowNonFinalized
)
//
"allow_non_finalized", l.Cfg.AllowNonFinalized)
return
output
,
false
,
nil
//
return output, false, nil
}
}
return
output
,
true
,
nil
return
output
,
true
,
nil
}
}
...
...
op-proposer/proposer/operator.go
View file @
b6152b2f
...
@@ -111,11 +111,7 @@ func (l *Operator) GetProgress() OperatorProgress {
...
@@ -111,11 +111,7 @@ func (l *Operator) GetProgress() OperatorProgress {
return
progress
return
progress
}
}
func
(
l
*
Operator
)
SetProgress
(
blockNum
uint64
,
index
uint64
)
{
func
(
l
*
Operator
)
SetProgress
(
progress
OperatorProgress
)
{
progress
:=
OperatorProgress
{
BlockNumber
:
blockNum
,
Index
:
index
,
}
value
,
err
:=
json
.
Marshal
(
progress
)
value
,
err
:=
json
.
Marshal
(
progress
)
if
err
!=
nil
{
if
err
!=
nil
{
l
.
Log
.
Error
(
"failed to marshal operator progress"
,
"err"
,
err
)
l
.
Log
.
Error
(
"failed to marshal operator progress"
,
"err"
,
err
)
...
@@ -202,7 +198,7 @@ func (l *Operator) StopOperatorIfRunning() error {
...
@@ -202,7 +198,7 @@ func (l *Operator) StopOperatorIfRunning() error {
func
(
l
*
Operator
)
getL2ooIndex
(
callOpts
*
bind
.
CallOpts
,
l2BlockNumber
uint64
)
(
*
big
.
Int
,
error
)
{
func
(
l
*
Operator
)
getL2ooIndex
(
callOpts
*
bind
.
CallOpts
,
l2BlockNumber
uint64
)
(
*
big
.
Int
,
error
)
{
index
,
err
:=
l
.
l2ooContract
.
GetL2OutputIndexAfter
(
callOpts
,
big
.
NewInt
(
int64
(
l2BlockNumber
)))
index
,
err
:=
l
.
l2ooContract
.
GetL2OutputIndexAfter
(
callOpts
,
big
.
NewInt
(
int64
(
l2BlockNumber
)))
if
err
!=
nil
{
if
err
!=
nil
{
l
.
Log
.
Error
(
"failed to get l2 output index after"
,
"err"
,
err
)
l
.
Log
.
Error
(
"failed to get l2 output index after"
,
"err"
,
err
,
"l2blk"
,
l2BlockNumber
)
return
nil
,
err
return
nil
,
err
}
}
return
index
,
nil
return
index
,
nil
...
@@ -242,7 +238,7 @@ func (l *Operator) DoOperator(ctx context.Context) {
...
@@ -242,7 +238,7 @@ func (l *Operator) DoOperator(ctx context.Context) {
l
.
Log
.
Error
(
"failed to get latest block number from l2oo"
,
"err"
,
err
)
l
.
Log
.
Error
(
"failed to get latest block number from l2oo"
,
"err"
,
err
)
return
return
}
}
l
.
Log
.
Info
(
"latest block number from l2oo"
,
"l2Latest"
,
l2Latest
,
"progress"
,
progress
)
l
.
Log
.
Info
(
"
operator
latest block number from l2oo"
,
"l2Latest"
,
l2Latest
,
"progress"
,
progress
)
currentFinished
:=
false
currentFinished
:=
false
if
progress
.
Total
==
0
||
progress
.
Index
==
(
progress
.
Total
-
1
)
{
if
progress
.
Total
==
0
||
progress
.
Index
==
(
progress
.
Total
-
1
)
{
currentFinished
=
true
currentFinished
=
true
...
@@ -299,7 +295,11 @@ func (l *Operator) DoOperator(ctx context.Context) {
...
@@ -299,7 +295,11 @@ func (l *Operator) DoOperator(ctx context.Context) {
}
else
{
}
else
{
index
++
index
++
// update process.
// update process.
l
.
SetProgress
(
index
,
progress
.
Total
)
l
.
SetProgress
(
OperatorProgress
{
BlockNumber
:
progress
.
BlockNumber
,
Index
:
index
,
Total
:
progress
.
Total
,
})
}
}
}
}
}
}
...
@@ -311,11 +311,28 @@ func (l *Operator) DoOperator(ctx context.Context) {
...
@@ -311,11 +311,28 @@ func (l *Operator) DoOperator(ctx context.Context) {
}
}
// 4. to process next block.
// 4. to process next block.
for
blkNum
:=
progress
.
BlockNumber
+
1
;
blkNum
<=
l2Latest
.
Uint64
();
blkNum
++
{
for
blkNum
:=
progress
.
BlockNumber
+
1
;
blkNum
<=
l2Latest
.
Uint64
();
blkNum
++
{
ooIndex
,
err
:=
l
.
getL2ooIndex
(
callOpts
,
blkNum
)
if
err
!=
nil
{
l
.
Log
.
Error
(
"operator failed to get l2oo index and output"
,
"err"
,
err
)
return
}
withDrawalTxs
:=
make
([]
common
.
Hash
,
0
)
withDrawalTxs
:=
make
([]
common
.
Hash
,
0
)
if
txs
,
err
:=
rollupClient
.
WithdrawalTxs
(
ctx
,
blkNum
);
err
!=
nil
{
if
txs
,
err
:=
rollupClient
.
WithdrawalTxs
(
ctx
,
blkNum
);
err
!=
nil
{
l
.
Log
.
Error
(
"failed to get withdrawal txs"
,
"blknum"
,
blkNum
,
"err"
,
err
)
l
.
Log
.
Error
(
"failed to get withdrawal txs"
,
"blknum"
,
blkNum
,
"err"
,
err
)
return
return
}
else
{
}
else
{
if
len
(
txs
)
==
0
{
l
.
Log
.
Info
(
"ignore block no txs to withdrawal"
,
"blknum"
,
blkNum
)
l
.
SetOperatorTaskList
(
OperatorTaskList
{})
l
.
SetProgress
(
OperatorProgress
{
BlockNumber
:
blkNum
,
Index
:
0
,
Total
:
0
,
})
continue
}
withDrawalTxs
=
append
(
withDrawalTxs
,
txs
...
)
withDrawalTxs
=
append
(
withDrawalTxs
,
txs
...
)
}
}
newProgress
:=
OperatorProgress
{
newProgress
:=
OperatorProgress
{
...
@@ -331,13 +348,7 @@ func (l *Operator) DoOperator(ctx context.Context) {
...
@@ -331,13 +348,7 @@ func (l *Operator) DoOperator(ctx context.Context) {
tasks
=
append
(
tasks
,
task
)
tasks
=
append
(
tasks
,
task
)
}
}
l
.
SetOperatorTaskList
(
tasks
)
l
.
SetOperatorTaskList
(
tasks
)
l
.
SetProgress
(
newProgress
.
BlockNumber
,
newProgress
.
Index
)
l
.
SetProgress
(
newProgress
)
ooIndex
,
err
:=
l
.
getL2ooIndex
(
callOpts
,
progress
.
BlockNumber
)
if
err
!=
nil
{
l
.
Log
.
Error
(
"failed to get l2oo index and output"
,
"err"
,
err
)
return
}
// 5. to process each withdrawal tx.
// 5. to process each withdrawal tx.
index
:=
newProgress
.
Index
index
:=
newProgress
.
Index
...
@@ -373,7 +384,11 @@ func (l *Operator) DoOperator(ctx context.Context) {
...
@@ -373,7 +384,11 @@ func (l *Operator) DoOperator(ctx context.Context) {
}
else
{
}
else
{
index
++
index
++
// update process.
// update process.
l
.
SetProgress
(
index
,
newProgress
.
Total
)
l
.
SetProgress
(
OperatorProgress
{
BlockNumber
:
newProgress
.
BlockNumber
,
Index
:
index
,
Total
:
newProgress
.
Total
,
})
}
}
}
}
}
}
...
...
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