Skip to content

Commit c0dfee3

Browse files
authored
cannon: Drop support for version 6 of the Cannon VM (#15616)
* Pull Cannon version 6 from tagged docker image * Drop v6 from supported version helper * Update reproducible-prestate task - drop v6, move to v7 * Rework VMType handling * Update e2e tests - only run 'next' cannon if it is in development * Add some comments to Dockerfile.repro * Update dockerdiff file to check latest vm * Update cannon-prestate tasks * Update op-deployer/opcm MipsVersion to 7 * Drop requirement to test dclz/o backwards compatibility * Update alpha cannon tag to match convention * Continue building the next Cannon prestate * Update Dockerfile.diff go version to 1.23 * Drop go 1.22 test programs * Move MIPS_VERSION constant so it can be used in scripts and tests * Lint contracts
1 parent 225370c commit c0dfee3

35 files changed

+129
-188
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ cannon-prestates: cannon-prestate-mt64 cannon-prestate-interop
143143
.PHONY: cannon-prestates
144144

145145
cannon-prestate-mt64: op-program cannon ## Generates prestate using cannon and op-program in the latest 64-bit multithreaded cannon format
146-
./cannon/bin/cannon load-elf --type multithreaded64-3 --path op-program/bin/op-program-client64.elf --out op-program/bin/prestate-mt64.bin.gz --meta op-program/bin/meta-mt64.json
146+
./cannon/bin/cannon load-elf --type multithreaded64-4 --path op-program/bin/op-program-client64.elf --out op-program/bin/prestate-mt64.bin.gz --meta op-program/bin/meta-mt64.json
147147
./cannon/bin/cannon run --proof-at '=0' --stop-at '=1' --input op-program/bin/prestate-mt64.bin.gz --meta op-program/bin/meta-mt64.json --proof-fmt 'op-program/bin/%d-mt64.json' --output ""
148148
mv op-program/bin/0-mt64.json op-program/bin/prestate-proof-mt64.json
149149
.PHONY: cannon-prestate-mt64
150150

151151
cannon-prestate-interop: op-program cannon ## Generates interop prestate using cannon and op-program in the latest 64-bit multithreaded cannon format
152-
./cannon/bin/cannon load-elf --type multithreaded64-3 --path op-program/bin/op-program-client-interop.elf --out op-program/bin/prestate-interop.bin.gz --meta op-program/bin/meta-interop.json
152+
./cannon/bin/cannon load-elf --type multithreaded64-4 --path op-program/bin/op-program-client-interop.elf --out op-program/bin/prestate-interop.bin.gz --meta op-program/bin/meta-interop.json
153153
./cannon/bin/cannon run --proof-at '=0' --stop-at '=1' --input op-program/bin/prestate-interop.bin.gz --meta op-program/bin/meta-interop.json --proof-fmt 'op-program/bin/%d-interop.json' --output ""
154154
mv op-program/bin/0-interop.json op-program/bin/prestate-proof-interop.json
155155
.PHONY: cannon-prestate-interop

cannon/Dockerfile.diff

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22.7-alpine3.20 AS builder
1+
FROM golang:1.23.8-alpine3.21 AS builder
22

33
RUN apk add --no-cache make bash
44

@@ -23,15 +23,14 @@ ARG GIT_DATE
2323

2424
ARG TARGETOS TARGETARCH
2525

26-
# TODO(#15591): Update to test cannon-multithreaded64-4 when new VM stabilizes
27-
FROM --platform=$BUILDPLATFORM us-docker.pkg.dev/oplabs-tools-artifacts/images/cannon:v1.4.0 AS cannon-multithreaded64-3
26+
FROM --platform=$BUILDPLATFORM us-docker.pkg.dev/oplabs-tools-artifacts/images/cannon:v1.5.0-alpha.1 AS cannon-multithreaded64-4
2827

2928
FROM --platform=$BUILDPLATFORM builder AS cannon-verify
30-
COPY --from=cannon-multithreaded64-3 /usr/local/bin/cannon /usr/local/bin/cannon-multithreaded64-3
29+
COPY --from=cannon-multithreaded64-4 /usr/local/bin/cannon /usr/local/bin/cannon-multithreaded64-4
3130

32-
# Check cannon-multithreaded64-3
33-
# verify the latest multithreaded VM behavior against multithreaded64-3
34-
RUN cd cannon && make diff-multithreaded64-3-cannon -e OTHER_CANNON=/usr/local/bin/cannon-multithreaded64-3
31+
# Check cannon-multithreaded64-4
32+
# verify the latest multithreaded VM behavior against multithreaded64-4
33+
RUN cd cannon && make diff-multithreaded64-4-cannon -e OTHER_CANNON=/usr/local/bin/cannon-multithreaded64-4
3534
RUN --mount=type=cache,target=/root/.cache/go-build cd cannon && \
36-
make diff-multithreaded64-3-cannon -e OTHER_CANNON=/usr/local/bin/cannon-multithreaded64-3 \
35+
make diff-multithreaded64-4-cannon -e OTHER_CANNON=/usr/local/bin/cannon-multithreaded64-4 \
3736
GOOS=$TARGETOS GOARCH=$TARGETARCH GITCOMMIT=$GIT_COMMIT GITDATE=$GIT_DATE

cannon/Makefile

+4-9
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ cannon64-impl:
3030
# Each embed is suffixed with the latest `StateVersion` number corresponding to the target VM and architecture.
3131
cannon-embeds: cannon64-impl
3232
# 64-bit multithreaded vm
33-
@cp bin/cannon64-impl ./multicannon/embeds/cannon-6
3433
@cp bin/cannon64-impl ./multicannon/embeds/cannon-7
3534

3635
cannon: cannon-embeds
@@ -39,10 +38,7 @@ cannon: cannon-embeds
3938
clean:
4039
rm -rf bin multicannon/embeds/cannon*
4140

42-
elf: elf-go-122 elf-go-123
43-
44-
elf-go-122:
45-
make -C ./testdata/go-1-22 elf
41+
elf: elf-go-123
4642

4743
elf-go-123:
4844
make -C ./testdata/go-1-23 elf
@@ -63,12 +59,12 @@ test: elf contract
6359
go test -v ./...
6460

6561

66-
diff-%-cannon: cannon elf-go-122
62+
diff-%-cannon: cannon elf
6763
# Load an elf file to create a prestate, and check that both cannon versions generate the same prestate
6864
@VM=$*; \
6965
echo "Running diff for VM type $${VM}"; \
70-
$$OTHER_CANNON load-elf --type $$VM --path ./testdata/go-1-22/bin/hello.64.elf --out ./bin/prestate-other.bin.gz --meta ""; \
71-
./bin/cannon load-elf --type $$VM --path ./testdata/go-1-22/bin/hello.64.elf --out ./bin/prestate.bin.gz --meta "";
66+
$$OTHER_CANNON load-elf --type $$VM --path ./testdata/go-1-23/bin/hello.64.elf --out ./bin/prestate-other.bin.gz --meta ""; \
67+
./bin/cannon load-elf --type $$VM --path ./testdata/go-1-23/bin/hello.64.elf --out ./bin/prestate.bin.gz --meta "";
7268
@cmp ./bin/prestate-other.bin.gz ./bin/prestate.bin.gz;
7369
@if [ $$? -eq 0 ]; then \
7470
echo "Generated identical prestates"; \
@@ -113,7 +109,6 @@ fuzz:
113109
cannon \
114110
clean \
115111
elf \
116-
elf-go-122 \
117112
elf-go-123 \
118113
test \
119114
lint \

cannon/mipsevm/tests/evm_common64_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,6 @@ func TestEVM_SingleStep_DCloDClz64(t *testing.T) {
540540
features := versions.FeaturesForVersion(v.Version)
541541
return features.SupportDclzDclo
542542
}), "dclz/dclo feature not tested")
543-
require.True(t, slices.ContainsFunc(vmVersions, func(v VersionedVMTestCase) bool {
544-
features := versions.FeaturesForVersion(v.Version)
545-
return !features.SupportDclzDclo
546-
}), "dclz/dclo backwards compatibility feature not tested")
547543

