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
5 changes: 0 additions & 5 deletions .semgrep/rules/sol-rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ rules:
exclude:
- packages/contracts-bedrock/src/libraries/Bytes.sol
- packages/contracts-bedrock/src/legacy/LegacyMintableERC20.sol
- packages/contracts-bedrock/src/cannon/libraries/MIPSMemory.sol
- packages/contracts-bedrock/src/cannon/libraries/MIPSInstructions.sol

- id: sol-style-malformed-revert
languages: [solidity]
Expand All @@ -180,9 +178,6 @@ rules:
- pattern-not-regex: string\.concat\(\"(\w+:\s[^"]*)\"\,.+\)
- pattern-not-regex: \"([a-zA-Z0-9\s]+-[a-zA-Z0-9\s]+)\"
- pattern-not-regex: \"([a-zA-Z0-9\s]+-[a-zA-Z0-9\s]+-[a-zA-Z0-9\s]+)\"
paths:
exclude:
- packages/contracts-bedrock/src/cannon/libraries/MIPSInstructions.sol

- id: sol-style-use-abi-encodecall
languages: [solidity]
Expand Down
14 changes: 13 additions & 1 deletion cannon/mipsevm/versions/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,21 @@ func GetStateVersionStrings() []string {
return vers
}

// GetCurrentVersion returns the current default version.
func GetCurrentVersion() StateVersion {
return VersionMultiThreaded64_v4
}

// GetExperimentalVersion returns the newest in-development version of Cannon if it exists, otherwise returns the same
// value as GetCurrentVersion.
func GetExperimentalVersion() StateVersion {
lastVersionIndex := len(StateVersionTypes) - 1
return StateVersionTypes[lastVersionIndex]
}

// 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_v4
return ver == GetCurrentVersion() || ver == GetExperimentalVersion()
}

// IsSupported returns true if the state version is currently supported
Expand Down
28 changes: 28 additions & 0 deletions cannon/mipsevm/versions/version_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package versions

import (
"slices"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -51,3 +52,30 @@ func TestIsSupported(t *testing.T) {
})
}
}

func TestGetCurrentVersion(t *testing.T) {
require.True(t, IsSupported(int(GetCurrentVersion())))
}

func TestGetExperimentalVersion(t *testing.T) {
require.True(t, IsSupported(int(GetExperimentalVersion())))

require.GreaterOrEqual(t, GetExperimentalVersion(), GetCurrentVersion())

// Experimental version should be equal to the latest version
expectedValue := slices.Max(StateVersionTypes)
require.Equal(t, expectedValue, GetExperimentalVersion())
}

func TestStateVersionTypes(t *testing.T) {
// Versions should be in ascending order
lastVersion := StateVersion(0)
for i, version := range StateVersionTypes {
if i == 0 {
require.GreaterOrEqual(t, version, lastVersion)
} else {
require.Greater(t, version, lastVersion)
}
lastVersion = version
}
}
3 changes: 2 additions & 1 deletion op-chain-ops/interopgen/recipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/params"

"github.com/ethereum-optimism/optimism/cannon/mipsevm/versions"
"github.com/ethereum-optimism/optimism/op-chain-ops/devkeys"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
)
Expand Down Expand Up @@ -76,7 +77,7 @@ func (recipe *InteropDevRecipe) Build(addrs devkeys.Addresses) (*WorldConfig, er
ChallengePeriodSeconds: big.NewInt(120),
ProofMaturityDelaySeconds: big.NewInt(12),
DisputeGameFinalityDelaySeconds: big.NewInt(6),
MipsVersion: big.NewInt(6),
MipsVersion: big.NewInt(int64(versions.GetExperimentalVersion())),
},
UseInterop: true,
},
Expand Down
5 changes: 3 additions & 2 deletions op-deployer/pkg/deployer/state/chain_intent.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"

"github.com/ethereum-optimism/optimism/cannon/mipsevm/versions"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
)

Expand All @@ -21,9 +22,9 @@ const (
func (v VMType) MipsVersion() uint64 {
switch v {
case VMTypeCannon:
return 7
return uint64(versions.GetCurrentVersion())
case VMTypeCannonNext:
return 7
return uint64(versions.GetExperimentalVersion())
default:
// Not a mips VM - return empty value
return 0
Expand Down
3 changes: 2 additions & 1 deletion packages/contracts-bedrock/scripts/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { DeployUtils } from "scripts/libraries/DeployUtils.sol";
import { DeploySuperchain2 } from "scripts/deploy/DeploySuperchain2.s.sol";
import { DeployImplementations2 } from "scripts/deploy/DeployImplementations2.s.sol";
import { DeployAltDA2 } from "scripts/deploy/DeployAltDA2.s.sol";
import { StandardConstants } from "scripts/deploy/StandardConstants.sol";

// Libraries
import { Types } from "scripts/libraries/Types.sol";
Expand Down Expand Up @@ -268,7 +269,7 @@ contract Deploy is Deployer {
challengePeriodSeconds: cfg.preimageOracleChallengePeriod(),
proofMaturityDelaySeconds: cfg.proofMaturityDelaySeconds(),
disputeGameFinalityDelaySeconds: cfg.disputeGameFinalityDelaySeconds(),
mipsVersion: 6,
mipsVersion: StandardConstants.MIPS_VERSION,
l1ContractsRelease: "dev",
superchainConfigProxy: superchainConfig,
protocolVersionsProxy: IProtocolVersions(artifacts.mustGetAddress("ProtocolVersionsProxy")),
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/snapshots/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@
"sourceCodeHash": "0x734a6b2aa6406bc145d848ad6071d3af1d40852aeb8f4b2f6f51beaad476e2d3"
},
"src/cannon/MIPS64.sol:MIPS64": {
"initCodeHash": "0xcbe1c834c7f1c954ccad3e613f440fed6732dccc0a8786dac8d831752d5613f3",
"sourceCodeHash": "0x59352159a7c46f8cf9a408b20f90e6802ad78ee65bbc215cb825ecfef7beebc1"
"initCodeHash": "0x10aad63177f6592bcd3d42d7ebd7d784c01e518f5189b8a543fc096ab9be69a0",
"sourceCodeHash": "0x4ca87ab2c6c2356c329587f5b69fac3ddc2fc76e389e81faea1a616a3d841403"
},
"src/cannon/PreimageOracle.sol:PreimageOracle": {
"initCodeHash": "0x6af5b0e83b455aab8d0946c160a4dc049a4e03be69f8a2a9e87b574f27b25a66",
Expand Down
8 changes: 4 additions & 4 deletions packages/contracts-bedrock/src/cannon/MIPS64.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ contract MIPS64 is ISemver {
}

/// @notice The semantic version of the MIPS64 contract.
/// @custom:semver 1.2.1
string public constant version = "1.2.1";
/// @custom:semver 1.3.0
string public constant version = "1.3.0";

/// @notice The preimage oracle contract.
IPreimageOracle internal immutable ORACLE;
Expand All @@ -92,8 +92,8 @@ contract MIPS64 is ISemver {

/// @param _oracle The address of the preimage oracle contract.
constructor(IPreimageOracle _oracle, uint256 _stateVersion) {
// Supports VersionMultiThreaded64_v3 (6) and VersionMultiThreaded64_v4 (7)
if (_stateVersion != 6 && _stateVersion != 7) {
// Supports VersionMultiThreaded64_v4 (7)
if (_stateVersion != 7) {
revert UnsupportedStateVersion();
}
ORACLE = _oracle;
Expand Down
Loading