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 @@ -150,13 +150,13 @@ cannon-prestate: op-program cannon ## Generates prestate using cannon and op-pro
.PHONY: cannon-prestate

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-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 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 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-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 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 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
2 changes: 1 addition & 1 deletion cannon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ cannon-embeds: cannon32-impl cannon64-impl
# 32-bit multithreaded vm
@cp bin/cannon32-impl ./multicannon/embeds/cannon-5
# 64-bit multithreaded vm
@cp bin/cannon64-impl ./multicannon/embeds/cannon-7
@cp bin/cannon64-impl ./multicannon/embeds/cannon-6

cannon: cannon-embeds
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v $(LDFLAGS) -o ./bin/cannon ./multicannon/
Expand Down
2 changes: 0 additions & 2 deletions cannon/mipsevm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ Supported 63 instructions:
| `Conditional Branch` | `bne` | Branch on not equal. |
| `Logical` | `clo` | Count leading ones. |
| `Logical` | `clz` | Count leading zeros. |
| `Logical` | `dclo` | Count Leading Ones in Doubleword. |
| `Logical` | `dclz` | Count Leading Zeros in Doubleword. |
| `Arithmetic` | `div` | Divide. |
| `Arithmetic` | `divu` | Divide unsigned. |
| `Unconditional Jump` | `j` | Jump. |
Expand Down
10 changes: 0 additions & 10 deletions cannon/mipsevm/exec/mips_instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,16 +350,6 @@ func ExecuteMipsInstruction(insn uint32, opcode uint32, fun uint32, rs, rt, mem
rs <<= 1
}
return Word(i)
case 0x24, 0x25: // dclz, dclo
assertMips64Fun(insn)
if fun == 0x24 {
rs = ^rs
}
i := uint32(0)
for ; uint64(rs)&0x80000000_00000000 != 0; i++ {
rs <<= 1
}
return Word(i)
}
case 0x0F: // lui
return SignExtend(rt<<16, 32)
Expand Down
51 changes: 0 additions & 51 deletions cannon/mipsevm/tests/evm_common64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,54 +509,3 @@ func TestEVM_SingleStep_Branch64(t *testing.T) {

testBranch(t, cases)
}

func TestEVM_SingleStep_CloClz64(t *testing.T) {
rsReg := uint32(7)
rdReg := uint32(8)
cases := []struct {
name string
rs Word
funct uint32
expectedResult Word
}{
// dclo
{name: "dclo", rs: Word(0xFF_FF_FF_FF_FF_FF_FF_FF), expectedResult: Word(64), funct: 0b10_0101},
{name: "dclo", rs: Word(0xFF_FF_FF_FF_FF_FF_FF_FE), expectedResult: Word(63), funct: 0b10_0101},
{name: "dclo", rs: Word(0xFF_FF_FF_FF_00_00_00_00), expectedResult: Word(32), funct: 0b10_0101},
{name: "dclo", rs: Word(0x80_00_00_00_00_00_00_00), expectedResult: Word(1), funct: 0b10_0101},
{name: "dclo", rs: Word(0x0), expectedResult: Word(0), funct: 0b10_0101},
// dclz
{name: "dclz", rs: Word(0x0), expectedResult: Word(64), funct: 0b10_0100},
{name: "dclz", rs: Word(0x1), expectedResult: Word(63), funct: 0b10_0100},
{name: "dclz", rs: Word(0x10_00_00_00), expectedResult: Word(35), funct: 0b10_0100},
{name: "dclz", rs: Word(0x80_00_00_00), expectedResult: Word(32), funct: 0b10_0100},
{name: "dclz", rs: Word(0x80_00_00_00_00_00_00_00), expectedResult: Word(0), funct: 0b10_0100},
}

versions := GetMipsVersionTestCases(t)
for _, v := range versions {
for i, tt := range cases {
testName := fmt.Sprintf("%v (%v)", tt.name, v.Name)
t.Run(testName, func(t *testing.T) {
// Set up state
goVm := v.VMFactory(nil, os.Stdout, os.Stderr, testutil.CreateLogger(), testutil.WithRandomization(int64(i)))
state := goVm.GetState()
insn := 0b01_1100<<26 | rsReg<<21 | rdReg<<11 | tt.funct
testutil.StoreInstruction(state.GetMemory(), state.GetPC(), insn)
state.GetRegistersRef()[rsReg] = tt.rs
step := state.GetStep()

// Setup expectations
expected := testutil.NewExpectedState(state)
expected.ExpectStep()
expected.Registers[rdReg] = tt.expectedResult
stepWitness, err := goVm.Step(true)
require.NoError(t, err)

// Check expectations
expected.Validate(t, state)
testutil.ValidateEVM(t, stepWitness, step, goVm, v.StateHashFn, v.Contracts)
})
}
}
}
Binary file removed cannon/mipsevm/versions/testdata/states/7.bin.gz
Binary file not shown.
11 changes: 2 additions & 9 deletions cannon/mipsevm/versions/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ const (
VersionMultiThreaded64_v2
// VersionMultiThreaded_v2 is the latest 32-bit multithreaded vm
VersionMultiThreaded_v2
// VersionMultiThreaded64_v3 does not support mips64r1 because dclo|dclz instructions were not supported
// VersionMultiThreaded64_v3 is the latest 64-bit multithreaded vm
VersionMultiThreaded64_v3
// VersionMultiThreaded64_v4 is the latest 64-bit multithreaded vm
VersionMultiThreaded64_v4
)

