Skip to content

Commit

Permalink
Merge tag 'v3.1.0' into release/v3.x-fh
Browse files Browse the repository at this point in the history
Arbitrum Nitro v3.1.0
  • Loading branch information
sduchesneau committed Jul 17, 2024
2 parents ee40e81 + 7d1d84c commit 2a4fa74
Show file tree
Hide file tree
Showing 93 changed files with 3,521 additions and 729 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/arbitrator-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Setup nodejs
uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '18'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- name: Setup nodejs
uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '18'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'

Expand Down Expand Up @@ -174,7 +174,7 @@ jobs:
run: |
packages=`go list ./...`
stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -timeout 60m -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -parallel=8 -tags=stylustest -run="TestProgramLong" > >(stdbuf -oL tee full.log | grep -vE "INFO|seal")
- name: Archive detailed run log
uses: actions/upload-artifact@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
- name: Setup nodejs
uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '18'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'

Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,52 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
context: .
tags: localhost:5000/nitro-node-dev:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: Start background nitro-testnode
shell: bash
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 "module-root=$module_root" >> "$GITHUB_OUTPUT"
echo -e "\x1b[1;34mWAVM module root:\x1b[0m $module_root"
- name: Upload WAVM machine as artifact
uses: actions/upload-artifact@v3
with:
name: wavm-machine-${{ steps.module-root.outputs.module-root }}
path: target/machines/latest/*
if-no-files-found: error

- name: Move cache
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Clear cache on failure
if: failure()
run: |
keys=(${{ runner.os }}-buildx- ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }})
for key in "${keys[@]}"; do
curl -X DELETE -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/actions/caches/$key"
done
>>>>>>> v3.1.0
42 changes: 32 additions & 10 deletions .github/workflows/merge-checks.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,42 @@
name: Merge Checks

on:
pull_request:
pull_request_target:
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"'"}'
26 changes: 26 additions & 0 deletions .github/workflows/submodule-pin-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

declare -Ar exceptions=(
[contracts]=origin/develop
[nitro-testnode]=origin/master

#TODO Rachel to check these are the intended branches.
[arbitrator/langs/c]=origin/vm-storage-cache
[arbitrator/tools/wasmer]=origin/adopt-v4.2.8
)

divergent=0
for mod in `git submodule --quiet foreach 'echo $name'`; do
branch=origin/HEAD
if [[ -v exceptions[$mod] ]]; then
branch=${exceptions[$mod]}
fi

if ! git -C $mod merge-base --is-ancestor HEAD $branch; then
echo $mod diverges from $branch
divergent=1
fi
done

exit $divergent

21 changes: 21 additions & 0 deletions .github/workflows/submodule-pin-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Submodule Pin Check

on:
pull_request:
branches: [ master ]
types: [synchronize, opened, reopened]

jobs:
submodule-pin-check:
name: Submodule Pin Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive

- name: Check all submodules are ancestors of origin/HEAD or configured branch
run: ${{ github.workspace }}/.github/workflows/submodule-pin-check.sh

52 changes: 27 additions & 25 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:16-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 @@ -205,8 +205,9 @@ COPY ./scripts/download-machine.sh .
#RUN ./download-machine.sh consensus-v11.1 0x68e4fe5023f792d4ef584796c84d710303a5e12ea02d6e37e2b5e9c4332507c4
#RUN ./download-machine.sh consensus-v20 0x8b104a2e80ac6165dc58b9048de12f301d70b02a0ab51396c22b4b4b802a16a4
RUN ./download-machine.sh consensus-v30 0xb0de9cb89e4d944ae6023a3b62276e54804c242fd8c4c2d8e6cc4450f5fa8b1b && true
RUN ./download-machine.sh consensus-v31 0x260f5fa5c3176a856893642e149cf128b5a8de9f828afec8d11184415dd8dc69

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 +234,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 All @@ -255,7 +256,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get install -y \
ca-certificates \
wabt && \
wabt \
sysstat && \
/usr/sbin/update-ca-certificates && \
useradd -s /bin/bash user && \
mkdir -p /home/user/l1keystore && \
Expand All @@ -270,9 +272,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 @@ -292,7 +294,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 @@ -304,7 +306,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 @@ -328,5 +330,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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ test-go-deps: \
build-replay-env \
$(stylus_test_wasms) \
$(arbitrator_stylus_lib) \
$(arbitrator_generated_header) \
$(patsubst %,$(arbitrator_cases)/%.wasm, global-state read-inboxmsg-10 global-state-wrapper const)

build-prover-header: $(arbitrator_generated_header)
Expand Down
2 changes: 1 addition & 1 deletion arbitrator/langs/bf
Submodule bf updated 1 files
+2 −2 README.md
5 changes: 4 additions & 1 deletion arbitrator/prover/src/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,10 @@ impl<'a> WasmBinary<'a> {
cached_init = cached_init.saturating_add(data_len.saturating_mul(75244) / 100_000);
cached_init = cached_init.saturating_add(footprint as u64 * 5);

let mut init = cached_init;
let mut init: u64 = 0;
if compile.version == 1 {
init = cached_init; // in version 1 cached cost is part of init cost
}
init = init.saturating_add(funcs.saturating_mul(8252) / 1000);
init = init.saturating_add(type_len.saturating_mul(1059) / 1000);
init = init.saturating_add(wasm_len.saturating_mul(1286) / 10_000);
Expand Down
Loading

0 comments on commit 2a4fa74

Please sign in to comment.