Skip to content

Commit

Permalink
Merge branch 'develop' into k0621/sec-90-fd-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jun 23, 2023
2 parents 5ce5bbd + 505751c commit cda9d84
Show file tree
Hide file tree
Showing 143 changed files with 4,538 additions and 5,154 deletions.
5 changes: 2 additions & 3 deletions cannon/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ And as it executes each step, it can optionally produce the witness data for the
The Cannon CLI is used to load a program into an initial state,
transition it N steps quickly without witness generation, and 1 step while producing a witness.

`mipsevm` is backed by the Unicorn emulator, but instrumented for proof generation,
and handles delay-slots by isolating each individual instruction and tracking `nextPC`
to emulate the delayed `PC` changes after delay-slot execution.
`mipsevm` is instrumented for proof generation and handles delay-slots by isolating each individual instruction
and tracking `nextPC` to emulate the delayed `PC` changes after delay-slot execution.

## Witness Data

Expand Down
4 changes: 2 additions & 2 deletions cannon/mipsevm/evm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestEVM(t *testing.T) {
// TODO: maybe more readable to decode the evmPost state, and do attribute-wise comparison.
uniPost := us.state.EncodeWitness()
require.Equal(t, hexutil.Bytes(uniPost).String(), hexutil.Bytes(evmPost).String(),
"unicorn produced different state than EVM")
"mipsevm produced different state than EVM")
}
require.Equal(t, uint32(endAddr), state.PC, "must reach end")
// inspect test result
Expand Down Expand Up @@ -175,7 +175,7 @@ func TestHelloEVM(t *testing.T) {
// TODO: maybe more readable to decode the evmPost state, and do attribute-wise comparison.
uniPost := us.state.EncodeWitness()
require.Equal(t, hexutil.Bytes(uniPost).String(), hexutil.Bytes(evmPost).String(),
"unicorn produced different state than EVM")
"mipsevm produced different state than EVM")
}
end := time.Now()
delta := end.Sub(start)
Expand Down
3 changes: 1 addition & 2 deletions cannon/mipsevm/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
)

// Note: 2**12 = 4 KiB, the minimum page-size in Unicorn for mmap
// as well as the Go runtime min phys page size.
// Note: 2**12 = 4 KiB, the min phys page size in the Go runtime.
const (
PageAddrSize = 12
PageKeySize = 32 - PageAddrSize
Expand Down
9 changes: 0 additions & 9 deletions cannon/mipsevm/mips.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,6 @@ func (m *InstrumentedState) handleSyscall() error {
v0 = a0
//fmt.Printf("mmap hint 0x%x size 0x%x\n", v0, sz)
}
// Go does this thing where it first gets memory with PROT_NONE,
// and then mmaps with a hint with prot=3 (PROT_READ|WRITE).
// We can ignore the NONE case, to avoid duplicate/overlapping mmap calls to unicorn.
//prot := a2
//if prot != 0 {
// if err := mu.MemMap(uint64(v0), uint64(sz)); err != nil {
// log.Fatalf("mmap fail: %v", err)
// }
//}
case 4045: // brk
v0 = 0x40000000
case 4120: // clone (not supported)
Expand Down
22 changes: 16 additions & 6 deletions endpoint-monitor/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
FROM golang:1.18.0-alpine3.15 as builder
FROM golang:1.19.9-alpine3.16 as builder

COPY ./endpoint-monitor /app

WORKDIR /app
RUN apk --no-cache add make jq bash git alpine-sdk

COPY ./endpoint-monitor /app/endpoint-monitor
COPY ./op-service /app/op-service
COPY ./op-node /app/op-node
COPY ./go.mod /app/go.mod
COPY ./go.sum /app/go.sum

COPY ./.git /app/.git

WORKDIR /app/endpoint-monitor

RUN go mod download

RUN make build

FROM alpine:3.15
FROM alpine:3.16
RUN apk --no-cache add ca-certificates

RUN addgroup -S app && adduser -S app -G app
USER app
WORKDIR /app

COPY --from=builder /app/bin/endpoint-monitor /app
COPY --from=builder /app/endpoint-monitor/bin/endpoint-monitor /app

ENTRYPOINT ["/app/endpoint-monitor"]
2 changes: 1 addition & 1 deletion endpoint-monitor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The endpoint-monitor runs websocket checks on edge-proxyd endpoints and downstre

## Setup

Install go1.18
Install go1.19

```bash
make build
Expand Down
2 changes: 1 addition & 1 deletion endpoint-monitor/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

oplog "github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum/go-ethereum/log"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"

endpointMonitor "github.com/ethereum-optimism/optimism/endpoint-monitor"
)
Expand Down
35 changes: 19 additions & 16 deletions endpoint-monitor/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
opservice "github.com/ethereum-optimism/optimism/op-service"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

type ProviderConfig struct {
Expand All @@ -24,24 +24,27 @@ const (
)

func CLIFlags(envPrefix string) []cli.Flag {
prefixEnvVars := func(name string) []string {
return opservice.PrefixEnvVar(envPrefix, name)
}
flags := []cli.Flag{
cli.StringSliceFlag{
&cli.StringSliceFlag{
Name: ProvidersFlagName,
Usage: "List of providers",
Required: true,
EnvVar: opservice.PrefixEnvVar(envPrefix, "PROVIDERS"),
EnvVars: prefixEnvVars("PROVIDERS"),
},
cli.DurationFlag{
Name: CheckIntervalFlagName,
Usage: "Check interval duration",
Value: 5 * time.Minute,
EnvVar: opservice.PrefixEnvVar(envPrefix, "CHECK_INTERVAL"),
&cli.DurationFlag{
Name: CheckIntervalFlagName,
Usage: "Check interval duration",
Value: 5 * time.Minute,
EnvVars: prefixEnvVars("CHECK_INTERVAL"),
},
cli.DurationFlag{
Name: CheckDurationFlagName,
Usage: "Check duration",
Value: 4 * time.Minute,
EnvVar: opservice.PrefixEnvVar(envPrefix, "CHECK_DURATION"),
&cli.DurationFlag{
Name: CheckDurationFlagName,
Usage: "Check duration",
Value: 4 * time.Minute,
EnvVars: prefixEnvVars("CHECK_DURATION"),
},
}
flags = append(flags, opmetrics.CLIFlags(envPrefix)...)
Expand Down Expand Up @@ -73,9 +76,9 @@ func (c Config) Check() error {

func NewConfig(ctx *cli.Context) Config {
return Config{
Providers: ctx.GlobalStringSlice(ProvidersFlagName),
CheckInterval: ctx.GlobalDuration(CheckIntervalFlagName),
CheckDuration: ctx.GlobalDuration(CheckDurationFlagName),
Providers: ctx.StringSlice(ProvidersFlagName),
CheckInterval: ctx.Duration(CheckIntervalFlagName),
CheckDuration: ctx.Duration(CheckDurationFlagName),
LogConfig: oplog.ReadCLIConfig(ctx),
MetricsConfig: opmetrics.ReadCLIConfig(ctx),
}
Expand Down
6 changes: 3 additions & 3 deletions endpoint-monitor/endpoint_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"

"github.com/ethereum-optimism/optimism/l2geth/core/types"
"github.com/ethereum-optimism/optimism/l2geth/ethclient"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
)

var (
Expand Down
42 changes: 0 additions & 42 deletions endpoint-monitor/go.mod

This file was deleted.

Loading

0 comments on commit cda9d84

Please sign in to comment.