548544
for _, v := range vmVersions {
549545
for i, tt := range cases {

cannon/mipsevm/versions/version.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,11 @@ func GetStateVersionStrings() []string {
9898

9999
// IsSupportedMultiThreaded64 returns true if the state version is a 64-bit multithreaded VM that is currently supported
100100
func IsSupportedMultiThreaded64(ver StateVersion) bool {
101-
return ver == VersionMultiThreaded64_v3 || ver == VersionMultiThreaded64_v4
101+
return ver == VersionMultiThreaded64_v4
102+
}
103+
104+
// IsSupported returns true if the state version is currently supported
105+
func IsSupported(ver int) bool {
106+
stateVer := StateVersion(ver)
107+
return IsSupportedMultiThreaded64(stateVer)
102108
}

cannon/mipsevm/versions/version_test.go

+36
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,39 @@ func TestParseStateVersion(t *testing.T) {
1515
})
1616
}
1717
}
18+
19+
func TestIsSupported(t *testing.T) {
20+
type TestCase struct {
21+
name string
22+
input int
23+
expected bool
24+
}
25+
cases := []TestCase{}
26+
27+
maxSupportedValue := 0
28+
for _, ver := range StateVersionTypes {
29+
versionValue := int(ver)
30+
if versionValue > maxSupportedValue {
31+
maxSupportedValue = versionValue
32+
}
33+
if IsSupportedMultiThreaded64(ver) {
34+
cases = append(cases, TestCase{name: "Supported version " + ver.String(), input: versionValue, expected: true})
35+
} else {
36+
cases = append(cases, TestCase{name: "Unsupported version " + ver.String(), input: versionValue, expected: false})
37+
}
38+
}
39+
40+
cases = append(cases,
41+
TestCase{name: "Min unsupported version", input: maxSupportedValue + 1, expected: false},
42+
TestCase{name: "Min unsupported version + 1", input: maxSupportedValue + 2, expected: false},
43+
TestCase{name: "Unsupported version overflows uint8", input: 256, expected: false},
44+
TestCase{name: "Unsupported version overflows uint8", input: 257, expected: false},
45+
)
46+
47+
for _, tc := range cases {
48+
t.Run(tc.name, func(t *testing.T) {
49+
actual := IsSupported(tc.input)
50+
require.Equal(t, tc.expected, actual)
51+
})
52+
}
53+
}

