Skip to content

Commit

Permalink
Merge branch 'develop' into sc/superchain-erc20-factory
Browse files Browse the repository at this point in the history
  • Loading branch information
agusduha committed Aug 22, 2024
2 parents 2534555 + 0cf2a11 commit b210604
Show file tree
Hide file tree
Showing 286 changed files with 13,944 additions and 6,244 deletions.
91 changes: 51 additions & 40 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,17 @@ jobs:
name: Copy L2OO allocs to .devnet-l2oo
command: cp -r .devnet/ .devnet-l2oo/
- run:
name: Generate Plasma allocs
command: DEVNET_PLASMA="true" make devnet-allocs
name: Generate AltDA allocs
command: DEVNET_ALTDA="true" make devnet-allocs
- run:
name: Copy Plasma allocs to .devnet-plasma
command: cp -r .devnet/ .devnet-plasma/
name: Copy AltDA allocs to .devnet-altda
command: cp -r .devnet/ .devnet-altda/
- run:
name: Generate Generic Plasma allocs
command: DEVNET_PLASMA="true" GENERIC_PLASMA="true" make devnet-allocs
name: Generate Generic AltDA allocs
command: DEVNET_ALTDA="true" GENERIC_ALTDA="true" make devnet-allocs
- run:
name: Copy Plasma allocs to .devnet-plasma
command: cp -r .devnet/ .devnet-plasma-generic/
name: Copy AltDA allocs to .devnet-altda
command: cp -r .devnet/ .devnet-altda-generic/
- run:
name: Generate default allocs
command: make devnet-allocs
Expand All @@ -239,18 +239,18 @@ jobs:
- ".devnet-l2oo/allocs-l2-ecotone.json"
- ".devnet-l2oo/allocs-l2-fjord.json"
- ".devnet-l2oo/allocs-l2-granite.json"
- ".devnet-plasma/allocs-l1.json"
- ".devnet-plasma/addresses.json"
- ".devnet-plasma/allocs-l2-delta.json"
- ".devnet-plasma/allocs-l2-ecotone.json"
- ".devnet-plasma/allocs-l2-fjord.json"
- ".devnet-plasma/allocs-l2-granite.json"
- ".devnet-plasma-generic/allocs-l1.json"
- ".devnet-plasma-generic/addresses.json"
- ".devnet-plasma-generic/allocs-l2-delta.json"
- ".devnet-plasma-generic/allocs-l2-ecotone.json"
- ".devnet-plasma-generic/allocs-l2-fjord.json"
- ".devnet-plasma-generic/allocs-l2-granite.json"
- ".devnet-altda/allocs-l1.json"
- ".devnet-altda/addresses.json"
- ".devnet-altda/allocs-l2-delta.json"
- ".devnet-altda/allocs-l2-ecotone.json"
- ".devnet-altda/allocs-l2-fjord.json"
- ".devnet-altda/allocs-l2-granite.json"
- ".devnet-altda-generic/allocs-l1.json"
- ".devnet-altda-generic/addresses.json"
- ".devnet-altda-generic/allocs-l2-delta.json"
- ".devnet-altda-generic/allocs-l2-ecotone.json"
- ".devnet-altda-generic/allocs-l2-fjord.json"
- ".devnet-altda-generic/allocs-l2-granite.json"
- "packages/contracts-bedrock/deploy-config/devnetL1.json"
- "packages/contracts-bedrock/deployments/devnetL1"
- notify-failures-on-develop
Expand Down Expand Up @@ -838,11 +838,11 @@ jobs:
command: echo 'export OP_E2E_USE_L2OO=true' >> $BASH_ENV
- when:
condition:
equal: ['-plasma', <<parameters.variant>>]
equal: ['-altda', <<parameters.variant>>]
steps:
- run:
name: Set OP_E2E_USE_PLASMA = true
command: echo 'export OP_E2E_USE_PLASMA=true' >> $BASH_ENV
name: Set OP_E2E_USE_ALTDA = true
command: echo 'export OP_E2E_USE_ALTDA=true' >> $BASH_ENV
- check-changed:
patterns: op-(.+),cannon,contracts-bedrock
- run:
Expand Down Expand Up @@ -1067,26 +1067,26 @@ jobs:
DEVNET_NO_BUILD: 'true'
# Default value; Can be overridden.
DEVNET_L2OO: 'false'
DEVNET_PLASMA: 'false'
DEVNET_ALTDA: 'false'
steps:
- checkout
- when:
condition:
equal: ['plasma', <<parameters.variant>>]
equal: ['altda', <<parameters.variant>>]
steps:
- run:
name: Set DEVNET_PLASMA = true
command: echo 'export DEVNET_PLASMA=true' >> $BASH_ENV
name: Set DEVNET_ALTDA = true
command: echo 'export DEVNET_ALTDA=true' >> $BASH_ENV
- when:
condition:
equal: ['plasma-generic', <<parameters.variant>>]
equal: ['altda-generic', <<parameters.variant>>]
steps:
- run:
name: Set DEVNET_PLASMA = true
command: echo 'export DEVNET_PLASMA=true' >> $BASH_ENV
name: Set DEVNET_ALTDA = true
command: echo 'export DEVNET_ALTDA=true' >> $BASH_ENV
- run:
name: Set GENERIC_PLASMA = true
command: echo 'export GENERIC_PLASMA=true' >> $BASH_ENV
name: Set GENERIC_ALTDA = true
command: echo 'export GENERIC_ALTDA=true' >> $BASH_ENV
- check-changed:
patterns: op-(.+),packages,ops-bedrock,bedrock-devnet
- run:
Expand Down Expand Up @@ -1443,12 +1443,22 @@ jobs:
docker_layer_caching: true
- run:
name: Run Kontrol Tests
command: just test-kontrol
command: |
curl -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $RV_COMPUTE_TOKEN" \
https://api.github.com/repos/runtimeverification/optimism-ci/actions/workflows/optimism-ci.yaml/dispatches \
-d '{
"ref": "master",
"inputs": {
"branch_name": "<<pipeline.git.branch>>",
"extra_args": "script",
"statuses_sha": "<< pipeline.git.revision >>",
"org": "ethereum-optimism",
"repository": "optimism"
}
}'
working_directory: ./packages/contracts-bedrock
- store_artifacts:
path: ./packages/contracts-bedrock/test/kontrol/logs/kontrol-results_latest.tar.gz
- store_test_results:
path: ./packages/contracts-bedrock
- notify-failures-on-develop

