Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 7 additions & 8 deletions cannon/Dockerfile.diff
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
13 changes: 4 additions & 9 deletions cannon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"; \
Expand Down Expand Up @@ -113,7 +109,6 @@ fuzz:
cannon \
clean \
elf \
elf-go-122 \
elf-go-123 \
test \
lint \
Expand Down
4 changes: 0 additions & 4 deletions cannon/mipsevm/tests/evm_common64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 7 additions & 1 deletion cannon/mipsevm/versions/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
36 changes: 36 additions & 0 deletions cannon/mipsevm/versions/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
}
7 changes: 1 addition & 6 deletions cannon/testdata/Makefile
Original file line number Diff line number Diff line change
@@ -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
30 changes: 0 additions & 30 deletions cannon/testdata/go-1-22/Makefile

This file was deleted.

5 changes: 0 additions & 5 deletions cannon/testdata/go-1-22/hello/go.mod

This file was deleted.

7 changes: 0 additions & 7 deletions cannon/testdata/go-1-22/hello/main.go

This file was deleted.

8 changes: 4 additions & 4 deletions op-deployer/pkg/deployer/bootstrap/implementations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion op-deployer/pkg/deployer/integration_test/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions op-deployer/pkg/deployer/opcm/implementations2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions op-deployer/pkg/deployer/opcm/mips2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion op-deployer/pkg/deployer/opcm/mips_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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},
}

Expand Down
2 changes: 1 addition & 1 deletion op-deployer/pkg/deployer/pipeline/dispute_games.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion op-deployer/pkg/deployer/standard/standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 6 additions & 10 deletions op-deployer/pkg/deployer/state/chain_intent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading