Skip to content

Commit

Permalink
change base branch and address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshvanahalli committed Oct 10, 2024
2 parents 16f981f + a1cb06d commit 94cd9b4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,17 @@ jobs:
run: |
echo "Running redis tests" >> full.log
TEST_REDIS=redis://localhost:6379/0 gotestsum --format short-verbose -- -p 1 -run TestRedis ./arbnode/... ./system_tests/... -coverprofile=coverage-redis.txt -covermode=atomic -coverpkg=./...
- name: create block input json file
if: matrix.test-mode == 'defaults'
run: |
BLOCK_INPUT_JSON_PATH="${{ github.workspace }}/target/block_input.json" gotestsum --format short-verbose -- -run TestProgramStorage$ ./system_tests/... --count 1
- name: run arbitrator prover on block input json
if: matrix.test-mode == 'defaults'
run: |
make build-prover-bin
target/bin/prover target/machines/latest/machine.wavm.br -b --json-inputs="${{ github.workspace }}/target/block_input.json"
- name: run challenge tests
if: matrix.test-mode == 'challenge'
Expand Down
2 changes: 1 addition & 1 deletion arbnode/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ func (a *BlockValidatorDebugAPI) ValidateMessageNumber(

func (a *BlockValidatorDebugAPI) ValidationInputsAt(ctx context.Context, msgNum hexutil.Uint64, target ethdb.WasmTarget,
) (server_api.InputJSON, error) {
return a.val.ValidationInputsAt(ctx, arbutil.MessageIndex(msgNum), target)
return a.val.ValidationInputsAt(ctx, arbutil.MessageIndex(msgNum), []ethdb.WasmTarget{target})
}
4 changes: 2 additions & 2 deletions staker/stateless_block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,12 +511,12 @@ func (v *StatelessBlockValidator) ValidateResult(
return true, &entry.End, nil
}

func (v *StatelessBlockValidator) ValidationInputsAt(ctx context.Context, pos arbutil.MessageIndex, target ethdb.WasmTarget) (server_api.InputJSON, error) {
func (v *StatelessBlockValidator) ValidationInputsAt(ctx context.Context, pos arbutil.MessageIndex, targets []ethdb.WasmTarget) (server_api.InputJSON, error) {
entry, err := v.CreateReadyValidationEntry(ctx, pos)
if err != nil {
return server_api.InputJSON{}, err
}
input, err := entry.ToInput([]ethdb.WasmTarget{target})
input, err := entry.ToInput(targets)
if err != nil {
return server_api.InputJSON{}, err
}
Expand Down
16 changes: 7 additions & 9 deletions system_tests/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
"github.com/offchainlabs/nitro/util/headerreader"
"github.com/offchainlabs/nitro/util/redisutil"
"github.com/offchainlabs/nitro/util/signature"
"github.com/offchainlabs/nitro/validator/inputs"
"github.com/offchainlabs/nitro/validator/server_api"
"github.com/offchainlabs/nitro/validator/server_common"
"github.com/offchainlabs/nitro/validator/valnode"
Expand Down Expand Up @@ -1718,8 +1717,8 @@ func logParser[T any](t *testing.T, source string, name string) func(*types.Log)

// recordBlock writes a json file with all of the data needed to validate a block.
//
// This can be used as an input to the arbitrator's prover (target=rawdb.TargetWavm) and jit (target=rawdb.LocalTarget()) binaries to validate a block.
func recordBlock(t *testing.T, block uint64, builder *NodeBuilder, target ethdb.WasmTarget) {
// This can be used as an input to the arbitrator prover to validate a block.
func recordBlock(t *testing.T, block uint64, builder *NodeBuilder, targets []ethdb.WasmTarget, blockInputJSONPath string) {
t.Helper()
ctx := builder.ctx
inboxPos := arbutil.MessageIndex(block)
Expand All @@ -1733,15 +1732,14 @@ func recordBlock(t *testing.T, block uint64, builder *NodeBuilder, target ethdb.
break
}
}
validationInputsWriter, err := inputs.NewWriter(inputs.WithSlug(t.Name()))
Require(t, err)
inputJson, err := builder.L2.ConsensusNode.StatelessBlockValidator.ValidationInputsAt(ctx, inboxPos, target)
inputJson, err := builder.L2.ConsensusNode.StatelessBlockValidator.ValidationInputsAt(ctx, inboxPos, targets)
if err != nil {
Fatal(t, "failed to get validation inputs", block, err)
}
if err := validationInputsWriter.Write(&inputJson); err != nil {
Fatal(t, "failed to write validation inputs", block, err)
}
contents, err := json.Marshal(inputJson)
Require(t, err)
err = os.WriteFile(blockInputJSONPath, contents, 0600)
Require(t, err)
}

func populateMachineDir(t *testing.T, cr *github.ConsensusRelease) string {
Expand Down
13 changes: 5 additions & 8 deletions system_tests/program_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,11 @@ func storageTest(t *testing.T, jit bool) {
validateBlocks(t, 2, jit, builder)

// Captures a block_input_<id>.json file for the block that included the
// storage write transaction.
recordBlock(t, receipt.BlockNumber.Uint64(), builder, rawdb.TargetWavm)
// storage write transaction. Include wasm targets necessary for arbitrator prover and jit binaries
blockInputJSONPath := os.Getenv("BLOCK_INPUT_JSON_PATH")
if blockInputJSONPath != "" {
recordBlock(t, receipt.BlockNumber.Uint64(), builder, []ethdb.WasmTarget{rawdb.TargetWavm, rawdb.LocalTarget()}, blockInputJSONPath)
}
}

func TestProgramTransientStorage(t *testing.T) {
Expand Down Expand Up @@ -492,12 +495,6 @@ func transientStorageTest(t *testing.T, jit bool) {
}

validateBlocks(t, 7, jit, builder)

// Captures a block_input_<id>.json file for the block that included the storage
// related transaction. Has userwasms for WasmTarget recognized by jit binary
receipt, err := EnsureTxSucceeded(ctx, l2client, tx)
Require(t, err)
recordBlock(t, receipt.BlockNumber.Uint64(), builder, rawdb.LocalTarget())
}

func TestProgramMath(t *testing.T) {
Expand Down

0 comments on commit 94cd9b4

Please sign in to comment.