workflows:
Expand Down Expand Up @@ -1566,7 +1576,7 @@ workflows:
name: op-e2e-action-tests<< matrix.variant >>
matrix:
parameters:
variant: ["", "-l2oo", "-plasma"]
variant: ["", "-l2oo", "-altda"]
module: op-e2e
target: test-actions
parallelism: 1
Expand Down Expand Up @@ -1611,7 +1621,7 @@ workflows:
- op-e2e-HTTP-tests
- op-e2e-fault-proof-tests
- op-e2e-action-tests
- op-e2e-action-tests-plasma
- op-e2e-action-tests-altda
- docker-build:
name: op-node-docker-build
docker_name: op-node
Expand Down Expand Up @@ -1668,7 +1678,7 @@ workflows:
- devnet:
matrix:
parameters:
variant: ["default", "plasma", "plasma-generic"]
variant: ["default", "altda", "altda-generic"]
requires:
- pnpm-monorepo
- op-batcher-docker-build
Expand Down Expand Up @@ -1990,6 +2000,7 @@ workflows:
- kontrol-tests:
context:
- slack
- runtimeverification

scheduled-docker-publish:
when:
Expand Down
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/op-heartbeat @ethereum-optimism/go-reviewers
/op-node @ethereum-optimism/go-reviewers
/op-node/rollup @protolambda @ajsutton
/op-plasma @ethereum-optimism/go-reviewers
/op-alt-da @ethereum-optimism/go-reviewers
/op-preimage @ethereum-optimism/go-reviewers
/op-program @ethereum-optimism/go-reviewers
/op-proposer @ethereum-optimism/go-reviewers
Expand Down
1 change: 1 addition & 0 deletions .semgrepignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ tests/
# Semgrep-action log folder
.semgrep_logs/

op-chain-ops/script/testdata

packages/*/node_modules
packages/*/test
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ PYTHON?=python3
help: ## Prints this help message
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

build: build-go build-ts ## Builds both Go and TypeScript components
build: build-go build-contracts ## Builds Go components and contracts-bedrock
.PHONY: build

build-go: submodules op-node op-proposer op-batcher ## Builds op-node, op-proposer and op-batcher
.PHONY: build-go

