-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6424 from ethereum-optimism/refcell/solver-module
fix(op-challenger): Refactor Solver Component into its own Module
- Loading branch information
Showing
7 changed files
with
96 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/ethereum-optimism/optimism/op-challenger/fault/alphabet" | ||
) | ||
|
||
func NewAlphabetClaimBuilder(t *testing.T, maxDepth int) *ClaimBuilder { | ||
alphabetProvider := &alphabetWithProofProvider{alphabet.NewAlphabetProvider("abcdefghijklmnopqrstuvwxyz", uint64(maxDepth))} | ||
return NewClaimBuilder(t, maxDepth, alphabetProvider) | ||
} | ||
|
||
type alphabetWithProofProvider struct { | ||
*alphabet.AlphabetProvider | ||
} | ||
|
||
func (a *alphabetWithProofProvider) GetPreimage(i uint64) ([]byte, []byte, error) { | ||
preimage, _, err := a.AlphabetProvider.GetPreimage(i) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
return preimage, []byte{byte(i)}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package test | ||
|
||
import ( | ||
"github.com/ethereum-optimism/optimism/op-challenger/fault/types" | ||
) | ||
|
||
type SequenceBuilder struct { | ||
builder *ClaimBuilder | ||
lastClaim types.Claim | ||
} | ||
|
||
// Seq starts building a claim by following a sequence of attack and defend moves from the root | ||
// The returned SequenceBuilder can be used to add additional moves. e.g: | ||
// claim := Seq(true).Attack(false).Attack(true).Defend(true).Get() | ||
func (c *ClaimBuilder) Seq(rootCorrect bool) *SequenceBuilder { | ||
claim := c.CreateRootClaim(rootCorrect) | ||
return &SequenceBuilder{ | ||
builder: c, | ||
lastClaim: claim, | ||
} | ||
} | ||
|
||
func (s *SequenceBuilder) Attack(correct bool) *SequenceBuilder { | ||
claim := s.builder.AttackClaim(s.lastClaim, correct) | ||
return &SequenceBuilder{ | ||
builder: s.builder, | ||
lastClaim: claim, | ||
} | ||
} | ||
|
||
func (s *SequenceBuilder) Defend(correct bool) *SequenceBuilder { | ||
claim := s.builder.DefendClaim(s.lastClaim, correct) | ||
return &SequenceBuilder{ | ||
builder: s.builder, | ||
lastClaim: claim, | ||
} | ||
} | ||
|
||
func (s *SequenceBuilder) Get() types.Claim { | ||
return s.lastClaim | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters