Skip to content

Commit

Permalink
Merge branch 'master' into add-ci-submodule-pin-check
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan-Wilson authored Jul 10, 2024
2 parents 919b737 + de3dcff commit 70d64f6
Show file tree
Hide file tree
Showing 15 changed files with 1,021 additions and 148 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,20 @@ jobs:
run: |
cd nitro-testnode
./test-node.bash --init --dev &
- name: Wait for rpc to come up
shell: bash
run: |
${{ github.workspace }}/.github/workflows/waitForNitro.sh
- name: Print WAVM module root
id: module-root
run: |
# Unfortunately, `docker cp` seems to always result in a "permission denied"
# We work around this by piping a tarball through stdout
docker run --rm --entrypoint tar localhost:5000/nitro-node-dev:latest -cf - target/machines/latest | tar xf -
module_root="$(cat "target/machines/latest/module-root.txt")"
echo "name=module-root=$module_root" >> $GITHUB_STATE
echo "module-root=$module_root" >> "$GITHUB_OUTPUT"
echo -e "\x1b[1;34mWAVM module root:\x1b[0m $module_root"
- name: Upload WAVM machine as artifact
Expand Down
40 changes: 31 additions & 9 deletions .github/workflows/merge-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,38 @@ on:
branches: [ master ]
types: [synchronize, opened, reopened, labeled, unlabeled]

permissions:
statuses: write

jobs:
design-approved-check:
if: ${{ !contains(github.event.*.labels.*.name, 'design-approved') }}
name: Design Approved Check
check-design-approved:
name: Check if Design Approved
runs-on: ubuntu-latest
steps:
- name: Check for design-approved label
- name: Check if design approved and update status
run: |
echo "Pull request is missing the 'design-approved' label"
echo "This workflow fails so that the pull request cannot be merged"
exit 1
set -x pipefail
status_state="pending"
if ${{ contains(github.event.*.labels.*.name, 'design-approved') }}; then
status_state="success"
else
resp="$(curl -sSL --fail-with-body \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/commits/${{ github.event.pull_request.head.sha }}/statuses")"
if ! jq -e '.[] | select(.context == "Design Approved Check")' > /dev/null <<< "$resp"; then
# Design not approved yet and no status exists
# Keep it without a status to keep the green checkmark appearing
# Otherwise, the commit and PR's CI will appear to be indefinitely pending
# Merging will still be blocked until the required status appears
exit 0
fi
fi
curl -sSL --fail-with-body \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ github.event.pull_request.head.sha }}" \
-d '{"context":"Design Approved Check","state":"'"$status_state"'"}'
48 changes: 24 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:bookworm-slim as brotli-wasm-builder
FROM debian:bookworm-slim AS brotli-wasm-builder
WORKDIR /workspace
RUN apt-get update && \
apt-get install -y cmake make git lbzip2 python3 xz-utils && \
Expand All @@ -10,21 +10,21 @@ COPY scripts/build-brotli.sh scripts/
COPY brotli brotli
RUN cd emsdk && . ./emsdk_env.sh && cd .. && ./scripts/build-brotli.sh -w -t /workspace/install/

FROM scratch as brotli-wasm-export
FROM scratch AS brotli-wasm-export
COPY --from=brotli-wasm-builder /workspace/install/ /

FROM debian:bookworm-slim as brotli-library-builder
FROM debian:bookworm-slim AS brotli-library-builder
WORKDIR /workspace
COPY scripts/build-brotli.sh scripts/
COPY brotli brotli
RUN apt-get update && \
apt-get install -y cmake make gcc git && \
./scripts/build-brotli.sh -l -t /workspace/install/

FROM scratch as brotli-library-export
FROM scratch AS brotli-library-export
COPY --from=brotli-library-builder /workspace/install/ /

FROM node:18-bookworm-slim as contracts-builder
FROM node:18-bookworm-slim AS contracts-builder
RUN apt-get update && \
apt-get install -y git python3 make g++ curl
RUN curl -L https://foundry.paradigm.xyz | bash && . ~/.bashrc && ~/.foundry/bin/foundryup
Expand All @@ -35,11 +35,11 @@ COPY contracts contracts/
COPY Makefile .
RUN . ~/.bashrc && NITRO_BUILD_IGNORE_TIMESTAMPS=1 make build-solidity

FROM debian:bookworm-20231218 as wasm-base
FROM debian:bookworm-20231218 AS wasm-base
WORKDIR /workspace
RUN apt-get update && apt-get install -y curl build-essential=12.9

