Skip to content

Commit

Permalink
chore: merge develop without conflicts (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xDiscotech authored Sep 9, 2024
1 parent b702f29 commit d517107
Show file tree
Hide file tree
Showing 297 changed files with 6,392 additions and 28,266 deletions.
407 changes: 248 additions & 159 deletions .circleci/config.yml

Large diffs are not rendered by default.

62 changes: 27 additions & 35 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,43 +1,35 @@
# Packages
/packages/contracts-bedrock @ethereum-optimism/contract-reviewers
/packages/sdk @ethereum-optimism/devxpod
# Monorepo - default to go-reviewers
* @ethereum-optimism/go-reviewers

# OP Stack general
/bedrock-devnet @ethereum-optimism/go-reviewers @ethereum-optimism/op-stack
/op-alt-da @ethereum-optimism/go-reviewers @ethereum-optimism/op-stack
/op-batcher @ethereum-optimism/go-reviewers @ethereum-optimism/op-stack
/op-chain-ops @ethereum-optimism/go-reviewers @ethereum-optimism/op-stack
/op-e2e @ethereum-optimism/go-reviewers @ethereum-optimism/op-stack
/op-node @ethereum-optimism/go-reviewers @ethereum-optimism/op-stack
/op-proposer @ethereum-optimism/go-reviewers @ethereum-optimism/op-stack
/op-wheel @ethereum-optimism/go-reviewers @ethereum-optimism/op-stack
/ops-bedrock @ethereum-optimism/go-reviewers @ethereum-optimism/op-stack

# Expert areas
/op-node/rollup @ethereum-optimism/go-reviewers @ethereum-optimism/consensus

/op-supervisor @ethereum-optimism/go-reviewers @ethereum-optimism/interop

# Bedrock codebases
/bedrock-devnet @ethereum-optimism/go-reviewers
/cannon @ethereum-optimism/go-reviewers
/op-batcher @ethereum-optimism/go-reviewers
/op-bootnode @ethereum-optimism/go-reviewers
/op-chain-ops @ethereum-optimism/go-reviewers
/op-challenger @ethereum-optimism/go-reviewers
/op-dispute-mon @ethereum-optimism/go-reviewers
/op-e2e @ethereum-optimism/go-reviewers
/op-node @ethereum-optimism/go-reviewers
/op-node/rollup @protolambda @ajsutton
/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
/op-service @ethereum-optimism/go-reviewers
/op-supervisor @ethereum-optimism/go-reviewers
/op-wheel @ethereum-optimism/go-reviewers
/ops-bedrock @ethereum-optimism/go-reviewers
/op-conductor @0x00101010 @zhwrd @mslipper
/op-conductor @ethereum-optimism/go-reviewers @ethereum-optimism/op-conductor

/cannon @ethereum-optimism/go-reviewers @ethereum-optimism/proofs
/op-dispute-mon @ethereum-optimism/go-reviewers @ethereum-optimism/proofs
/op-challenger @ethereum-optimism/go-reviewers @ethereum-optimism/proofs
/op-preimage @ethereum-optimism/go-reviewers @ethereum-optimism/proofs
/op-program @ethereum-optimism/go-reviewers @ethereum-optimism/proofs

# Ops
/.circleci @ethereum-optimism/monorepo-ops-reviewers
/.github @ethereum-optimism/monorepo-ops-reviewers
/ops @ethereum-optimism/monorepo-ops-reviewers
/docker-bake.hcl @ethereum-optimism/monorepo-ops-reviewers

# Misc
/proxyd @ethereum-optimism/infra-reviewers
/infra @ethereum-optimism/infra-reviewers
/specs @ethereum-optimism/contract-reviewers @ethereum-optimism/go-reviewers

# Don't add owners if only package.json is updated
/packages/*/package.json
/*/package.json

# JavaScript Releases
/packages/*/CHANGELOG.md @ethereum-optimism/release-managers
/*/CHANGELOG.md @ethereum-optimism/release-managers
# Contracts
/packages/contracts-bedrock @ethereum-optimism/contract-reviewers
4 changes: 0 additions & 4 deletions .npmrc

This file was deleted.

2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"recommendations": [
"editorconfig.editorconfig",
"juanblanco.solidity",
"nomicfoundation.hardhat-solidity",
"golang.go"
]
}
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ cannon-prestate: op-program cannon ## Generates prestate using cannon and op-pro
.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 mt --path op-program/bin/op-program-client.elf --out op-program/bin/prestate-mt.json --meta op-program/bin/meta-mt.json
./cannon/bin/cannon run --type mt --proof-at '=0' --stop-at '=1' --input op-program/bin/prestate-mt.json --meta op-program/bin/meta-mt.json --proof-fmt 'op-program/bin/%d-mt.json' --output ""
./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 run --type cannon-mt --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

