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
ce93b945
Commit
ce93b945
authored
Oct 31, 2023
by
Tei Im
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix op-program to get output root from specified block number
parent
3e16cd7b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
13 deletions
+16
-13
driver.go
op-program/client/driver/driver.go
+4
-4
driver_test.go
op-program/client/driver/driver_test.go
+6
-6
engine.go
op-program/client/l2/engine.go
+5
-2
program.go
op-program/client/program.go
+1
-1
No files found.
op-program/client/driver/driver.go
View file @
ce93b945
...
@@ -25,13 +25,13 @@ type Derivation interface {
...
@@ -25,13 +25,13 @@ type Derivation interface {
type
L2Source
interface
{
type
L2Source
interface
{
derive
.
Engine
derive
.
Engine
L2OutputRoot
()
(
eth
.
Bytes32
,
error
)
L2OutputRoot
(
uint64
)
(
eth
.
Bytes32
,
error
)
}
}
type
Driver
struct
{
type
Driver
struct
{
logger
log
.
Logger
logger
log
.
Logger
pipeline
Derivation
pipeline
Derivation
l2OutputRoot
func
()
(
eth
.
Bytes32
,
error
)
l2OutputRoot
func
(
uint64
)
(
eth
.
Bytes32
,
error
)
targetBlockNum
uint64
targetBlockNum
uint64
}
}
...
@@ -77,8 +77,8 @@ func (d *Driver) SafeHead() eth.L2BlockRef {
...
@@ -77,8 +77,8 @@ func (d *Driver) SafeHead() eth.L2BlockRef {
return
d
.
pipeline
.
SafeL2Head
()
return
d
.
pipeline
.
SafeL2Head
()
}
}
func
(
d
*
Driver
)
ValidateClaim
(
claimedOutputRoot
eth
.
Bytes32
)
error
{
func
(
d
*
Driver
)
ValidateClaim
(
l2ClaimBlockNum
uint64
,
claimedOutputRoot
eth
.
Bytes32
)
error
{
outputRoot
,
err
:=
d
.
l2OutputRoot
()
outputRoot
,
err
:=
d
.
l2OutputRoot
(
l2ClaimBlockNum
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"calculate L2 output root: %w"
,
err
)
return
fmt
.
Errorf
(
"calculate L2 output root: %w"
,
err
)
}
}
...
...
op-program/client/driver/driver_test.go
View file @
ce93b945
...
@@ -73,29 +73,29 @@ func TestValidateClaim(t *testing.T) {
...
@@ -73,29 +73,29 @@ func TestValidateClaim(t *testing.T) {
t
.
Run
(
"Valid"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"Valid"
,
func
(
t
*
testing
.
T
)
{
driver
:=
createDriver
(
t
,
io
.
EOF
)
driver
:=
createDriver
(
t
,
io
.
EOF
)
expected
:=
eth
.
Bytes32
{
0x11
}
expected
:=
eth
.
Bytes32
{
0x11
}
driver
.
l2OutputRoot
=
func
()
(
eth
.
Bytes32
,
error
)
{
driver
.
l2OutputRoot
=
func
(
_
uint64
)
(
eth
.
Bytes32
,
error
)
{
return
expected
,
nil
return
expected
,
nil
}
}
err
:=
driver
.
ValidateClaim
(
expected
)
err
:=
driver
.
ValidateClaim
(
uint64
(
0
),
expected
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
})
})
t
.
Run
(
"Invalid"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"Invalid"
,
func
(
t
*
testing
.
T
)
{
driver
:=
createDriver
(
t
,
io
.
EOF
)
driver
:=
createDriver
(
t
,
io
.
EOF
)
driver
.
l2OutputRoot
=
func
()
(
eth
.
Bytes32
,
error
)
{
driver
.
l2OutputRoot
=
func
(
_
uint64
)
(
eth
.
Bytes32
,
error
)
{
return
eth
.
Bytes32
{
0x22
},
nil
return
eth
.
Bytes32
{
0x22
},
nil
}
}
err
:=
driver
.
ValidateClaim
(
eth
.
Bytes32
{
0x11
})
err
:=
driver
.
ValidateClaim
(
uint64
(
0
),
eth
.
Bytes32
{
0x11
})
require
.
ErrorIs
(
t
,
err
,
ErrClaimNotValid
)
require
.
ErrorIs
(
t
,
err
,
ErrClaimNotValid
)
})
})
t
.
Run
(
"Error"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"Error"
,
func
(
t
*
testing
.
T
)
{
driver
:=
createDriver
(
t
,
io
.
EOF
)
driver
:=
createDriver
(
t
,
io
.
EOF
)
expectedErr
:=
errors
.
New
(
"boom"
)
expectedErr
:=
errors
.
New
(
"boom"
)
driver
.
l2OutputRoot
=
func
()
(
eth
.
Bytes32
,
error
)
{
driver
.
l2OutputRoot
=
func
(
_
uint64
)
(
eth
.
Bytes32
,
error
)
{
return
eth
.
Bytes32
{},
expectedErr
return
eth
.
Bytes32
{},
expectedErr
}
}
err
:=
driver
.
ValidateClaim
(
eth
.
Bytes32
{
0x11
})
err
:=
driver
.
ValidateClaim
(
uint64
(
0
),
eth
.
Bytes32
{
0x11
})
require
.
ErrorIs
(
t
,
err
,
expectedErr
)
require
.
ErrorIs
(
t
,
err
,
expectedErr
)
})
})
}
}
...
...
op-program/client/l2/engine.go
View file @
ce93b945
...
@@ -34,8 +34,11 @@ func NewOracleEngine(rollupCfg *rollup.Config, logger log.Logger, backend engine
...
@@ -34,8 +34,11 @@ func NewOracleEngine(rollupCfg *rollup.Config, logger log.Logger, backend engine
}
}
}
}
func
(
o
*
OracleEngine
)
L2OutputRoot
()
(
eth
.
Bytes32
,
error
)
{
func
(
o
*
OracleEngine
)
L2OutputRoot
(
l2ClaimBlockNum
uint64
)
(
eth
.
Bytes32
,
error
)
{
outBlock
:=
o
.
backend
.
CurrentHeader
()
outBlock
:=
o
.
backend
.
GetHeaderByNumber
(
l2ClaimBlockNum
)
if
outBlock
==
nil
{
return
eth
.
Bytes32
{},
fmt
.
Errorf
(
"failed to get L2 block at %d"
,
l2ClaimBlockNum
)
}
stateDB
,
err
:=
o
.
backend
.
StateAt
(
outBlock
.
Root
)
stateDB
,
err
:=
o
.
backend
.
StateAt
(
outBlock
.
Root
)
if
err
!=
nil
{
if
err
!=
nil
{
return
eth
.
Bytes32
{},
fmt
.
Errorf
(
"failed to open L2 state db at block %s: %w"
,
outBlock
.
Hash
(),
err
)
return
eth
.
Bytes32
{},
fmt
.
Errorf
(
"failed to open L2 state db at block %s: %w"
,
outBlock
.
Hash
(),
err
)
...
...
op-program/client/program.go
View file @
ce93b945
...
@@ -79,7 +79,7 @@ func runDerivation(logger log.Logger, cfg *rollup.Config, l2Cfg *params.ChainCon
...
@@ -79,7 +79,7 @@ func runDerivation(logger log.Logger, cfg *rollup.Config, l2Cfg *params.ChainCon
return
err
return
err
}
}
}
}
return
d
.
ValidateClaim
(
eth
.
Bytes32
(
l2Claim
))
return
d
.
ValidateClaim
(
l2ClaimBlockNum
,
eth
.
Bytes32
(
l2Claim
))
}
}
func
CreateHinterChannel
()
oppio
.
FileChannel
{
func
CreateHinterChannel
()
oppio
.
FileChannel
{
...
...
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