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
cab9dfe9
Unverified
Commit
cab9dfe9
authored
Jul 24, 2023
by
inphi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename L2OutputRoot
parent
e93af705
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
23 additions
and
22 deletions
+23
-22
mock_l2.go
op-node/testutils/mock_l2.go
+4
-4
cache.go
op-program/client/l2/cache.go
+2
-2
engine_backend.go
op-program/client/l2/engine_backend.go
+1
-1
oracle.go
op-program/client/l2/oracle.go
+2
-2
stub_oracle.go
op-program/client/l2/test/stub_oracle.go
+1
-1
flags.go
op-program/host/flags/flags.go
+2
-2
l2_client.go
op-program/host/l2_client.go
+2
-1
prefetcher.go
op-program/host/prefetcher/prefetcher.go
+2
-2
retry.go
op-program/host/prefetcher/retry.go
+2
-2
retry_test.go
op-program/host/prefetcher/retry_test.go
+4
-4
goerli.go
op-program/verify/cmd/goerli.go
+1
-1
No files found.
op-node/testutils/mock_l2.go
View file @
cab9dfe9
...
@@ -44,11 +44,11 @@ func (m *MockL2Client) ExpectSystemConfigByL2Hash(hash common.Hash, cfg eth.Syst
...
@@ -44,11 +44,11 @@ func (m *MockL2Client) ExpectSystemConfigByL2Hash(hash common.Hash, cfg eth.Syst
m
.
Mock
.
On
(
"SystemConfigByL2Hash"
,
hash
)
.
Once
()
.
Return
(
cfg
,
&
err
)
m
.
Mock
.
On
(
"SystemConfigByL2Hash"
,
hash
)
.
Once
()
.
Return
(
cfg
,
&
err
)
}
}
func
(
m
*
MockL2Client
)
L2
OutputByRoot
(
ctx
context
.
Context
,
root
common
.
Hash
)
(
eth
.
Output
,
error
)
{
func
(
m
*
MockL2Client
)
OutputByRoot
(
ctx
context
.
Context
,
root
common
.
Hash
)
(
eth
.
Output
,
error
)
{
out
:=
m
.
Mock
.
MethodCalled
(
"
L2
OutputByRoot"
,
root
)
out
:=
m
.
Mock
.
MethodCalled
(
"OutputByRoot"
,
root
)
return
out
[
0
]
.
(
eth
.
Output
),
*
out
[
1
]
.
(
*
error
)
return
out
[
0
]
.
(
eth
.
Output
),
*
out
[
1
]
.
(
*
error
)
}
}
func
(
m
*
MockL2Client
)
Expect
L2
OutputByRoot
(
root
common
.
Hash
,
output
eth
.
Output
,
err
error
)
{
func
(
m
*
MockL2Client
)
ExpectOutputByRoot
(
root
common
.
Hash
,
output
eth
.
Output
,
err
error
)
{
m
.
Mock
.
On
(
"
L2
OutputByRoot"
,
root
)
.
Once
()
.
Return
(
output
,
&
err
)
m
.
Mock
.
On
(
"OutputByRoot"
,
root
)
.
Once
()
.
Return
(
output
,
&
err
)
}
}
op-program/client/l2/cache.go
View file @
cab9dfe9
...
@@ -65,12 +65,12 @@ func (o *CachingOracle) BlockByHash(blockHash common.Hash) *types.Block {
...
@@ -65,12 +65,12 @@ func (o *CachingOracle) BlockByHash(blockHash common.Hash) *types.Block {
return
block
return
block
}
}
func
(
o
*
CachingOracle
)
L2
OutputByRoot
(
root
common
.
Hash
)
eth
.
Output
{
func
(
o
*
CachingOracle
)
OutputByRoot
(
root
common
.
Hash
)
eth
.
Output
{
output
,
ok
:=
o
.
outputs
.
Get
(
root
)
output
,
ok
:=
o
.
outputs
.
Get
(
root
)
if
ok
{
if
ok
{
return
output
return
output
}
}
output
=
o
.
oracle
.
L2
OutputByRoot
(
root
)
output
=
o
.
oracle
.
OutputByRoot
(
root
)
o
.
outputs
.
Add
(
root
,
output
)
o
.
outputs
.
Add
(
root
,
output
)
return
output
return
output
}
}
op-program/client/l2/engine_backend.go
View file @
cab9dfe9
...
@@ -41,7 +41,7 @@ type OracleBackedL2Chain struct {
...
@@ -41,7 +41,7 @@ type OracleBackedL2Chain struct {
var
_
engineapi
.
EngineBackend
=
(
*
OracleBackedL2Chain
)(
nil
)
var
_
engineapi
.
EngineBackend
=
(
*
OracleBackedL2Chain
)(
nil
)
func
NewOracleBackedL2Chain
(
logger
log
.
Logger
,
oracle
Oracle
,
chainCfg
*
params
.
ChainConfig
,
l2OutputRoot
common
.
Hash
)
(
*
OracleBackedL2Chain
,
error
)
{
func
NewOracleBackedL2Chain
(
logger
log
.
Logger
,
oracle
Oracle
,
chainCfg
*
params
.
ChainConfig
,
l2OutputRoot
common
.
Hash
)
(
*
OracleBackedL2Chain
,
error
)
{
output
:=
oracle
.
L2
OutputByRoot
(
l2OutputRoot
)
output
:=
oracle
.
OutputByRoot
(
l2OutputRoot
)
outputV0
,
ok
:=
output
.
(
*
eth
.
OutputV0
)
outputV0
,
ok
:=
output
.
(
*
eth
.
OutputV0
)
if
!
ok
{
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"unsupported L2 output version: %d"
,
output
.
Version
())
return
nil
,
fmt
.
Errorf
(
"unsupported L2 output version: %d"
,
output
.
Version
())
...
...
op-program/client/l2/oracle.go
View file @
cab9dfe9
...
@@ -33,7 +33,7 @@ type Oracle interface {
...
@@ -33,7 +33,7 @@ type Oracle interface {
// BlockByHash retrieves the block with the given hash.
// BlockByHash retrieves the block with the given hash.
BlockByHash
(
blockHash
common
.
Hash
)
*
types
.
Block
BlockByHash
(
blockHash
common
.
Hash
)
*
types
.
Block
L2
OutputByRoot
(
root
common
.
Hash
)
eth
.
Output
OutputByRoot
(
root
common
.
Hash
)
eth
.
Output
}
}
// PreimageOracle implements Oracle using by interfacing with the pure preimage.Oracle
// PreimageOracle implements Oracle using by interfacing with the pure preimage.Oracle
...
@@ -88,7 +88,7 @@ func (p *PreimageOracle) CodeByHash(codeHash common.Hash) []byte {
...
@@ -88,7 +88,7 @@ func (p *PreimageOracle) CodeByHash(codeHash common.Hash) []byte {
return
p
.
oracle
.
Get
(
preimage
.
Keccak256Key
(
codeHash
))
return
p
.
oracle
.
Get
(
preimage
.
Keccak256Key
(
codeHash
))
}
}
func
(
p
*
PreimageOracle
)
L2
OutputByRoot
(
l2OutputRoot
common
.
Hash
)
eth
.
Output
{
func
(
p
*
PreimageOracle
)
OutputByRoot
(
l2OutputRoot
common
.
Hash
)
eth
.
Output
{
p
.
hint
.
Hint
(
L2OutputHint
(
l2OutputRoot
))
p
.
hint
.
Hint
(
L2OutputHint
(
l2OutputRoot
))
data
:=
p
.
oracle
.
Get
(
preimage
.
Keccak256Key
(
l2OutputRoot
))
data
:=
p
.
oracle
.
Get
(
preimage
.
Keccak256Key
(
l2OutputRoot
))
output
,
err
:=
eth
.
UnmarshalOutput
(
data
)
output
,
err
:=
eth
.
UnmarshalOutput
(
data
)
...
...
op-program/client/l2/test/stub_oracle.go
View file @
cab9dfe9
...
@@ -59,7 +59,7 @@ func (o StubBlockOracle) BlockByHash(blockHash common.Hash) *types.Block {
...
@@ -59,7 +59,7 @@ func (o StubBlockOracle) BlockByHash(blockHash common.Hash) *types.Block {
return
block
return
block
}
}
func
(
o
StubBlockOracle
)
L2
OutputByRoot
(
root
common
.
Hash
)
eth
.
Output
{
func
(
o
StubBlockOracle
)
OutputByRoot
(
root
common
.
Hash
)
eth
.
Output
{
output
,
ok
:=
o
.
Outputs
[
root
]
output
,
ok
:=
o
.
Outputs
[
root
]
if
!
ok
{
if
!
ok
{
o
.
t
.
Fatalf
(
"requested unknown output root %s"
,
root
)
o
.
t
.
Fatalf
(
"requested unknown output root %s"
,
root
)
...
...
op-program/host/flags/flags.go
View file @
cab9dfe9
...
@@ -47,12 +47,12 @@ var (
...
@@ -47,12 +47,12 @@ var (
}
}
L2Head
=
&
cli
.
StringFlag
{
L2Head
=
&
cli
.
StringFlag
{
Name
:
"l2.head"
,
Name
:
"l2.head"
,
Usage
:
"Hash of the
agreed L2 block to start derivation from
"
,
Usage
:
"Hash of the
L2 block at l2.outputroot
"
,
EnvVars
:
prefixEnvVars
(
"L2_HEAD"
),
EnvVars
:
prefixEnvVars
(
"L2_HEAD"
),
}
}
L2OutputRoot
=
&
cli
.
StringFlag
{
L2OutputRoot
=
&
cli
.
StringFlag
{
Name
:
"l2.outputroot"
,
Name
:
"l2.outputroot"
,
Usage
:
"
L2 Output Root at l2.head
"
,
Usage
:
"
Agreed L2 Output Root to start derivation from
"
,
EnvVars
:
prefixEnvVars
(
"L2_OUTPUT_ROOT"
),
EnvVars
:
prefixEnvVars
(
"L2_OUTPUT_ROOT"
),
}
}
L2Claim
=
&
cli
.
StringFlag
{
L2Claim
=
&
cli
.
StringFlag
{
...
...
op-program/host/l2_client.go
View file @
cab9dfe9
...
@@ -17,6 +17,7 @@ import (
...
@@ -17,6 +17,7 @@ import (
type
L2Client
struct
{
type
L2Client
struct
{
*
sources
.
L2Client
*
sources
.
L2Client
// l2Head is the L2 block hash that we use to fetch L2 output
l2Head
common
.
Hash
l2Head
common
.
Hash
}
}
...
@@ -36,7 +37,7 @@ func NewL2Client(client client.RPC, log log.Logger, metrics caching.Metrics, con
...
@@ -36,7 +37,7 @@ func NewL2Client(client client.RPC, log log.Logger, metrics caching.Metrics, con
},
nil
},
nil
}
}
func
(
s
*
L2Client
)
L2
OutputByRoot
(
ctx
context
.
Context
,
l2OutputRoot
common
.
Hash
)
(
eth
.
Output
,
error
)
{
func
(
s
*
L2Client
)
OutputByRoot
(
ctx
context
.
Context
,
l2OutputRoot
common
.
Hash
)
(
eth
.
Output
,
error
)
{
output
,
err
:=
s
.
outputAtBlock
(
ctx
,
s
.
l2Head
)
output
,
err
:=
s
.
outputAtBlock
(
ctx
,
s
.
l2Head
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
...
op-program/host/prefetcher/prefetcher.go
View file @
cab9dfe9
...
@@ -29,7 +29,7 @@ type L2Source interface {
...
@@ -29,7 +29,7 @@ type L2Source interface {
InfoAndTxsByHash
(
ctx
context
.
Context
,
blockHash
common
.
Hash
)
(
eth
.
BlockInfo
,
types
.
Transactions
,
error
)
InfoAndTxsByHash
(
ctx
context
.
Context
,
blockHash
common
.
Hash
)
(
eth
.
BlockInfo
,
types
.
Transactions
,
error
)
NodeByHash
(
ctx
context
.
Context
,
hash
common
.
Hash
)
([]
byte
,
error
)
NodeByHash
(
ctx
context
.
Context
,
hash
common
.
Hash
)
([]
byte
,
error
)
CodeByHash
(
ctx
context
.
Context
,
hash
common
.
Hash
)
([]
byte
,
error
)
CodeByHash
(
ctx
context
.
Context
,
hash
common
.
Hash
)
([]
byte
,
error
)
L2
OutputByRoot
(
ctx
context
.
Context
,
root
common
.
Hash
)
(
eth
.
Output
,
error
)
OutputByRoot
(
ctx
context
.
Context
,
root
common
.
Hash
)
(
eth
.
Output
,
error
)
}
}
type
Prefetcher
struct
{
type
Prefetcher
struct
{
...
@@ -126,7 +126,7 @@ func (p *Prefetcher) prefetch(ctx context.Context, hint string) error {
...
@@ -126,7 +126,7 @@ func (p *Prefetcher) prefetch(ctx context.Context, hint string) error {
}
}
return
p
.
kvStore
.
Put
(
preimage
.
Keccak256Key
(
hash
)
.
PreimageKey
(),
code
)
return
p
.
kvStore
.
Put
(
preimage
.
Keccak256Key
(
hash
)
.
PreimageKey
(),
code
)
case
l2
.
HintL2Output
:
case
l2
.
HintL2Output
:
output
,
err
:=
p
.
l2Fetcher
.
L2
OutputByRoot
(
ctx
,
hash
)
output
,
err
:=
p
.
l2Fetcher
.
OutputByRoot
(
ctx
,
hash
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to fetch L2 output root %s: %w"
,
hash
,
err
)
return
fmt
.
Errorf
(
"failed to fetch L2 output root %s: %w"
,
hash
,
err
)
}
}
...
...
op-program/host/prefetcher/retry.go
View file @
cab9dfe9
...
@@ -125,10 +125,10 @@ func (s *RetryingL2Source) CodeByHash(ctx context.Context, hash common.Hash) ([]
...
@@ -125,10 +125,10 @@ func (s *RetryingL2Source) CodeByHash(ctx context.Context, hash common.Hash) ([]
return
code
,
err
return
code
,
err
}
}
func
(
s
*
RetryingL2Source
)
L2
OutputByRoot
(
ctx
context
.
Context
,
root
common
.
Hash
)
(
eth
.
Output
,
error
)
{
func
(
s
*
RetryingL2Source
)
OutputByRoot
(
ctx
context
.
Context
,
root
common
.
Hash
)
(
eth
.
Output
,
error
)
{
var
output
eth
.
Output
var
output
eth
.
Output
err
:=
backoff
.
DoCtx
(
ctx
,
maxAttempts
,
s
.
strategy
,
func
()
error
{
err
:=
backoff
.
DoCtx
(
ctx
,
maxAttempts
,
s
.
strategy
,
func
()
error
{
o
,
err
:=
s
.
source
.
L2
OutputByRoot
(
ctx
,
root
)
o
,
err
:=
s
.
source
.
OutputByRoot
(
ctx
,
root
)
if
err
!=
nil
{
if
err
!=
nil
{
s
.
logger
.
Warn
(
"Failed to fetch l2 output"
,
"root"
,
root
,
"err"
,
err
)
s
.
logger
.
Warn
(
"Failed to fetch l2 output"
,
"root"
,
root
,
"err"
,
err
)
return
err
return
err
...
...
op-program/host/prefetcher/retry_test.go
View file @
cab9dfe9
...
@@ -229,13 +229,13 @@ func (m *MockL2Source) ExpectCodeByHash(hash common.Hash, code []byte, err error
...
@@ -229,13 +229,13 @@ func (m *MockL2Source) ExpectCodeByHash(hash common.Hash, code []byte, err error
m
.
Mock
.
On
(
"CodeByHash"
,
hash
)
.
Once
()
.
Return
(
code
,
&
err
)
m
.
Mock
.
On
(
"CodeByHash"
,
hash
)
.
Once
()
.
Return
(
code
,
&
err
)
}
}
func
(
m
*
MockL2Source
)
L2
OutputByRoot
(
ctx
context
.
Context
,
root
common
.
Hash
)
(
eth
.
Output
,
error
)
{
func
(
m
*
MockL2Source
)
OutputByRoot
(
ctx
context
.
Context
,
root
common
.
Hash
)
(
eth
.
Output
,
error
)
{
out
:=
m
.
Mock
.
MethodCalled
(
"
L2
OutputByRoot"
,
root
)
out
:=
m
.
Mock
.
MethodCalled
(
"OutputByRoot"
,
root
)
return
out
[
0
]
.
(
eth
.
Output
),
*
out
[
1
]
.
(
*
error
)
return
out
[
0
]
.
(
eth
.
Output
),
*
out
[
1
]
.
(
*
error
)
}
}
func
(
m
*
MockL2Source
)
Expect
L2
OutputByRoot
(
root
common
.
Hash
,
output
eth
.
Output
,
err
error
)
{
func
(
m
*
MockL2Source
)
ExpectOutputByRoot
(
root
common
.
Hash
,
output
eth
.
Output
,
err
error
)
{
m
.
Mock
.
On
(
"
L2
OutputByRoot"
,
root
)
.
Once
()
.
Return
(
output
,
&
err
)
m
.
Mock
.
On
(
"OutputByRoot"
,
root
)
.
Once
()
.
Return
(
output
,
&
err
)
}
}
var
_
L2Source
=
(
*
MockL2Source
)(
nil
)
var
_
L2Source
=
(
*
MockL2Source
)(
nil
)
op-program/verify/cmd/goerli.go
View file @
cab9dfe9
...
@@ -110,7 +110,7 @@ func Run(l1RpcUrl string, l2RpcUrl string, l2OracleAddr common.Address) error {
...
@@ -110,7 +110,7 @@ func Run(l1RpcUrl string, l2RpcUrl string, l2OracleAddr common.Address) error {
return
fmt
.
Errorf
(
"retrieve agreed output: %w"
,
err
)
return
fmt
.
Errorf
(
"retrieve agreed output: %w"
,
err
)
}
}
if
agreedOutput
.
OutputRoot
==
output
.
OutputRoot
{
if
agreedOutput
.
OutputRoot
==
output
.
OutputRoot
{
// TODO(inphi): Don't return here but keep searching prece
e
ding blocks for a different output
// TODO(inphi): Don't return here but keep searching preceding blocks for a different output
return
fmt
.
Errorf
(
"agreed output is the same as the output claim"
)
return
fmt
.
Errorf
(
"agreed output is the same as the output claim"
)
}
}
...
...
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