Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d7f7d7d
cannon: Update go version
mbaxter Feb 20, 2025
4cdd3e7
Noop eventfd2 syscall
mbaxter Mar 6, 2025
5dce901
Run semver-lock
mbaxter Mar 6, 2025
4513b74
Add new VM version
mbaxter Mar 7, 2025
38e1ab8
Add testdata for new state version
mbaxter Mar 7, 2025
f69469d
Update cannon-embeds task
mbaxter Mar 7, 2025
71eeec3
Update test program go versions
mbaxter Mar 10, 2025
0779ccc
Tweak step limits in tests
mbaxter Mar 10, 2025
91ebef5
Update cannon-embeds to embed versions 6 and 7
mbaxter Apr 17, 2025
046a334
Fix syscallNum type
mbaxter Apr 17, 2025
88c5ca1
Update tests to run across all relevant vm versions
mbaxter Apr 21, 2025
c203d09
Update contracts to feature-toggle the eventFd2 syscall
mbaxter Apr 22, 2025
8981153
Run semver-lock
mbaxter Apr 22, 2025
9e47af6
Update noop syscalls in tests
mbaxter Apr 22, 2025
3288691
Disable program tests for the 32-bit VM
mbaxter Apr 22, 2025
e95acce
Fix reflection error
mbaxter Apr 23, 2025
08c891e
Skip 32-bit program tests
mbaxter Apr 23, 2025
9059142
Fix fuzz test param
mbaxter Apr 23, 2025
d369b13
Update todo
mbaxter Apr 23, 2025
c0e393b
Rename examples testdata to go-1-23
mbaxter Apr 24, 2025
4eaf12f
Update references to testdata/examples
mbaxter Apr 24, 2025
d9da33e
Fix testdata Makefile, add go-1-22 testdata
mbaxter Apr 24, 2025
4c05241
Undo MIPS2 version bump
mbaxter Apr 24, 2025
4eef548
Create separate dockerfile for go1.23 prestates
mbaxter Apr 24, 2025
9839593
Run e2e tests against new vm
mbaxter Apr 24, 2025
c928c2f
Fix semver comment
mbaxter Apr 24, 2025
0504e3b
Use tagged cannon binaries for legacy 32-bit VMs
mbaxter Apr 24, 2025
dee571b
Bump MIPS64 version
mbaxter Apr 24, 2025
db0b853
Rework test helpers to avoid calling t.Parallel multiple times
mbaxter Apr 25, 2025
2fad8fa
Cut more calls to InitParallel
mbaxter Apr 25, 2025
eb9c844
Reorder preimage docker build steps
mbaxter Apr 25, 2025
63d55ef
Merge branch 'develop' into mbax/issue-13447/go-1.23
mbaxter Apr 25, 2025
d8f3bf1
Fix reproducible-prestate output for mt64Next
mbaxter Apr 25, 2025
1244cdc
Drop the single-threaded VM variant from fp e2e tests
mbaxter Apr 25, 2025
4fd46d8
op-e2e: Use mt64Next prestate
ajsutton Apr 27, 2025
c3eb1db
ci: Extend timeout for cannon tests
ajsutton Apr 28, 2025
3df5d02
op-e2e: Only run super cannon tests on the mt64Next variant.
ajsutton Apr 28, 2025
1fa6ef8
op-e2e: Set cannon test timeout to 90m.
ajsutton Apr 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ jobs:
- run:
name: build Cannon example binaries
command: make elf # only compile ELF binaries with Go, we do not have MIPS GCC for creating the debug-dumps.
working_directory: cannon/testdata/example
working_directory: cannon/testdata
- run:
name: Cannon Go lint
command: |
Expand Down Expand Up @@ -2148,7 +2148,7 @@ workflows:
notify: true
mentions: "@proofs-team"
no_output_timeout: 60m
test_timeout: 75m
test_timeout: 90m
resource_class: ethereum-optimism/latitude-fps-1
environment_overrides: |
export OP_E2E_CANNON_ENABLED="true"
Expand Down
2 changes: 1 addition & 1 deletion cannon/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ cache
venv
.idea
*.log
testdata/example/bin
contracts/out
*.pprof
*.out
bin
testdata/**/bin/
multicannon/embeds/cannon*
1 change: 1 addition & 0 deletions cannon/Dockerfile.diff
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ARG GIT_DATE