FROM wasm-base as wasm-libs-builder
FROM wasm-base AS wasm-libs-builder
# clang / lld used by soft-float wasm
RUN apt-get update && \
apt-get install -y clang=1:14.0-55.7~deb12u1 lld=1:14.0-55.7~deb12u1 wabt
Expand All @@ -59,10 +59,10 @@ COPY --from=brotli-wasm-export / target/
RUN apt-get update && apt-get install -y cmake
RUN . ~/.cargo/env && NITRO_BUILD_IGNORE_TIMESTAMPS=1 RUSTFLAGS='-C symbol-mangling-version=v0' make build-wasm-libs

FROM scratch as wasm-libs-export
FROM scratch AS wasm-libs-export
COPY --from=wasm-libs-builder /workspace/ /

FROM wasm-base as wasm-bin-builder
FROM wasm-base AS wasm-bin-builder
# pinned go version
RUN curl -L https://golang.org/dl/go1.21.10.linux-`dpkg --print-architecture`.tar.gz | tar -C /usr/local -xzf -
COPY ./Makefile ./go.mod ./go.sum ./
Expand Down Expand Up @@ -91,7 +91,7 @@ COPY --from=contracts-builder workspace/contracts/node_modules/@offchainlabs/upg
COPY --from=contracts-builder workspace/.make/ .make/
RUN PATH="$PATH:/usr/local/go/bin" NITRO_BUILD_IGNORE_TIMESTAMPS=1 make build-wasm-bin

FROM rust:1.75-slim-bookworm as prover-header-builder
FROM rust:1.75-slim-bookworm AS prover-header-builder
WORKDIR /workspace
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
Expand All @@ -113,10 +113,10 @@ COPY brotli brotli
RUN apt-get update && apt-get install -y cmake
RUN NITRO_BUILD_IGNORE_TIMESTAMPS=1 make build-prover-header

FROM scratch as prover-header-export
FROM scratch AS prover-header-export
COPY --from=prover-header-builder /workspace/target/ /

FROM rust:1.75-slim-bookworm as prover-builder
FROM rust:1.75-slim-bookworm AS prover-builder
WORKDIR /workspace
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
Expand Down Expand Up @@ -156,10 +156,10 @@ RUN NITRO_BUILD_IGNORE_TIMESTAMPS=1 make build-prover-lib
RUN NITRO_BUILD_IGNORE_TIMESTAMPS=1 make build-prover-bin
RUN NITRO_BUILD_IGNORE_TIMESTAMPS=1 make build-jit

FROM scratch as prover-export
FROM scratch AS prover-export
COPY --from=prover-builder /workspace/target/ /

FROM debian:bookworm-slim as module-root-calc
FROM debian:bookworm-slim AS module-root-calc
WORKDIR /workspace
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
Expand All @@ -181,7 +181,7 @@ COPY ./solgen ./solgen
COPY ./contracts ./contracts
RUN NITRO_BUILD_IGNORE_TIMESTAMPS=1 make build-replay-env

FROM debian:bookworm-slim as machine-versions
FROM debian:bookworm-slim AS machine-versions
RUN apt-get update && apt-get install -y unzip wget curl
WORKDIR /workspace/machines
# Download WAVM machines
Expand All @@ -206,7 +206,7 @@ COPY ./scripts/download-machine.sh .
#RUN ./download-machine.sh consensus-v20 0x8b104a2e80ac6165dc58b9048de12f301d70b02a0ab51396c22b4b4b802a16a4
RUN ./download-machine.sh consensus-v30 0xb0de9cb89e4d944ae6023a3b62276e54804c242fd8c4c2d8e6cc4450f5fa8b1b && true

FROM golang:1.21.10-bookworm as node-builder
FROM golang:1.21.10-bookworm AS node-builder
WORKDIR /workspace
ARG version=""
ARG datetime=""
Expand All @@ -233,17 +233,17 @@ RUN mkdir -p target/bin
COPY .nitro-tag.txt /nitro-tag.txt
RUN NITRO_BUILD_IGNORE_TIMESTAMPS=1 make build

FROM node-builder as fuzz-builder
FROM node-builder AS fuzz-builder
RUN mkdir fuzzers/
RUN ./scripts/fuzz.bash --build --binary-path /workspace/fuzzers/

