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
e327353f
Unverified
Commit
e327353f
authored
Sep 27, 2023
by
mergify[bot]
Committed by
GitHub
Sep 27, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into dependabot/npm_and_yarn/typescript-5.2.2
parents
2a150d56
194f5a73
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
178 additions
and
115 deletions
+178
-115
presets.go
indexer/config/presets.go
+48
-0
alphabet_helper.go
op-e2e/e2eutils/disputegame/alphabet_helper.go
+5
-1
dishonest_helper.go
op-e2e/e2eutils/disputegame/dishonest_helper.go
+113
-0
game_helper.go
op-e2e/e2eutils/disputegame/game_helper.go
+10
-109
faultproof_test.go
op-e2e/faultproof_test.go
+2
-5
No files found.
indexer/config/presets.go
View file @
e327353f
...
@@ -121,4 +121,52 @@ var Presets = map[int]Preset{
...
@@ -121,4 +121,52 @@ var Presets = map[int]Preset{
L1StartingHeight
:
8942381
,
L1StartingHeight
:
8942381
,
},
},
},
},
11155420
:
{
Name
:
"OP Sepolia"
,
ChainConfig
:
ChainConfig
{
Preset
:
11155420
,
L1Contracts
:
L1Contracts
{
AddressManager
:
common
.
HexToAddress
(
"0x9bFE9c5609311DF1c011c47642253B78a4f33F4B"
),
SystemConfigProxy
:
common
.
HexToAddress
(
"0x034edD2A225f7f429A63E0f1D2084B9E0A93b538"
),
OptimismPortalProxy
:
common
.
HexToAddress
(
"0x16Fc5058F25648194471939df75CF27A2fdC48BC"
),
L2OutputOracleProxy
:
common
.
HexToAddress
(
"0x90E9c4f8a994a250F6aEfd61CAFb4F2e895D458F"
),
L1CrossDomainMessengerProxy
:
common
.
HexToAddress
(
"0x58Cc85b8D04EA49cC6DBd3CbFFd00B4B8D6cb3ef"
),
L1StandardBridgeProxy
:
common
.
HexToAddress
(
"0xFBb0621E0B23b5478B630BD55a5f21f67730B0F1"
),
L1ERC721BridgeProxy
:
common
.
HexToAddress
(
"0xd83e03D576d23C9AEab8cC44Fa98d058D2176D1f"
),
},
L1StartingHeight
:
4071408
,
},
},
424
:
{
Name
:
"PGN"
,
ChainConfig
:
ChainConfig
{
Preset
:
424
,
L1Contracts
:
L1Contracts
{
AddressManager
:
common
.
HexToAddress
(
"0x09d5DbA52F0ee2C4A5E94FD5C802bD74Ca9cAD3e"
),
SystemConfigProxy
:
common
.
HexToAddress
(
"0x7Df716EAD1d83a2BF35B416B7BC84bd0700357C9"
),
OptimismPortalProxy
:
common
.
HexToAddress
(
"0xb26Fd985c5959bBB382BAFdD0b879E149e48116c"
),
L2OutputOracleProxy
:
common
.
HexToAddress
(
"0xA38d0c4E6319F9045F20318BA5f04CDe94208608"
),
L1CrossDomainMessengerProxy
:
common
.
HexToAddress
(
"0x97BAf688E5d0465E149d1d5B497Ca99392a6760e"
),
L1StandardBridgeProxy
:
common
.
HexToAddress
(
"0xD0204B9527C1bA7bD765Fa5CCD9355d38338272b"
),
L1ERC721BridgeProxy
:
common
.
HexToAddress
(
"0xaFF0F8aaB6Cc9108D34b3B8423C76d2AF434d115"
),
},
L1StartingHeight
:
17672702
,
},
},
58008
:
{
Name
:
"PGN Sepolia"
,
ChainConfig
:
ChainConfig
{
Preset
:
58008
,
L1Contracts
:
L1Contracts
{
AddressManager
:
common
.
HexToAddress
(
"0x0Ad91488288BBe60ff38258785568A6D1EB3B983"
),
SystemConfigProxy
:
common
.
HexToAddress
(
"0x4BCCC52151f0ad7C62D45Ce0aA77d9d8ffCE534e"
),
OptimismPortalProxy
:
common
.
HexToAddress
(
"0xF04BdD5353Bb0EFF6CA60CfcC78594278eBfE179"
),
L2OutputOracleProxy
:
common
.
HexToAddress
(
"0xD5bAc3152ffC25318F848B3DD5dA6C85171BaEEe"
),
L1CrossDomainMessengerProxy
:
common
.
HexToAddress
(
"0x97f3558Ce48FE71B8CeFA5497708A49531D5A8E1"
),
L1StandardBridgeProxy
:
common
.
HexToAddress
(
"0xFaE6abCAF30D23e233AC7faF747F2fC3a5a6Bfa3"
),
L1ERC721BridgeProxy
:
common
.
HexToAddress
(
"0xBA8397B6f255618D5985d0fB427D8c0496F3a5FA"
),
},
L1StartingHeight
:
17672702
,
},
},
}
}
op-e2e/e2eutils/disputegame/alphabet_helper.go
View file @
e327353f
...
@@ -35,7 +35,7 @@ func (g *AlphabetGameHelper) StartChallenger(ctx context.Context, l1Endpoint str
...
@@ -35,7 +35,7 @@ func (g *AlphabetGameHelper) StartChallenger(ctx context.Context, l1Endpoint str
return
c
return
c
}
}
func
(
g
*
AlphabetGameHelper
)
CreateHonestActor
(
ctx
context
.
Context
,
alphabetTrace
string
,
depth
uint64
)
*
HonestHelper
{
func
(
g
*
AlphabetGameHelper
)
CreateHonestActor
(
alphabetTrace
string
,
depth
uint64
)
*
HonestHelper
{
return
&
HonestHelper
{
return
&
HonestHelper
{
t
:
g
.
t
,
t
:
g
.
t
,
require
:
g
.
require
,
require
:
g
.
require
,
...
@@ -43,3 +43,7 @@ func (g *AlphabetGameHelper) CreateHonestActor(ctx context.Context, alphabetTrac
...
@@ -43,3 +43,7 @@ func (g *AlphabetGameHelper) CreateHonestActor(ctx context.Context, alphabetTrac
correctTrace
:
alphabet
.
NewTraceProvider
(
alphabetTrace
,
depth
),
correctTrace
:
alphabet
.
NewTraceProvider
(
alphabetTrace
,
depth
),
}
}
}
}
func
(
g
*
AlphabetGameHelper
)
CreateDishonestHelper
(
alphabetTrace
string
,
depth
uint64
,
defender
bool
)
*
DishonestHelper
{
return
newDishonestHelper
(
&
g
.
FaultGameHelper
,
g
.
CreateHonestActor
(
alphabetTrace
,
depth
),
defender
)
}
op-e2e/e2eutils/disputegame/dishonest_helper.go
0 → 100644
View file @
e327353f
package
disputegame
import
(
"context"
"errors"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/types"
"github.com/ethereum/go-ethereum/common"
)
type
dishonestClaim
struct
{
ParentIndex
int64
IsAttack
bool
Valid
bool
}
type
DishonestHelper
struct
{
*
FaultGameHelper
*
HonestHelper
claims
map
[
dishonestClaim
]
bool
defender
bool
}
func
newDishonestHelper
(
g
*
FaultGameHelper
,
correctTrace
*
HonestHelper
,
defender
bool
)
*
DishonestHelper
{
return
&
DishonestHelper
{
g
,
correctTrace
,
make
(
map
[
dishonestClaim
]
bool
),
defender
}
}
func
(
t
*
DishonestHelper
)
Attack
(
ctx
context
.
Context
,
claimIndex
int64
)
{
c
:=
dishonestClaim
{
claimIndex
,
true
,
false
}
if
t
.
claims
[
c
]
{
return
}
t
.
claims
[
c
]
=
true
t
.
FaultGameHelper
.
Attack
(
ctx
,
claimIndex
,
common
.
Hash
{
byte
(
claimIndex
)})
}
func
(
t
*
DishonestHelper
)
Defend
(
ctx
context
.
Context
,
claimIndex
int64
)
{
c
:=
dishonestClaim
{
claimIndex
,
false
,
false
}
if
t
.
claims
[
c
]
{
return
}
t
.
claims
[
c
]
=
true
t
.
FaultGameHelper
.
Defend
(
ctx
,
claimIndex
,
common
.
Hash
{
byte
(
claimIndex
)})
}
func
(
t
*
DishonestHelper
)
AttackCorrect
(
ctx
context
.
Context
,
claimIndex
int64
)
{
c
:=
dishonestClaim
{
claimIndex
,
true
,
true
}
if
t
.
claims
[
c
]
{
return
}
t
.
claims
[
c
]
=
true
t
.
HonestHelper
.
Attack
(
ctx
,
claimIndex
)
}
func
(
t
*
DishonestHelper
)
DefendCorrect
(
ctx
context
.
Context
,
claimIndex
int64
)
{
c
:=
dishonestClaim
{
claimIndex
,
false
,
true
}
if
t
.
claims
[
c
]
{
return
}
t
.
claims
[
c
]
=
true
t
.
HonestHelper
.
Defend
(
ctx
,
claimIndex
)
}
// ExhaustDishonestClaims makes all possible significant moves (mod honest challenger's) in a game.
// It is very inefficient and should NOT be used on games with large depths
func
(
d
*
DishonestHelper
)
ExhaustDishonestClaims
(
ctx
context
.
Context
)
{
depth
:=
d
.
MaxDepth
(
ctx
)
move
:=
func
(
claimIndex
int64
,
claimData
ContractClaim
)
{
// dishonest level, valid attack
// dishonest level, invalid attack
// dishonest level, valid defense
// dishonest level, invalid defense
// honest level, invalid attack
// honest level, invalid defense
pos
:=
types
.
NewPositionFromGIndex
(
claimData
.
Position
.
Uint64
())
if
int64
(
pos
.
Depth
())
==
depth
{
return
}
d
.
LogGameData
(
ctx
)
d
.
FaultGameHelper
.
t
.
Logf
(
"Dishonest moves against claimIndex %d"
,
claimIndex
)
agreeWithLevel
:=
d
.
defender
==
(
pos
.
Depth
()
%
2
==
0
)
if
!
agreeWithLevel
{
d
.
AttackCorrect
(
ctx
,
claimIndex
)
if
claimIndex
!=
0
{
d
.
DefendCorrect
(
ctx
,
claimIndex
)
}
}
d
.
Attack
(
ctx
,
claimIndex
)
if
claimIndex
!=
0
{
d
.
Defend
(
ctx
,
claimIndex
)
}
}
var
numClaimsSeen
int64
for
{
newCount
,
err
:=
d
.
WaitForNewClaim
(
ctx
,
numClaimsSeen
)
if
errors
.
Is
(
err
,
context
.
DeadlineExceeded
)
{
// we assume that the honest challenger has stopped responding
// There's nothing to respond to.
break
}
d
.
FaultGameHelper
.
require
.
NoError
(
err
)
for
i
:=
numClaimsSeen
;
i
<
newCount
;
i
++
{
claimData
:=
d
.
getClaim
(
ctx
,
numClaimsSeen
)
move
(
numClaimsSeen
,
claimData
)
numClaimsSeen
++
}
}
}
op-e2e/e2eutils/disputegame/game_helper.go
View file @
e327353f
...
@@ -2,7 +2,6 @@ package disputegame
...
@@ -2,7 +2,6 @@ package disputegame
import
(
import
(
"context"
"context"
"errors"
"fmt"
"fmt"
"math/big"
"math/big"
"testing"
"testing"
...
@@ -39,6 +38,9 @@ func (g *FaultGameHelper) GameDuration(ctx context.Context) time.Duration {
...
@@ -39,6 +38,9 @@ func (g *FaultGameHelper) GameDuration(ctx context.Context) time.Duration {
return
time
.
Duration
(
duration
)
*
time
.
Second
return
time
.
Duration
(
duration
)
*
time
.
Second
}
}
// WaitForClaimCount waits until there are at least count claims in the game.
// This does not check that the number of claims is exactly the specified count to avoid intermittent failures
// where a challenger posts an additional claim before this method sees the number of claims it was waiting for.
func
(
g
*
FaultGameHelper
)
WaitForClaimCount
(
ctx
context
.
Context
,
count
int64
)
{
func
(
g
*
FaultGameHelper
)
WaitForClaimCount
(
ctx
context
.
Context
,
count
int64
)
{
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
2
*
time
.
Minute
)
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
2
*
time
.
Minute
)
defer
cancel
()
defer
cancel
()
...
@@ -48,7 +50,7 @@ func (g *FaultGameHelper) WaitForClaimCount(ctx context.Context, count int64) {
...
@@ -48,7 +50,7 @@ func (g *FaultGameHelper) WaitForClaimCount(ctx context.Context, count int64) {
return
false
,
err
return
false
,
err
}
}
g
.
t
.
Log
(
"Waiting for claim count"
,
"current"
,
actual
,
"expected"
,
count
,
"game"
,
g
.
addr
)
g
.
t
.
Log
(
"Waiting for claim count"
,
"current"
,
actual
,
"expected"
,
count
,
"game"
,
g
.
addr
)
return
actual
.
Cmp
(
big
.
NewInt
(
count
))
=
=
0
,
nil
return
actual
.
Cmp
(
big
.
NewInt
(
count
))
>
=
0
,
nil
})
})
g
.
require
.
NoErrorf
(
err
,
"Did not find expected claim count %v"
,
count
)
g
.
require
.
NoErrorf
(
err
,
"Did not find expected claim count %v"
,
count
)
}
}
...
@@ -123,6 +125,12 @@ func (g *FaultGameHelper) GetClaimValue(ctx context.Context, claimIdx int64) com
...
@@ -123,6 +125,12 @@ func (g *FaultGameHelper) GetClaimValue(ctx context.Context, claimIdx int64) com
return
claim
.
Claim
return
claim
.
Claim
}
}
func
(
g
*
FaultGameHelper
)
GetClaimPosition
(
ctx
context
.
Context
,
claimIdx
int64
)
types
.
Position
{
g
.
WaitForClaimCount
(
ctx
,
claimIdx
+
1
)
claim
:=
g
.
getClaim
(
ctx
,
claimIdx
)
return
types
.
NewPositionFromGIndex
(
claim
.
Position
.
Uint64
())
}
// getClaim retrieves the claim data for a specific index.
// getClaim retrieves the claim data for a specific index.
// Note that it is deliberately not exported as tests should use WaitForClaim to avoid race conditions.
// Note that it is deliberately not exported as tests should use WaitForClaim to avoid race conditions.
func
(
g
*
FaultGameHelper
)
getClaim
(
ctx
context
.
Context
,
claimIdx
int64
)
ContractClaim
{
func
(
g
*
FaultGameHelper
)
getClaim
(
ctx
context
.
Context
,
claimIdx
int64
)
ContractClaim
{
...
@@ -133,10 +141,6 @@ func (g *FaultGameHelper) getClaim(ctx context.Context, claimIdx int64) Contract
...
@@ -133,10 +141,6 @@ func (g *FaultGameHelper) getClaim(ctx context.Context, claimIdx int64) Contract
return
claimData
return
claimData
}
}
func
(
g
*
FaultGameHelper
)
GetClaimUnsafe
(
ctx
context
.
Context
,
claimIdx
int64
)
ContractClaim
{
return
g
.
getClaim
(
ctx
,
claimIdx
)
}
func
(
g
*
FaultGameHelper
)
WaitForClaimAtDepth
(
ctx
context
.
Context
,
depth
int
)
{
func
(
g
*
FaultGameHelper
)
WaitForClaimAtDepth
(
ctx
context
.
Context
,
depth
int
)
{
g
.
waitForClaim
(
g
.
waitForClaim
(
ctx
,
ctx
,
...
@@ -383,106 +387,3 @@ func (g *FaultGameHelper) gameData(ctx context.Context) string {
...
@@ -383,106 +387,3 @@ func (g *FaultGameHelper) gameData(ctx context.Context) string {
func
(
g
*
FaultGameHelper
)
LogGameData
(
ctx
context
.
Context
)
{
func
(
g
*
FaultGameHelper
)
LogGameData
(
ctx
context
.
Context
)
{
g
.
t
.
Log
(
g
.
gameData
(
ctx
))
g
.
t
.
Log
(
g
.
gameData
(
ctx
))
}
}
type
dishonestClaim
struct
{
ParentIndex
int64
IsAttack
bool
Valid
bool
}
type
DishonestHelper
struct
{
*
FaultGameHelper
*
HonestHelper
claims
map
[
dishonestClaim
]
bool
defender
bool
}
func
NewDishonestHelper
(
g
*
FaultGameHelper
,
correctTrace
*
HonestHelper
,
defender
bool
)
*
DishonestHelper
{
return
&
DishonestHelper
{
g
,
correctTrace
,
make
(
map
[
dishonestClaim
]
bool
),
defender
}
}
func
(
t
*
DishonestHelper
)
Attack
(
ctx
context
.
Context
,
claimIndex
int64
)
{
c
:=
dishonestClaim
{
claimIndex
,
true
,
false
}
if
t
.
claims
[
c
]
{
return
}
t
.
claims
[
c
]
=
true
t
.
FaultGameHelper
.
Attack
(
ctx
,
claimIndex
,
common
.
Hash
{
byte
(
claimIndex
)})
}
func
(
t
*
DishonestHelper
)
Defend
(
ctx
context
.
Context
,
claimIndex
int64
)
{
c
:=
dishonestClaim
{
claimIndex
,
false
,
false
}
if
t
.
claims
[
c
]
{
return
}
t
.
claims
[
c
]
=
true
t
.
FaultGameHelper
.
Defend
(
ctx
,
claimIndex
,
common
.
Hash
{
byte
(
claimIndex
)})
}
func
(
t
*
DishonestHelper
)
AttackCorrect
(
ctx
context
.
Context
,
claimIndex
int64
)
{
c
:=
dishonestClaim
{
claimIndex
,
true
,
true
}
if
t
.
claims
[
c
]
{
return
}
t
.
claims
[
c
]
=
true
t
.
HonestHelper
.
Attack
(
ctx
,
claimIndex
)
}
func
(
t
*
DishonestHelper
)
DefendCorrect
(
ctx
context
.
Context
,
claimIndex
int64
)
{
c
:=
dishonestClaim
{
claimIndex
,
false
,
true
}
if
t
.
claims
[
c
]
{
return
}
t
.
claims
[
c
]
=
true
t
.
HonestHelper
.
Defend
(
ctx
,
claimIndex
)
}
// ExhaustDishonestClaims makes all possible significant moves (mod honest challenger's) in a game.
// It is very inefficient and should NOT be used on games with large depths
func
(
d
*
DishonestHelper
)
ExhaustDishonestClaims
(
ctx
context
.
Context
)
{
depth
:=
d
.
MaxDepth
(
ctx
)
move
:=
func
(
claimIndex
int64
,
claimData
ContractClaim
)
{
// dishonest level, valid attack
// dishonest level, invalid attack
// dishonest level, valid defense
// dishonest level, invalid defense
// honest level, invalid attack
// honest level, invalid defense
pos
:=
types
.
NewPositionFromGIndex
(
claimData
.
Position
.
Uint64
())
if
int64
(
pos
.
Depth
())
==
depth
{
return
}
d
.
LogGameData
(
ctx
)
d
.
FaultGameHelper
.
t
.
Logf
(
"Dishonest moves against claimIndex %d"
,
claimIndex
)
agreeWithLevel
:=
d
.
defender
==
(
pos
.
Depth
()
%
2
==
0
)
if
!
agreeWithLevel
{
d
.
AttackCorrect
(
ctx
,
claimIndex
)
if
claimIndex
!=
0
{
d
.
DefendCorrect
(
ctx
,
claimIndex
)
}
}
d
.
Attack
(
ctx
,
claimIndex
)
if
claimIndex
!=
0
{
d
.
Defend
(
ctx
,
claimIndex
)
}
}
var
numClaimsSeen
int64
for
{
newCount
,
err
:=
d
.
WaitForNewClaim
(
ctx
,
numClaimsSeen
)
if
errors
.
Is
(
err
,
context
.
DeadlineExceeded
)
{
// we assume that the honest challenger has stopped responding
// There's nothing to respond to.
break
}
d
.
FaultGameHelper
.
require
.
NoError
(
err
)
for
i
:=
numClaimsSeen
;
i
<
newCount
;
i
++
{
claimData
:=
d
.
getClaim
(
ctx
,
numClaimsSeen
)
move
(
numClaimsSeen
,
claimData
)
numClaimsSeen
++
}
}
}
op-e2e/faultproof_test.go
View file @
e327353f
...
@@ -5,7 +5,6 @@ import (
...
@@ -5,7 +5,6 @@ import (
"testing"
"testing"
"time"
"time"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/types"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/disputegame"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/disputegame"
l2oo2
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/l2oo"
l2oo2
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/l2oo"
...
@@ -208,8 +207,7 @@ func TestChallengerCompleteExhaustiveDisputeGame(t *testing.T) {
...
@@ -208,8 +207,7 @@ func TestChallengerCompleteExhaustiveDisputeGame(t *testing.T) {
)
)
// Start dishonest challenger
// Start dishonest challenger
correctTrace
:=
game
.
CreateHonestActor
(
ctx
,
disputegame
.
CorrectAlphabet
,
4
)
dishonestHelper
:=
game
.
CreateDishonestHelper
(
disputegame
.
CorrectAlphabet
,
4
,
!
isRootCorrect
)
dishonestHelper
:=
disputegame
.
NewDishonestHelper
(
&
game
.
FaultGameHelper
,
correctTrace
,
!
isRootCorrect
)
dishonestHelper
.
ExhaustDishonestClaims
(
ctx
)
dishonestHelper
.
ExhaustDishonestClaims
(
ctx
)
// Wait until we've reached max depth before checking for inactivity
// Wait until we've reached max depth before checking for inactivity
...
@@ -464,8 +462,7 @@ func TestCannonPoisonedPostState(t *testing.T) {
...
@@ -464,8 +462,7 @@ func TestCannonPoisonedPostState(t *testing.T) {
game
.
WaitForClaimCount
(
ctx
,
claimCount
)
game
.
WaitForClaimCount
(
ctx
,
claimCount
)
// Defender moves last. If we're at max depth, then we're done
// Defender moves last. If we're at max depth, then we're done
dishonestClaim
:=
game
.
GetClaimUnsafe
(
ctx
,
claimCount
-
1
)
pos
:=
game
.
GetClaimPosition
(
ctx
,
claimCount
-
1
)
pos
:=
types
.
NewPositionFromGIndex
(
dishonestClaim
.
Position
.
Uint64
())
if
int64
(
pos
.
Depth
())
==
depth
{
if
int64
(
pos
.
Depth
())
==
depth
{
break
break
}
}
...
...
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