Commit 914157f9 authored by Inphi's avatar Inphi Committed by GitHub

devnet: Replace mt-cannon with 64-bit Cannon (#12924)

parent 78fed1ee
......@@ -147,8 +147,8 @@ cannon-prestate: op-program cannon ## Generates prestate using cannon and op-pro
mv op-program/bin/0.json op-program/bin/prestate-proof.json
.PHONY: cannon-prestate
cannon-prestate-mt: op-program cannon ## Generates prestate using cannon and op-program in the multithreaded cannon format
./cannon/bin/cannon load-elf --type multithreaded --path op-program/bin/op-program-client.elf --out op-program/bin/prestate-mt.bin.gz --meta op-program/bin/meta-mt.json
cannon-prestate-mt: op-program cannon ## Generates prestate using cannon and op-program in the multithreaded64 cannon format
./cannon/bin/cannon load-elf --type multithreaded64 --path op-program/bin/op-program-client64.elf --out op-program/bin/prestate-mt.bin.gz --meta op-program/bin/meta-mt.json
./cannon/bin/cannon run --proof-at '=0' --stop-at '=1' --input op-program/bin/prestate-mt.bin.gz --meta op-program/bin/meta-mt.json --proof-fmt 'op-program/bin/%d-mt.json' --output ""
mv op-program/bin/0-mt.json op-program/bin/prestate-proof-mt.json
.PHONY: cannon-prestate-mt
......
package faultproofs
import (
"bytes"
"context"
"encoding/json"
"math"
"math/big"
"os/exec"
"path/filepath"
"testing"
......@@ -12,7 +15,6 @@ import (
"github.com/ethereum-optimism/optimism/op-e2e/system/e2esys"
"github.com/ethereum-optimism/optimism/op-e2e/system/helpers"
"github.com/ethereum-optimism/optimism/cannon/mipsevm/versions"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
......@@ -276,9 +278,29 @@ func runCannon(t *testing.T, ctx context.Context, sys *e2esys.System, inputs uti
err := executor.DoGenerateProof(ctx, proofsDir, math.MaxUint, math.MaxUint, extraVmArgs...)
require.NoError(t, err, "failed to generate proof")
state, err := versions.LoadStateFromFile(vm.FinalStatePath(proofsDir, cfg.Cannon.BinarySnapshots))
require.NoError(t, err, "failed to parse state")
require.True(t, state.GetExited(), "cannon did not exit")
require.Zero(t, state.GetExitCode(), "cannon failed with exit code %d", state.GetExitCode())
t.Logf("Completed in %d steps", state.GetStep())
stdOut, _, err := runCmd(ctx, cfg.Cannon.VmBin, "witness", "--input", vm.FinalStatePath(proofsDir, cfg.Cannon.BinarySnapshots))
require.NoError(t, err, "failed to run witness cmd")
type stateData struct {
Step uint64 `json:"step"`
ExitCode uint8 `json:"exitCode"`
Exited bool `json:"exited"`
}
var data stateData
err = json.Unmarshal([]byte(stdOut), &data)
require.NoError(t, err, "failed to parse state data")
require.True(t, data.Exited, "cannon did not exit")
require.Zero(t, data.ExitCode, "cannon failed with exit code %d", data.ExitCode)
t.Logf("Completed in %d steps", data.Step)
}
func runCmd(ctx context.Context, binary string, args ...string) (stdOut string, stdErr string, err error) {
var outBuf bytes.Buffer
var errBuf bytes.Buffer
cmd := exec.CommandContext(ctx, binary, args...)
cmd.Stdout = &outBuf
cmd.Stderr = &errBuf
err = cmd.Run()
stdOut = outBuf.String()
stdErr = errBuf.String()
return
}
......@@ -45,6 +45,7 @@ After running `make reproducible-prestate`, the following files can be found in
[./bin/](./bin/):
- [`op-program`](./bin/op-program)
- [`op-program-client.elf`](./bin/op-program-client.elf)
- [`op-program-client64.elf`](./bin/op-program-client64.elf)
- [`prestate.bin.gz`](./bin/prestate.bin.gz)
- [`prestate-proof.json`](./bin/prestate-proof.json)
......
......@@ -695,12 +695,12 @@ contract Deploy is Deployer {
addr_ = address(oracle);
}
/// @notice Deploy Mips VM. Deploys either MIPS or MIPS2 depending on the environment
/// @notice Deploy Mips VM. Deploys either MIPS or MIPS64 depending on the environment
function deployMips() public broadcast returns (address addr_) {
addr_ = DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: Config.useMultithreadedCannon() ? "MIPS2" : "MIPS",
_name: Config.useMultithreadedCannon() ? "MIPS64" : "MIPS",
_args: DeployUtils.encodeConstructor(
abi.encodeCall(IMIPS2.__constructor__, (IPreimageOracle(mustGetAddress("PreimageOracle"))))
)
......@@ -1019,7 +1019,7 @@ contract Deploy is Deployer {
mipsAbsolutePrestate_ =
Claim.wrap(abi.decode(bytes(Process.bash(string.concat("cat ", filePath, " | jq -r .pre"))), (bytes32)));
console.log(
"[MT-Cannon Dispute Game] Using devnet MIPS2 Absolute prestate: %s",
"[MT-Cannon Dispute Game] Using devnet MIPS64 Absolute prestate: %s",
vm.toString(Claim.unwrap(mipsAbsolutePrestate_))
);
}
......
......@@ -376,7 +376,7 @@ contract DeployDisputeGame is Script {
vm.broadcast(msg.sender);
singleton = IMIPS(
DeployUtils.create1({
_name: mipsVersion == 1 ? "MIPS" : "MIPS2",
_name: mipsVersion == 1 ? "MIPS" : "MIPS64",
_args: DeployUtils.encodeConstructor(abi.encodeCall(IMIPS.__constructor__, (preimageOracle)))
})
);
......
......@@ -802,7 +802,7 @@ contract DeployImplementations is Script {
vm.broadcast(msg.sender);
singleton = IMIPS(
DeployUtils.create1({
_name: mipsVersion == 1 ? "MIPS" : "MIPS2",
_name: mipsVersion == 1 ? "MIPS" : "MIPS64",
_args: DeployUtils.encodeConstructor(abi.encodeCall(IMIPS.__constructor__, (preimageOracle)))
})
);
......
......@@ -98,7 +98,7 @@ contract DeployMIPS is Script {
vm.broadcast(msg.sender);
singleton = IMIPS(
DeployUtils.create1({
_name: mipsVersion == 1 ? "MIPS" : "MIPS2",
_name: mipsVersion == 1 ? "MIPS" : "MIPS64",
_args: DeployUtils.encodeConstructor(abi.encodeCall(IMIPS.__constructor__, (preimageOracle)))
})
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment