Skip to content

Commit

Permalink
Merge pull request #2349 from OffchainLabs/input-writes
Browse files Browse the repository at this point in the history
Write validation inputs to json file in working directory
  • Loading branch information
eljobe authored Jun 3, 2024
2 parents 06235f4 + 9e54cf8 commit 7373a4e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions validator/client/validation_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ func (c *ExecutionClient) LatestWasmModuleRoot() containers.PromiseInterface[com

func (c *ExecutionClient) WriteToFile(input *validator.ValidationInput, expOut validator.GoGlobalState, moduleRoot common.Hash) containers.PromiseInterface[struct{}] {
jsonInput := server_api.ValidationInputToJson(input)
if err := jsonInput.WriteToFile(); err != nil {
return stopwaiter.LaunchPromiseThread[struct{}](c, func(ctx context.Context) (struct{}, error) {
return struct{}{}, err
})
}
return stopwaiter.LaunchPromiseThread[struct{}](c, func(ctx context.Context) (struct{}, error) {
err := c.client.CallContext(ctx, nil, server_api.Namespace+"_writeToFile", jsonInput, expOut, moduleRoot)
return struct{}{}, err
Expand Down
13 changes: 13 additions & 0 deletions validator/server_api/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ package server_api

import (
"encoding/base64"
"encoding/json"
"fmt"
"os"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
Expand Down Expand Up @@ -64,6 +66,17 @@ type InputJSON struct {
DebugChain bool
}

func (i *InputJSON) WriteToFile() error {
contents, err := json.MarshalIndent(i, "", " ")
if err != nil {
return err
}
if err = os.WriteFile(fmt.Sprintf("block_inputs_%d.json", i.Id), contents, 0600); err != nil {
return err
}
return nil
}

type UserWasmJson struct {
Module string
Asm string
Expand Down

0 comments on commit 7373a4e

Please sign in to comment.