Skip to content

Commit b1b5f08

Browse files
committed
cannon: integrate into monorepo
1 parent d45a659 commit b1b5f08

25 files changed

+29
-22
lines changed

cannon/cmd/load_elf.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
"github.com/urfave/cli/v2"
88

9-
"github.com/ethereum-optimism/cannon/mipsevm"
9+
"github.com/ethereum-optimism/optimism/cannon/mipsevm"
1010
)
1111

1212
var (

cannon/cmd/matcher.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"strconv"
66
"strings"
77

8-
"github.com/ethereum-optimism/cannon/mipsevm"
8+
"github.com/ethereum-optimism/optimism/cannon/mipsevm"
99
)
1010

1111
type StepMatcher func(st *mipsevm.State) bool

cannon/cmd/run.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414

1515
"github.com/pkg/profile"
1616

17-
"github.com/ethereum-optimism/cannon/mipsevm"
18-
"github.com/ethereum-optimism/cannon/preimage"
17+
"github.com/ethereum-optimism/optimism/cannon/mipsevm"
18+
"github.com/ethereum-optimism/optimism/op-preimage"
1919
)
2020

2121
var (

cannon/docs/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ to emulate the delayed `PC` changes after delay-slot execution.
4040

4141
There are 3 types of witness data involved in onchain execution:
4242
- [Packed State](#packed-state)
43-
- [Memory proofs](#memory-proofs)
43+
- [Memory proofs](#memory-proofs)
4444
- [Pre-image data](#pre-image-data)
4545

4646
### Packed State
@@ -131,7 +131,7 @@ since all sibling data that is combined with the new leaf value was already auth
131131
### Pre-image data
132132

133133
Pre-image data is accessed through syscalls exclusively.
134-
The OP-stack fault-proof [Pre-image Oracle specs](https://github.com/ethereum-optimism/optimism/blob/develop/specs/fault-proof.md#pre-image-oracle)
134+
The OP-stack fault-proof [Pre-image Oracle specs](../../specs/fault-proof.md#pre-image-oracle)
135135
define the ABI for communicating pre-images.
136136

137137
This ABI is implemented by the VM by intercepting the `read`/`write` syscalls to specific file descriptors:

cannon/example/claim/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ module claim
22

33
go 1.20
44

5-
require github.com/ethereum-optimism/cannon/preimage v0.0.0
5+
require github.com/ethereum-optimism/optimism/op-preimage v0.0.0
66

77
require (
88
golang.org/x/crypto v0.8.0 // indirect
99
golang.org/x/sys v0.7.0 // indirect
1010
)
1111

12-
replace github.com/ethereum-optimism/cannon/preimage v0.0.0 => ../../preimage
12+
replace github.com/ethereum-optimism/optimism/op-preimage v0.0.0 => ../../../op-preimage

cannon/example/claim/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66
"os"
77

8-
"github.com/ethereum-optimism/cannon/preimage"
8+
"github.com/ethereum-optimism/optimism/op-preimage"
99
)
1010

1111
type rawHint string

cannon/go.mod

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
module github.com/ethereum-optimism/cannon
1+
module github.com/ethereum-optimism/optimism/cannon
22

33
go 1.20
44

55
require (
6-
github.com/ethereum-optimism/cannon/preimage v0.0.0
6+
github.com/ethereum-optimism/optimism/op-preimage v0.0.0
77
github.com/ethereum/go-ethereum v1.11.5
88
github.com/pkg/profile v1.7.0
99
github.com/stretchr/testify v1.8.2
@@ -66,4 +66,4 @@ require (
6666
gopkg.in/yaml.v3 v3.0.1 // indirect
6767
)
6868

69-
replace github.com/ethereum-optimism/cannon/preimage v0.0.0 => ./preimage
69+
replace github.com/ethereum-optimism/optimism/op-preimage v0.0.0 => ../op-preimage

cannon/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
"github.com/urfave/cli/v2"
1212

13-
"github.com/ethereum-optimism/cannon/cmd"
13+
"github.com/ethereum-optimism/optimism/cannon/cmd"
1414
)
1515

1616
func main() {

cannon/mipsevm/evm.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ func LoadContracts() (*Contracts, error) {
4242
}
4343

4444
func LoadContract(name string) (*Contract, error) {
45-
// TODO change to forge build output
46-
dat, err := os.ReadFile(fmt.Sprintf("../contracts/out/%s.sol/%s.json", name, name))
45+
dat, err := os.ReadFile(fmt.Sprintf("../../packages/contracts-bedrock/forge-artifacts/%s.sol/%s.json", name, name))
4746
if err != nil {
4847
return nil, fmt.Errorf("failed to read contract JSON definition of %q: %w", name, err)
4948
}

cannon/mipsevm/evm_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ func testContractsSetup(t *testing.T) (*Contracts, *Addresses, *SourceMapTracer)
2121
contracts, err := LoadContracts()
2222
require.NoError(t, err)
2323

24-
mipsSrcMap, err := contracts.MIPS.SourceMap([]string{"../contracts/src/MIPS.sol"})
24+
mipsSrcMap, err := contracts.MIPS.SourceMap([]string{"../../packages/contracts-bedrock/contracts/cannon/MIPS.sol"})
2525
require.NoError(t, err)
26-
oracleSrcMap, err := contracts.Oracle.SourceMap([]string{"../contracts/src/Oracle.sol"})
26+
oracleSrcMap, err := contracts.Oracle.SourceMap([]string{"../../packages/contracts-bedrock/contracts/cannon/Oracle.sol"})
2727
require.NoError(t, err)
2828

2929
addrs := &Addresses{

cannon/mipsevm/solutil_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import (
1010
func TestSourcemap(t *testing.T) {
1111
contract, err := LoadContract("MIPS")
1212
require.NoError(t, err)
13-
srcMap, err := contract.SourceMap([]string{"../contracts/src/MIPS.sol"})
13+
srcMap, err := contract.SourceMap([]string{"../../packages/contracts-bedrock/contracts/cannon/MIPS.sol"})
1414
require.NoError(t, err)
1515
for i := 0; i < len(contract.DeployedBytecode.Object); i++ {
1616
info := srcMap.FormattedInfo(uint64(i))
17-
if !strings.HasPrefix(info, "generated:") && !strings.HasPrefix(info, "../contracts/src/MIPS.sol") {
17+
if !strings.HasPrefix(info, "generated:") && !strings.HasPrefix(info, "../../packages/contracts-bedrock/contracts/cannon/MIPS.sol") {
1818
t.Fatalf("unexpected info: %q", info)
1919
}
2020
}

cannon/mipsevm/state_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"github.com/ethereum/go-ethereum/crypto"
1717
"github.com/stretchr/testify/require"
1818

19-
"github.com/ethereum-optimism/cannon/preimage"
19+
"github.com/ethereum-optimism/optimism/op-preimage"
2020
)
2121

2222
// 0xbf_c0_00_00 ... baseAddrEnd is used in tests to write the results to

cannon/mipsevm/witness.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"errors"
66
"fmt"
77

8-
"github.com/ethereum-optimism/cannon/preimage"
8+
"github.com/ethereum-optimism/optimism/op-preimage"
99
)
1010

1111
type StepWitness struct {

op-preimage/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# op-preimage
2+
3+
`op-preimage` offers 0-dependency Go bindings to interact as client or sever over the Pre-image Oracle ABI.
4+
5+
Read more about the Preimage Oracle in the [specs](../specs/fault-proof.md).
6+
7+
See [op-program](../op-program) and [Cannon client examples](../cannon/example) for client-side usage.
8+
See [Cannon `mipsevm`](../cannon/mipsevm) for server-side usage.
File renamed without changes.

cannon/preimage/go.mod op-preimage/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/ethereum-optimism/cannon/preimage
1+
module github.com/ethereum-optimism/optimism/op-preimage
22

33
go 1.20
44

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)