Skip to content

Commit

Permalink
Use op-service/serialize
Browse files Browse the repository at this point in the history
  • Loading branch information
mininny committed Oct 2, 2024
1 parent 997d606 commit d2480b8
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 22 deletions.
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ go 1.21
toolchain go1.21.1

replace github.com/ethereum/go-ethereum v1.14.8 => github.com/ethereum-optimism/op-geth v1.101408.0-rc.4.0.20240827042333-110c433a2469

replace github.com/ethereum-optimism/optimism v1.9.2 => github.com/testinprod-io/optimism v0.0.0-20241001233047-6a2de66c6e6d
replace github.com/ethereum-optimism/optimism v1.9.2 => github.com/testinprod-io/optimism v0.0.0-20241002192014-a9e250e1feac

require (
github.com/ethereum-optimism/optimism v1.9.2
Expand Down Expand Up @@ -78,7 +77,6 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect
github.com/google/uuid v1.6.0 // indirect
Expand Down Expand Up @@ -151,7 +149,6 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/onsi/ginkgo/v2 v2.20.0 // indirect
github.com/onsi/gomega v1.34.1 // indirect
github.com/opencontainers/runtime-spec v1.2.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
Expand Down Expand Up @@ -219,5 +216,6 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/blake3 v1.3.0 // indirect
lukechampine.com/uint128 v1.3.0 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,6 @@ github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a h1:1ur3QoCqvE5fl+nylMaIr9PVV1w343YRDtsy+Rwu7XI=
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48=
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
github.com/testinprod-io/optimism v0.0.0-20241001233047-6a2de66c6e6d h1:5tOocZ84k0E6C7G53eXgkrydFW59zA4Z3w5jCFghXzY=
github.com/testinprod-io/optimism v0.0.0-20241001233047-6a2de66c6e6d/go.mod h1:fLtZa7iBSxRebPnKNMkwsOy8VTjOvp7XLuD+bGvvNc8=
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
Expand Down Expand Up @@ -1024,6 +1022,8 @@ honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
lukechampine.com/blake3 v1.3.0 h1:sJ3XhFINmHSrYCgl958hscfIa3bw8x4DqMP3u1YvoYE=
lukechampine.com/blake3 v1.3.0/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k=
lukechampine.com/uint128 v1.3.0 h1:cDdUVfRwDUDovz610ABgFD17nXD4/uDgVHl2sC3+sbo=
lukechampine.com/uint128 v1.3.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU=
rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA=
sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck=
Expand Down
2 changes: 1 addition & 1 deletion op-e2e/e2eutils/disputegame/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (h *AsteriscFactoryHelper) StartOutputAsteriscGame(ctx context.Context, l2N

return &OutputAsteriscGameHelper{
OutputCannonGameHelper: op_e2e_disputegame.OutputCannonGameHelper{
OutputGameHelper: *op_e2e_disputegame.NewOutputGameHelper(h.T, h.Require, h.Client, h.Opts, h.PrivKey, game, h.FactoryAddr, createdEvent.DisputeProxy, provider, h.System),
OutputGameHelper: *op_e2e_disputegame.NewOutputGameHelper(h.T, h.Require, h.Client, h.Opts, h.PrivKey, game, h.FactoryAddr, createdEvent.DisputeProxy, provider, h.System, h.AllocType),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion rvgo/cmd/load_elf.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"fmt"

cannon "github.com/ethereum-optimism/optimism/cannon/cmd"

Check failure on line 7 in rvgo/cmd/load_elf.go

View workflow job for this annotation

GitHub Actions / rvgo-tests

missing go.sum entry for module providing package github.com/ethereum-optimism/optimism/cannon/cmd (imported by github.com/ethereum-optimism/asterisc/rvgo/cmd); to add:
"github.com/ethereum-optimism/optimism/cannon/serialize"
"github.com/ethereum-optimism/optimism/op-service/ioutil"

Check failure on line 8 in rvgo/cmd/load_elf.go

View workflow job for this annotation

GitHub Actions / rvgo-tests

missing go.sum entry for module providing package github.com/ethereum-optimism/optimism/op-service/ioutil (imported by github.com/ethereum-optimism/asterisc/rvgo/cmd); to add:
"github.com/ethereum-optimism/optimism/op-service/jsonutil"
"github.com/ethereum-optimism/optimism/op-service/serialize"
"github.com/urfave/cli/v2"

"github.com/ethereum-optimism/asterisc/rvgo/fast"
Expand Down
2 changes: 1 addition & 1 deletion rvgo/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (

"github.com/ethereum-optimism/asterisc/rvgo/fast"
cannon "github.com/ethereum-optimism/optimism/cannon/cmd"
"github.com/ethereum-optimism/optimism/cannon/serialize"
preimage "github.com/ethereum-optimism/optimism/op-preimage"
"github.com/ethereum-optimism/optimism/op-service/ioutil"
"github.com/ethereum-optimism/optimism/op-service/jsonutil"
"github.com/ethereum-optimism/optimism/op-service/serialize"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
Expand Down
40 changes: 29 additions & 11 deletions rvgo/cmd/witness.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package cmd

import (
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"os"

"github.com/urfave/cli/v2"

Expand All @@ -12,37 +15,52 @@ import (
)

type WitnessOutput struct {
Witness []byte `json:"witness"`
StateHash [32]byte `json:"stateHash"`
Witness hexutil.Bytes `json:"witness"`
StateHash common.Hash `json:"stateHash"`
Step uint64 `json:"step"`
Exited bool `json:"exited"`
ExitCode uint8 `json:"exitCode"`
PC uint64 `json:"pc"`
}

func Witness(ctx *cli.Context) error {
input := ctx.Path(cannon.WitnessInputFlag.Name)
output := ctx.Path(cannon.WitnessOutputFlag.Name)
witnessOutput := ctx.Path(cannon.WitnessOutputFlag.Name)
state, err := fast.LoadVMStateFromFile(input)
if err != nil {
return fmt.Errorf("invalid input state (%v): %w", input, err)
}

witness := state.EncodeWitness()
stateHash, err := witness.StateHash()
if err != nil {
return fmt.Errorf("failed to compute witness hash: %w", err)
return fmt.Errorf("invalid Witness (%v): %w", witness, err)
}

if witnessOutput != "" {
if err := os.WriteFile(witnessOutput, witness, OutFilePerm); err != nil {
return fmt.Errorf("writing output to %v: %w", witnessOutput, err)
}
}
witnessOutput := &WitnessOutput{
Witness: witness,
output := &WitnessOutput{
Witness: []byte(witness),
StateHash: stateHash,
Step: state.GetStep(),
Exited: state.Exited,
ExitCode: state.ExitCode,
PC: state.PC,
}
if err := jsonutil.WriteJSON(witnessOutput, ioutil.ToStdOutOrFileOrNoop(output, OutFilePerm)); err != nil {
return fmt.Errorf("failed to write witness output %w", err)

if err := jsonutil.WriteJSON(output, ioutil.ToStdOut()); err != nil {
return fmt.Errorf("failed to write response: %w", err)
}
fmt.Println(stateHash.Hex())
return nil
}

var WitnessCommand = &cli.Command{
Name: "witness",
Usage: "Convert an Asterisc JSON state into a binary witness",
Description: "Convert an Asterisc JSON state into a binary witness. The statehash is written to stdout",
Usage: "Convert an Asterisc JSON/binary state into a binary witness",
Description: "Convert an Asterisc JSON/binary state into a binary witness. Basic Data about the state is printed to stdout in JSON format",
Action: Witness,
Flags: []cli.Flag{
cannon.WitnessInputFlag,
Expand Down
3 changes: 1 addition & 2 deletions rvgo/fast/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import (
"io"

"github.com/ethereum-optimism/optimism/op-service/jsonutil"

Check failure on line 8 in rvgo/fast/state.go

View workflow job for this annotation

GitHub Actions / rvgo-tests

missing go.sum entry for module providing package github.com/ethereum-optimism/optimism/op-service/jsonutil (imported by github.com/ethereum-optimism/asterisc/rvgo/cmd); to add:

"github.com/ethereum-optimism/optimism/cannon/serialize"
"github.com/ethereum-optimism/optimism/op-service/serialize"

Check failure on line 9 in rvgo/fast/state.go

View workflow job for this annotation

GitHub Actions / rvgo-tests

missing go.sum entry for module providing package github.com/ethereum-optimism/optimism/op-service/serialize (imported by github.com/ethereum-optimism/asterisc/rvgo/cmd); to add:

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
Expand Down

0 comments on commit d2480b8

Please sign in to comment.