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
15 changes: 5 additions & 10 deletions op-deployer/pkg/deployer/opcm/alphabet.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,9 @@ type DeployAlphabetVMOutput struct {
AlphabetVM common.Address
}

func DeployAlphabetVM(
host *script.Host,
input DeployAlphabetVMInput,
) (DeployAlphabetVMOutput, error) {
return RunScriptSingle[DeployAlphabetVMInput, DeployAlphabetVMOutput](
host,
input,
"DeployAlphabetVM.s.sol",
"DeployAlphabetVM",
)
type DeployAlphabetVMScript script.DeployScriptWithOutput[DeployAlphabetVMInput, DeployAlphabetVMOutput]

// NewDeployAlphabetVMScript loads and validates the DeployAlphabetVM2 script contract
func NewDeployAlphabetVMScript(host *script.Host) (DeployAlphabetVMScript, error) {
return script.NewDeployScriptWithOutputFromFile[DeployAlphabetVMInput, DeployAlphabetVMOutput](host, "DeployAlphabetVM.s.sol", "DeployAlphabetVM")
}
22 changes: 0 additions & 22 deletions op-deployer/pkg/deployer/opcm/alphabet2.go

This file was deleted.

50 changes: 0 additions & 50 deletions op-deployer/pkg/deployer/opcm/alphabet2_test.go

This file was deleted.

40 changes: 16 additions & 24 deletions op-deployer/pkg/deployer/opcm/alphabet_test.go
Original file line number Diff line number Diff line change
@@ -1,37 +1,29 @@
package opcm

import (
"math/big"
"testing"

"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/broadcaster"
"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"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require"
)

func TestDeployAlphabetVM(t *testing.T) {
t.Parallel()
func TestNewDeployAlphabetVMScript(t *testing.T) {
t.Run("should not fail with current version of DeployAlphabetVM contract", func(t *testing.T) {
// First we grab a test host
host1 := createTestHost(t)

_, artifacts := testutil.LocalArtifacts(t)
deployAlphabetVM, err := NewDeployAlphabetVMScript(host1)
require.NoError(t, err)

host, err := env.DefaultScriptHost(
broadcaster.NoopBroadcaster(),
testlog.Logger(t, log.LevelInfo),
common.Address{'D'},
artifacts,
)
require.NoError(t, err)
// Now we run the deploy script
output, err := deployAlphabetVM.Run(DeployAlphabetVMInput{
AbsolutePrestate: common.BigToHash(big.NewInt(1)),
PreimageOracle: common.BigToAddress(big.NewInt(2)),
})

input := DeployAlphabetVMInput{
AbsolutePrestate: common.Hash{'A'},
PreimageOracle: common.Address{'O'},
}

output, err := DeployAlphabetVM(host, input)
require.NoError(t, err)

require.NotEmpty(t, output.AlphabetVM)
// And do some simple asserts
require.NoError(t, err)
require.NotNil(t, output)
})
}
7 changes: 6 additions & 1 deletion op-deployer/pkg/deployer/pipeline/dispute_games.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ func deployDisputeGame(
var vmAddr common.Address
switch game.VMType {
case state.VMTypeAlphabet:
out, err := opcm.DeployAlphabetVM(env.L1ScriptHost, opcm.DeployAlphabetVMInput{
deployAlphabetVM, err := opcm.NewDeployAlphabetVMScript(env.L1ScriptHost)
if err != nil {
return fmt.Errorf("failed to load DeployAlphabetVM script: %w", err)
}

out, err := deployAlphabetVM.Run(opcm.DeployAlphabetVMInput{
AbsolutePrestate: game.DisputeAbsolutePrestate,
PreimageOracle: oracleAddr,
})
Expand Down
59 changes: 18 additions & 41 deletions packages/contracts-bedrock/scripts/deploy/DeployAlphabetVM.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,37 @@ pragma solidity 0.8.15;
import { Script } from "forge-std/Script.sol";

import { IPreimageOracle } from "interfaces/cannon/IPreimageOracle.sol";
import { BaseDeployIO } from "scripts/deploy/BaseDeployIO.sol";
import { AlphabetVM } from "test/mocks/AlphabetVM.sol";
import { Claim } from "src/dispute/lib/Types.sol";

contract DeployAlphabetVMInput is BaseDeployIO {
bytes32 internal _absolutePrestate;
IPreimageOracle internal _preimageOracle;

function set(bytes4 _sel, address _addr) public {
require(_addr != address(0), "DeployAlphabetVMInput: cannot set zero address");

if (_sel == this.preimageOracle.selector) _preimageOracle = IPreimageOracle(_addr);
else revert("DeployAlphabetVMInput: unknown selector");
contract DeployAlphabetVM is Script {
struct Input {
bytes32 absolutePrestate;
IPreimageOracle preimageOracle;
}

function set(bytes4 _sel, bytes32 _value) public {
if (_sel == this.absolutePrestate.selector) _absolutePrestate = _value;
else revert("DeployAlphabetVMInput: unknown selector");
struct Output {
AlphabetVM alphabetVM;
}

function absolutePrestate() public view returns (bytes32) {
require(_absolutePrestate != bytes32(0), "DeployAlphabetVMInput: not set");
return _absolutePrestate;
}
function run(Input memory _input) public returns (Output memory output_) {
assertValidInput(_input);

function preimageOracle() public view returns (IPreimageOracle) {
require(address(_preimageOracle) != address(0), "DeployAlphabetVMInput: not set");
return _preimageOracle;
}
}
Claim absolutePrestate = Claim.wrap(_input.absolutePrestate);
IPreimageOracle preimageOracle = _input.preimageOracle;

contract DeployAlphabetVMOutput is BaseDeployIO {
AlphabetVM internal _alphabetVM;
vm.broadcast(msg.sender);
AlphabetVM alphabetVM = new AlphabetVM(absolutePrestate, preimageOracle);

function set(bytes4 _sel, address _addr) public {
require(_addr != address(0), "DeployAlphabetVMOutput: cannot set zero address");
if (_sel == this.alphabetVM.selector) _alphabetVM = AlphabetVM(_addr);
else revert("DeployAlphabetVMOutput: unknown selector");
output_.alphabetVM = alphabetVM;
}

function alphabetVM() public view returns (AlphabetVM) {
require(address(_alphabetVM) != address(0), "DeployAlphabetVMOutput: not set");
return _alphabetVM;
function assertValidInput(Input memory _input) private pure {
require(_input.absolutePrestate != bytes32(0), "DeployAlphabetVM: absolutePrestate not set");
require(address(_input.preimageOracle) != address(0), "DeployAlphabetVM: preimageOracle not set");
}
}

contract DeployAlphabetVM is Script {
function run(DeployAlphabetVMInput _input, DeployAlphabetVMOutput _output) public {
Claim absolutePrestate = Claim.wrap(_input.absolutePrestate());
IPreimageOracle preimageOracle = _input.preimageOracle();

vm.broadcast(msg.sender);
AlphabetVM alphabetVM = new AlphabetVM(absolutePrestate, preimageOracle);

_output.set(_output.alphabetVM.selector, address(alphabetVM));
function assertValidOutput(Output memory _output) private pure {
require(address(_output.alphabetVM) != address(0), "DeployAlphabetVM: alphabetVM not set");
}
}

This file was deleted.

Loading