FROM debian:bookworm-slim as nitro-fuzzer
FROM debian:bookworm-slim AS nitro-fuzzer
COPY --from=fuzz-builder /workspace/fuzzers/*.fuzz /usr/local/bin/
COPY ./scripts/fuzz.bash /usr/local/bin
RUN mkdir /fuzzcache
ENTRYPOINT [ "/usr/local/bin/fuzz.bash", "FuzzStateTransition", "--binary-path", "/usr/local/bin/", "--fuzzcache-path", "/fuzzcache" ]

FROM debian:bookworm-slim as nitro-node-slim
FROM debian:bookworm-slim AS nitro-node-slim
WORKDIR /home/user
COPY --from=node-builder /workspace/target/bin/nitro /usr/local/bin/
COPY --from=node-builder /workspace/target/bin/relay /usr/local/bin/
Expand Down Expand Up @@ -271,9 +271,9 @@ USER user
WORKDIR /home/user/
ENTRYPOINT [ "/usr/local/bin/nitro" ]

FROM offchainlabs/nitro-node:v2.3.4-rc.5-b4cc111 as nitro-legacy
FROM offchainlabs/nitro-node:v2.3.4-rc.5-b4cc111 AS nitro-legacy

FROM nitro-node-slim as nitro-node
FROM nitro-node-slim AS nitro-node
USER root
COPY --from=prover-export /bin/jit /usr/local/bin/
COPY --from=node-builder /workspace/target/bin/daserver /usr/local/bin/
Expand All @@ -293,7 +293,7 @@ ENTRYPOINT [ "/usr/local/bin/nitro" , "--validation.wasm.allowed-wasm-module-roo

USER user

FROM nitro-node as nitro-node-validator
FROM nitro-node AS nitro-node-validator
USER root
COPY --from=nitro-legacy /usr/local/bin/nitro-val /home/user/nitro-legacy/bin/nitro-val
COPY --from=nitro-legacy /usr/local/bin/jit /home/user/nitro-legacy/bin/jit
Expand All @@ -305,7 +305,7 @@ COPY scripts/split-val-entry.sh /usr/local/bin
ENTRYPOINT [ "/usr/local/bin/split-val-entry.sh" ]
USER user

FROM nitro-node-validator as nitro-node-dev
FROM nitro-node-validator AS nitro-node-dev
USER root
# Copy in latest WASM module root
RUN rm -f /home/user/target/machines/latest
Expand All @@ -329,5 +329,5 @@ RUN export DEBIAN_FRONTEND=noninteractive && \

USER user

FROM nitro-node as nitro-node-default
FROM nitro-node AS nitro-node-default
# Just to ensure nitro-node-dist is default
5 changes: 4 additions & 1 deletion broadcastclient/broadcastclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"

"github.com/offchainlabs/nitro/arbutil"
m "github.com/offchainlabs/nitro/broadcaster/message"
"github.com/offchainlabs/nitro/util/contracts"
Expand Down Expand Up @@ -292,6 +291,10 @@ func (bc *BroadcastClient) connect(ctx context.Context, nextSeqNum arbutil.Messa
return nil, err
}
if err != nil {
connectionRejectedError := &ws.ConnectionRejectedError{}
if errors.As(err, &connectionRejectedError) && connectionRejectedError.StatusCode() == 429 {
log.Error("rate limit exceeded, please run own local relay because too many nodes are connecting to feed from same IP address", "err", err)
}
return nil, fmt.Errorf("broadcast client unable to connect: %w", err)
}
if config.RequireChainId && !foundChainId {
Expand Down
61 changes: 0 additions & 61 deletions cmd/genericconf/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import (

flag "github.com/spf13/pflag"

"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p/enode"
)

type HTTPConfig struct {
Expand Down Expand Up @@ -189,65 +187,6 @@ func AuthRPCConfigAddOptions(prefix string, f *flag.FlagSet) {
f.StringSlice(prefix+".api", AuthRPCConfigDefault.API, "APIs offered over the AUTH-RPC interface")
}

type P2PConfig struct {
ListenAddr string `koanf:"listen-addr"`
NoDial bool `koanf:"no-dial"`
NoDiscovery bool `koanf:"no-discovery"`
MaxPeers int `koanf:"max-peers"`
DiscoveryV5 bool `koanf:"discovery-v5"`
DiscoveryV4 bool `koanf:"discovery-v4"`
Bootnodes []string `koanf:"bootnodes"`
BootnodesV5 []string `koanf:"bootnodes-v5"`
}

func (p P2PConfig) Apply(stackConf *node.Config) {
stackConf.P2P.ListenAddr = p.ListenAddr
stackConf.P2P.NoDial = p.NoDial
stackConf.P2P.NoDiscovery = p.NoDiscovery
stackConf.P2P.MaxPeers = p.MaxPeers
stackConf.P2P.DiscoveryV5 = p.DiscoveryV5
stackConf.P2P.DiscoveryV4 = p.DiscoveryV4
stackConf.P2P.BootstrapNodes = parseBootnodes(p.Bootnodes)
stackConf.P2P.BootstrapNodesV5 = parseBootnodes(p.BootnodesV5)
}

func parseBootnodes(urls []string) []*enode.Node {
nodes := make([]*enode.Node, 0, len(urls))
for _, url := range urls {
if url != "" {
node, err := enode.Parse(enode.ValidSchemes, url)
if err != nil {
log.Crit("Bootstrap URL invalid", "enode", url, "err", err)
return nil
}
nodes = append(nodes, node)
}
}
return nodes
}

var P2PConfigDefault = P2PConfig{
ListenAddr: "",
NoDial: true,
NoDiscovery: true,
MaxPeers: 50,
DiscoveryV5: false,
DiscoveryV4: false,
Bootnodes: []string{},
BootnodesV5: []string{},
}

func P2PConfigAddOptions(prefix string, f *flag.FlagSet) {
f.String(prefix+".listen-addr", P2PConfigDefault.ListenAddr, "P2P listen address")
f.Bool(prefix+".no-dial", P2PConfigDefault.NoDial, "P2P no dial")
f.Bool(prefix+".no-discovery", P2PConfigDefault.NoDiscovery, "P2P no discovery")
f.Int(prefix+".max-peers", P2PConfigDefault.MaxPeers, "P2P max peers")
f.Bool(prefix+".discovery-v5", P2PConfigDefault.DiscoveryV5, "P2P discovery v5")
f.Bool(prefix+".discovery-v4", P2PConfigDefault.DiscoveryV4, "P2P discovery v4")
f.StringSlice(prefix+".bootnodes", P2PConfigDefault.Bootnodes, "P2P bootnodes")
f.StringSlice(prefix+".bootnodes-v5", P2PConfigDefault.BootnodesV5, "P2P bootnodes v5")
}

type MetricsServerConfig struct {
Addr string `koanf:"addr"`
Port int `koanf:"port"`
Expand Down
3 changes: 0 additions & 3 deletions cmd/nitro-val/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type ValidationNodeConfig struct {
HTTP genericconf.HTTPConfig `koanf:"http"`
WS genericconf.WSConfig `koanf:"ws"`
IPC genericconf.IPCConfig `koanf:"ipc"`
P2P genericconf.P2PConfig `koanf:"p2p"`
Auth genericconf.AuthRPCConfig `koanf:"auth"`
Metrics bool `koanf:"metrics"`
MetricsServer genericconf.MetricsServerConfig `koanf:"metrics-server"`
Expand Down Expand Up @@ -67,7 +66,6 @@ var ValidationNodeConfigDefault = ValidationNodeConfig{
HTTP: HTTPConfigDefault,
WS: WSConfigDefault,
IPC: IPCConfigDefault,
P2P: genericconf.P2PConfigDefault,
Auth: genericconf.AuthRPCConfigDefault,
Metrics: false,
MetricsServer: genericconf.MetricsServerConfigDefault,
Expand All @@ -87,7 +85,6 @@ func ValidationNodeConfigAddOptions(f *flag.FlagSet) {
genericconf.WSConfigAddOptions("ws", f)
genericconf.IPCConfigAddOptions("ipc", f)
genericconf.AuthRPCConfigAddOptions("auth", f)
genericconf.P2PConfigAddOptions("p2p", f)
f.Bool("metrics", ValidationNodeConfigDefault.Metrics, "enable metrics")
genericconf.MetricsServerAddOptions("metrics-server", f)
f.Bool("pprof", ValidationNodeConfigDefault.PProf, "enable pprof")
Expand Down
1 change: 0 additions & 1 deletion cmd/nitro-val/nitro_val.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func mainImpl() int {
nodeConfig.WS.Apply(&stackConf)
nodeConfig.Auth.Apply(&stackConf)
nodeConfig.IPC.Apply(&stackConf)
nodeConfig.P2P.Apply(&stackConf)
vcsRevision, strippedRevision, vcsTime := confighelpers.GetVersion()
stackConf.Version = strippedRevision

Expand Down
Loading

0 comments on commit 70d64f6

Please sign in to comment.