diff --git a/Makefile b/Makefile index 6b00fc252b70d..d8119a1056686 100644 --- a/Makefile +++ b/Makefile @@ -143,13 +143,13 @@ cannon-prestates: cannon-prestate-mt64 cannon-prestate-interop .PHONY: cannon-prestates cannon-prestate-mt64: op-program cannon ## Generates prestate using cannon and op-program in the latest 64-bit multithreaded cannon format - ./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 + ./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 ./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 "" mv op-program/bin/0-mt64.json op-program/bin/prestate-proof-mt64.json .PHONY: cannon-prestate-mt64 cannon-prestate-interop: op-program cannon ## Generates interop prestate using cannon and op-program in the latest 64-bit multithreaded cannon format - ./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 + ./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 ./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 "" mv op-program/bin/0-interop.json op-program/bin/prestate-proof-interop.json .PHONY: cannon-prestate-interop diff --git a/cannon/Dockerfile.diff b/cannon/Dockerfile.diff index 40c2e404e0ade..3f1a47eb8ade4 100644 --- a/cannon/Dockerfile.diff +++ b/cannon/Dockerfile.diff @@ -1,4 +1,4 @@ -FROM golang:1.22.7-alpine3.20 AS builder +FROM golang:1.23.8-alpine3.21 AS builder RUN apk add --no-cache make bash @@ -23,15 +23,14 @@ ARG GIT_DATE ARG TARGETOS TARGETARCH -# TODO(#15591): Update to test cannon-multithreaded64-4 when new VM stabilizes -FROM --platform=$BUILDPLATFORM us-docker.pkg.dev/oplabs-tools-artifacts/images/cannon:v1.4.0 AS cannon-multithreaded64-3 +FROM --platform=$BUILDPLATFORM us-docker.pkg.dev/oplabs-tools-artifacts/images/cannon:v1.5.0-alpha.1 AS cannon-multithreaded64-4 FROM --platform=$BUILDPLATFORM builder AS cannon-verify -COPY --from=cannon-multithreaded64-3 /usr/local/bin/cannon /usr/local/bin/cannon-multithreaded64-3 +COPY --from=cannon-multithreaded64-4 /usr/local/bin/cannon /usr/local/bin/cannon-multithreaded64-4 -# Check cannon-multithreaded64-3 -# verify the latest multithreaded VM behavior against multithreaded64-3 -RUN cd cannon && make diff-multithreaded64-3-cannon -e OTHER_CANNON=/usr/local/bin/cannon-multithreaded64-3 +# Check cannon-multithreaded64-4 +# verify the latest multithreaded VM behavior against multithreaded64-4 +RUN cd cannon && make diff-multithreaded64-4-cannon -e OTHER_CANNON=/usr/local/bin/cannon-multithreaded64-4 RUN --mount=type=cache,target=/root/.cache/go-build cd cannon && \ - make diff-multithreaded64-3-cannon -e OTHER_CANNON=/usr/local/bin/cannon-multithreaded64-3 \ + make diff-multithreaded64-4-cannon -e OTHER_CANNON=/usr/local/bin/cannon-multithreaded64-4 \ GOOS=$TARGETOS GOARCH=$TARGETARCH GITCOMMIT=$GIT_COMMIT GITDATE=$GIT_DATE diff --git a/cannon/Makefile b/cannon/Makefile index 994937bc4a230..f6f2559101130 100644 --- a/cannon/Makefile +++ b/cannon/Makefile @@ -30,7 +30,6 @@ cannon64-impl: # Each embed is suffixed with the latest `StateVersion` number corresponding to the target VM and architecture. cannon-embeds: cannon64-impl # 64-bit multithreaded vm - @cp bin/cannon64-impl ./multicannon/embeds/cannon-6 @cp bin/cannon64-impl ./multicannon/embeds/cannon-7 cannon: cannon-embeds @@ -39,10 +38,7 @@ cannon: cannon-embeds clean: rm -rf bin multicannon/embeds/cannon* -elf: elf-go-122 elf-go-123 - -elf-go-122: - make -C ./testdata/go-1-22 elf +elf: elf-go-123 elf-go-123: make -C ./testdata/go-1-23 elf @@ -63,12 +59,12 @@ test: elf contract go test -v ./... -diff-%-cannon: cannon elf-go-122 +diff-%-cannon: cannon elf # 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}"; \ - $$OTHER_CANNON load-elf --type $$VM --path ./testdata/go-1-22/bin/hello.64.elf --out ./bin/prestate-other.bin.gz --meta ""; \ - ./bin/cannon load-elf --type $$VM --path ./testdata/go-1-22/bin/hello.64.elf --out ./bin/prestate.bin.gz --meta ""; + $$OTHER_CANNON load-elf --type $$VM --path ./testdata/go-1-23/bin/hello.64.elf --out ./bin/prestate-other.bin.gz --meta ""; \ + ./bin/cannon load-elf --type $$VM --path ./testdata/go-1-23/bin/hello.64.elf --out ./bin/prestate.bin.gz --meta ""; @cmp ./bin/prestate-other.bin.gz ./bin/prestate.bin.gz; @if [ $$? -eq 0 ]; then \ echo "Generated identical prestates"; \ @@ -113,7 +109,6 @@ fuzz: cannon \ clean \ elf \ - elf-go-122 \ elf-go-123 \ test \ lint \ diff --git a/cannon/mipsevm/tests/evm_common64_test.go b/cannon/mipsevm/tests/evm_common64_test.go index fe48ac95501a1..ce6e64435596c 100644 --- a/cannon/mipsevm/tests/evm_common64_test.go +++ b/cannon/mipsevm/tests/evm_common64_test.go @@ -540,10 +540,6 @@ func TestEVM_SingleStep_DCloDClz64(t *testing.T) { features := versions.FeaturesForVersion(v.Version) return features.SupportDclzDclo }), "dclz/dclo feature not tested") - require.True(t, slices.ContainsFunc(vmVersions, func(v VersionedVMTestCase) bool { - features := versions.FeaturesForVersion(v.Version) - return !features.SupportDclzDclo - }), "dclz/dclo backwards compatibility feature not tested") for _, v := range vmVersions { for i, tt := range cases { diff --git a/cannon/mipsevm/versions/version.go b/cannon/mipsevm/versions/version.go index 88f0ec5ce892e..5ef48a779ab16 100644 --- a/cannon/mipsevm/versions/version.go +++ b/cannon/mipsevm/versions/version.go @@ -98,5 +98,11 @@ func GetStateVersionStrings() []string { // IsSupportedMultiThreaded64 returns true if the state version is a 64-bit multithreaded VM that is currently supported func IsSupportedMultiThreaded64(ver StateVersion) bool { - return ver == VersionMultiThreaded64_v3 || ver == VersionMultiThreaded64_v4 + return ver == VersionMultiThreaded64_v4 +} + +// IsSupported returns true if the state version is currently supported +func IsSupported(ver int) bool { + stateVer := StateVersion(ver) + return IsSupportedMultiThreaded64(stateVer) } diff --git a/cannon/mipsevm/versions/version_test.go b/cannon/mipsevm/versions/version_test.go index 2bfcf335edd30..b43aa5cfecd15 100644 --- a/cannon/mipsevm/versions/version_test.go +++ b/cannon/mipsevm/versions/version_test.go @@ -15,3 +15,39 @@ func TestParseStateVersion(t *testing.T) { }) } } + +func TestIsSupported(t *testing.T) { + type TestCase struct { + name string + input int + expected bool + } + cases := []TestCase{} + + maxSupportedValue := 0 + for _, ver := range StateVersionTypes { + versionValue := int(ver) + if versionValue > maxSupportedValue { + maxSupportedValue = versionValue + } + if IsSupportedMultiThreaded64(ver) { + cases = append(cases, TestCase{name: "Supported version " + ver.String(), input: versionValue, expected: true}) + } else { + cases = append(cases, TestCase{name: "Unsupported version " + ver.String(), input: versionValue, expected: false}) + } + } + + cases = append(cases, + TestCase{name: "Min unsupported version", input: maxSupportedValue + 1, expected: false}, + TestCase{name: "Min unsupported version + 1", input: maxSupportedValue + 2, expected: false}, + TestCase{name: "Unsupported version overflows uint8", input: 256, expected: false}, + TestCase{name: "Unsupported version overflows uint8", input: 257, expected: false}, + ) + + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + actual := IsSupported(tc.input) + require.Equal(t, tc.expected, actual) + }) + } +} diff --git a/cannon/testdata/Makefile b/cannon/testdata/Makefile index 90fd1b552dee3..8d33aee06b882 100644 --- a/cannon/testdata/Makefile +++ b/cannon/testdata/Makefile @@ -1,13 +1,8 @@ all: elf -go1-22: - make -C ./go-1-22 elf -.PHONY: go1-22 - go1-23: make -C ./go-1-23 elf .PHONY: go1-23 .PHONY: elf -elf: go1-22 go1-23 - +elf: go1-23 diff --git a/cannon/testdata/go-1-22/Makefile b/cannon/testdata/go-1-22/Makefile deleted file mode 100644 index e33cb5567d12e..0000000000000 --- a/cannon/testdata/go-1-22/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -all: elf - -.PHONY: elf32 -elf32: $(patsubst %/go.mod,bin/%.elf,$(wildcard */go.mod)) - -.PHONY: elf64 -elf64: $(patsubst %/go.mod,bin/%.64.elf,$(wildcard */go.mod)) - -.PHONY: elf -elf: elf32 elf64 - -.PHONY: dump -dump: $(patsubst %/go.mod,bin/%.dump,$(wildcard */go.mod)) - -bin: - mkdir bin - -bin/%.64.elf: bin - cd $(@:bin/%.64.elf=%) && GOOS=linux GOARCH=mips64 GOMIPS64=softfloat go build -o ../$@ . - -# take any directory with a go mod, and build an ELF -# verify output with: readelf -h bin/.elf -# result is mips32, big endian, R3000 -bin/%.elf: bin - cd $(@:bin/%.elf=%) && GOOS=linux GOARCH=mips GOMIPS=softfloat go build -o ../$@ . - -# take any ELF and dump it -# TODO: currently have the little-endian toolchain, but should use the big-endian one. The -EB compat flag works though. -bin/%.dump: bin - mipsel-linux-gnu-objdump -D --disassembler-options=no-aliases --wide --source -m mips:3000 -EB $(@:%.dump=%.elf) > $@ diff --git a/cannon/testdata/go-1-22/hello/go.mod b/cannon/testdata/go-1-22/hello/go.mod deleted file mode 100644 index f036b5dc97fce..0000000000000 --- a/cannon/testdata/go-1-22/hello/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module hello - -go 1.22.0 - -toolchain go1.22.7 diff --git a/cannon/testdata/go-1-22/hello/main.go b/cannon/testdata/go-1-22/hello/main.go deleted file mode 100644 index bcf1c75fc3f55..0000000000000 --- a/cannon/testdata/go-1-22/hello/main.go +++ /dev/null @@ -1,7 +0,0 @@ -package main - -import "os" - -func main() { - _, _ = os.Stdout.Write([]byte("hello world!\n")) -} diff --git a/op-deployer/pkg/deployer/bootstrap/implementations.go b/op-deployer/pkg/deployer/bootstrap/implementations.go index 50369ce92782f..d6810625613d2 100644 --- a/op-deployer/pkg/deployer/bootstrap/implementations.go +++ b/op-deployer/pkg/deployer/bootstrap/implementations.go @@ -8,11 +8,11 @@ import ( "math/big" "strings" - "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/standard" - + mipsVersion "github.com/ethereum-optimism/optimism/cannon/mipsevm/versions" "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/artifacts" "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/broadcaster" "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/opcm" + "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/standard" "github.com/ethereum-optimism/optimism/op-deployer/pkg/env" "github.com/ethereum-optimism/optimism/op-service/cliutil" opcrypto "github.com/ethereum-optimism/optimism/op-service/crypto" @@ -75,8 +75,8 @@ func (c *ImplementationsConfig) Check() error { } else { c.L1ContractsRelease = "dev" } - if c.MIPSVersion != 1 && c.MIPSVersion != 6 { - return errors.New("MIPS version must be specified as either 1 or 6") + if !mipsVersion.IsSupported(c.MIPSVersion) { + return errors.New("MIPS version is not supported") } if c.WithdrawalDelaySeconds == 0 { return errors.New("withdrawal delay in seconds must be specified") diff --git a/op-deployer/pkg/deployer/bootstrap/implementations_test.go b/op-deployer/pkg/deployer/bootstrap/implementations_test.go index 22da19af372db..adb77532d98c4 100644 --- a/op-deployer/pkg/deployer/bootstrap/implementations_test.go +++ b/op-deployer/pkg/deployer/bootstrap/implementations_test.go @@ -76,7 +76,7 @@ func testImplementations(t *testing.T, forkRPCURL string, cacheDir string) { ChallengePeriodSeconds: standard.ChallengePeriodSeconds, ProofMaturityDelaySeconds: standard.ProofMaturityDelaySeconds, DisputeGameFinalityDelaySeconds: standard.DisputeGameFinalityDelaySeconds, - MIPSVersion: 6, + MIPSVersion: int(standard.MIPSVersion), SuperchainConfigProxy: superchain.SuperchainConfigAddr, ProtocolVersionsProxy: superchain.ProtocolVersionsAddr, UpgradeController: proxyAdminOwner, diff --git a/op-deployer/pkg/deployer/integration_test/apply_test.go b/op-deployer/pkg/deployer/integration_test/apply_test.go index 66c20e39c3396..0e1eb91d00ce0 100644 --- a/op-deployer/pkg/deployer/integration_test/apply_test.go +++ b/op-deployer/pkg/deployer/integration_test/apply_test.go @@ -352,7 +352,7 @@ func TestProofParamOverrides(t *testing.T) { "preimageOracleChallengePeriod": standard.ChallengePeriodSeconds + 1, "proofMaturityDelaySeconds": standard.ProofMaturityDelaySeconds + 1, "disputeGameFinalityDelaySeconds": standard.DisputeGameFinalityDelaySeconds + 1, - "mipsVersion": 6, // Contract enforces a valid value be used + "mipsVersion": standard.MIPSVersion, // Contract enforces a valid value be used "respectedGameType": standard.DisputeGameType, // This must be set to the permissioned game "faultGameAbsolutePrestate": common.Hash{'A', 'B', 'S', 'O', 'L', 'U', 'T', 'E'}, "faultGameMaxDepth": standard.DisputeMaxGameDepth + 1, diff --git a/op-deployer/pkg/deployer/opcm/implementations2_test.go b/op-deployer/pkg/deployer/opcm/implementations2_test.go index 25bc79435659c..13dc404774d22 100644 --- a/op-deployer/pkg/deployer/opcm/implementations2_test.go +++ b/op-deployer/pkg/deployer/opcm/implementations2_test.go @@ -6,6 +6,8 @@ import ( "github.com/ethereum-optimism/optimism/op-chain-ops/script" "github.com/ethereum-optimism/optimism/op-chain-ops/script/addresses" + "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/standard" + "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" ) @@ -55,13 +57,14 @@ func TestNewDeployImplementationsScript(t *testing.T) { require.NoError(t, err) // Now we run the deploy script + mipsVersion := int64(standard.MIPSVersion) output, err := deployImplementations.Run(DeployImplementations2Input{ WithdrawalDelaySeconds: big.NewInt(1), MinProposalSizeBytes: big.NewInt(2), ChallengePeriodSeconds: big.NewInt(3), ProofMaturityDelaySeconds: big.NewInt(4), DisputeGameFinalityDelaySeconds: big.NewInt(5), - MipsVersion: big.NewInt(6), + MipsVersion: big.NewInt(mipsVersion), // Release version to set OPCM implementations for, of the format `op-contracts/vX.Y.Z`. L1ContractsRelease: "dev-release", SuperchainConfigProxy: proxyAddress, @@ -89,7 +92,7 @@ func TestNewDeployImplementationsScript(t *testing.T) { ChallengePeriodSeconds: big.NewInt(3), ProofMaturityDelaySeconds: big.NewInt(4), DisputeGameFinalityDelaySeconds: big.NewInt(5), - MipsVersion: big.NewInt(6), + MipsVersion: big.NewInt(mipsVersion), // Release version to set OPCM implementations for, of the format `op-contracts/vX.Y.Z`. L1ContractsRelease: "dev-release", SuperchainConfigProxy: proxyAddress, diff --git a/op-deployer/pkg/deployer/opcm/mips2_test.go b/op-deployer/pkg/deployer/opcm/mips2_test.go index 29314ef2a8dae..4bcc2bc1b5856 100644 --- a/op-deployer/pkg/deployer/opcm/mips2_test.go +++ b/op-deployer/pkg/deployer/opcm/mips2_test.go @@ -6,6 +6,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" + + "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/standard" ) func TestNewDeployMIPSScript(t *testing.T) { @@ -20,9 +22,10 @@ func TestNewDeployMIPSScript(t *testing.T) { require.NoError(t, err) // Then we deploy + mipsVersion := int64(standard.MIPSVersion) output, err := deploySuperchain.Run(DeployMIPS2Input{ PreimageOracle: common.Address{'P'}, - MipsVersion: big.NewInt(6), + MipsVersion: big.NewInt(mipsVersion), }) // And do some simple asserts @@ -36,7 +39,7 @@ func TestNewDeployMIPSScript(t *testing.T) { host2 := createTestHost(t) deprecatedOutput, err := DeployMIPS(host2, DeployMIPSInput{ PreimageOracle: common.Address{'P'}, - MipsVersion: 6, + MipsVersion: uint64(mipsVersion), }) // Make sure it succeeded diff --git a/op-deployer/pkg/deployer/opcm/mips_test.go b/op-deployer/pkg/deployer/opcm/mips_test.go index ea8d4ce9b144b..916972a7e9a73 100644 --- a/op-deployer/pkg/deployer/opcm/mips_test.go +++ b/op-deployer/pkg/deployer/opcm/mips_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/broadcaster" + "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/standard" "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/testutil" "github.com/ethereum-optimism/optimism/op-deployer/pkg/env" "github.com/ethereum-optimism/optimism/op-service/testlog" @@ -26,7 +27,7 @@ func TestDeployMIPS(t *testing.T) { require.NoError(t, err) input := DeployMIPSInput{ - MipsVersion: 6, + MipsVersion: uint64(standard.MIPSVersion), PreimageOracle: common.Address{0xab}, } diff --git a/op-deployer/pkg/deployer/pipeline/dispute_games.go b/op-deployer/pkg/deployer/pipeline/dispute_games.go index 1452c952da5af..83bfebabeadf6 100644 --- a/op-deployer/pkg/deployer/pipeline/dispute_games.go +++ b/op-deployer/pkg/deployer/pipeline/dispute_games.go @@ -84,7 +84,7 @@ func deployDisputeGame( return fmt.Errorf("failed to deploy Alphabet VM: %w", err) } vmAddr = out.AlphabetVM - case state.VMTypeCannon1, state.VMTypeCannon2, state.VMTypeCannon6, state.VMTypeCannon7: + case state.VMTypeCannon, state.VMTypeCannonNext: out, err := opcm.DeployMIPS(env.L1ScriptHost, opcm.DeployMIPSInput{ MipsVersion: game.VMType.MipsVersion(), PreimageOracle: oracleAddr, diff --git a/op-deployer/pkg/deployer/standard/standard.go b/op-deployer/pkg/deployer/standard/standard.go index c36a5537ecdae..bb1bf6f2068ad 100644 --- a/op-deployer/pkg/deployer/standard/standard.go +++ b/op-deployer/pkg/deployer/standard/standard.go @@ -25,7 +25,7 @@ const ( ChallengePeriodSeconds uint64 = 86400 ProofMaturityDelaySeconds uint64 = 604800 DisputeGameFinalityDelaySeconds uint64 = 302400 - MIPSVersion uint64 = 6 + MIPSVersion uint64 = 7 DisputeGameType uint32 = 1 // PERMISSIONED game type DisputeMaxGameDepth uint64 = 73 DisputeSplitDepth uint64 = 30 diff --git a/op-deployer/pkg/deployer/state/chain_intent.go b/op-deployer/pkg/deployer/state/chain_intent.go index df8b5e7bb26de..c671db4cc3f04 100644 --- a/op-deployer/pkg/deployer/state/chain_intent.go +++ b/op-deployer/pkg/deployer/state/chain_intent.go @@ -13,20 +13,16 @@ import ( type VMType string const ( - VMTypeAlphabet = "ALPHABET" - VMTypeCannon1 = "CANNON1" // Legacy: corresponds to 32-bit MIPS VM - VMTypeCannon2 = "CANNON2" // Legacy: corresponds to 64-bit MIPS VM StateVersion 6 - VMTypeCannon6 = "CANNON6" // Corresponds to VM State Version 6: https://github.com/ethereum-optimism/optimism/blob/4c05241bc534ae5837007c32995fc62f3dd059b6/cannon/mipsevm/versions/version.go#L25-L25 - VMTypeCannon7 = "CANNON7" // Corresponds to VM State Version 7: https://github.com/ethereum-optimism/optimism/blob/4c05241bc534ae5837007c32995fc62f3dd059b6/cannon/mipsevm/versions/version.go#L27-L27 + VMTypeAlphabet = "ALPHABET" + VMTypeCannon = "CANNON" // Corresponds to the currently released Cannon StateVersion. See: https://github.com/ethereum-optimism/optimism/blob/4c05241bc534ae5837007c32995fc62f3dd059b6/cannon/mipsevm/versions/version.go + 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 ) func (v VMType) MipsVersion() uint64 { switch v { - case VMTypeCannon1: - return 1 - case VMTypeCannon2, VMTypeCannon6: - return 6 - case VMTypeCannon7: + case VMTypeCannon: + return 7 + case VMTypeCannonNext: return 7 default: // Not a mips VM - return empty value diff --git a/op-e2e/config/init.go b/op-e2e/config/init.go index 57ac1ae572d9b..f78cb6f268bd9 100644 --- a/op-e2e/config/init.go +++ b/op-e2e/config/init.go @@ -506,12 +506,14 @@ func decompressGzipJSON(p string, thing any) { } func cannonVMType(allocType AllocType) state.VMType { - if allocType == AllocTypeMTCannon { - return state.VMTypeCannon6 - } else if allocType == AllocTypeMTCannonNext { - return state.VMTypeCannon7 + if allocType == AllocTypeMTCannonNext { + return state.VMTypeCannonNext } - return state.VMTypeCannon6 + return state.VMTypeCannon +} + +func IsCannonInDevelopment() bool { + return cannonVMType(AllocTypeMTCannonNext).MipsVersion() != cannonVMType(AllocTypeMTCannon).MipsVersion() } type prestateFile struct { @@ -529,11 +531,11 @@ func cannonPrestate(monorepoRoot string, allocType AllocType) common.Hash { var once *sync.Once var cacheVar *common.Hash cannonVmType := cannonVMType(allocType) - if cannonVmType == state.VMTypeCannon2 || cannonVmType == state.VMTypeCannon6 { + if cannonVmType == state.VMTypeCannon { filename = "prestate-proof-mt64.json" once = &cannonPrestateMTOnce cacheVar = &cannonPrestateMT - } else if cannonVmType == state.VMTypeCannon7 { + } else if cannonVmType == state.VMTypeCannonNext { filename = "prestate-proof-mt64Next.json" once = &cannonPrestateMTNextOnce cacheVar = &cannonPrestateMTNext diff --git a/op-e2e/e2eutils/challenger/helper.go b/op-e2e/e2eutils/challenger/helper.go index 44ab69be2750d..3338f6870adbb 100644 --- a/op-e2e/e2eutils/challenger/helper.go +++ b/op-e2e/e2eutils/challenger/helper.go @@ -35,7 +35,6 @@ import ( type PrestateVariant string const ( - STCannonVariant PrestateVariant = "" MTCannonVariant PrestateVariant = "mt64" MTCannonNextVariant PrestateVariant = "mt64Next" InteropVariant PrestateVariant = "interop" diff --git a/op-e2e/faultproofs/util.go b/op-e2e/faultproofs/util.go index 518a7579c46b8..93f2da0a1b9c0 100644 --- a/op-e2e/faultproofs/util.go +++ b/op-e2e/faultproofs/util.go @@ -127,14 +127,17 @@ type vmTestOptions[T any] struct { } func defaultVmTestOptions[T any]() vmTestOptions[T] { + allocTypes := []config.AllocType{ + config.AllocTypeMTCannon, + } + if config.IsCannonInDevelopment() { + allocTypes = append(allocTypes, config.AllocTypeMTCannonNext) + } return vmTestOptions[T]{ testNameModifier: func(vmName string, testcase T) string { return vmName }, - allocTypes: []config.AllocType{ - config.AllocTypeMTCannon, - config.AllocTypeMTCannonNext, - }, + allocTypes: allocTypes, } } diff --git a/op-program/Dockerfile.repro b/op-program/Dockerfile.repro index 985010a17b24b..42319c71185cd 100644 --- a/op-program/Dockerfile.repro +++ b/op-program/Dockerfile.repro @@ -1,4 +1,4 @@ -FROM golang:1.22.7-alpine3.20 AS src +FROM golang:1.23.8-alpine3.21 AS src RUN apk add --no-cache make gcc musl-dev linux-headers git jq bash just @@ -38,16 +38,18 @@ RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache GIT_DATE="$GIT_DATE" \ CANNON_VERSION="$CANNON_VERSION" \ OP_PROGRAM_VERSION="$OP_PROGRAM_VERSION" \ - build-current + build-all # Exports files to the specified output location. # Writing files to host requires buildkit to be enabled. # e.g. `BUILDKIT=1 docker build ...` FROM scratch AS export-stage COPY --from=builder /app/op-program/bin/op-program-client64.elf . +# Cannon64 files COPY --from=builder /app/op-program/bin/meta-mt64.json . COPY --from=builder /app/op-program/bin/prestate-mt64.bin.gz . COPY --from=builder /app/op-program/bin/prestate-proof-mt64.json . +# Interop files COPY --from=builder /app/op-program/bin/meta-interop.json . COPY --from=builder /app/op-program/bin/prestate-interop.bin.gz . COPY --from=builder /app/op-program/bin/prestate-proof-interop.json . diff --git a/op-program/Dockerfile.repro.next b/op-program/Dockerfile.repro.next deleted file mode 100644 index b76ec4fdccfc8..0000000000000 --- a/op-program/Dockerfile.repro.next +++ /dev/null @@ -1,49 +0,0 @@ -FROM golang:1.23.8-alpine3.21 AS src - -RUN apk add --no-cache make gcc musl-dev linux-headers git jq bash just - -COPY ./go.mod /app/go.mod -COPY ./go.sum /app/go.sum - -WORKDIR /app - -RUN echo "go mod cache: $(go env GOMODCACHE)" -RUN echo "go build cache: $(go env GOCACHE)" - -RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build go mod download - -COPY . /app - -# we need a separate stage for src so we can build a service provides prestates for unnanounced chains -FROM src AS builder -# We avoid copying the full .git dir into the build for just some metadata. -# Instead, specify: -# --build-arg GIT_COMMIT=$(git rev-parse HEAD) -# --build-arg GIT_DATE=$(git show -s --format='%ct') -ARG GIT_COMMIT -ARG GIT_DATE - -ARG CANNON_VERSION=v0.0.0 -ARG OP_PROGRAM_VERSION=v0.0.0 - -ARG TARGETOS TARGETARCH - -WORKDIR /app -RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build just \ - -d /app/op-program \ - -f /app/op-program/repro.justfile \ - GOOS="$TARGETOS" \ - GOARCH="$TARGETARCH" \ - GIT_COMMIT="$GIT_COMMIT" \ - GIT_DATE="$GIT_DATE" \ - CANNON_VERSION="$CANNON_VERSION" \ - OP_PROGRAM_VERSION="$OP_PROGRAM_VERSION" \ - build-next - -# Exports files to the specified output location. -# Writing files to host requires buildkit to be enabled. -# e.g. `BUILDKIT=1 docker build ...` -FROM scratch AS export-stage -COPY --from=builder /app/op-program/bin/meta-mt64Next.json . -COPY --from=builder /app/op-program/bin/prestate-mt64Next.bin.gz . -COPY --from=builder /app/op-program/bin/prestate-proof-mt64Next.json . diff --git a/op-program/Dockerfile.repro.next.dockerignore b/op-program/Dockerfile.repro.next.dockerignore deleted file mode 100644 index 1a9566cebcc43..0000000000000 --- a/op-program/Dockerfile.repro.next.dockerignore +++ /dev/null @@ -1,16 +0,0 @@ -# exclude everything by default to limit context size and cache miss -* -# module definition -!go.* -# internal dependencies -!cannon/ -!op-alt-da/ -!op-node/ -!op-preimage/ -!op-program/ -!op-service/ -!op-supervisor/ - -**/bin -**/testdata -**/tests \ No newline at end of file diff --git a/op-program/Makefile b/op-program/Makefile index 1067ef3b08258..e71db34eb5275 100644 --- a/op-program/Makefile +++ b/op-program/Makefile @@ -46,7 +46,6 @@ check-custom-chains: op-program-host ./bin/op-program configs check-custom-chains reproducible-prestate: check-custom-chains - @docker build --output ./bin/ --progress plain -f Dockerfile.repro.next ../ @docker build --output ./bin/ --progress plain -f Dockerfile.repro ../ @echo "-------------------- Production Prestates --------------------\n" @echo "\nCannon64 Absolute prestate hash: " diff --git a/op-program/repro.justfile b/op-program/repro.justfile index 226c1a209ee56..96fc1388aefb5 100644 --- a/op-program/repro.justfile +++ b/op-program/repro.justfile @@ -53,9 +53,9 @@ prestate TYPE CLIENT_SUFFIX PRESTATE_SUFFIX: (client TYPE CLIENT_SUFFIX PRESTATE --output "" mv /app/op-program/bin/0{{PRESTATE_SUFFIX}}.json /app/op-program/bin/prestate-proof{{PRESTATE_SUFFIX}}.json -build-mt64: (prestate "multithreaded64-3" "64" "-mt64") +build-mt64: (prestate "multithreaded64-4" "64" "-mt64") build-mt64Next: (prestate "multithreaded64-4" "64" "-mt64Next") -build-interop: (prestate "multithreaded64-3" "-interop" "-interop") +build-interop: (prestate "multithreaded64-4" "-interop" "-interop") build-all: build-mt64 build-mt64Next build-interop build-current: build-mt64 build-interop diff --git a/ops/docker/op-stack-go/Dockerfile b/ops/docker/op-stack-go/Dockerfile index 1b32afb29ef20..1a8cb61c4a89e 100644 --- a/ops/docker/op-stack-go/Dockerfile +++ b/ops/docker/op-stack-go/Dockerfile @@ -84,6 +84,7 @@ COPY --from=cannon-builder-v1-4-0 /usr/local/bin/cannon-2 ./cannon/multicannon/e COPY --from=cannon-builder-v1-2-0 /usr/local/bin/cannon-3 ./cannon/multicannon/embeds/cannon-3 COPY --from=cannon-builder-v1-3-0 /usr/local/bin/cannon-4 ./cannon/multicannon/embeds/cannon-4 COPY --from=cannon-builder-v1-4-0 /usr/local/bin/cannon-5 ./cannon/multicannon/embeds/cannon-5 +COPY --from=cannon-builder-v1-4-0 /usr/local/bin/cannon-6 ./cannon/multicannon/embeds/cannon-6 # Build current binaries RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build cd cannon && make cannon \ GOOS=$TARGETOS GOARCH=$TARGETARCH GITCOMMIT=$GIT_COMMIT GITDATE=$GIT_DATE VERSION="$CANNON_VERSION" diff --git a/packages/contracts-bedrock/scripts/deploy/DeployMIPS.s.sol b/packages/contracts-bedrock/scripts/deploy/DeployMIPS.s.sol index eb91c903bb256..4f2c47ab579b6 100644 --- a/packages/contracts-bedrock/scripts/deploy/DeployMIPS.s.sol +++ b/packages/contracts-bedrock/scripts/deploy/DeployMIPS.s.sol @@ -12,6 +12,7 @@ import { DeployUtils } from "scripts/libraries/DeployUtils.sol"; import { IPreimageOracle } from "interfaces/cannon/IPreimageOracle.sol"; import { IMIPS } from "interfaces/cannon/IMIPS.sol"; import { IMIPS2 } from "interfaces/cannon/IMIPS2.sol"; +import { StandardConstants } from "scripts/deploy/StandardConstants.sol"; /// @title DeployMIPSInput contract DeployMIPSInput is BaseDeployIO { @@ -23,7 +24,7 @@ contract DeployMIPSInput is BaseDeployIO { function set(bytes4 _sel, uint256 _value) public { if (_sel == this.mipsVersion.selector) { - require(_value == 6, "DeployMIPS: unknown mips version"); + require(_value == StandardConstants.MIPS_VERSION, "DeployMIPS: unsupported mips version"); _mipsVersion = _value; } else { revert("DeployMIPS: unknown selector"); @@ -41,7 +42,7 @@ contract DeployMIPSInput is BaseDeployIO { function mipsVersion() public view returns (uint256) { require(_mipsVersion != 0, "DeployMIPS: mipsVersion not set"); - require(_mipsVersion == 6, "DeployMIPS: unknown mips version"); + require(_mipsVersion == StandardConstants.MIPS_VERSION, "DeployMIPS: unsupported mips version"); return _mipsVersion; } diff --git a/packages/contracts-bedrock/scripts/deploy/DeployMIPS2.s.sol b/packages/contracts-bedrock/scripts/deploy/DeployMIPS2.s.sol index 7937cf8bf1297..64be5028ee13e 100644 --- a/packages/contracts-bedrock/scripts/deploy/DeployMIPS2.s.sol +++ b/packages/contracts-bedrock/scripts/deploy/DeployMIPS2.s.sol @@ -11,6 +11,7 @@ import { DeployUtils } from "scripts/libraries/DeployUtils.sol"; import { IPreimageOracle } from "interfaces/cannon/IPreimageOracle.sol"; import { IMIPS } from "interfaces/cannon/IMIPS.sol"; import { IMIPS2 } from "interfaces/cannon/IMIPS2.sol"; +import { StandardConstants } from "scripts/deploy/StandardConstants.sol"; /// @title DeployMIPS contract DeployMIPS2 is Script { @@ -53,7 +54,7 @@ contract DeployMIPS2 is Script { function assertValidInput(Input memory _input) public pure { require(address(_input.preimageOracle) != address(0), "DeployMIPS: preimageOracle not set"); require(_input.mipsVersion != 0, "DeployMIPS: mipsVersion not set"); - require(_input.mipsVersion == 6, "DeployMIPS: unknown mips version"); + require(_input.mipsVersion == StandardConstants.MIPS_VERSION, "DeployMIPS: unsupported mips version"); } function assertValidOutput(Input memory _input, Output memory _output) public view { diff --git a/packages/contracts-bedrock/scripts/deploy/StandardConstants.sol b/packages/contracts-bedrock/scripts/deploy/StandardConstants.sol new file mode 100644 index 0000000000000..e3ac46ec44bc3 --- /dev/null +++ b/packages/contracts-bedrock/scripts/deploy/StandardConstants.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.15; + +library StandardConstants { + uint256 public constant MIPS_VERSION = 7; +} diff --git a/packages/contracts-bedrock/test/opcm/DeployImplementations.t.sol b/packages/contracts-bedrock/test/opcm/DeployImplementations.t.sol index c9383d798a257..8506b795f5000 100644 --- a/packages/contracts-bedrock/test/opcm/DeployImplementations.t.sol +++ b/packages/contracts-bedrock/test/opcm/DeployImplementations.t.sol @@ -7,6 +7,7 @@ import { Test, stdStorage, StdStorage } from "forge-std/Test.sol"; // Libraries import { DeployUtils } from "scripts/libraries/DeployUtils.sol"; import { Chains } from "scripts/libraries/Chains.sol"; +import { StandardConstants } from "scripts/deploy/StandardConstants.sol"; // Interfaces import { IDelayedWETH } from "interfaces/dispute/IDelayedWETH.sol"; @@ -279,7 +280,7 @@ contract DeployImplementations_Test is Test { dii.set(dii.withdrawalDelaySeconds.selector, 1); dii.set(dii.minProposalSizeBytes.selector, 1); dii.set(dii.challengePeriodSeconds.selector, 1); - dii.set(dii.mipsVersion.selector, 6); + dii.set(dii.mipsVersion.selector, StandardConstants.MIPS_VERSION); dii.set(dii.superchainConfigProxy.selector, address(superchainConfigProxy)); dii.set(dii.protocolVersionsProxy.selector, address(protocolVersionsProxy)); dii.set(dii.superchainProxyAdmin.selector, address(superchainProxyAdmin)); @@ -386,7 +387,7 @@ contract DeployImplementations_Test is Test { dii.set(dii.challengePeriodSeconds.selector, challengePeriodSeconds); dii.set(dii.proofMaturityDelaySeconds.selector, proofMaturityDelaySeconds); dii.set(dii.disputeGameFinalityDelaySeconds.selector, disputeGameFinalityDelaySeconds); - dii.set(dii.mipsVersion.selector, 6); + dii.set(dii.mipsVersion.selector, StandardConstants.MIPS_VERSION); dii.set(dii.l1ContractsRelease.selector, release); dii.set(dii.superchainConfigProxy.selector, address(superchainConfigProxy)); dii.set(dii.protocolVersionsProxy.selector, address(protocolVersionsProxy)); @@ -401,7 +402,7 @@ contract DeployImplementations_Test is Test { assertEq(challengePeriodSeconds, dii.challengePeriodSeconds(), "300"); assertEq(proofMaturityDelaySeconds, dii.proofMaturityDelaySeconds(), "400"); assertEq(disputeGameFinalityDelaySeconds, dii.disputeGameFinalityDelaySeconds(), "500"); - assertEq(6, dii.mipsVersion(), "512"); + assertEq(StandardConstants.MIPS_VERSION, dii.mipsVersion(), "512"); assertEq(release, dii.l1ContractsRelease(), "525"); assertEq(address(superchainConfigProxy), address(dii.superchainConfigProxy()), "550"); assertEq(address(protocolVersionsProxy), address(dii.protocolVersionsProxy()), "575"); @@ -423,7 +424,7 @@ contract DeployImplementations_Test is Test { dii.set(dii.challengePeriodSeconds.selector, challengePeriodSeconds); dii.set(dii.proofMaturityDelaySeconds.selector, proofMaturityDelaySeconds); dii.set(dii.disputeGameFinalityDelaySeconds.selector, disputeGameFinalityDelaySeconds); - dii.set(dii.mipsVersion.selector, 6); + dii.set(dii.mipsVersion.selector, StandardConstants.MIPS_VERSION); string memory release = "dev-release"; dii.set(dii.l1ContractsRelease.selector, release); dii.set(dii.superchainConfigProxy.selector, address(superchainConfigProxy)); diff --git a/packages/contracts-bedrock/test/opcm/DeployImplementations2.t.sol b/packages/contracts-bedrock/test/opcm/DeployImplementations2.t.sol index 31f24e9f335c0..7c3073a6ef79d 100644 --- a/packages/contracts-bedrock/test/opcm/DeployImplementations2.t.sol +++ b/packages/contracts-bedrock/test/opcm/DeployImplementations2.t.sol @@ -8,6 +8,7 @@ import { Test, stdStorage, StdStorage } from "forge-std/Test.sol"; import { DeployUtils } from "scripts/libraries/DeployUtils.sol"; import { Chains } from "scripts/libraries/Chains.sol"; import { LibString } from "@solady/utils/LibString.sol"; +import { StandardConstants } from "scripts/deploy/StandardConstants.sol"; // Interfaces import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol"; @@ -116,7 +117,7 @@ contract DeployImplementations2_Test is Test { uint256(_challengePeriodSeconds), _proofMaturityDelaySeconds, _disputeGameFinalityDelaySeconds, - 6, // mipsVersion + StandardConstants.MIPS_VERSION, // mipsVersion _l1ContractsRelease, superchainConfigProxy, protocolVersionsProxy, @@ -249,7 +250,7 @@ contract DeployImplementations2_Test is Test { challengePeriodSeconds, proofMaturityDelaySeconds, disputeGameFinalityDelaySeconds, - 6, // mipsVersion + StandardConstants.MIPS_VERSION, // mipsVersion "dev-release", // l1ContractsRelease superchainConfigProxy, protocolVersionsProxy, diff --git a/packages/contracts-bedrock/test/opcm/DeployMIPS2.t.sol b/packages/contracts-bedrock/test/opcm/DeployMIPS2.t.sol index f4d927b7b4e45..71f6de0f2ddc0 100644 --- a/packages/contracts-bedrock/test/opcm/DeployMIPS2.t.sol +++ b/packages/contracts-bedrock/test/opcm/DeployMIPS2.t.sol @@ -8,6 +8,7 @@ import { IPreimageOracle } from "interfaces/cannon/IPreimageOracle.sol"; import { DeployMIPS2 } from "scripts/deploy/DeployMIPS2.s.sol"; import { MIPS64 } from "src/cannon/MIPS64.sol"; +import { StandardConstants } from "scripts/deploy/StandardConstants.sol"; contract DeployMIPS2_Test is Test { DeployMIPS2 deployMIPS; @@ -22,7 +23,7 @@ contract DeployMIPS2_Test is Test { function testFuzz_run_mipsVersion2_succeeds(DeployMIPS2.Input memory _input) public { vm.assume(address(_input.preimageOracle) != address(0)); - _input.mipsVersion = 6; + _input.mipsVersion = StandardConstants.MIPS_VERSION; // Run the deployment script. DeployMIPS2.Output memory output1 = deployMIPS.run(_input); diff --git a/packages/contracts-bedrock/test/opcm/DeployOPChain.t.sol b/packages/contracts-bedrock/test/opcm/DeployOPChain.t.sol index 45702e733b016..cdd40a9b62cde 100644 --- a/packages/contracts-bedrock/test/opcm/DeployOPChain.t.sol +++ b/packages/contracts-bedrock/test/opcm/DeployOPChain.t.sol @@ -11,6 +11,7 @@ import { } from "scripts/deploy/DeployImplementations.s.sol"; import { DeployOPChainInput, DeployOPChain, DeployOPChainOutput } from "scripts/deploy/DeployOPChain.s.sol"; import { DeployUtils } from "scripts/libraries/DeployUtils.sol"; +import { StandardConstants } from "scripts/deploy/StandardConstants.sol"; import { IProxyAdmin } from "interfaces/universal/IProxyAdmin.sol"; @@ -367,7 +368,7 @@ contract DeployOPChain_TestBase is Test { dii.set(dii.challengePeriodSeconds.selector, challengePeriodSeconds); dii.set(dii.proofMaturityDelaySeconds.selector, proofMaturityDelaySeconds); dii.set(dii.disputeGameFinalityDelaySeconds.selector, disputeGameFinalityDelaySeconds); - dii.set(dii.mipsVersion.selector, 6); + dii.set(dii.mipsVersion.selector, StandardConstants.MIPS_VERSION); dii.set(dii.l1ContractsRelease.selector, release); dii.set(dii.superchainConfigProxy.selector, address(superchainConfigProxy)); dii.set(dii.protocolVersionsProxy.selector, address(protocolVersionsProxy));