Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update redesign with dev #77

Merged
merged 117 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
ec3f634
ci: Sanitize op-program for unsupported instructions (#12007)
Inphi Sep 24, 2024
308ce74
OPSM: Deploy Permissioned Game (#12064)
maurelian Sep 24, 2024
43224ed
op-service: remove test print statement (#12083)
bitwiseguy Sep 24, 2024
8b76931
feat: Implement release-based contract deployment (#12035)
blmalone Sep 24, 2024
1ee7ea1
fix: justfile clean command (#12092)
blmalone Sep 24, 2024
5b9b3b8
Add permissioned game output assertions (#12093)
maurelian Sep 24, 2024
712b760
cannon: Drop unnecessary wakeup field reset (#12095)
mbaxter Sep 24, 2024
9c02f54
chore: emit event on deploy (#12090)
mds1 Sep 24, 2024
22094b4
check deposit on validateMessage (#12088)
hamdiallam Sep 24, 2024
cbbb45e
op-node: Remove unused field in `ChannelBank` (#12001)
palango Sep 25, 2024
3072549
MTCannon: Add add/addi/addu/addiu opcodes tests (#12085)
GrapeBaBa Sep 25, 2024
56502dd
cannon: Multi VM executor (#12072)
Inphi Sep 25, 2024
decf451
cannon: Build the cannon docker image and publish on cannon release t…
ajsutton Sep 25, 2024
4f1e8a7
remove unused function (#12087)
zhiqiangxu Sep 25, 2024
106993f
op-batcher: Move decision about data availability type to channel sub…
geoknee Sep 25, 2024
b0e6d13
cannon: Support the --version argument for multicannon. (#12101)
ajsutton Sep 25, 2024
da9bc72
show log for `devnet` (#12102)
zhiqiangxu Sep 25, 2024
b55f4d7
rename: OPStackManafer -> OPContractsManager (#12091)
blmalone Sep 25, 2024
10a16aa
op-supervisor: logs-db empty-db edge-case fix (#12097)
protolambda Sep 25, 2024
616a078
op-batcher: prevent over-assessment of DA type (#12115)
geoknee Sep 25, 2024
36180d7
rename: proxyAdminOwner -> superchainProxyAdminOwner (#12106)
blmalone Sep 25, 2024
06f1406
Add support for pre-existing OPSM (#12099)
mslipper Sep 25, 2024
e81c50d
fix: OPCM additional safety checks (#12107)
blmalone Sep 25, 2024
f37d53b
feat(opcm): Update comment about what gets deployed where (#12128)
maurelian Sep 25, 2024
d125012
test: move OPCM tests to own dir (#12110)
maurelian Sep 25, 2024
d90e434
use deterministic seed for test data (#12129)
geoknee Sep 25, 2024
c19d51b
op-supervisor: head pointers, refactor block processor (#12031)
protolambda Sep 25, 2024
c6d3adf
Update README.md (#12125)
DenseDenise Sep 25, 2024
d8cb523
fix(ct): correct input and return argument formatting (#12131)
smartcontracts Sep 25, 2024
e2599c6
dependabot(gomod): bump github.com/minio/minio-go/v7 (#12117)
dependabot[bot] Sep 25, 2024
0b2d0b2
use DeployUtils lib for deployments in deploy script (#12070)
AmadiMichael Sep 25, 2024
2a25c62
ci: Add finalized v1.3.1 to list of reproducible prestate checks (#12…
ajsutton Sep 25, 2024
2d1f41c
feat(L2toL2CrossDomainMessenger): update `sendMessage` to return rela…
tremarkley Sep 26, 2024
874c0e9
Make honestActorConfig public so that it can be used in asterisc e2e …
mininny Sep 26, 2024
12a38d0
op-challenger: Skip prestate verifications for the permissioned game.…
ajsutton Sep 26, 2024
42305d8
cannon: Fix custom --help for multicannon subcommands (#12112)
Inphi Sep 26, 2024
4680790
cannon: update phony makefile targets (#12109)
Inphi Sep 26, 2024
4a608f6
move AttachEmitter block inside nil check (#12144)
zhiqiangxu Sep 26, 2024
d42fc0b
op-batcher,op-e2e: replace magic numbers like 6 with consts, eg MaxBl…
zhiqiangxu Sep 26, 2024
300d9f3
feat(deploy): deploy implementations before proxies (#12114)
maurelian Sep 26, 2024
087bb74
feat: Sepolia Standard Versions OPCM (#12121)
blmalone Sep 26, 2024
e1fe38e
MT Cannon: add more cannon operator instr tests (#12104)
GrapeBaBa Sep 26, 2024
de46c9a
proofs-tools: Update challenger to v1.1.2-rc.1 (#12143)
ajsutton Sep 26, 2024
c65c1f8
support EstimateGas for blob tx (#12086)
zhiqiangxu Sep 26, 2024
3210a8c
chore: rename isthmus to interop on golang files (#12133)
0xDiscotech Sep 26, 2024
a0eee5c
chore: solidity isthmus to interop (#12132)
0xDiscotech Sep 26, 2024
bb87eef
cannon: Consistent state serialization (#12151)
Inphi Sep 26, 2024
99251ea
OPSM: update bond defaults (#12155)
mds1 Sep 26, 2024
ec80f9c
chore: make interopgen deploy step fns public (#12150)
jakim929 Sep 26, 2024
7ff6940
ci-builder: bump go tool versions (#12159)
sebastianst Sep 26, 2024
c8afa15
cannon: Output information about the state in JSON format from the wi…
ajsutton Sep 26, 2024
368c133
op-challenger: Use witness subcommand instead of parsing cannon state…
ajsutton Sep 26, 2024
521fab3
feat: Change OPCM salt to include user supplied arg (#12152)
blmalone Sep 26, 2024
73534e2
fix: remove old standard-versions.toml file (#12153)
blmalone Sep 26, 2024
5798c5f
fix: Temporarily stop deploying DelayedWETHPermissionlessGameProxy (#…
blmalone Sep 26, 2024
d83f12d
feat(op-conductor): implement startup handshake (#12047)
0x00101010 Sep 26, 2024
6202822
feat(opcm): Create and use new ISystemConfigV160 (#12163)
maurelian Sep 26, 2024
0561fd4
op-supervisor: cleanup cross-L2 safety types (#12098)
protolambda Sep 26, 2024
c7ab63b
fix: Update absolute prestate (#12161)
blmalone Sep 26, 2024
6163b32
ci: Add Cannon STF verify recurring job (#12165)
Inphi Sep 27, 2024
8be1550
Update CONTRIBUTING.md (#12164)
tsnob Sep 27, 2024
a9c7f34
Use DA /put path from spec (#12081)
karlb Sep 27, 2024
32a3637
fix(ct): correct constructor parameters (#12158)
smartcontracts Sep 27, 2024
169f808
Remove devnet tests (#12170)
mslipper Sep 27, 2024
b0a4c11
maint(ct): add leftover interfaces (#12167)
smartcontracts Sep 27, 2024
6b2a3fe
op-node/rollup/derive: Implement Holocene Frame Queue (#12069)
sebastianst Sep 27, 2024
724b4e5
contracts-bedrock: better error message (#12148)
tynes Sep 27, 2024
d141b53
typo fix (#12179)
AmadiMichael Sep 27, 2024
a96b228
sent message event and l2tol2cdm relayMessage entrypoint (#11592)
hamdiallam Sep 27, 2024
644dc2b
Cleanups for production, add standard addresses (#12169)
mslipper Sep 27, 2024
289cd71
Supervisor: Safety Index (#12154)
axelKingsley Sep 27, 2024
b1dfd74
OPCM: Adds a test, cleans up some TODOs, new justfile command (#12182)
mds1 Sep 27, 2024
5eaac1d
maint(ct): remove Kontrol interfaces (#12178)
smartcontracts Sep 27, 2024
6ba2ac0
Interfaces in OPCM and OPCMInterop (#12188)
maurelian Sep 28, 2024
cd7e9d4
feat: Rewrite natspec checker in Go (#12191)
mslipper Sep 29, 2024
f2d5e32
add `retry.Do0` (#12194)
zhiqiangxu Sep 29, 2024
d340262
op-program: Switch fpp-verify back to running in separate process. (#…
ajsutton Sep 30, 2024
cd1cc10
test: Transfer to finalSystemOwner rather than SystemOwnerSafe (#12116)
maurelian Sep 30, 2024
fa9ab5e
fix(ct): kontrol summary bug (#12193)
smartcontracts Sep 30, 2024
3aabfe6
fix(ct): give kontrol access to full src (#12181)
smartcontracts Sep 30, 2024
52d0e60
cannon: Support F_GETFD cmd to fcntl (#12050)
ajsutton Sep 30, 2024
de2d9fc
test: Ensure all foundry tests are organized into subdirs (#12111)
maurelian Sep 30, 2024
fe8f2ae
Delete interface directory (#12208)
codewaicher Sep 30, 2024
7467980
contracts-bedrock: bump forge-std (#12149)
tynes Sep 30, 2024
f0227a8
tag-tool: Add --prerelease option (#12210)
Inphi Sep 30, 2024
b127499
ci: Cannon v2 STF verify (#12211)
Inphi Sep 30, 2024
b6e27b6
test(deploy): Deploy a distinct ProxyAdmin for Superchain contracts (…
maurelian Sep 30, 2024
909d7fd
supervisor: Fix nil check (#12209)
Inphi Sep 30, 2024
5bd72f6
Holocene extensions to L1Block.sol (#12096)
roberto-bayardo Sep 30, 2024
75b0e66
cannon: Bump go tests to go1.22 (#12214)
mbaxter Sep 30, 2024
31e244c
- fix lint issue in Encoding.sol (#12215)
roberto-bayardo Oct 1, 2024
b5b68de
fix(ci): add files to semgrep ignore (#12219)
smartcontracts Oct 1, 2024
d05fb50
cannon: Update version of go used in cannon stf-diff (#12218)
ajsutton Oct 1, 2024
c2dc0ab
op-e2e: Support specifying allocs in tests (#12216)
mslipper Oct 1, 2024
fed6f35
fix(ci): temporarily make semgrep scan ok on err (#12227)
smartcontracts Oct 1, 2024
a2653a3
cannon: 64-bit Refactor (#12029)
Inphi Oct 1, 2024
7feffce
Configurable GasLimit for op-deployer (#12224)
blmalone Oct 1, 2024
8a7db41
op-deployer: Fix init bugs (#12230)
mslipper Oct 1, 2024
dd2b21c
make check-interfaces.sh warn on old versions of bash (#12220)
roberto-bayardo Oct 1, 2024
d8cde65
cannon: Fix cli --stop-at-preimage value parsing (#12234)
Inphi Oct 1, 2024
a4d81ba
use interfaces in opcm contracts (#12217)
AmadiMichael Oct 1, 2024
28726a3
Revert "Holocene extensions to L1Block.sol (#12096)" (#12236)
roberto-bayardo Oct 1, 2024
73038c8
op-e2e/system/fjord: Fix check script test (#12231)
sebastianst Oct 1, 2024
445a3d4
feat(sequencer): Origin Selector asynchronously prefetches the next o…
BrianBland Oct 2, 2024
ab8b371
MT Cannon: add cannon load/store opcodes tests (#12196)
GrapeBaBa Oct 2, 2024
e7dbd84
feat: Use DeploySuperchain script in Deploy.s.sol (#12203)
maurelian Oct 2, 2024
b1d119f
op-e2e: Retrieve AllocType from System instead of env (#12221)
ajsutton Oct 2, 2024
a12738b
feat: deployImplementations and depImplementationsInterop (#12226)
maurelian Oct 2, 2024
40a70bd
Eth: BlockRef (#12251)
axelKingsley Oct 2, 2024
28283a9
Configurable Dispute Game Parameters (#12228)
blmalone Oct 2, 2024
ef46b05
feat: Add a test to simplify deploy script testing (#12235)
maurelian Oct 2, 2024
1217d4a
op-deployer: Custom gas price estimator (#12239)
mslipper Oct 2, 2024
d1f6501
batcher: use abstract Queue type for blocks state (#12180)
geoknee Oct 2, 2024
2c7de99
cannon: Define 64-bit syscalls (#12256)
Inphi Oct 2, 2024
33bc0be
feat: Extract deployment of pre-v1.6.0 code (#12233)
maurelian Oct 2, 2024
7fcaf6c
Merge branch 'develop' into fix/redesign-merge-conflicts
agusduha Oct 2, 2024
619f23c
fix: pre pr
agusduha Oct 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
349 changes: 83 additions & 266 deletions .circleci/config.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ packages/contracts-bedrock/deployments/anvil
!.envrc.example
*.log

.devnet
.devnet*

# Ignore local fuzzing results
**/testdata/fuzz/
Expand Down
20 changes: 19 additions & 1 deletion .semgrepignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,27 @@ tests/
.semgrep_logs/

op-chain-ops/script/testdata
op-chain-ops/script/testdata/scripts/ScriptExample.s.sol

packages/*/node_modules
packages/*/test

# Autogenerated solidity library
# TODO: Define these exclusions inside of the semgrep rules once those rules
# are all defined locally in the repository instead of the semgrep app.

# Contracts: autogenerated solidity library
packages/contracts-bedrock/scripts/libraries/Solarray.sol

# Contracts: vendor interfaces
packages/contracts-bedrock/scripts/interfaces/IGnosisSafe.sol
packages/contracts-bedrock/src/EAS/

# Contracts: deliberate exclusions
packages/contracts-bedrock/src/universal/WETH98.sol
packages/contracts-bedrock/src/universal/interfaces/IWETH.sol
packages/contracts-bedrock/src/L2/SuperchainWETH.sol
packages/contracts-bedrock/src/L2/interfaces/ISuperchainWETH.sol
packages/contracts-bedrock/src/governance/GovernanceToken.sol
packages/contracts-bedrock/src/governance/interfaces/IGovernanceToken.sol
packages/contracts-bedrock/src/dispute/interfaces/IFaultDisputeGame.sol
packages/contracts-bedrock/src/dispute/interfaces/IPermissionedDisputeGame.sol
21 changes: 17 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,21 @@ reproducible-prestate: ## Builds reproducible-prestate binary
.PHONY: reproducible-prestate

# Include any files required for the devnet to build and run.
DEVNET_CANNON_PRESTATE_FILES := op-program/bin/prestate-proof.json op-program/bin/prestate.json op-program/bin/prestate-proof-mt.json op-program/bin/prestate-mt.bin.gz
DEVNET_CANNON_PRESTATE_FILES := op-program/bin/prestate-proof.json op-program/bin/prestate.bin.gz op-program/bin/prestate-proof-mt.json op-program/bin/prestate-mt.bin.gz


$(DEVNET_CANNON_PRESTATE_FILES):
make cannon-prestate
make cannon-prestate-mt

cannon-prestate: op-program cannon ## Generates prestate using cannon and op-program
./cannon/bin/cannon load-elf --path op-program/bin/op-program-client.elf --out op-program/bin/prestate.json --meta op-program/bin/meta.json
./cannon/bin/cannon run --proof-at '=0' --stop-at '=1' --input op-program/bin/prestate.json --meta op-program/bin/meta.json --proof-fmt 'op-program/bin/%d.json' --output ""
./cannon/bin/cannon load-elf --type singlethreaded-2 --path op-program/bin/op-program-client.elf --out op-program/bin/prestate.bin.gz --meta op-program/bin/meta.json
./cannon/bin/cannon run --proof-at '=0' --stop-at '=1' --input op-program/bin/prestate.bin.gz --meta op-program/bin/meta.json --proof-fmt 'op-program/bin/%d.json' --output ""
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 cannon-mt --path op-program/bin/op-program-client.elf --out op-program/bin/prestate-mt.bin.gz --meta op-program/bin/meta-mt.json
./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/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
Expand Down Expand Up @@ -206,6 +206,19 @@ devnet-allocs: pre-devnet ## Generates allocations for the local devnet
PYTHONPATH=./bedrock-devnet $(PYTHON) ./bedrock-devnet/main.py --monorepo-dir=. --allocs
.PHONY: devnet-allocs

devnet-allocs-tests:
DEVNET_L2OO=true make devnet-allocs
cp -r .devnet/ .devnet-l2oo/
DEVNET_ALTDA=true make devnet-allocs
cp -r .devnet/ .devnet-alt-da/
DEVNET_ALTDA=false GENERIC_ALTDA=true make devnet-allocs
cp -r .devnet/ .devnet-alt-da-generic/
USE_MT_CANNON=true make devnet-allocs
cp -r .devnet/ .devnet-mt-cannon
make devnet-allocs
cp -r .devnet/ .devnet-standard/
.PHONY: devnet-allocs-tests

devnet-logs: ## Displays logs for the local devnet
@(cd ./ops-bedrock && docker compose logs -f)
.PHONY: devnet-logs
Expand Down
2 changes: 2 additions & 0 deletions bedrock-devnet/devnet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from multiprocessing import Process, Queue
import concurrent.futures
from collections import namedtuple
# This import is necessary for devnet logs to be shown.
from . import log_setup


pjoin = os.path.join
Expand Down
4 changes: 1 addition & 3 deletions cannon/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ venv
*.log
testdata/example/bin
contracts/out
state.json
*.json
*.json.gz
*.pprof
*.out
bin
multicannon/embeds/cannon*
34 changes: 34 additions & 0 deletions cannon/Dockerfile.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM golang:1.22.7-alpine3.20 as builder

RUN apk add --no-cache make bash

COPY ./go.mod /app/go.mod
COPY ./go.sum /app/go.sum

WORKDIR /app

RUN echo "go mod cache: $(go env GOMODCACHE)"
RUN echo "go build cache: $(go env GOCACHE)"

RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build go mod download

COPY . /app

# We avoid copying the full .git dir into the build for just some metadata.
# Instead, specify:
# --build-arg GIT_COMMIT=$(git rev-parse HEAD)
# --build-arg GIT_DATE=$(git show -s --format='%ct')
ARG GIT_COMMIT
ARG GIT_DATE

ARG TARGETOS TARGETARCH

FROM --platform=$BUILDPLATFORM us-docker.pkg.dev/oplabs-tools-artifacts/images/cannon:v1.1.0-alpha.1 AS cannon-v2

FROM --platform=$BUILDPLATFORM builder as cannon-verify
COPY --from=cannon-v2 /usr/local/bin/cannon /usr/local/bin/cannon-v2
# verify the latest singlethreaded VM behavior against cannon-v2
RUN cd cannon && make diff-singlethreaded-2-cannon -e OTHER_CANNON=/usr/local/bin/cannon-v2
RUN --mount=type=cache,target=/root/.cache/go-build cd cannon && \
make diff-singlethreaded-2-cannon -e OTHER_CANNON=/usr/local/bin/cannon-v2 \
GOOS=$TARGETOS GOARCH=$TARGETARCH GITCOMMIT=$GIT_COMMIT GITDATE=$GIT_DATE
64 changes: 58 additions & 6 deletions cannon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,77 @@ VERSION ?= v0.0.0

LDFLAGSSTRING +=-X main.GitCommit=$(GITCOMMIT)
LDFLAGSSTRING +=-X main.GitDate=$(GITDATE)
LDFLAGSSTRING +=-X github.com/ethereum-optimism/optimism/op-program/version.Version=$(VERSION)
LDFLAGSSTRING +=-X github.com/ethereum-optimism/optimism/op-program/version.Meta=$(VERSION_META)
LDFLAGSSTRING +=-X github.com/ethereum-optimism/optimism/cannon/multicannon/version.Version=$(VERSION)
LDFLAGSSTRING +=-X github.com/ethereum-optimism/optimism/cannon/multicannon/version.Meta=$(VERSION_META)
LDFLAGS := -ldflags "$(LDFLAGSSTRING)"

# Use the old Apple linker to workaround broken xcode - https://github.com/golang/go/issues/65169
ifeq ($(shell uname),Darwin)
FUZZLDFLAGS := -ldflags=-extldflags=-Wl,-ld_classic
endif

cannon:
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v $(LDFLAGS) -o ./bin/cannon .
.DEFAULT_GOAL := cannon

cannon32-impl:
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build --tags=cannon32 -v $(LDFLAGS) -o ./bin/cannon32-impl .

cannon64-impl:
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build --tags=cannon64 -v $(LDFLAGS) -o ./bin/cannon64-impl .

cannon-embeds: cannon32-impl cannon64-impl
# singlethreaded-v2
@cp bin/cannon32-impl ./multicannon/embeds/cannon-2
# multithreaded
@cp bin/cannon32-impl ./multicannon/embeds/cannon-1
# 64-bit multithreaded
@cp bin/cannon64-impl ./multicannon/embeds/cannon-3

cannon: cannon-embeds
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v $(LDFLAGS) -o ./bin/cannon ./multicannon/

clean:
rm -rf bin
rm -rf bin multicannon/embeds/cannon*

elf:
make -C ./testdata/example elf

sanitize-program:
@if ! { mips-linux-gnu-objdump -d -j .text $$GUEST_PROGRAM | awk '{print $3}' | grep -Ew -m1 '(bgezal|bltzal)'; }; then \
echo "guest program is sanitized for unsupported instructions"; \
else \
echo "found unsupported instructions in the guest program"; \
exit 1; \
fi

contract:
cd ../packages/contracts-bedrock && forge build

test: elf contract
go test -v ./...

diff-%-cannon: cannon elf
$$OTHER_CANNON load-elf --type $* --path ./testdata/example/bin/hello.elf --out ./bin/prestate-other.bin.gz --meta ""
./bin/cannon load-elf --type $* --path ./testdata/example/bin/hello.elf --out ./bin/prestate.bin.gz --meta ""
@cmp ./bin/prestate-other.bin.gz ./bin/prestate.bin.gz
@if [ $$? -eq 0 ]; then \
echo "Generated identical prestates"; \
else \
echo "Generated different prestates"; \
exit 1; \
fi
$$OTHER_CANNON run --proof-at '=0' --stop-at '=100000000' --input=./bin/prestate.bin.gz --output ./bin/out-other.bin.gz --meta ""
./bin/cannon run --proof-at '=0' --stop-at '=100000000' --input=./bin/prestate.bin.gz --output ./bin/out.bin.gz --meta ""
@cmp ./bin/out-other.bin.gz ./bin/out.bin.gz
@if [ $$? -eq 0 ]; then \
echo "Generated identical states"; \
else \
echo "Generated different prestates"; \
exit 1; \
fi

cannon-stf-verify:
@docker build --progress plain -f Dockerfile.diff ../

fuzz:
# Common vm tests
go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzStateSyscallBrk ./mipsevm/tests
Expand All @@ -44,8 +91,13 @@ fuzz:
go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzStateSyscallCloneMT ./mipsevm/tests

.PHONY: \
cannon32-impl \
cannon64-impl \
cannon-embeds \
cannon \
clean \
test \
lint \
fuzz
fuzz \
diff-%-cannon \
cannon-stf-verify
2 changes: 1 addition & 1 deletion cannon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ make cannon

# Transform MIPS op-program client binary into first VM state.
# This outputs state.json (VM state) and meta.json (for debug symbols).
./bin/cannon load-elf --path=../op-program/bin/op-program-client.elf
./bin/cannon load-elf --type singlethreaded --path=../op-program/bin/op-program-client.elf

# Run cannon emulator (with example inputs)
# Note that the server-mode op-program command is passed into cannon (after the --),
Expand Down
66 changes: 32 additions & 34 deletions cannon/cmd/load_elf.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ import (
"github.com/ethereum-optimism/optimism/cannon/mipsevm/singlethreaded"
"github.com/ethereum-optimism/optimism/cannon/mipsevm/versions"
"github.com/ethereum-optimism/optimism/cannon/serialize"
openum "github.com/ethereum-optimism/optimism/op-service/enum"
"github.com/ethereum-optimism/optimism/op-service/ioutil"
"github.com/ethereum-optimism/optimism/op-service/jsonutil"
)

var (
LoadELFVMTypeFlag = &cli.StringFlag{
Name: "type",
Usage: "VM type to create state for. Options are 'cannon' (default), 'cannon-mt'",
Value: "cannon",
Required: false,
Usage: "VM type to create state for. Valid options: " + openum.EnumString(stateVersions()),
Required: true,
}
LoadELFPathFlag = &cli.PathFlag{
Name: "path",
Usage: "Path to 32-bit big-endian MIPS ELF file",
Usage: "Path to 32/64-bit big-endian MIPS ELF file",
TakesFile: true,
Required: true,
}
Expand All @@ -43,21 +43,12 @@ var (
}
)

type VMType string

var (
cannonVMType VMType = "cannon"
mtVMType VMType = "cannon-mt"
)

func vmTypeFromString(ctx *cli.Context) (VMType, error) {
if vmTypeStr := ctx.String(LoadELFVMTypeFlag.Name); vmTypeStr == string(cannonVMType) {
return cannonVMType, nil
} else if vmTypeStr == string(mtVMType) {
return mtVMType, nil
} else {
return "", fmt.Errorf("unknown VM type %q", vmTypeStr)
func stateVersions() []string {
vers := make([]string, len(versions.StateVersionTypes))
for i, v := range versions.StateVersionTypes {
vers[i] = v.String()
}
return vers
}

func LoadELF(ctx *cli.Context) error {
Expand All @@ -73,9 +64,12 @@ func LoadELF(ctx *cli.Context) error {
var createInitialState func(f *elf.File) (mipsevm.FPVMState, error)

var patcher = program.PatchStack
if vmType, err := vmTypeFromString(ctx); err != nil {
ver, err := versions.ParseStateVersion(ctx.String(LoadELFVMTypeFlag.Name))
if err != nil {
return err
} else if vmType == cannonVMType {
}
switch ver {
case versions.VersionSingleThreaded2:
createInitialState = func(f *elf.File) (mipsevm.FPVMState, error) {
return program.LoadELF(f, singlethreaded.CreateInitialState)
}
Expand All @@ -86,12 +80,12 @@ func LoadELF(ctx *cli.Context) error {
}
return program.PatchStack(state)
}
} else if vmType == mtVMType {
case versions.VersionMultiThreaded, versions.VersionMultiThreaded64:
createInitialState = func(f *elf.File) (mipsevm.FPVMState, error) {
return program.LoadELF(f, multithreaded.CreateInitialState)
}
} else {
return fmt.Errorf("invalid VM type: %q", vmType)
default:
return fmt.Errorf("unsupported state version: %d (%s)", ver, ver.String())
}

state, err := createInitialState(elfProgram)
Expand All @@ -118,15 +112,19 @@ func LoadELF(ctx *cli.Context) error {
return serialize.Write(ctx.Path(LoadELFOutFlag.Name), versionedState, OutFilePerm)
}

var LoadELFCommand = &cli.Command{
Name: "load-elf",
Usage: "Load ELF file into Cannon state",
Description: "Load ELF file into Cannon state",
Action: LoadELF,
Flags: []cli.Flag{
LoadELFVMTypeFlag,
LoadELFPathFlag,
LoadELFOutFlag,
LoadELFMetaFlag,
},
func CreateLoadELFCommand(action cli.ActionFunc) *cli.Command {
return &cli.Command{
Name: "load-elf",
Usage: "Load ELF file into Cannon state",
Description: "Load ELF file into Cannon state",
Action: action,
Flags: []cli.Flag{
LoadELFVMTypeFlag,
LoadELFPathFlag,
LoadELFOutFlag,
LoadELFMetaFlag,
},
}
}

var LoadELFCommand = CreateLoadELFCommand(LoadELF)
Loading