cannon/testdata/Makefile

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
all: elf
22

3-
go1-22:
4-
make -C ./go-1-22 elf
5-
.PHONY: go1-22
6-
73
go1-23:
84
make -C ./go-1-23 elf
95
.PHONY: go1-23
106

117
.PHONY: elf
12-
elf: go1-22 go1-23
13-
8+
elf: go1-23

cannon/testdata/go-1-22/Makefile

-30
This file was deleted.

cannon/testdata/go-1-22/hello/go.mod

-5
This file was deleted.

cannon/testdata/go-1-22/hello/main.go

-7
This file was deleted.

op-deployer/pkg/deployer/bootstrap/implementations.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import (
88
"math/big"
99
"strings"
1010

11-
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/standard"
12-
11+
mipsVersion "github.com/ethereum-optimism/optimism/cannon/mipsevm/versions"
1312
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/artifacts"
1413
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/broadcaster"
1514
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/opcm"
15+
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/standard"
1616
"github.com/ethereum-optimism/optimism/op-deployer/pkg/env"
1717
"github.com/ethereum-optimism/optimism/op-service/cliutil"
1818
opcrypto "github.com/ethereum-optimism/optimism/op-service/crypto"
@@ -75,8 +75,8 @@ func (c *ImplementationsConfig) Check() error {
7575
} else {
7676
c.L1ContractsRelease = "dev"
7777
}
78-
if c.MIPSVersion != 1 && c.MIPSVersion != 6 {
79-
return errors.New("MIPS version must be specified as either 1 or 6")
78+
if !mipsVersion.IsSupported(c.MIPSVersion) {
79+
return errors.New("MIPS version is not supported")
8080
}
8181
if c.WithdrawalDelaySeconds == 0 {
8282
return errors.New("withdrawal delay in seconds must be specified")

op-deployer/pkg/deployer/bootstrap/implementations_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func testImplementations(t *testing.T, forkRPCURL string, cacheDir string) {
7676
ChallengePeriodSeconds: standard.ChallengePeriodSeconds,
7777
ProofMaturityDelaySeconds: standard.ProofMaturityDelaySeconds,
7878
DisputeGameFinalityDelaySeconds: standard.DisputeGameFinalityDelaySeconds,
79-
MIPSVersion: 6,
79+
MIPSVersion: int(standard.MIPSVersion),
8080
SuperchainConfigProxy: superchain.SuperchainConfigAddr,
8181
ProtocolVersionsProxy: superchain.ProtocolVersionsAddr,
8282
UpgradeController: proxyAdminOwner,

op-deployer/pkg/deployer/integration_test/apply_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ func TestProofParamOverrides(t *testing.T) {
352352
"preimageOracleChallengePeriod": standard.ChallengePeriodSeconds + 1,
353353
"proofMaturityDelaySeconds": standard.ProofMaturityDelaySeconds + 1,
354354
"disputeGameFinalityDelaySeconds": standard.DisputeGameFinalityDelaySeconds + 1,
355-
"mipsVersion": 6, // Contract enforces a valid value be used
355+
"mipsVersion": standard.MIPSVersion, // Contract enforces a valid value be used
356356
"respectedGameType": standard.DisputeGameType, // This must be set to the permissioned game
357357
"faultGameAbsolutePrestate": common.Hash{'A', 'B', 'S', 'O', 'L', 'U', 'T', 'E'},
358358
"faultGameMaxDepth": standard.DisputeMaxGameDepth + 1,

op-deployer/pkg/deployer/opcm/implementations2_test.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66

77
"github.com/ethereum-optimism/optimism/op-chain-ops/script"
88
"github.com/ethereum-optimism/optimism/op-chain-ops/script/addresses"
9+
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/standard"
10+
911
"github.com/ethereum/go-ethereum/common"
1012
"github.com/stretchr/testify/require"
1113
)
@@ -55,13 +57,14 @@ func TestNewDeployImplementationsScript(t *testing.T) {
5557
require.NoError(t, err)
5658

5759
// Now we run the deploy script
60+
mipsVersion := int64(standard.MIPSVersion)
5861
output, err := deployImplementations.Run(DeployImplementations2Input{
5962
WithdrawalDelaySeconds: big.NewInt(1),
6063
MinProposalSizeBytes: big.NewInt(2),
6164
ChallengePeriodSeconds: big.NewInt(3),
6265
ProofMaturityDelaySeconds: big.NewInt(4),
6366
DisputeGameFinalityDelaySeconds: big.NewInt(5),
64-
MipsVersion: big.NewInt(6),
67+
MipsVersion: big.NewInt(mipsVersion),
6568
// Release version to set OPCM implementations for, of the format `op-contracts/vX.Y.Z`.
6669
L1ContractsRelease: "dev-release",
6770
SuperchainConfigProxy: proxyAddress,
@@ -89,7 +92,7 @@ func TestNewDeployImplementationsScript(t *testing.T) {
8992
ChallengePeriodSeconds: big.NewInt(3),
9093
ProofMaturityDelaySeconds: big.NewInt(4),
9194
DisputeGameFinalityDelaySeconds: big.NewInt(5),
92-
MipsVersion: big.NewInt(6),
95+
MipsVersion: big.NewInt(mipsVersion),
9396
// Release version to set OPCM implementations for, of the format `op-contracts/vX.Y.Z`.
9497
L1ContractsRelease: "dev-release",
9598
SuperchainConfigProxy: proxyAddress,

op-deployer/pkg/deployer/opcm/mips2_test.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66

77
"github.com/ethereum/go-ethereum/common"
88
"github.com/stretchr/testify/require"
9+
10+
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/standard"
911
)
1012

1113
func TestNewDeployMIPSScript(t *testing.T) {
@@ -20,9 +22,10 @@ func TestNewDeployMIPSScript(t *testing.T) {
2022
require.NoError(t, err)
2123

2224
// Then we deploy
25+
mipsVersion := int64(standard.MIPSVersion)
2326
output, err := deploySuperchain.Run(DeployMIPS2Input{
2427
PreimageOracle: common.Address{'P'},
25-
MipsVersion: big.NewInt(6),
28+
MipsVersion: big.NewInt(mipsVersion),
2629
})
2730

2831
// And do some simple asserts
@@ -36,7 +39,7 @@ func TestNewDeployMIPSScript(t *testing.T) {
3639
host2 := createTestHost(t)
3740
deprecatedOutput, err := DeployMIPS(host2, DeployMIPSInput{
3841
PreimageOracle: common.Address{'P'},
39-
MipsVersion: 6,
42+
MipsVersion: uint64(mipsVersion),
4043
})
4144

4245
// Make sure it succeeded

op-deployer/pkg/deployer/opcm/mips_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"testing"
55

66
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/broadcaster"
7+
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/standard"
78
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/testutil"
89
"github.com/ethereum-optimism/optimism/op-deployer/pkg/env"
910
"github.com/ethereum-optimism/optimism/op-service/testlog"
@@ -26,7 +27,7 @@ func TestDeployMIPS(t *testing.T) {
2627
require.NoError(t, err)
2728

2829
input := DeployMIPSInput{
29-
MipsVersion: 6,
30+
MipsVersion: uint64(standard.MIPSVersion),
3031
PreimageOracle: common.Address{0xab},
3132
}
3233

op-deployer/pkg/deployer/pipeline/dispute_games.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func deployDisputeGame(
8484
return fmt.Errorf("failed to deploy Alphabet VM: %w", err)
8585
}
8686
vmAddr = out.AlphabetVM
87-
case state.VMTypeCannon1, state.VMTypeCannon2, state.VMTypeCannon6, state.VMTypeCannon7:
87+
case state.VMTypeCannon, state.VMTypeCannonNext:
8888
out, err := opcm.DeployMIPS(env.L1ScriptHost, opcm.DeployMIPSInput{
8989
MipsVersion: game.VMType.MipsVersion(),
9090
PreimageOracle: oracleAddr,

op-deployer/pkg/deployer/standard/standard.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const (
2525
ChallengePeriodSeconds uint64 = 86400
2626
ProofMaturityDelaySeconds uint64 = 604800
2727
DisputeGameFinalityDelaySeconds uint64 = 302400
28-
MIPSVersion uint64 = 6
28+
MIPSVersion uint64 = 7
2929
DisputeGameType uint32 = 1 // PERMISSIONED game type
3030
DisputeMaxGameDepth uint64 = 73
3131
DisputeSplitDepth uint64 = 30

op-deployer/pkg/deployer/state/chain_intent.go

+6-10
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,16 @@ import (
1313
type VMType string
1414

1515
const (
16-
VMTypeAlphabet = "ALPHABET"
17-
VMTypeCannon1 = "CANNON1" // Legacy: corresponds to 32-bit MIPS VM
18-
VMTypeCannon2 = "CANNON2" // Legacy: corresponds to 64-bit MIPS VM StateVersion 6
19-
VMTypeCannon6 = "CANNON6" // Corresponds to VM State Version 6: https://github.com/ethereum-optimism/optimism/blob/4c05241bc534ae5837007c32995fc62f3dd059b6/cannon/mipsevm/versions/version.go#L25-L25
20-
VMTypeCannon7 = "CANNON7" // Corresponds to VM State Version 7: https://github.com/ethereum-optimism/optimism/blob/4c05241bc534ae5837007c32995fc62f3dd059b6/cannon/mipsevm/versions/version.go#L27-L27
16+
VMTypeAlphabet = "ALPHABET"
17+
VMTypeCannon = "CANNON" // Corresponds to the currently released Cannon StateVersion. See: https://github.com/ethereum-optimism/optimism/blob/4c05241bc534ae5837007c32995fc62f3dd059b6/cannon/mipsevm/versions/version.go
18+
VMTypeCannonNext = "CANNON-NEXT" // Corresponds to the next in-development Cannon StateVersion. See: https://github.com/ethereum-optimism/optimism/blob/4c05241bc534ae5837007c32995fc62f3dd059b6/cannon/mipsevm/versions/version.go
2119
)
2220

2321
func (v VMType) MipsVersion() uint64 {
2422
switch v {
25-
case VMTypeCannon1:
26-
return 1
27-
case VMTypeCannon2, VMTypeCannon6:
28-
return 6
29-
case VMTypeCannon7:
23+
case VMTypeCannon:
24+
return 7
25+
case VMTypeCannonNext:
3026
return 7
3127
default:
3228
// Not a mips VM - return empty value

0 commit comments

Comments
 (0)