Skip to content

Commit

Permalink
Merge branch 'master' into log-connection-error
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshvanahalli authored Sep 28, 2023
2 parents 520bdb9 + 15ea478 commit bbc046f
Show file tree
Hide file tree
Showing 157 changed files with 6,177 additions and 1,970 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/arbitrator-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ run-name: Arbitrator CI triggered from @${{ github.actor }} of ${{ github.head_r

on:
workflow_dispatch:
merge_group:
pull_request:
paths:
- 'arbitrator/**'
Expand All @@ -24,7 +25,7 @@ jobs:
runs-on: ubuntu-8
steps:
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v3
with:
submodules: recursive

Expand All @@ -36,12 +37,12 @@ jobs:
sudo ln -s /usr/bin/wasm-ld-14 /usr/local/bin/wasm-ld
- name: Install go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.20.x

- name: Setup nodejs
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'
Expand Down Expand Up @@ -119,7 +120,7 @@ jobs:

- name: Setup emsdk
if: steps.cache-cbrotli.outputs.cache-hit != 'true'
uses: mymindstorm/setup-emsdk@v11
uses: mymindstorm/setup-emsdk@v12
with:
# Make sure to set a version number!
version: 3.1.6
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/arbitrator-skip-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Arbitrator skip CI
run-name: Arbitrator skip CI triggered from @${{ github.actor }} of ${{ github.head_ref }}

on:
merge_group:
pull_request:
paths-ignore:
- 'arbitrator/**'
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ run-name: Go tests CI triggered from @${{ github.actor }} of ${{ github.head_ref

on:
workflow_dispatch:
merge_group:
pull_request:
push:
branches:
Expand All @@ -28,22 +29,22 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: true

- name: Install dependencies
run: sudo apt update && sudo apt install -y wabt gotestsum

- name: Setup nodejs
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'

- name: Install go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.20.x

Expand Down Expand Up @@ -129,6 +130,10 @@ jobs:
version: latest
skip-go-installation: true
skip-pkg-cache: true
- name: Custom Lint
run: |
go run ./linter/koanf ./...
go run ./linter/pointercheck ./...
- name: Set environment variables
run: |
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ name: "CodeQL"
on:
push:
branches: [ "master" ]
merge_group:
branches: [ "master" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
Expand All @@ -23,6 +25,7 @@ on:
jobs:
analyze:
name: Analyze
if: github.repository == 'OffchainLabs/nitro' # don't run in any forks without "Advanced Security" enabled
runs-on: ubuntu-8
permissions:
actions: read
Expand Down Expand Up @@ -59,14 +62,14 @@ jobs:
config-file: ./.github/codeql/codeql-config.yml

- name: Setup nodejs
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'

- name: Install go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.20.x

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ run-name: Docker build CI triggered from @${{ github.actor }} of ${{ github.head

on:
workflow_dispatch:
merge_group:
pull_request:
push:
branches:
Expand All @@ -22,7 +23,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: recursive

Expand Down Expand Up @@ -65,7 +66,7 @@ jobs:
# 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 "::set-output name=module-root::$module_root"
echo "name=module-root=$module_root" >> $GITHUB_STATE
echo -e "\x1b[1;34mWAVM module root:\x1b[0m $module_root"
- name: Upload WAVM machine as artifact
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ solgen/go/
target/
yarn-error.log
local/
testdata
system_tests/test-data/*
system_tests/testdata/*
arbos/testdata/*
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ 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/
COPY --from=node-builder /workspace/target/bin/nitro-val /usr/local/bin/
COPY --from=node-builder /workspace/target/bin/seq-coordinator-manager /usr/local/bin/
COPY --from=machine-versions /workspace/machines /home/user/target/machines
USER root
RUN export DEBIAN_FRONTEND=noninteractive && \
Expand Down
15 changes: 10 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# have to update an existing file. So - for docker, convert all dependencies
# to order-only dependencies (timestamps ignored).
# WARNING: when using this trick, you cannot use the $< automatic variable

ifeq ($(origin NITRO_BUILD_IGNORE_TIMESTAMPS),undefined)
DEP_PREDICATE:=
ORDER_ONLY_PREDICATE:=|
Expand Down Expand Up @@ -87,7 +88,7 @@ push: lint test-go .make/fmt
all: build build-replay-env test-gen-proofs
@touch .make/all

build: $(patsubst %,$(output_root)/bin/%, nitro deploy relay daserver datool seq-coordinator-invalidate nitro-val)
build: $(patsubst %,$(output_root)/bin/%, nitro deploy relay daserver datool seq-coordinator-invalidate nitro-val seq-coordinator-manager)
@printf $(done)

build-node-deps: $(go_source) build-prover-header build-prover-lib build-jit .make/solgen .make/cbrotli-lib
Expand Down Expand Up @@ -184,6 +185,9 @@ $(output_root)/bin/seq-coordinator-invalidate: $(DEP_PREDICATE) build-node-deps
$(output_root)/bin/nitro-val: $(DEP_PREDICATE) build-node-deps
go build $(GOLANG_PARAMS) -o $@ "$(CURDIR)/cmd/nitro-val"

$(output_root)/bin/seq-coordinator-manager: $(DEP_PREDICATE) build-node-deps
go build $(GOLANG_PARAMS) -o $@ "$(CURDIR)/cmd/seq-coordinator-manager"

# recompile wasm, but don't change timestamp unless files differ
$(replay_wasm): $(DEP_PREDICATE) $(go_source) .make/solgen
mkdir -p `dirname $(replay_wasm)`
Expand Down Expand Up @@ -303,6 +307,8 @@ contracts/test/prover/proofs/%.json: $(arbitrator_cases)/%.wasm $(arbitrator_pro
# strategic rules to minimize dependency building

.make/lint: $(DEP_PREDICATE) build-node-deps $(ORDER_ONLY_PREDICATE) .make
go run ./linter/koanf ./...
go run ./linter/pointercheck ./...
golangci-lint run --fix
yarn --cwd contracts solhint
@touch $@
Expand Down Expand Up @@ -345,10 +351,9 @@ contracts/test/prover/proofs/%.json: $(arbitrator_cases)/%.wasm $(arbitrator_pro
test -f target/lib-wasm/libbrotlidec-static.a || ./scripts/build-brotli.sh -w -d
@touch $@

.make/wasm-lib: $(DEP_PREDICATE) $(ORDER_ONLY_PREDICATE) .make
test -f arbitrator/wasm-libraries/soft-float/bindings32.o || ./scripts/build-brotli.sh -f -d -t .
test -f arbitrator/wasm-libraries/soft-float/bindings64.o || ./scripts/build-brotli.sh -f -d -t .
test -f arbitrator/wasm-libraries/soft-float/SoftFloat/build/Wasm-Clang/softfloat.a || ./scripts/build-brotli.sh -f -d -t .
.make/wasm-lib: $(DEP_PREDICATE) arbitrator/wasm-libraries/soft-float/SoftFloat/build/Wasm-Clang/softfloat.a $(ORDER_ONLY_PREDICATE) .make
test -f arbitrator/wasm-libraries/soft-float/bindings32.o || ./scripts/build-brotli.sh -f -d -t ..
test -f arbitrator/wasm-libraries/soft-float/bindings64.o || ./scripts/build-brotli.sh -f -d -t ..
@touch $@

.make:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<br />
<p align="center">
<a href="https://arbitrum.io/">
<img src="https://arbitrum.io/wp-content/uploads/2021/08/Arbitrum_Symbol-Full-color-White-background-768x840.png" alt="Logo" width="80" height="80">
<img src="https://arbitrum.io/assets/arbitrum/logo_color.png" alt="Logo" width="80" height="80">
</a>

<h3 align="center">Arbitrum Nitro</h3>
Expand All @@ -14,7 +14,7 @@

## About Arbitrum Nitro

<img src="https://arbitrum.io/wp-content/uploads/2021/08/Arbitrum_Symbol-Full-color-White-background-768x840.png" alt="Logo" width="80" height="80">
<img src="https://arbitrum.io/assets/arbitrum/logo_color.png" alt="Logo" width="80" height="80">

Nitro is the latest iteration of the Arbitrum technology. It is a fully integrated, complete
layer 2 optimistic rollup system, including fraud proofs, the sequencer, the token bridges,
Expand Down
6 changes: 3 additions & 3 deletions arbitrator/jit/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ pub fn wasm_write(mut env: WasmEnvMut, sp: u32) {
}

pub fn nanotime1(mut env: WasmEnvMut, sp: u32) {
let (sp, mut env) = GoStack::new(sp, &mut env);
let (sp, env) = GoStack::new(sp, &mut env);
env.go_state.time += env.go_state.time_interval;
sp.write_u64(0, env.go_state.time);
}

pub fn walltime(mut env: WasmEnvMut, sp: u32) {
let (sp, mut env) = GoStack::new(sp, &mut env);
let (sp, env) = GoStack::new(sp, &mut env);
env.go_state.time += env.go_state.time_interval;
sp.write_u64(0, env.go_state.time / 1_000_000_000);
sp.write_u32(1, (env.go_state.time % 1_000_000_000) as u32);
}

pub fn walltime1(mut env: WasmEnvMut, sp: u32) {
let (sp, mut env) = GoStack::new(sp, &mut env);
let (sp, env) = GoStack::new(sp, &mut env);
env.go_state.time += env.go_state.time_interval;
sp.write_u64(0, env.go_state.time / 1_000_000_000);
sp.write_u64(1, env.go_state.time % 1_000_000_000);
Expand Down
4 changes: 2 additions & 2 deletions arbitrator/jit/src/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,10 @@ pub fn js_value_index(mut env: WasmEnvMut, sp: u32) {

pub fn js_value_call(mut env: WasmEnvMut, sp: u32) -> MaybeEscape {
let Some(resume) = env.data().exports.resume.clone() else {
return Escape::failure(format!("wasmer failed to bind {}", "resume".red()))
return Escape::failure(format!("wasmer failed to bind {}", "resume".red()));
};
let Some(get_stack_pointer) = env.data().exports.get_stack_pointer.clone() else {
return Escape::failure(format!("wasmer failed to bind {}", "getsp".red()))
return Escape::failure(format!("wasmer failed to bind {}", "getsp".red()));
};
let sp = GoStack::simple(sp, &env);
let data = env.data_mut();
Expand Down
2 changes: 1 addition & 1 deletion arbitrator/prover/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ pub struct MachineState<'a> {
initial_hash: Bytes32,
}

pub type PreimageResolver = Arc<dyn Fn(u64, Bytes32) -> Option<CBytes>>;
pub type PreimageResolver = Arc<dyn Fn(u64, Bytes32) -> Option<CBytes> + Send + Sync>;

/// Wraps a preimage resolver to provide an easier API
/// and cache the last preimage retrieved.
Expand Down
7 changes: 7 additions & 0 deletions arbitrator/prover/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ impl From<&[u8]> for CBytes {
}
}

// There's no thread safety concerns for CBytes.
// This type is basically a Box<[u8]> (which is Send + Sync) with libc as an allocator.
// Any data races between threads are prevented by Rust borrowing rules,
// and the data isn't thread-local so there's no concern moving it between threads.
unsafe impl Send for CBytes {}
unsafe impl Sync for CBytes {}

#[derive(Serialize, Deserialize)]
#[serde(remote = "Type")]
enum RemoteType {
Expand Down
5 changes: 4 additions & 1 deletion arbitrator/wasm-libraries/go-stub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,10 @@ pub unsafe extern "C" fn wavm__go_after_run() {
while let Some(info) = state.times.pop() {
while state.pending_ids.contains(&info.id) {
TIME = std::cmp::max(TIME, info.time);
drop(state);
// Important: the current reference to state shouldn't be used after this resume call,
// as it might during the resume call the reference might be invalidated.
// That's why immediately after this resume call, we replace the reference
// with a new reference to TIMEOUT_STATE.
wavm_guest_call__resume();
state = TIMEOUT_STATE.get_or_insert_with(Default::default);
}
Expand Down
Loading

0 comments on commit bbc046f

Please sign in to comment.