Expand Down
5 changes: 3 additions & 2 deletions cannon/cmd/load_elf.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/ethereum-optimism/optimism/cannon/mipsevm"
"github.com/ethereum-optimism/optimism/cannon/mipsevm/multithreaded"
"github.com/ethereum-optimism/optimism/cannon/serialize"
"github.com/urfave/cli/v2"

"github.com/ethereum-optimism/optimism/cannon/mipsevm/program"
Expand Down Expand Up @@ -51,14 +52,14 @@ func LoadELF(ctx *cli.Context) error {
return program.LoadELF(f, singlethreaded.CreateInitialState)
}
writeState = func(path string, state mipsevm.FPVMState) error {
return jsonutil.WriteJSON[*singlethreaded.State](path, state.(*singlethreaded.State), OutFilePerm)
return serialize.Write[*singlethreaded.State](path, state.(*singlethreaded.State), OutFilePerm)
}
} else if vmType == mtVMType {
createInitialState = func(f *elf.File) (mipsevm.FPVMState, error) {
return program.LoadELF(f, multithreaded.CreateInitialState)
}
writeState = func(path string, state mipsevm.FPVMState) error {
return jsonutil.WriteJSON[*multithreaded.State](path, state.(*multithreaded.State), OutFilePerm)
return serialize.Write[*multithreaded.State](path, state.(*multithreaded.State), OutFilePerm)
}
} else {
return fmt.Errorf("invalid VM type: %q", vmType)
Expand Down
27 changes: 24 additions & 3 deletions cannon/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/ethereum-optimism/optimism/cannon/mipsevm/multithreaded"
"github.com/ethereum-optimism/optimism/cannon/serialize"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/log"
Expand Down Expand Up @@ -217,9 +218,29 @@ func (p *ProcessPreimageOracle) Close() error {
if p.cmd == nil {
return nil
}

tryWait := func(dur time.Duration) (bool, error) {
ctx, cancel := context.WithTimeout(context.Background(), dur)
defer cancel()
select {
case <-ctx.Done():
return false, nil
case err := <-p.waitErr:
return true, err
}
}
// Give the pre-image server time to exit cleanly before killing it.
time.Sleep(time.Second * 1)
if exited, err := tryWait(1 * time.Second); exited {
return err
}
// Politely ask the process to exit and give it some more time
_ = p.cmd.Process.Signal(os.Interrupt)
if exited, err := tryWait(30 * time.Second); exited {
return err
}

// Force the process to exit
_ = p.cmd.Process.Signal(os.Kill)
return <-p.waitErr
}

Expand Down Expand Up @@ -434,7 +455,7 @@ func Run(ctx *cli.Context) error {
}

if snapshotAt(state) {
if err := jsonutil.WriteJSON(fmt.Sprintf(snapshotFmt, step), state, OutFilePerm); err != nil {
if err := serialize.Write(fmt.Sprintf(snapshotFmt, step), state, OutFilePerm); err != nil {
return fmt.Errorf("failed to write state snapshot: %w", err)
}
}
Expand Down Expand Up @@ -491,7 +512,7 @@ func Run(ctx *cli.Context) error {
vm.Traceback()
}

if err := jsonutil.WriteJSON(ctx.Path(RunOutputFlag.Name), state, OutFilePerm); err != nil {
if err := serialize.Write(ctx.Path(RunOutputFlag.Name), state, OutFilePerm); err != nil {
return fmt.Errorf("failed to write state output: %w", err)
}
if debugInfoFile := ctx.Path(RunDebugInfoFlag.Name); debugInfoFile != "" {
Expand Down
6 changes: 3 additions & 3 deletions cannon/cmd/witness.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (

"github.com/ethereum-optimism/optimism/cannon/mipsevm"
"github.com/ethereum-optimism/optimism/cannon/mipsevm/multithreaded"
"github.com/ethereum-optimism/optimism/cannon/serialize"
"github.com/urfave/cli/v2"

"github.com/ethereum-optimism/optimism/cannon/mipsevm/singlethreaded"
"github.com/ethereum-optimism/optimism/op-service/jsonutil"
)

var (
Expand All @@ -33,12 +33,12 @@ func Witness(ctx *cli.Context) error {
if vmType, err := vmTypeFromString(ctx); err != nil {
return err
} else if vmType == cannonVMType {
state, err = jsonutil.LoadJSON[singlethreaded.State](input)
state, err = serialize.Load[singlethreaded.State](input)
if err != nil {
return fmt.Errorf("invalid input state (%v): %w", input, err)
}
} else if vmType == mtVMType {
state, err = jsonutil.LoadJSON[multithreaded.State](input)
state, err = serialize.Load[multithreaded.State](input)
if err != nil {
return fmt.Errorf("invalid input state (%v): %w", input, err)
}
Expand Down
3 changes: 3 additions & 0 deletions cannon/mipsevm/iface.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package mipsevm

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

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

type FPVMState interface {
serialize.Serializable

GetMemory() *memory.Memory

// GetHeap returns the current memory address at the top of the heap
Expand Down
42 changes: 42 additions & 0 deletions cannon/mipsevm/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,48 @@ func (m *Memory) SetMemoryRange(addr uint32, r io.Reader) error {
}
}

// Serialize writes the memory in a simple binary format which can be read again using Deserialize
// The format is a simple concatenation of fields, with prefixed item count for repeating items and using big endian
// encoding for numbers.
//
// len(PageCount) uint32
// For each page (order is arbitrary):
//
// page index uint32
// page Data [PageSize]byte
func (m *Memory) Serialize(out io.Writer) error {
if err := binary.Write(out, binary.BigEndian, uint32(m.PageCount())); err != nil {
return err
}
for pageIndex, page := range m.pages {
if err := binary.Write(out, binary.BigEndian, pageIndex); err != nil {
return err
}
if _, err := out.Write(page.Data[:]); err != nil {
return err
}
}
return nil
}

func (m *Memory) Deserialize(in io.Reader) error {
var pageCount uint32
if err := binary.Read(in, binary.BigEndian, &pageCount); err != nil {
return err
}
for i := uint32(0); i < pageCount; i++ {
var pageIndex uint32
if err := binary.Read(in, binary.BigEndian, &pageIndex); err != nil {
return err
}
page := m.AllocPage(pageIndex)
if _, err := io.ReadFull(in, page.Data[:]); err != nil {
return err
}
}
return nil
}

type memReader struct {
m *Memory
addr uint32
Expand Down
4 changes: 2 additions & 2 deletions cannon/mipsevm/multithreaded/instrumented.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package multithreaded
import (
"io"

"github.com/ethereum-optimism/optimism/cannon/serialize"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/log"

"github.com/ethereum-optimism/optimism/cannon/mipsevm"
"github.com/ethereum-optimism/optimism/cannon/mipsevm/exec"
"github.com/ethereum-optimism/optimism/cannon/mipsevm/program"
"github.com/ethereum-optimism/optimism/op-service/jsonutil"
)

type InstrumentedState struct {
Expand Down Expand Up @@ -41,7 +41,7 @@ func NewInstrumentedState(state *State, po mipsevm.PreimageOracle, stdOut, stdEr
}

func NewInstrumentedStateFromFile(stateFile string, po mipsevm.PreimageOracle, stdOut, stdErr io.Writer, log log.Logger) (*InstrumentedState, error) {
state, err := jsonutil.LoadJSON[State](stateFile)
state, err := serialize.Load[State](stateFile)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit d517107

Please sign in to comment.