ARG TARGETOS TARGETARCH

# TODO(#14692): Update to test cannon-multithreaded64-4 when new VM stabilizes
FROM --platform=$BUILDPLATFORM us-docker.pkg.dev/oplabs-tools-artifacts/images/cannon:v1.1.0-alpha.4 AS cannon-v2
FROM --platform=$BUILDPLATFORM us-docker.pkg.dev/oplabs-tools-artifacts/images/cannon:v1.4.0 AS cannon-multithreaded64-3

Expand Down
19 changes: 14 additions & 5 deletions cannon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,21 @@ cannon-embeds: cannon32-impl cannon64-impl
@cp bin/cannon32-impl ./multicannon/embeds/cannon-5
# 64-bit multithreaded vm
@cp bin/cannon64-impl ./multicannon/embeds/cannon-6
@cp bin/cannon64-impl ./multicannon/embeds/cannon-7

cannon: cannon-embeds
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v $(LDFLAGS) -o ./bin/cannon ./multicannon/

clean:
rm -rf bin multicannon/embeds/cannon*

elf:
make -C ./testdata/example elf
elf: elf-go-122 elf-go-123

elf-go-122:
make -C ./testdata/go-1-22 elf

elf-go-123:
make -C ./testdata/go-1-23 elf

sanitize-program:
mips-linux-gnu-objdump -d -j .text $$GUEST_PROGRAM > ./bin/dump.txt
Expand All @@ -67,7 +73,7 @@ test: elf contract test64
test64: elf contract
go test -tags=cannon64 -run '(TestEVM.*64|TestHelloEVM|TestClaimEVM)' ./mipsevm/tests

diff-%-cannon: cannon elf
diff-%-cannon: cannon elf-go-122
# Load an elf file to create a prestate, and check that both cannon versions generate the same prestate
@VM=$*; \
echo "Running diff for VM type $${VM}"; \
Expand All @@ -78,8 +84,8 @@ diff-%-cannon: cannon elf
echo "Loading 32-bit program"; \
ELF_SUFFIX="elf"; \
fi; \
$$OTHER_CANNON load-elf --type $$VM --path ./testdata/example/bin/hello.$${ELF_SUFFIX} --out ./bin/prestate-other.bin.gz --meta ""; \
./bin/cannon load-elf --type $$VM --path ./testdata/example/bin/hello.$${ELF_SUFFIX} --out ./bin/prestate.bin.gz --meta "";
$$OTHER_CANNON load-elf --type $$VM --path ./testdata/go-1-22/bin/hello.$${ELF_SUFFIX} --out ./bin/prestate-other.bin.gz --meta ""; \
./bin/cannon load-elf --type $$VM --path ./testdata/go-1-22/bin/hello.$${ELF_SUFFIX} --out ./bin/prestate.bin.gz --meta "";
@cmp ./bin/prestate-other.bin.gz ./bin/prestate.bin.gz;
@if [ $$? -eq 0 ]; then \
echo "Generated identical prestates"; \
Expand Down Expand Up @@ -134,6 +140,9 @@ fuzz:
cannon-embeds \
cannon \
clean \
elf \
elf-go-122 \
elf-go-123 \
test \
lint \
fuzz \
Expand Down
4 changes: 2 additions & 2 deletions cannon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ The smart-contracts are integrated into the Optimism monorepo contracts:

`mipsevm` is Go tooling to test the onchain MIPS implementation, and generate proof data.

## `example`
## `testdata`

Example programs that can be run and proven with Cannon.
Optional dependency, but required for `mipsevm` Go tests.
See [`testdata/example/Makefile`](./testdata/example/Makefile) for building the example MIPS binaries.
See [`testdata/Makefile`](testdata/Makefile) for building these MIPS binaries.

## License

