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
316ed4b4
Unverified
Commit
316ed4b4
authored
Jan 16, 2025
by
Adrian Sutton
Committed by
GitHub
Jan 16, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-challenger: Move Proposal out of contracts (#13795)
Its only used by split adapter and isn't related to the contracts.
parent
5d52bea9
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
76 additions
and
75 deletions
+76
-75
faultdisputegame.go
op-challenger/game/fault/contracts/faultdisputegame.go
+0
-5
output_alphabet.go
op-challenger/game/fault/trace/outputs/output_alphabet.go
+1
-2
output_asterisc.go
op-challenger/game/fault/trace/outputs/output_asterisc.go
+1
-2
output_cannon.go
op-challenger/game/fault/trace/outputs/output_cannon.go
+1
-2
provider_cache.go
op-challenger/game/fault/trace/outputs/provider_cache.go
+2
-2
provider_cache_test.go
...hallenger/game/fault/trace/outputs/provider_cache_test.go
+7
-7
split_adapter.go
op-challenger/game/fault/trace/outputs/split_adapter.go
+11
-31
split_adapter_test.go
op-challenger/game/fault/trace/outputs/split_adapter_test.go
+12
-12
local_context.go
op-challenger/game/fault/trace/split/local_context.go
+26
-0
local.go
op-challenger/game/fault/trace/utils/local.go
+7
-3
local_test.go
op-challenger/game/fault/trace/utils/local_test.go
+7
-8
output_cannon_helper.go
op-e2e/e2eutils/disputegame/output_cannon_helper.go
+1
-1
No files found.
op-challenger/game/fault/contracts/faultdisputegame.go
View file @
316ed4b4
...
...
@@ -67,11 +67,6 @@ type FaultDisputeGameContractLatest struct {
contract
*
batching
.
BoundContract
}
type
Proposal
struct
{
L2BlockNumber
*
big
.
Int
OutputRoot
common
.
Hash
}
// outputRootProof is designed to match the solidity OutputRootProof struct.
type
outputRootProof
struct
{
Version
[
32
]
byte
...
...
op-challenger/game/fault/trace/outputs/output_alphabet.go
View file @
316ed4b4
...
...
@@ -3,7 +3,6 @@ package outputs
import
(
"context"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/contracts"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/alphabet"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/split"
...
...
@@ -27,7 +26,7 @@ func NewOutputAlphabetTraceAccessor(
poststateBlock
uint64
,
)
(
*
trace
.
Accessor
,
error
)
{
outputProvider
:=
NewTraceProvider
(
logger
,
prestateProvider
,
rollupClient
,
l2Client
,
l1Head
,
splitDepth
,
prestateBlock
,
poststateBlock
)
alphabetCreator
:=
func
(
ctx
context
.
Context
,
localContext
common
.
Hash
,
depth
types
.
Depth
,
agreed
contracts
.
Proposal
,
claimed
contract
s
.
Proposal
)
(
types
.
TraceProvider
,
error
)
{
alphabetCreator
:=
func
(
ctx
context
.
Context
,
localContext
common
.
Hash
,
depth
types
.
Depth
,
agreed
utils
.
Proposal
,
claimed
util
s
.
Proposal
)
(
types
.
TraceProvider
,
error
)
{
provider
:=
alphabet
.
NewTraceProvider
(
agreed
.
L2BlockNumber
,
depth
)
return
provider
,
nil
}
...
...
op-challenger/game/fault/trace/outputs/output_asterisc.go
View file @
316ed4b4
...
...
@@ -8,7 +8,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/contracts"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/asterisc"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/split"
...
...
@@ -35,7 +34,7 @@ func NewOutputAsteriscTraceAccessor(
poststateBlock
uint64
,
)
(
*
trace
.
Accessor
,
error
)
{
outputProvider
:=
NewTraceProvider
(
logger
,
prestateProvider
,
rollupClient
,
l2Client
,
l1Head
,
splitDepth
,
prestateBlock
,
poststateBlock
)
asteriscCreator
:=
func
(
ctx
context
.
Context
,
localContext
common
.
Hash
,
depth
types
.
Depth
,
agreed
contracts
.
Proposal
,
claimed
contract
s
.
Proposal
)
(
types
.
TraceProvider
,
error
)
{
asteriscCreator
:=
func
(
ctx
context
.
Context
,
localContext
common
.
Hash
,
depth
types
.
Depth
,
agreed
utils
.
Proposal
,
claimed
util
s
.
Proposal
)
(
types
.
TraceProvider
,
error
)
{
logger
:=
logger
.
New
(
"pre"
,
agreed
.
OutputRoot
,
"post"
,
claimed
.
OutputRoot
,
"localContext"
,
localContext
)
subdir
:=
filepath
.
Join
(
dir
,
localContext
.
Hex
())
localInputs
,
err
:=
utils
.
FetchLocalInputsFromProposals
(
ctx
,
l1Head
.
Hash
,
l2Client
,
agreed
,
claimed
)
...
...
op-challenger/game/fault/trace/outputs/output_cannon.go
View file @
316ed4b4
...
...
@@ -8,7 +8,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/contracts"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/cannon"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/split"
...
...
@@ -35,7 +34,7 @@ func NewOutputCannonTraceAccessor(
poststateBlock
uint64
,
)
(
*
trace
.
Accessor
,
error
)
{
outputProvider
:=
NewTraceProvider
(
logger
,
prestateProvider
,
rollupClient
,
l2Client
,
l1Head
,
splitDepth
,
prestateBlock
,
poststateBlock
)
cannonCreator
:=
func
(
ctx
context
.
Context
,
localContext
common
.
Hash
,
depth
types
.
Depth
,
agreed
contracts
.
Proposal
,
claimed
contract
s
.
Proposal
)
(
types
.
TraceProvider
,
error
)
{
cannonCreator
:=
func
(
ctx
context
.
Context
,
localContext
common
.
Hash
,
depth
types
.
Depth
,
agreed
utils
.
Proposal
,
claimed
util
s
.
Proposal
)
(
types
.
TraceProvider
,
error
)
{
logger
:=
logger
.
New
(
"pre"
,
agreed
.
OutputRoot
,
"post"
,
claimed
.
OutputRoot
,
"localContext"
,
localContext
)
subdir
:=
filepath
.
Join
(
dir
,
localContext
.
Hex
())
localInputs
,
err
:=
utils
.
FetchLocalInputsFromProposals
(
ctx
,
l1Head
.
Hash
,
l2Client
,
agreed
,
claimed
)
...
...
op-challenger/game/fault/trace/outputs/provider_cache.go
View file @
316ed4b4
...
...
@@ -3,7 +3,7 @@ package outputs
import
(
"context"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/
contract
s"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/
trace/util
s"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/types"
"github.com/ethereum-optimism/optimism/op-service/sources/caching"
"github.com/ethereum/go-ethereum/common"
...
...
@@ -14,7 +14,7 @@ type ProviderCache struct {
creator
ProposalTraceProviderCreator
}
func
(
c
*
ProviderCache
)
GetOrCreate
(
ctx
context
.
Context
,
localContext
common
.
Hash
,
depth
types
.
Depth
,
agreed
contracts
.
Proposal
,
claimed
contract
s
.
Proposal
)
(
types
.
TraceProvider
,
error
)
{
func
(
c
*
ProviderCache
)
GetOrCreate
(
ctx
context
.
Context
,
localContext
common
.
Hash
,
depth
types
.
Depth
,
agreed
utils
.
Proposal
,
claimed
util
s
.
Proposal
)
(
types
.
TraceProvider
,
error
)
{
provider
,
ok
:=
c
.
cache
.
Get
(
localContext
)
if
ok
{
return
provider
,
nil
...
...
op-challenger/game/fault/trace/outputs/provider_cache_test.go
View file @
316ed4b4
...
...
@@ -6,8 +6,8 @@ import (
"math/big"
"testing"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/contracts"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/alphabet"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/utils"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/types"
"github.com/ethereum-optimism/optimism/op-challenger/metrics"
"github.com/ethereum/go-ethereum/common"
...
...
@@ -15,17 +15,17 @@ import (
)
func
TestProviderCache
(
t
*
testing
.
T
)
{
agreed
:=
contract
s
.
Proposal
{
agreed
:=
util
s
.
Proposal
{
L2BlockNumber
:
big
.
NewInt
(
34
),
OutputRoot
:
common
.
Hash
{
0xaa
},
}
claimed
:=
contract
s
.
Proposal
{
claimed
:=
util
s
.
Proposal
{
L2BlockNumber
:
big
.
NewInt
(
35
),
OutputRoot
:
common
.
Hash
{
0xcc
},
}
depth
:=
types
.
Depth
(
6
)
var
createdProvider
types
.
TraceProvider
creator
:=
func
(
ctx
context
.
Context
,
localContext
common
.
Hash
,
depth
types
.
Depth
,
agreed
contracts
.
Proposal
,
claimed
contract
s
.
Proposal
)
(
types
.
TraceProvider
,
error
)
{
creator
:=
func
(
ctx
context
.
Context
,
localContext
common
.
Hash
,
depth
types
.
Depth
,
agreed
utils
.
Proposal
,
claimed
util
s
.
Proposal
)
(
types
.
TraceProvider
,
error
)
{
createdProvider
=
alphabet
.
NewTraceProvider
(
big
.
NewInt
(
0
),
depth
)
return
createdProvider
,
nil
}
...
...
@@ -57,20 +57,20 @@ func TestProviderCache(t *testing.T) {
func
TestProviderCache_DoNotCacheErrors
(
t
*
testing
.
T
)
{
callCount
:=
0
providerErr
:=
errors
.
New
(
"boom"
)
creator
:=
func
(
ctx
context
.
Context
,
localContext
common
.
Hash
,
depth
types
.
Depth
,
agreed
contracts
.
Proposal
,
claimed
contract
s
.
Proposal
)
(
types
.
TraceProvider
,
error
)
{
creator
:=
func
(
ctx
context
.
Context
,
localContext
common
.
Hash
,
depth
types
.
Depth
,
agreed
utils
.
Proposal
,
claimed
util
s
.
Proposal
)
(
types
.
TraceProvider
,
error
)
{
callCount
++
return
nil
,
providerErr
}
localContext1
:=
common
.
Hash
{
0xdd
}
cache
:=
NewProviderCache
(
metrics
.
NoopMetrics
,
"test"
,
creator
)
provider
,
err
:=
cache
.
GetOrCreate
(
context
.
Background
(),
localContext1
,
6
,
contracts
.
Proposal
{},
contract
s
.
Proposal
{})
provider
,
err
:=
cache
.
GetOrCreate
(
context
.
Background
(),
localContext1
,
6
,
utils
.
Proposal
{},
util
s
.
Proposal
{})
require
.
Nil
(
t
,
provider
)
require
.
ErrorIs
(
t
,
err
,
providerErr
)
require
.
Equal
(
t
,
1
,
callCount
)
// Should call the creator again on the second attempt
provider
,
err
=
cache
.
GetOrCreate
(
context
.
Background
(),
localContext1
,
6
,
contracts
.
Proposal
{},
contract
s
.
Proposal
{})
provider
,
err
=
cache
.
GetOrCreate
(
context
.
Background
(),
localContext1
,
6
,
utils
.
Proposal
{},
util
s
.
Proposal
{})
require
.
Nil
(
t
,
provider
)
require
.
ErrorIs
(
t
,
err
,
providerErr
)
require
.
Equal
(
t
,
2
,
callCount
)
...
...
op-challenger/game/fault/trace/outputs/split_adapter.go
View file @
316ed4b4
...
...
@@ -5,18 +5,17 @@ import (
"fmt"
"math/big"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/contracts"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/split"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/utils"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)
type
ProposalTraceProviderCreator
func
(
ctx
context
.
Context
,
localContext
common
.
Hash
,
depth
types
.
Depth
,
agreed
contracts
.
Proposal
,
claimed
contract
s
.
Proposal
)
(
types
.
TraceProvider
,
error
)
type
ProposalTraceProviderCreator
func
(
ctx
context
.
Context
,
localContext
common
.
Hash
,
depth
types
.
Depth
,
agreed
utils
.
Proposal
,
claimed
util
s
.
Proposal
)
(
types
.
TraceProvider
,
error
)
func
OutputRootSplitAdapter
(
topProvider
*
OutputTraceProvider
,
creator
ProposalTraceProviderCreator
)
split
.
ProviderCreator
{
return
func
(
ctx
context
.
Context
,
depth
types
.
Depth
,
pre
types
.
Claim
,
post
types
.
Claim
)
(
types
.
TraceProvider
,
error
)
{
localContext
:=
CreateLocalContext
(
pre
,
post
)
localContext
:=
split
.
CreateLocalContext
(
pre
,
post
)
agreed
,
disputed
,
err
:=
FetchProposals
(
ctx
,
topProvider
,
pre
,
post
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -25,54 +24,35 @@ func OutputRootSplitAdapter(topProvider *OutputTraceProvider, creator ProposalTr
}
}
func
FetchProposals
(
ctx
context
.
Context
,
topProvider
*
OutputTraceProvider
,
pre
types
.
Claim
,
post
types
.
Claim
)
(
contracts
.
Proposal
,
contract
s
.
Proposal
,
error
)
{
func
FetchProposals
(
ctx
context
.
Context
,
topProvider
*
OutputTraceProvider
,
pre
types
.
Claim
,
post
types
.
Claim
)
(
utils
.
Proposal
,
util
s
.
Proposal
,
error
)
{
usePrestateBlock
:=
pre
==
(
types
.
Claim
{})
var
agreed
contract
s
.
Proposal
var
agreed
util
s
.
Proposal
if
usePrestateBlock
{
prestateRoot
,
err
:=
topProvider
.
AbsolutePreStateCommitment
(
ctx
)
if
err
!=
nil
{
return
contracts
.
Proposal
{},
contract
s
.
Proposal
{},
fmt
.
Errorf
(
"failed to retrieve absolute prestate output root: %w"
,
err
)
return
utils
.
Proposal
{},
util
s
.
Proposal
{},
fmt
.
Errorf
(
"failed to retrieve absolute prestate output root: %w"
,
err
)
}
agreed
=
contract
s
.
Proposal
{
agreed
=
util
s
.
Proposal
{
L2BlockNumber
:
new
(
big
.
Int
)
.
SetUint64
(
topProvider
.
prestateBlock
),
OutputRoot
:
prestateRoot
,
}
}
else
{
preBlockNum
,
err
:=
topProvider
.
HonestBlockNumber
(
ctx
,
pre
.
Position
)
if
err
!=
nil
{
return
contracts
.
Proposal
{},
contract
s
.
Proposal
{},
fmt
.
Errorf
(
"unable to calculate pre-claim block number: %w"
,
err
)
return
utils
.
Proposal
{},
util
s
.
Proposal
{},
fmt
.
Errorf
(
"unable to calculate pre-claim block number: %w"
,
err
)
}
agreed
=
contract
s
.
Proposal
{
agreed
=
util
s
.
Proposal
{
L2BlockNumber
:
new
(
big
.
Int
)
.
SetUint64
(
preBlockNum
),
OutputRoot
:
pre
.
Value
,
}
}
postBlockNum
,
err
:=
topProvider
.
ClaimedBlockNumber
(
post
.
Position
)
if
err
!=
nil
{
return
contracts
.
Proposal
{},
contract
s
.
Proposal
{},
fmt
.
Errorf
(
"unable to calculate post-claim block number: %w"
,
err
)
return
utils
.
Proposal
{},
util
s
.
Proposal
{},
fmt
.
Errorf
(
"unable to calculate post-claim block number: %w"
,
err
)
}
claimed
:=
contract
s
.
Proposal
{
claimed
:=
util
s
.
Proposal
{
L2BlockNumber
:
new
(
big
.
Int
)
.
SetUint64
(
postBlockNum
),
OutputRoot
:
post
.
Value
,
}
return
agreed
,
claimed
,
nil
}
func
CreateLocalContext
(
pre
types
.
Claim
,
post
types
.
Claim
)
common
.
Hash
{
return
crypto
.
Keccak256Hash
(
localContextPreimage
(
pre
,
post
))
}
func
localContextPreimage
(
pre
types
.
Claim
,
post
types
.
Claim
)
[]
byte
{
encodeClaim
:=
func
(
c
types
.
Claim
)
[]
byte
{
data
:=
make
([]
byte
,
64
)
copy
(
data
[
0
:
32
],
c
.
Value
.
Bytes
())
c
.
Position
.
ToGIndex
()
.
FillBytes
(
data
[
32
:
])
return
data
}
var
data
[]
byte
if
pre
!=
(
types
.
Claim
{})
{
data
=
encodeClaim
(
pre
)
}
data
=
append
(
data
,
encodeClaim
(
post
)
...
)
return
data
}
op-challenger/game/fault/trace/outputs/split_adapter_test.go
View file @
316ed4b4
...
...
@@ -7,8 +7,8 @@ import (
"math/big"
"testing"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/contracts"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/split"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/utils"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/types"
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum-optimism/optimism/op-service/testlog"
...
...
@@ -73,18 +73,18 @@ func TestOutputRootSplitAdapter(t *testing.T) {
ParentContractIndex
:
1
,
}
expectedAgreed
:=
contract
s
.
Proposal
{
expectedAgreed
:=
util
s
.
Proposal
{
L2BlockNumber
:
big
.
NewInt
(
test
.
expectedAgreedBlockNum
),
OutputRoot
:
preClaim
.
Value
,
}
expectedClaimed
:=
contract
s
.
Proposal
{
expectedClaimed
:=
util
s
.
Proposal
{
L2BlockNumber
:
big
.
NewInt
(
test
.
expectedClaimedBlockNum
),
OutputRoot
:
postClaim
.
Value
,
}
_
,
err
:=
adapter
(
context
.
Background
(),
5
,
preClaim
,
postClaim
)
require
.
ErrorIs
(
t
,
err
,
creatorError
)
require
.
Equal
(
t
,
CreateLocalContext
(
preClaim
,
postClaim
),
creator
.
localContext
)
require
.
Equal
(
t
,
split
.
CreateLocalContext
(
preClaim
,
postClaim
),
creator
.
localContext
)
require
.
Equal
(
t
,
expectedAgreed
,
creator
.
agreed
)
require
.
Equal
(
t
,
expectedClaimed
,
creator
.
claimed
)
})
...
...
@@ -104,18 +104,18 @@ func TestOutputRootSplitAdapter_FromAbsolutePrestate(t *testing.T) {
ParentContractIndex
:
1
,
}
expectedAgreed
:=
contract
s
.
Proposal
{
expectedAgreed
:=
util
s
.
Proposal
{
L2BlockNumber
:
big
.
NewInt
(
20
),
OutputRoot
:
prestateOutputRoot
,
// Absolute prestate output root
}
expectedClaimed
:=
contract
s
.
Proposal
{
expectedClaimed
:=
util
s
.
Proposal
{
L2BlockNumber
:
big
.
NewInt
(
21
),
OutputRoot
:
postClaim
.
Value
,
}
_
,
err
:=
adapter
(
context
.
Background
(),
5
,
types
.
Claim
{},
postClaim
)
require
.
ErrorIs
(
t
,
err
,
creatorError
)
require
.
Equal
(
t
,
CreateLocalContext
(
types
.
Claim
{},
postClaim
),
creator
.
localContext
)
require
.
Equal
(
t
,
split
.
CreateLocalContext
(
types
.
Claim
{},
postClaim
),
creator
.
localContext
)
require
.
Equal
(
t
,
expectedAgreed
,
creator
.
agreed
)
require
.
Equal
(
t
,
expectedClaimed
,
creator
.
claimed
)
}
...
...
@@ -146,11 +146,11 @@ func setupAdapterTest(t *testing.T, topDepth types.Depth) (split.ProviderCreator
type
capturingCreator
struct
{
localContext
common
.
Hash
agreed
contract
s
.
Proposal
claimed
contract
s
.
Proposal
agreed
util
s
.
Proposal
claimed
util
s
.
Proposal
}
func
(
c
*
capturingCreator
)
Create
(
_
context
.
Context
,
localContext
common
.
Hash
,
_
types
.
Depth
,
agreed
contracts
.
Proposal
,
claimed
contract
s
.
Proposal
)
(
types
.
TraceProvider
,
error
)
{
func
(
c
*
capturingCreator
)
Create
(
_
context
.
Context
,
localContext
common
.
Hash
,
_
types
.
Depth
,
agreed
utils
.
Proposal
,
claimed
util
s
.
Proposal
)
(
types
.
TraceProvider
,
error
)
{
c
.
localContext
=
localContext
c
.
agreed
=
agreed
c
.
claimed
=
claimed
...
...
@@ -207,9 +207,9 @@ func TestCreateLocalContext(t *testing.T) {
Position
:
test
.
postPosition
,
},
}
actualPreimage
:=
l
ocalContextPreimage
(
pre
,
post
)
actualPreimage
:=
split
.
L
ocalContextPreimage
(
pre
,
post
)
require
.
Equal
(
t
,
test
.
expected
,
actualPreimage
)
localContext
:=
CreateLocalContext
(
pre
,
post
)
localContext
:=
split
.
CreateLocalContext
(
pre
,
post
)
require
.
Equal
(
t
,
crypto
.
Keccak256Hash
(
test
.
expected
),
localContext
)
})
}
...
...
op-challenger/game/fault/trace/split/local_context.go
0 → 100644
View file @
316ed4b4
package
split
import
(
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)
func
CreateLocalContext
(
pre
types
.
Claim
,
post
types
.
Claim
)
common
.
Hash
{
return
crypto
.
Keccak256Hash
(
LocalContextPreimage
(
pre
,
post
))
}
func
LocalContextPreimage
(
pre
types
.
Claim
,
post
types
.
Claim
)
[]
byte
{
encodeClaim
:=
func
(
c
types
.
Claim
)
[]
byte
{
data
:=
make
([]
byte
,
64
)
copy
(
data
[
0
:
32
],
c
.
Value
.
Bytes
())
c
.
Position
.
ToGIndex
()
.
FillBytes
(
data
[
32
:
])
return
data
}
var
data
[]
byte
if
pre
!=
(
types
.
Claim
{})
{
data
=
encodeClaim
(
pre
)
}
data
=
append
(
data
,
encodeClaim
(
post
)
...
)
return
data
}
op-challenger/game/fault/trace/utils/local.go
View file @
316ed4b4
...
...
@@ -5,7 +5,6 @@ import (
"fmt"
"math/big"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/contracts"
"github.com/ethereum/go-ethereum/common"
ethtypes
"github.com/ethereum/go-ethereum/core/types"
)
...
...
@@ -28,7 +27,12 @@ type L1HeadSource interface {
type
GameInputsSource
interface
{
L1HeadSource
GetProposals
(
ctx
context
.
Context
)
(
agreed
contracts
.
Proposal
,
disputed
contracts
.
Proposal
,
err
error
)
GetProposals
(
ctx
context
.
Context
)
(
agreed
Proposal
,
disputed
Proposal
,
err
error
)
}
type
Proposal
struct
{
L2BlockNumber
*
big
.
Int
OutputRoot
common
.
Hash
}
func
FetchLocalInputs
(
ctx
context
.
Context
,
caller
GameInputsSource
,
l2Client
L2HeaderSource
)
(
LocalGameInputs
,
error
)
{
...
...
@@ -44,7 +48,7 @@ func FetchLocalInputs(ctx context.Context, caller GameInputsSource, l2Client L2H
return
FetchLocalInputsFromProposals
(
ctx
,
l1Head
,
l2Client
,
agreedOutput
,
claimedOutput
)
}
func
FetchLocalInputsFromProposals
(
ctx
context
.
Context
,
l1Head
common
.
Hash
,
l2Client
L2HeaderSource
,
agreedOutput
contracts
.
Proposal
,
claimedOutput
contracts
.
Proposal
)
(
LocalGameInputs
,
error
)
{
func
FetchLocalInputsFromProposals
(
ctx
context
.
Context
,
l1Head
common
.
Hash
,
l2Client
L2HeaderSource
,
agreedOutput
Proposal
,
claimedOutput
Proposal
)
(
LocalGameInputs
,
error
)
{
agreedHeader
,
err
:=
l2Client
.
HeaderByNumber
(
ctx
,
agreedOutput
.
L2BlockNumber
)
if
err
!=
nil
{
return
LocalGameInputs
{},
fmt
.
Errorf
(
"fetch L2 block header %v: %w"
,
agreedOutput
.
L2BlockNumber
,
err
)
...
...
op-challenger/game/fault/trace/utils/local_test.go
View file @
316ed4b4
...
...
@@ -5,7 +5,6 @@ import (
"math/big"
"testing"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/contracts"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
ethtypes
"github.com/ethereum/go-ethereum/core/types"
...
...
@@ -16,11 +15,11 @@ func TestFetchLocalInputs(t *testing.T) {
ctx
:=
context
.
Background
()
contract
:=
&
mockGameInputsSource
{
l1Head
:
common
.
Hash
{
0xcc
},
starting
:
contracts
.
Proposal
{
starting
:
Proposal
{
L2BlockNumber
:
big
.
NewInt
(
2222
),
OutputRoot
:
common
.
Hash
{
0xdd
},
},
disputed
:
contracts
.
Proposal
{
disputed
:
Proposal
{
L2BlockNumber
:
big
.
NewInt
(
3333
),
OutputRoot
:
common
.
Hash
{
0xee
},
},
...
...
@@ -44,11 +43,11 @@ func TestFetchLocalInputs(t *testing.T) {
func
TestFetchLocalInputsFromProposals
(
t
*
testing
.
T
)
{
ctx
:=
context
.
Background
()
agreed
:=
contracts
.
Proposal
{
agreed
:=
Proposal
{
L2BlockNumber
:
big
.
NewInt
(
2222
),
OutputRoot
:
common
.
Hash
{
0xdd
},
}
claimed
:=
contracts
.
Proposal
{
claimed
:=
Proposal
{
L2BlockNumber
:
big
.
NewInt
(
3333
),
OutputRoot
:
common
.
Hash
{
0xee
},
}
...
...
@@ -72,15 +71,15 @@ func TestFetchLocalInputsFromProposals(t *testing.T) {
type
mockGameInputsSource
struct
{
l1Head
common
.
Hash
starting
contracts
.
Proposal
disputed
contracts
.
Proposal
starting
Proposal
disputed
Proposal
}
func
(
s
*
mockGameInputsSource
)
GetL1Head
(
_
context
.
Context
)
(
common
.
Hash
,
error
)
{
return
s
.
l1Head
,
nil
}
func
(
s
*
mockGameInputsSource
)
GetProposals
(
_
context
.
Context
)
(
contracts
.
Proposal
,
contracts
.
Proposal
,
error
)
{
func
(
s
*
mockGameInputsSource
)
GetProposals
(
_
context
.
Context
)
(
Proposal
,
Proposal
,
error
)
{
return
s
.
starting
,
s
.
disputed
,
nil
}
...
...
op-e2e/e2eutils/disputegame/output_cannon_helper.go
View file @
316ed4b4
...
...
@@ -314,7 +314,7 @@ func (g *OutputCannonGameHelper) createCannonTraceProvider(ctx context.Context,
g
.
T
.
Logf
(
"Using trace between blocks %v and %v
\n
"
,
agreed
.
L2BlockNumber
,
disputed
.
L2BlockNumber
)
localInputs
,
err
:=
utils
.
FetchLocalInputsFromProposals
(
ctx
,
l1Head
.
Hash
,
l2Client
,
agreed
,
disputed
)
g
.
Require
.
NoError
(
err
,
"Failed to fetch local inputs"
)
localContext
=
outputs
.
CreateLocalContext
(
pre
,
post
)
localContext
=
split
.
CreateLocalContext
(
pre
,
post
)
dir
:=
filepath
.
Join
(
cfg
.
Datadir
,
"cannon-trace"
)
subdir
:=
filepath
.
Join
(
dir
,
localContext
.
Hex
())
return
cannon
.
NewTraceProviderForTest
(
logger
,
metrics
.
NoopMetrics
.
ToTypedVmMetrics
(
types
.
TraceTypeCannon
.
String
()),
cfg
,
localInputs
,
subdir
,
g
.
MaxDepth
(
ctx
)
-
splitDepth
-
1
),
nil
...
...
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