build-contracts:
(cd packages/contracts-bedrock && just build)
.PHONY: build-contracts

lint-go: ## Lints Go code with specific linters
golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout 5m -e "errors.As" -e "errors.Is" ./...
.PHONY: lint-go
Expand Down
30 changes: 15 additions & 15 deletions bedrock-devnet/devnet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
# Global environment variables
DEVNET_NO_BUILD = os.getenv('DEVNET_NO_BUILD') == "true"
DEVNET_L2OO = os.getenv('DEVNET_L2OO') == "true"
DEVNET_PLASMA = os.getenv('DEVNET_PLASMA') == "true"
GENERIC_PLASMA = os.getenv('GENERIC_PLASMA') == "true"
DEVNET_ALTDA = os.getenv('DEVNET_ALTDA') == "true"
GENERIC_ALTDA = os.getenv('GENERIC_ALTDA') == "true"

class Bunch:
def __init__(self, **kwds):
Expand Down Expand Up @@ -123,9 +123,9 @@ def init_devnet_l1_deploy_config(paths, update_timestamp=False):
deploy_config['l1GenesisBlockTimestamp'] = '{:#x}'.format(int(time.time()))
if DEVNET_L2OO:
deploy_config['useFaultProofs'] = False
if DEVNET_PLASMA:
deploy_config['usePlasma'] = True
if GENERIC_PLASMA:
if DEVNET_ALTDA:
deploy_config['useAltDA'] = True
if GENERIC_ALTDA:
deploy_config['daCommitmentType'] = "GenericCommitment"
write_json(paths.devnet_config_path, deploy_config)

Expand Down Expand Up @@ -175,7 +175,7 @@ def devnet_deploy(paths):
log.info('L1 genesis already generated.')
else:
log.info('Generating L1 genesis.')
if not os.path.exists(paths.allocs_l1_path) or DEVNET_L2OO or DEVNET_PLASMA:
if not os.path.exists(paths.allocs_l1_path) or DEVNET_L2OO or DEVNET_ALTDA:
# If this is a devnet variant then we need to generate the allocs
# file here always. This is because CI will run devnet-allocs
# without setting the appropriate env var which means the allocs will be wrong.
Expand Down Expand Up @@ -267,19 +267,19 @@ def devnet_deploy(paths):
docker_env['DG_TYPE'] = '254'
docker_env['PROPOSAL_INTERVAL'] = '12s'

if DEVNET_PLASMA:
docker_env['PLASMA_ENABLED'] = 'true'
if DEVNET_ALTDA:
docker_env['ALTDA_ENABLED'] = 'true'
docker_env['DA_TYPE'] = 'calldata'
else:
docker_env['PLASMA_ENABLED'] = 'false'
docker_env['ALTDA_ENABLED'] = 'false'
docker_env['DA_TYPE'] = 'blobs'

if GENERIC_PLASMA:
docker_env['PLASMA_GENERIC_DA'] = 'true'
docker_env['PLASMA_DA_SERVICE'] = 'true'
if GENERIC_ALTDA:
docker_env['ALTDA_GENERIC_DA'] = 'true'
docker_env['ALTDA_SERVICE'] = 'true'
else:
docker_env['PLASMA_GENERIC_DA'] = 'false'
docker_env['PLASMA_DA_SERVICE'] = 'false'
docker_env['ALTDA_GENERIC_DA'] = 'false'
docker_env['ALTDA_SERVICE'] = 'false'

# Bring up the rest of the services.
log.info('Bringing up `op-node`, `op-proposer` and `op-batcher`.')
Expand All @@ -291,7 +291,7 @@ def devnet_deploy(paths):
run_command(['docker', 'compose', 'up', '-d', 'op-challenger'], cwd=paths.ops_bedrock_dir, env=docker_env)

# Optionally bring up Alt-DA Mode components.
if DEVNET_PLASMA:
if DEVNET_ALTDA:
log.info('Bringing up `da-server`, `sentinel`.') # TODO(10141): We don't have public sentinel images yet
run_command(['docker', 'compose', 'up', '-d', 'da-server'], cwd=paths.ops_bedrock_dir, env=docker_env)

Expand Down
6 changes: 5 additions & 1 deletion cannon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,19 @@ test: elf contract
go test -v ./...