var StateVersionTypes = []StateVersion{
Expand All @@ -35,7 +33,6 @@ var StateVersionTypes = []StateVersion{
VersionMultiThreaded64_v2,
VersionMultiThreaded_v2,
VersionMultiThreaded64_v3,
VersionMultiThreaded64_v4,
}

func (s StateVersion) String() string {
Expand All @@ -54,8 +51,6 @@ func (s StateVersion) String() string {
return "multithreaded-2"
case VersionMultiThreaded64_v3:
return "multithreaded64-3"
case VersionMultiThreaded64_v4:
return "multithreaded64-4"
default:
return "unknown"
}
Expand All @@ -77,8 +72,6 @@ func ParseStateVersion(ver string) (StateVersion, error) {
return VersionMultiThreaded_v2, nil
case "multithreaded64-3":
return VersionMultiThreaded64_v3, nil
case "multithreaded64-4":
return VersionMultiThreaded64_v4, nil
default:
return StateVersion(0), errors.New("unknown state version")
}
Expand All @@ -98,7 +91,7 @@ func GetStateVersionStrings() []string {

// GetCurrentMultiThreaded64 returns the 64-bit multithreaded VM version that is currently supported
func GetCurrentMultiThreaded64() StateVersion {
return VersionMultiThreaded64_v4
return VersionMultiThreaded64_v3
}

// GetCurrentMultiThreaded returns the 32-bit multithreaded VM version that is currently supported
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 @@ -140,8 +140,8 @@
"sourceCodeHash": "0x20256a2196daca39b56bfae1c90b8871349916dc47461b5ca078c2013c067571"
},
"src/cannon/MIPS64.sol:MIPS64": {
"initCodeHash": "0xb57a15cd4238a102dd87ff817aea1a22aa4dbf1c543c8e952691e2b08dd1af83",
"sourceCodeHash": "0x53b27fbb84b42f52ff843585c21494a6480736d3a79659bba7d1b16ee95e53d2"
"initCodeHash": "0x0a274f73b9fae62524a5773e480b398846e1140aed373be211a07cb586e4758e",
"sourceCodeHash": "0xb710bd6d4844f9ee45f301bb815786619b5e2d6b2f85ae17f39bee4f414f1957"
},
"src/cannon/PreimageOracle.sol:PreimageOracle": {
"initCodeHash": "0x6af5b0e83b455aab8d0946c160a4dc049a4e03be69f8a2a9e87b574f27b25a66",
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/src/cannon/MIPS64.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ contract MIPS64 is ISemver {
}

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

/// @notice The preimage oracle contract.
IPreimageOracle internal immutable ORACLE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,18 +469,6 @@ library MIPS64Instructions {
}
return i;
}
// dclz, dclo
else if (_fun == 0x24 || _fun == 0x25) {
if (_fun == 0x24) {
_rs = ~_rs;
}
uint32 i = 0;
while (_rs & 0x80000000_00000000 != 0) {
i++;
_rs <<= 1;
}
return i;
}
}
// lui
else if (_opcode == 0x0F) {
Expand Down