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
16 changes: 14 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ jobs:
- checkout
- check-changed:
patterns: cannon,packages/contracts-bedrock/src/cannon,op-preimage,go.mod
- attach_workspace:
at: "."
- run:
name: prep Cannon results dir
command: mkdir -p /tmp/test-results
Expand Down Expand Up @@ -783,12 +785,19 @@ jobs:
on_changes:
description: changed pattern to fire fuzzer on
type: string
uses_artifacts:
description: should load in foundry artifacts
type: boolean
default: false
docker:
- image: <<pipeline.parameters.ci_builder_image>>
steps:
- checkout
- check-changed:
patterns: "<<parameters.package_name>>"
- attach_workspace:
at: "."
if: ${{ uses_artifacts }}
- restore_cache:
name: Restore Go modules cache
key: gomod-{{ checksum "go.sum" }}
Expand Down Expand Up @@ -1708,7 +1717,8 @@ workflows:
name: cannon-fuzz
package_name: cannon
on_changes: cannon,packages/contracts-bedrock/src/cannon
requires: ["go-mod-download"]
uses_artifacts: true
requires: ["go-mod-download", "pnpm-monorepo"]
- go-test:
name: op-heartbeat-tests
module: op-heartbeat
Expand Down Expand Up @@ -1907,7 +1917,9 @@ workflows:
docker_tags: <<pipeline.git.revision>>,<<pipeline.git.branch>>
- check-generated-mocks-op-node
- check-generated-mocks-op-service
- cannon-go-lint-and-test
- cannon-go-lint-and-test:
requires:
- pnpm-monorepo
- cannon-build-test-vectors
- shellcheck/check:
name: shell-check
Expand Down
44 changes: 33 additions & 11 deletions cannon/mipsevm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package mipsevm

import (
"encoding/binary"
"encoding/json"
"fmt"
"math/big"
"os"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
Expand All @@ -15,28 +17,48 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/params"

"github.com/ethereum-optimism/optimism/op-bindings/bindings"
)

// LoadContracts loads the Cannon contracts, from op-bindings package
// LoadContracts loads the Cannon contracts, from the contracts package.
func LoadContracts() (*Contracts, error) {
var mips, oracle Contract
mips.DeployedBytecode.Object = hexutil.MustDecode(bindings.MIPSDeployedBin)
oracle.DeployedBytecode.Object = hexutil.MustDecode(bindings.PreimageOracleDeployedBin)
mips, err := loadContract("../../packages/contracts-bedrock/forge-artifacts/MIPS.sol/MIPS.json")
if err != nil {
return nil, fmt.Errorf("failed to load MIPS contract: %w", err)
}

oracle, err := loadContract("../../packages/contracts-bedrock/forge-artifacts/PreimageOracle.sol/PreimageOracle.json")
if err != nil {
return nil, fmt.Errorf("failed to load Oracle contract: %w", err)
}

return &Contracts{
MIPS: &mips,
Oracle: &oracle,
MIPS: mips,
Oracle: oracle,
}, nil
}

func loadContract(path string) (*Contract, error) {
file, err := os.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("artifact at %s not found: %w", path, err)
}

contract := Contract{}
if err := json.Unmarshal(file, &contract); err != nil {
return nil, err
}
return &contract, nil
}

type Contract struct {
DeployedBytecode struct {
Object hexutil.Bytes `json:"object"`
SourceMap string `json:"sourceMap"`
} `json:"deployedBytecode"`

// ignore abi,bytecode,etc.
Bytecode struct {
Object hexutil.Bytes `json:"object"`
} `json:"bytecode"`
// ignore abi,etc.
}

type Contracts struct {
Expand Down Expand Up @@ -76,7 +98,7 @@ func NewEVMEnv(contracts *Contracts, addrs *Addresses) (*vm.EVM, *state.StateDB)

var mipsCtorArgs [32]byte
copy(mipsCtorArgs[12:], addrs.Oracle[:])
mipsDeploy := append(hexutil.MustDecode(bindings.MIPSMetaData.Bin), mipsCtorArgs[:]...)
mipsDeploy := append(hexutil.MustDecode(contracts.MIPS.Bytecode.Object.String()), mipsCtorArgs[:]...)
startingGas := uint64(30_000_000)
_, deployedMipsAddr, leftOverGas, err := env.Create(vm.AccountRef(addrs.Sender), mipsDeploy, startingGas, common.U2560)
if err != nil {
Expand Down