Commit b1b5f085 authored by protolambda's avatar protolambda

cannon: integrate into monorepo

parent d45a659b
...@@ -6,7 +6,7 @@ import ( ...@@ -6,7 +6,7 @@ import (
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
"github.com/ethereum-optimism/cannon/mipsevm" "github.com/ethereum-optimism/optimism/cannon/mipsevm"
) )
var ( var (
......
...@@ -5,7 +5,7 @@ import ( ...@@ -5,7 +5,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/ethereum-optimism/cannon/mipsevm" "github.com/ethereum-optimism/optimism/cannon/mipsevm"
) )
type StepMatcher func(st *mipsevm.State) bool type StepMatcher func(st *mipsevm.State) bool
......
...@@ -14,8 +14,8 @@ import ( ...@@ -14,8 +14,8 @@ import (
"github.com/pkg/profile" "github.com/pkg/profile"
"github.com/ethereum-optimism/cannon/mipsevm" "github.com/ethereum-optimism/optimism/cannon/mipsevm"
"github.com/ethereum-optimism/cannon/preimage" "github.com/ethereum-optimism/optimism/op-preimage"
) )
var ( var (
......
...@@ -131,7 +131,7 @@ since all sibling data that is combined with the new leaf value was already auth ...@@ -131,7 +131,7 @@ since all sibling data that is combined with the new leaf value was already auth
### Pre-image data ### Pre-image data
Pre-image data is accessed through syscalls exclusively. Pre-image data is accessed through syscalls exclusively.
The OP-stack fault-proof [Pre-image Oracle specs](https://github.com/ethereum-optimism/optimism/blob/develop/specs/fault-proof.md#pre-image-oracle) The OP-stack fault-proof [Pre-image Oracle specs](../../specs/fault-proof.md#pre-image-oracle)
define the ABI for communicating pre-images. define the ABI for communicating pre-images.
This ABI is implemented by the VM by intercepting the `read`/`write` syscalls to specific file descriptors: This ABI is implemented by the VM by intercepting the `read`/`write` syscalls to specific file descriptors:
......
...@@ -2,11 +2,11 @@ module claim ...@@ -2,11 +2,11 @@ module claim
go 1.20 go 1.20
require github.com/ethereum-optimism/cannon/preimage v0.0.0 require github.com/ethereum-optimism/optimism/op-preimage v0.0.0
require ( require (
golang.org/x/crypto v0.8.0 // indirect golang.org/x/crypto v0.8.0 // indirect
golang.org/x/sys v0.7.0 // indirect golang.org/x/sys v0.7.0 // indirect
) )
replace github.com/ethereum-optimism/cannon/preimage v0.0.0 => ../../preimage replace github.com/ethereum-optimism/optimism/op-preimage v0.0.0 => ../../../op-preimage
...@@ -5,7 +5,7 @@ import ( ...@@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"os" "os"
"github.com/ethereum-optimism/cannon/preimage" "github.com/ethereum-optimism/optimism/op-preimage"
) )
type rawHint string type rawHint string
......
module github.com/ethereum-optimism/cannon module github.com/ethereum-optimism/optimism/cannon
go 1.20 go 1.20
require ( require (
github.com/ethereum-optimism/cannon/preimage v0.0.0 github.com/ethereum-optimism/optimism/op-preimage v0.0.0
github.com/ethereum/go-ethereum v1.11.5 github.com/ethereum/go-ethereum v1.11.5
github.com/pkg/profile v1.7.0 github.com/pkg/profile v1.7.0
github.com/stretchr/testify v1.8.2 github.com/stretchr/testify v1.8.2
...@@ -66,4 +66,4 @@ require ( ...@@ -66,4 +66,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )
replace github.com/ethereum-optimism/cannon/preimage v0.0.0 => ./preimage replace github.com/ethereum-optimism/optimism/op-preimage v0.0.0 => ../op-preimage
...@@ -10,7 +10,7 @@ import ( ...@@ -10,7 +10,7 @@ import (
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
"github.com/ethereum-optimism/cannon/cmd" "github.com/ethereum-optimism/optimism/cannon/cmd"
) )
func main() { func main() {
......
...@@ -42,8 +42,7 @@ func LoadContracts() (*Contracts, error) { ...@@ -42,8 +42,7 @@ func LoadContracts() (*Contracts, error) {
} }
func LoadContract(name string) (*Contract, error) { func LoadContract(name string) (*Contract, error) {
// TODO change to forge build output dat, err := os.ReadFile(fmt.Sprintf("../../packages/contracts-bedrock/forge-artifacts/%s.sol/%s.json", name, name))
dat, err := os.ReadFile(fmt.Sprintf("../contracts/out/%s.sol/%s.json", name, name))
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to read contract JSON definition of %q: %w", name, err) return nil, fmt.Errorf("failed to read contract JSON definition of %q: %w", name, err)
} }
......
...@@ -21,9 +21,9 @@ func testContractsSetup(t *testing.T) (*Contracts, *Addresses, *SourceMapTracer) ...@@ -21,9 +21,9 @@ func testContractsSetup(t *testing.T) (*Contracts, *Addresses, *SourceMapTracer)
contracts, err := LoadContracts() contracts, err := LoadContracts()
require.NoError(t, err) require.NoError(t, err)
mipsSrcMap, err := contracts.MIPS.SourceMap([]string{"../contracts/src/MIPS.sol"}) mipsSrcMap, err := contracts.MIPS.SourceMap([]string{"../../packages/contracts-bedrock/contracts/cannon/MIPS.sol"})
require.NoError(t, err) require.NoError(t, err)
oracleSrcMap, err := contracts.Oracle.SourceMap([]string{"../contracts/src/Oracle.sol"}) oracleSrcMap, err := contracts.Oracle.SourceMap([]string{"../../packages/contracts-bedrock/contracts/cannon/Oracle.sol"})
require.NoError(t, err) require.NoError(t, err)
addrs := &Addresses{ addrs := &Addresses{
......
...@@ -10,11 +10,11 @@ import ( ...@@ -10,11 +10,11 @@ import (
func TestSourcemap(t *testing.T) { func TestSourcemap(t *testing.T) {
contract, err := LoadContract("MIPS") contract, err := LoadContract("MIPS")
require.NoError(t, err) require.NoError(t, err)
srcMap, err := contract.SourceMap([]string{"../contracts/src/MIPS.sol"}) srcMap, err := contract.SourceMap([]string{"../../packages/contracts-bedrock/contracts/cannon/MIPS.sol"})
require.NoError(t, err) require.NoError(t, err)
for i := 0; i < len(contract.DeployedBytecode.Object); i++ { for i := 0; i < len(contract.DeployedBytecode.Object); i++ {
info := srcMap.FormattedInfo(uint64(i)) info := srcMap.FormattedInfo(uint64(i))
if !strings.HasPrefix(info, "generated:") && !strings.HasPrefix(info, "../contracts/src/MIPS.sol") { if !strings.HasPrefix(info, "generated:") && !strings.HasPrefix(info, "../../packages/contracts-bedrock/contracts/cannon/MIPS.sol") {
t.Fatalf("unexpected info: %q", info) t.Fatalf("unexpected info: %q", info)
} }
} }
......
...@@ -16,7 +16,7 @@ import ( ...@@ -16,7 +16,7 @@ import (
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/ethereum-optimism/cannon/preimage" "github.com/ethereum-optimism/optimism/op-preimage"
) )
// 0xbf_c0_00_00 ... baseAddrEnd is used in tests to write the results to // 0xbf_c0_00_00 ... baseAddrEnd is used in tests to write the results to
......
...@@ -5,7 +5,7 @@ import ( ...@@ -5,7 +5,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/ethereum-optimism/cannon/preimage" "github.com/ethereum-optimism/optimism/op-preimage"
) )
type StepWitness struct { type StepWitness struct {
......
# op-preimage
`op-preimage` offers 0-dependency Go bindings to interact as client or sever over the Pre-image Oracle ABI.
Read more about the Preimage Oracle in the [specs](../specs/fault-proof.md).
See [op-program](../op-program) and [Cannon client examples](../cannon/example) for client-side usage.
See [Cannon `mipsevm`](../cannon/mipsevm) for server-side usage.
module github.com/ethereum-optimism/cannon/preimage module github.com/ethereum-optimism/optimism/op-preimage
go 1.20 go 1.20
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment