Skip to content

Commit

Permalink
Merge pull request #6258 from ethereum-optimism/refcell/steptest/chal…
Browse files Browse the repository at this point in the history
…lenger

feat(op-challenger): Validate Step Function Manual ABI Packing
  • Loading branch information
OptimismBot authored Jul 11, 2023
2 parents 9226e8f + 4c733eb commit 0f07717
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
22 changes: 22 additions & 0 deletions op-challenger/fault/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,25 @@ func TestBuildFaultAttackData(t *testing.T) {

require.Equal(t, data, tx.Data())
}

// TestBuildFaultStepData ensures that the manual ABI packing is the same as going through the bound contract.
func TestBuildFaultStepData(t *testing.T) {
_, opts, _, contract, err := setupFaultDisputeGame()
require.NoError(t, err)

responder, _ := newTestFaultResponder(t, false)

data, err := responder.buildStepTxData(StepCallData{
ClaimIndex: 2,
IsAttack: false,
StateData: []byte{0x01},
Proof: []byte{0x02},
})
require.NoError(t, err)

opts.GasLimit = 100_000
tx, err := contract.Step(opts, big.NewInt(2), false, []byte{0x01}, []byte{0x02})
require.NoError(t, err)

require.Equal(t, data, tx.Data())
}
1 change: 0 additions & 1 deletion op-challenger/fault/responder.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ func (r *faultResponder) sendTxAndWait(ctx context.Context, txData []byte) error
func (r *faultResponder) buildStepTxData(stepData StepCallData) ([]byte, error) {
return r.fdgAbi.Pack(
"step",
big.NewInt(int64(stepData.StateIndex)),
big.NewInt(int64(stepData.ClaimIndex)),
stepData.IsAttack,
stepData.StateData,
Expand Down
1 change: 0 additions & 1 deletion op-challenger/fault/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ var (

// StepCallData encapsulates the data needed to perform a step.
type StepCallData struct {
StateIndex uint64
ClaimIndex uint64
IsAttack bool
StateData []byte
Expand Down

0 comments on commit 0f07717

Please sign in to comment.