Expand Down
1 change: 1 addition & 0 deletions cannon/mipsevm/arch/arch32.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const (
SysTgkill = 4266
SysGetRLimit = 4076
SysLseek = 4019
SysEventFd2 = 4325
// Profiling-related syscalls
SysSetITimer = 4104
SysTimerCreate = 4257
Expand Down
1 change: 1 addition & 0 deletions cannon/mipsevm/arch/arch64.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const (
SysTgkill = 5225
SysGetRLimit = 5095
SysLseek = 5008
SysEventFd2 = 5284
// Profiling-related syscalls
SysSetITimer = 5036
SysTimerCreate = 5216
Expand Down
1 change: 1 addition & 0 deletions cannon/mipsevm/iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ type Metadata interface {
// Toggles here are temporary and should be removed once the newer state version is deployed widely. The older
// version can then be supported via multicannon pulling in a specific build and support for it dropped in latest code.
type FeatureToggles struct {
SupportNoopSysEventFd2 bool
}

type FPVM interface {
Expand Down
12 changes: 10 additions & 2 deletions cannon/mipsevm/multithreaded/instrumented_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func TestInstrumentedState_Claim(t *testing.T) {

func TestInstrumentedState_UtilsCheck(t *testing.T) {
// Sanity check that test running utilities will return a non-zero exit code on failure
testutil.Cannon64OnlyTest(t, "32-bit Cannon is deprecated")
t.Parallel()
cases := []struct {
name string
Expand Down Expand Up @@ -75,6 +76,7 @@ func TestInstrumentedState_UtilsCheck(t *testing.T) {
}

func TestInstrumentedState_MultithreadedProgram(t *testing.T) {
testutil.Cannon64OnlyTest(t, "32-bit Cannon is deprecated")
if os.Getenv("SKIP_SLOW_TESTS") == "true" {
t.Skip("Skipping slow test because SKIP_SLOW_TESTS is enabled")
}
Expand Down Expand Up @@ -208,6 +210,7 @@ func TestInstrumentedState_MultithreadedProgram(t *testing.T) {
}
}
func TestInstrumentedState_Alloc(t *testing.T) {
testutil.Cannon64OnlyTest(t, "32-bit Cannon is deprecated")
if os.Getenv("SKIP_SLOW_TESTS") == "true" {
t.Skip("Skipping slow test because SKIP_SLOW_TESTS is enabled")
}
Expand Down Expand Up @@ -259,9 +262,14 @@ func TestInstrumentedState_Alloc(t *testing.T) {
// dependency loop, so we just cover the everything enabled case as that should be the upcoming version.
func allFeaturesEnabled() mipsevm.FeatureToggles {
toggles := mipsevm.FeatureToggles{}
tRef := reflect.ValueOf(toggles)
tRef := reflect.ValueOf(&toggles).Elem() // Get a pointer and then dereference

for i := 0; i < tRef.NumField(); i++ {
tRef.Field(i).Set(reflect.ValueOf(true))
field := tRef.Field(i)
if field.Kind() == reflect.Bool && field.CanSet() {
field.SetBool(true)
}
}

return toggles
}
12 changes: 10 additions & 2 deletions cannon/mipsevm/multithreaded/mips.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,20 +189,28 @@ func (m *InstrumentedState) handleSyscall() error {
case arch.SysTimerDelete:
case arch.SysGetRLimit:
case arch.SysLseek:
case arch.SysEventFd2:
if !m.features.SupportNoopSysEventFd2 {
m.handleUnrecognizedSyscall(syscallNum)
}
default:
// These syscalls have the same values on 64-bit. So we use if-stmts here to avoid "duplicate case" compiler error for the cannon64 build
if arch.IsMips32 && (syscallNum == arch.SysFstat64 || syscallNum == arch.SysStat64 || syscallNum == arch.SysLlseek) {
// noop
} else {
m.Traceback()
panic(fmt.Sprintf("unrecognized syscall: %d", syscallNum))
m.handleUnrecognizedSyscall(syscallNum)
}
}

exec.HandleSyscallUpdates(&thread.Cpu, &thread.Registers, v0, v1)
return nil
}

func (m *InstrumentedState) handleUnrecognizedSyscall(syscallNum Word) {
m.Traceback()
panic(fmt.Sprintf("unrecognized syscall: %d", syscallNum))
}

func (m *InstrumentedState) syscallYield(thread *ThreadState) {
v0 := Word(0)
v1 := Word(0)
Expand Down
4 changes: 2 additions & 2 deletions cannon/mipsevm/multithreaded/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestState_EncodeWitness(t *testing.T) {
}

func TestState_JSONCodec(t *testing.T) {
elfProgram, err := elf.Open("../../testdata/example/bin/hello.elf")
elfProgram, err := elf.Open("../../testdata/go-1-23/bin/hello.elf")
require.NoError(t, err, "open ELF file")
state, err := program.LoadELF(elfProgram, CreateInitialState)
require.NoError(t, err, "load ELF into state")
Expand Down Expand Up @@ -138,7 +138,7 @@ func TestState_JSONCodec(t *testing.T) {
}

func TestState_Binary(t *testing.T) {
elfProgram, err := elf.Open("../../testdata/example/bin/hello.elf")
elfProgram, err := elf.Open("../../testdata/go-1-23/bin/hello.elf")
require.NoError(t, err, "open ELF file")
state, err := program.LoadELF(elfProgram, CreateInitialState)
require.NoError(t, err, "load ELF into state")
Expand Down
8 changes: 0 additions & 8 deletions cannon/mipsevm/singlethreaded/instrumented_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,3 @@ func vmFactory(state *State, po mipsevm.PreimageOracle, stdOut, stdErr io.Writer
func TestInstrumentedState_OpenMips(t *testing.T) {
testutil.RunVMTests_OpenMips(t, CreateEmptyState, vmFactory)
}

func TestInstrumentedState_Hello(t *testing.T) {
testutil.RunVMTest_Hello(t, CreateInitialState, vmFactory, true)
}

func TestInstrumentedState_Claim(t *testing.T) {
testutil.RunVMTest_Claim(t, CreateInitialState, vmFactory, true)
}
4 changes: 2 additions & 2 deletions cannon/mipsevm/singlethreaded/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestStateHash(t *testing.T) {
}

func TestStateJSONCodec(t *testing.T) {
elfProgram, err := elf.Open("../../testdata/example/bin/hello.elf")
elfProgram, err := elf.Open("../../testdata/go-1-23/bin/hello.elf")
require.NoError(t, err, "open ELF file")
state, err := program.LoadELF(elfProgram, CreateInitialState)
require.NoError(t, err, "load ELF into state")
Expand All @@ -88,7 +88,7 @@ func TestStateJSONCodec(t *testing.T) {
}

func TestStateBinaryCodec(t *testing.T) {
elfProgram, err := elf.Open("../../testdata/example/bin/hello.elf")
elfProgram, err := elf.Open("../../testdata/go-1-23/bin/hello.elf")
require.NoError(t, err, "open ELF file")
state, err := program.LoadELF(elfProgram, CreateInitialState)
require.NoError(t, err, "load ELF into state")
Expand Down
5 changes: 4 additions & 1 deletion cannon/mipsevm/tests/evm_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,7 @@ func TestEVM_Fault(t *testing.T) {
}

func TestEVM_HelloProgram(t *testing.T) {
testutil.Cannon64OnlyTest(t, "32-bit Cannon is deprecated")
if os.Getenv("SKIP_SLOW_TESTS") == "true" {
t.Skip("Skipping slow test because SKIP_SLOW_TESTS is enabled")
}
Expand All @@ -1028,7 +1029,7 @@ func TestEVM_HelloProgram(t *testing.T) {
state := goVm.GetState()

start := time.Now()
for i := 0; i < 430_000; i++ {
for i := 0; i < 450_000; i++ {
step := goVm.GetState().GetStep()
if goVm.GetState().GetExited() {
break
Expand Down Expand Up @@ -1056,6 +1057,7 @@ func TestEVM_HelloProgram(t *testing.T) {
}

func TestEVM_ClaimProgram(t *testing.T) {
testutil.Cannon64OnlyTest(t, "32-bit Cannon is deprecated")
if os.Getenv("SKIP_SLOW_TESTS") == "true" {
t.Skip("Skipping slow test because SKIP_SLOW_TESTS is enabled")
}
Expand Down Expand Up @@ -1102,6 +1104,7 @@ func TestEVM_ClaimProgram(t *testing.T) {
}

func TestEVM_EntryProgram(t *testing.T) {
testutil.Cannon64OnlyTest(t, "32-bit Cannon is deprecated")
if os.Getenv("SKIP_SLOW_TESTS") == "true" {
t.Skip("Skipping slow test because SKIP_SLOW_TESTS is enabled")
}
Expand Down
Loading