fuzz:
# Common vm tests
go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzStateSyscallBrk ./mipsevm/tests
go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzStateSyscallClone ./mipsevm/tests
go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzStateSyscallMmap ./mipsevm/tests
go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzStateSyscallExitGroup ./mipsevm/tests
go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzStateSyscallFcntl ./mipsevm/tests
go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzStateHintRead ./mipsevm/tests
go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 20s -fuzz=FuzzStatePreimageRead ./mipsevm/tests
go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzStateHintWrite ./mipsevm/tests
go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 20s -fuzz=FuzzStatePreimageWrite ./mipsevm/tests
# Single-threaded tests
go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzStateSyscallCloneST ./mipsevm/tests
# Multi-threaded tests
go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzStateSyscallCloneMT ./mipsevm/tests

.PHONY: \
cannon \
Expand Down
3 changes: 2 additions & 1 deletion cannon/mipsevm/exec/mips_instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ func ExecuteMipsInstruction(insn, opcode, fun, rs, rt, mem uint32) uint32 {
case 0x06: // srlv
return rt >> (rs & 0x1F)
case 0x07: // srav
return SignExtend(rt>>rs, 32-rs)
shamt := rs & 0x1F
return SignExtend(rt>>shamt, 32-shamt)
// functs in range [0x8, 0x1b] are handled specially by other functions
case 0x08: // jr
return rs
Expand Down
8 changes: 7 additions & 1 deletion cannon/mipsevm/exec/mips_syscalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/ethereum-optimism/optimism/cannon/mipsevm"
"github.com/ethereum-optimism/optimism/cannon/mipsevm/memory"
"github.com/ethereum-optimism/optimism/cannon/mipsevm/program"
)

// Syscall codes
Expand Down Expand Up @@ -132,7 +133,6 @@ const (
// Other constants
const (
SchedQuantum = 100_000
BrkStart = 0x40000000
)

func GetSyscallArgs(registers *[32]uint32) (syscallNum, a0, a1, a2, a3 uint32) {
Expand All @@ -158,6 +158,12 @@ func HandleSysMmap(a0, a1, heap uint32) (v0, v1, newHeap uint32) {
v0 = heap
//fmt.Printf("mmap heap 0x%x size 0x%x\n", v0, sz)
newHeap += sz
// Fail if new heap exceeds memory limit, newHeap overflows around to low memory, or sz overflows
if newHeap > program.HEAP_END || newHeap < heap || sz < a1 {
v0 = SysErrorSignal
v1 = MipsEINVAL
return v0, v1, heap
}
} else {
v0 = a0
//fmt.Printf("mmap hint 0x%x size 0x%x\n", v0, sz)
Expand Down
27 changes: 25 additions & 2 deletions cannon/mipsevm/iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,31 @@ package mipsevm

import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"

"github.com/ethereum-optimism/optimism/cannon/mipsevm/memory"
)

type FPVMState interface {
GetMemory() *memory.Memory

// GetHeap returns the current memory address at the top of the heap
GetHeap() uint32

// GetPreimageKey returns the most recently accessed preimage key
GetPreimageKey() common.Hash

// GetPreimageOffset returns the current offset into the current preimage
GetPreimageOffset() uint32

// GetPC returns the currently executing program counter
GetPC() uint32

// GetRegisters returns the currently active registers
GetRegisters() *[32]uint32
// GetCpu returns the currently active cpu scalars, including the program counter
GetCpu() CpuScalars

// GetRegistersRef returns a pointer to the currently active registers
GetRegistersRef() *[32]uint32

// GetStep returns the current VM step
GetStep() uint64
Expand All @@ -24,6 +37,16 @@ type FPVMState interface {
// GetExitCode returns the exit code
GetExitCode() uint8

// GetLastHint returns optional metadata which is not part of the VM state itself.
// It is used to remember the last pre-image hint,
// so a VM can start from any state without fetching prior pre-images,
// and instead just repeat the last hint on setup,
// to make sure pre-image requests can be served.
// The first 4 bytes are a uin32 length prefix.
// Warning: the hint MAY NOT BE COMPLETE. I.e. this is buffered,
// and should only be read when len(LastHint) > 4 && uint32(LastHint[:4]) <= len(LastHint[4:])
GetLastHint() hexutil.Bytes

// EncodeWitness returns the witness for the current state and the state hash
EncodeWitness() (witness []byte, hash common.Hash)
}
Expand Down
Loading

0 comments on commit b210604

Please sign in to comment.