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
1bb18729
Unverified
Commit
1bb18729
authored
Jul 24, 2023
by
mergify[bot]
Committed by
GitHub
Jul 24, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into refcell/challenger-touchup
parents
22d72617
fe481a49
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
19 deletions
+16
-19
provider.go
op-challenger/fault/alphabet/provider.go
+6
-4
provider_test.go
op-challenger/fault/alphabet/provider_test.go
+3
-4
claimbuilder_test.go
op-challenger/fault/claimbuilder_test.go
+3
-2
service.go
op-challenger/fault/service.go
+2
-1
types.go
op-challenger/fault/types/types.go
+0
-6
helper.go
op-e2e/e2eutils/disputegame/helper.go
+2
-2
No files found.
op-challenger/fault/alphabet
_
provider.go
→
op-challenger/fault/alphabet
/
provider.go
View file @
1bb18729
package
faul
t
package
alphabe
t
import
(
"errors"
"math/big"
"strings"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)
var
_
types
.
TraceProvider
=
(
*
AlphabetProvider
)(
nil
)
var
(
ErrIndexTooLarge
=
errors
.
New
(
"index is larger than the maximum index"
)
)
// AlphabetProvider is a [TraceProvider] that provides claims for specific
// indices in the given trace.
...
...
@@ -30,7 +32,7 @@ func NewAlphabetProvider(state string, depth uint64) *AlphabetProvider {
func
(
ap
*
AlphabetProvider
)
GetPreimage
(
i
uint64
)
([]
byte
,
[]
byte
,
error
)
{
// The index cannot be larger than the maximum index as computed by the depth.
if
i
>=
ap
.
maxLen
{
return
nil
,
nil
,
types
.
ErrIndexTooLarge
return
nil
,
nil
,
ErrIndexTooLarge
}
// We extend the deepest hash to the maximum depth if the trace is not expansive.
if
i
>=
uint64
(
len
(
ap
.
state
))
{
...
...
op-challenger/fault/alphabet
_
provider_test.go
→
op-challenger/fault/alphabet
/
provider_test.go
View file @
1bb18729
package
faul
t
package
alphabe
t
import
(
"math/big"
"testing"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/require"
...
...
@@ -72,7 +71,7 @@ func TestGetPreimage_Succeeds(t *testing.T) {
func
TestGetPreimage_TooLargeIndex_Fails
(
t
*
testing
.
T
)
{
ap
:=
NewAlphabetProvider
(
"abc"
,
2
)
_
,
_
,
err
:=
ap
.
GetPreimage
(
4
)
require
.
ErrorIs
(
t
,
err
,
types
.
ErrIndexTooLarge
)
require
.
ErrorIs
(
t
,
err
,
ErrIndexTooLarge
)
}
// TestGet_Succeeds tests the Get function.
...
...
@@ -89,7 +88,7 @@ func TestGet_Succeeds(t *testing.T) {
func
TestGet_IndexTooLarge
(
t
*
testing
.
T
)
{
ap
:=
NewAlphabetProvider
(
"abc"
,
2
)
_
,
err
:=
ap
.
Get
(
4
)
require
.
ErrorIs
(
t
,
err
,
types
.
ErrIndexTooLarge
)
require
.
ErrorIs
(
t
,
err
,
ErrIndexTooLarge
)
}
// TestGet_Extends tests the Get function with an index that is larger
...
...
op-challenger/fault/claimbuilder_test.go
View file @
1bb18729
...
...
@@ -4,6 +4,7 @@ import (
"math/big"
"testing"
"github.com/ethereum-optimism/optimism/op-challenger/fault/alphabet"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
...
...
@@ -20,7 +21,7 @@ func NewClaimBuilder(t *testing.T, maxDepth int) *ClaimBuilder {
return
&
ClaimBuilder
{
require
:
require
.
New
(
t
),
maxDepth
:
maxDepth
,
correct
:
&
alphabetWithProofProvider
{
NewAlphabetProvider
(
"abcdefghijklmnopqrstuvwxyz"
,
uint64
(
maxDepth
))},
correct
:
&
alphabetWithProofProvider
{
alphabet
.
NewAlphabetProvider
(
"abcdefghijklmnopqrstuvwxyz"
,
uint64
(
maxDepth
))},
}
}
...
...
@@ -146,7 +147,7 @@ func (s *SequenceBuilder) Get() types.Claim {
}
type
alphabetWithProofProvider
struct
{
*
AlphabetProvider
*
alphabet
.
AlphabetProvider
}
func
(
a
*
alphabetWithProofProvider
)
GetPreimage
(
i
uint64
)
([]
byte
,
[]
byte
,
error
)
{
...
...
op-challenger/fault/service.go
View file @
1bb18729
...
...
@@ -6,6 +6,7 @@ import (
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-challenger/config"
"github.com/ethereum-optimism/optimism/op-challenger/fault/alphabet"
"github.com/ethereum-optimism/optimism/op-challenger/fault/cannon"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
...
...
@@ -57,7 +58,7 @@ func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*se
case
config
.
TraceTypeCannon
:
trace
=
cannon
.
NewCannonTraceProvider
(
logger
,
cfg
.
CannonDatadir
)
case
config
.
TraceTypeAlphabet
:
trace
=
NewAlphabetProvider
(
cfg
.
AlphabetTrace
,
uint64
(
cfg
.
GameDepth
))
trace
=
alphabet
.
NewAlphabetProvider
(
cfg
.
AlphabetTrace
,
uint64
(
cfg
.
GameDepth
))
default
:
return
nil
,
fmt
.
Errorf
(
"unsupported trace type: %v"
,
cfg
.
TraceType
)
}
...
...
op-challenger/fault/types/types.go
View file @
1bb18729
package
types
import
(
"errors"
"github.com/ethereum/go-ethereum/common"
)
var
(
ErrIndexTooLarge
=
errors
.
New
(
"index is larger than the maximum index"
)
)
type
GameStatus
uint8
const
(
...
...
op-e2e/e2eutils/disputegame/helper.go
View file @
1bb18729
...
...
@@ -10,7 +10,7 @@ import (
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-chain-ops/deployer"
"github.com/ethereum-optimism/optimism/op-challenger/config"
"github.com/ethereum-optimism/optimism/op-challenger/fault"
"github.com/ethereum-optimism/optimism/op-challenger/fault
/alphabet
"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger"
"github.com/ethereum-optimism/optimism/op-service/client/utils"
...
...
@@ -67,7 +67,7 @@ func NewFactoryHelper(t *testing.T, ctx context.Context, client *ethclient.Clien
func
(
h
*
FactoryHelper
)
StartAlphabetGame
(
ctx
context
.
Context
,
claimedAlphabet
string
)
*
FaultGameHelper
{
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
1
*
time
.
Minute
)
defer
cancel
()
trace
:=
faul
t
.
NewAlphabetProvider
(
claimedAlphabet
,
4
)
trace
:=
alphabe
t
.
NewAlphabetProvider
(
claimedAlphabet
,
4
)
rootClaim
,
err
:=
trace
.
Get
(
lastAlphabetTraceIndex
)
h
.
require
.
NoError
(
err
)
tx
,
err
:=
h
.
factory
.
Create
(
h
.
opts
,
faultGameType
,
rootClaim
,
alphaExtraData
)
...
...
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