Skip to content

Commit

Permalink
Merge branch 'master' into promise_exec_client
Browse files Browse the repository at this point in the history
  • Loading branch information
eljobe authored Jan 16, 2025
2 parents 53701a7 + 46d9938 commit aec3f68
Show file tree
Hide file tree
Showing 63 changed files with 924 additions and 352 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/arbitrator-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,22 @@ jobs:
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'

- name: Install rust stable
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 'stable'
components: 'llvm-tools-preview, rustfmt, clippy'

- name: Install rust nightly
uses: dtolnay/rust-toolchain@nightly
id: install-rust-nightly
with:
toolchain: 'nightly-2024-08-06'
toolchain: 'nightly-2024-10-06'
targets: 'wasm32-wasi, wasm32-unknown-unknown'
components: 'rust-src, rustfmt, clippy'

- name: Install rust stable
id: install-rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: '1.80.1'
targets: 'wasm32-wasi, wasm32-unknown-unknown'
components: 'llvm-tools-preview, rustfmt, clippy'

- name: Set STYLUS_NIGHTLY_VER environment variable
run: echo "STYLUS_NIGHTLY_VER=+$(rustup toolchain list | grep '^nightly' | head -n1 | cut -d' ' -f1)" >> "$GITHUB_ENV"

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,17 @@ jobs:
- name: Install rust stable
uses: dtolnay/rust-toolchain@stable
id: install-rust
with:
toolchain: 'stable'
toolchain: '1.80.1'
targets: 'wasm32-wasi, wasm32-unknown-unknown'
components: 'llvm-tools-preview, rustfmt, clippy'

- name: Install rust nightly
uses: dtolnay/rust-toolchain@nightly
id: install-rust-nightly
with:
toolchain: 'nightly-2024-08-06'
toolchain: 'nightly-2024-10-06'
targets: 'wasm32-wasi, wasm32-unknown-unknown'
components: 'rust-src, rustfmt, clippy'

Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ RUN rm -f /home/user/target/machines/latest
COPY --from=prover-export /bin/jit /usr/local/bin/
COPY --from=node-builder /workspace/target/bin/deploy /usr/local/bin/
COPY --from=node-builder /workspace/target/bin/seq-coordinator-invalidate /usr/local/bin/
COPY --from=node-builder /workspace/target/bin/mockexternalsigner /usr/local/bin/
COPY --from=module-root-calc /workspace/target/machines/latest/machine.wavm.br /home/user/target/machines/latest/
COPY --from=module-root-calc /workspace/target/machines/latest/until-host-io-state.bin /home/user/target/machines/latest/
COPY --from=module-root-calc /workspace/target/machines/latest/module-root.txt /home/user/target/machines/latest/
Expand Down
31 changes: 30 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ all: build build-replay-env test-gen-proofs
@touch .make/all

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

.PHONY: build-node-deps
Expand Down Expand Up @@ -314,6 +314,9 @@ $(output_root)/bin/daserver: $(DEP_PREDICATE) build-node-deps
$(output_root)/bin/datool: $(DEP_PREDICATE) build-node-deps
go build $(GOLANG_PARAMS) -o $@ "$(CURDIR)/cmd/datool"

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

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

Expand Down Expand Up @@ -440,54 +443,80 @@ $(stylus_test_dir)/%.wasm: $(stylus_test_dir)/%.b $(stylus_lang_bf)

$(stylus_test_keccak_wasm): $(stylus_test_keccak_src)
$(cargo_nightly) --manifest-path $< --release --config $(stylus_cargo)
wasm2wat $@ > $@.wat #removing reference types
wat2wasm $@.wat -o $@
@touch -c $@ # cargo might decide to not rebuild the binary

$(stylus_test_keccak-100_wasm): $(stylus_test_keccak-100_src)
$(cargo_nightly) --manifest-path $< --release --config $(stylus_cargo)
wasm2wat $@ > $@.wat #removing reference types
wat2wasm $@.wat -o $@
@touch -c $@ # cargo might decide to not rebuild the binary

$(stylus_test_fallible_wasm): $(stylus_test_fallible_src)
$(cargo_nightly) --manifest-path $< --release --config $(stylus_cargo)
wasm2wat $@ > $@.wat #removing reference types
wat2wasm $@.wat -o $@
@touch -c $@ # cargo might decide to not rebuild the binary

$(stylus_test_storage_wasm): $(stylus_test_storage_src)
$(cargo_nightly) --manifest-path $< --release --config $(stylus_cargo)
wasm2wat $@ > $@.wat #removing reference types
wat2wasm $@.wat -o $@
@touch -c $@ # cargo might decide to not rebuild the binary

$(stylus_test_multicall_wasm): $(stylus_test_multicall_src)
$(cargo_nightly) --manifest-path $< --release --config $(stylus_cargo)
wasm2wat $@ > $@.wat #removing reference types
wat2wasm $@.wat -o $@
@touch -c $@ # cargo might decide to not rebuild the binary

$(stylus_test_log_wasm): $(stylus_test_log_src)
$(cargo_nightly) --manifest-path $< --release --config $(stylus_cargo)
wasm2wat $@ > $@.wat #removing reference types
wat2wasm $@.wat -o $@
@touch -c $@ # cargo might decide to not rebuild the binary

$(stylus_test_create_wasm): $(stylus_test_create_src)
$(cargo_nightly) --manifest-path $< --release --config $(stylus_cargo)
wasm2wat $@ > $@.wat #removing reference types
wat2wasm $@.wat -o $@
@touch -c $@ # cargo might decide to not rebuild the binary

$(stylus_test_math_wasm): $(stylus_test_math_src)
$(cargo_nightly) --manifest-path $< --release --config $(stylus_cargo)
wasm2wat $@ > $@.wat #removing reference types
wat2wasm $@.wat -o $@
@touch -c $@ # cargo might decide to not rebuild the binary

$(stylus_test_evm-data_wasm): $(stylus_test_evm-data_src)
$(cargo_nightly) --manifest-path $< --release --config $(stylus_cargo)
wasm2wat $@ > $@.wat #removing reference types
wat2wasm $@.wat -o $@
@touch -c $@ # cargo might decide to not rebuild the binary

$(stylus_test_read-return-data_wasm): $(stylus_test_read-return-data_src)
$(cargo_nightly) --manifest-path $< --release --config $(stylus_cargo)
wasm2wat $@ > $@.wat #removing reference types
wat2wasm $@.wat -o $@
@touch -c $@ # cargo might decide to not rebuild the binary

$(stylus_test_sdk-storage_wasm): $(stylus_test_sdk-storage_src)
$(cargo_nightly) --manifest-path $< --release --config $(stylus_cargo)
wasm2wat $@ > $@.wat #removing reference types
wat2wasm $@.wat -o $@
@touch -c $@ # cargo might decide to not rebuild the binary

$(stylus_test_erc20_wasm): $(stylus_test_erc20_src)
$(cargo_nightly) --manifest-path $< --release --config $(stylus_cargo)
wasm2wat $@ > $@.wat #removing reference types
wat2wasm $@.wat -o $@
@touch -c $@ # cargo might decide to not rebuild the binary

$(stylus_test_hostio-test_wasm): $(stylus_test_hostio-test_src)
$(cargo_nightly) --manifest-path $< --release --config $(stylus_cargo)
wasm2wat $@ > $@.wat #removing reference types
wat2wasm $@.wat -o $@
@touch -c $@ # cargo might decide to not rebuild the binary

contracts/test/prover/proofs/float%.json: $(arbitrator_cases)/float%.wasm $(prover_bin) $(output_latest)/soft-float.wasm
Expand Down
4 changes: 2 additions & 2 deletions arbitrator/arbutil/src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,13 +595,13 @@ impl Display for OperatorCode {
}
}

impl<'a> From<Operator<'a>> for OperatorCode {
impl From<Operator<'_>> for OperatorCode {
fn from(op: Operator) -> Self {
OperatorCode::from(&op)
}
}

impl<'a> From<&Operator<'a>> for OperatorCode {
impl From<&Operator<'_>> for OperatorCode {
fn from(op: &Operator) -> Self {
use Operator as O;

Expand Down
2 changes: 1 addition & 1 deletion arbitrator/jit/src/caller_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl<'a> JitEnv<'a> for WasmEnvMut<'a> {
}
}

impl<'s> JitMemAccess<'s> {
impl JitMemAccess<'_> {
fn view(&self) -> MemoryView {
self.memory.view(&self.store)
}
Expand Down
2 changes: 1 addition & 1 deletion arbitrator/prover/src/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ pub fn parse<'a>(input: &'a [u8], path: &'_ Path) -> Result<WasmBinary<'a>> {
Ok(binary)
}

impl<'a> Debug for WasmBinary<'a> {
impl Debug for WasmBinary<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("WasmBinary")
.field("types", &self.types)
Expand Down
2 changes: 1 addition & 1 deletion arbitrator/prover/src/programs/counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub struct FuncCounter<'a> {
block: Vec<Operator<'a>>,
}

impl<'a> FuncCounter<'a> {
impl FuncCounter<'_> {
fn new(counters: Arc<Mutex<Vec<GlobalIndex>>>) -> Self {
let block = vec![];
Self { counters, block }
Expand Down
4 changes: 2 additions & 2 deletions arbitrator/prover/src/programs/depth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub struct FuncDepthChecker<'a> {
done: bool,
}

impl<'a> FuncDepthChecker<'a> {
impl FuncDepthChecker<'_> {
fn new(
global: GlobalIndex,
funcs: Arc<HashMap<FunctionIndex, FunctionType>>,
Expand Down Expand Up @@ -227,7 +227,7 @@ impl<'a> FuncMiddleware<'a> for FuncDepthChecker<'a> {
}
}

impl<'a> FuncDepthChecker<'a> {
impl FuncDepthChecker<'_> {
fn worst_case_depth(&self) -> Result<u32> {
use Operator::*;

Expand Down
3 changes: 2 additions & 1 deletion arbitrator/prover/src/programs/meter.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright 2022-2023, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
#![allow(clippy::needless_lifetimes)]

use crate::{
programs::{
Expand Down Expand Up @@ -122,7 +123,7 @@ pub struct FuncMeter<'a, F: OpcodePricer> {
sigs: Arc<SigMap>,
}

impl<'a, F: OpcodePricer> FuncMeter<'a, F> {
impl<F: OpcodePricer> FuncMeter<'_, F> {
fn new(
ink_global: GlobalIndex,
status_global: GlobalIndex,
Expand Down
6 changes: 3 additions & 3 deletions arbitrator/prover/src/programs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl ModuleMod for ModuleInfo {
fn drop_exports_and_names(&mut self, keep: &HashMap<&str, ExportKind>) {
self.exports.retain(|name, export| {
keep.get(name.as_str())
.map_or(false, |x| *x == (*export).into())
.is_some_and(|x| *x == (*export).into())
});
self.function_names.clear();
}
Expand All @@ -263,7 +263,7 @@ impl ModuleMod for ModuleInfo {
}
}

impl<'a> ModuleMod for WasmBinary<'a> {
impl ModuleMod for WasmBinary<'_> {
fn add_global(&mut self, name: &str, _ty: Type, init: GlobalInit) -> Result<GlobalIndex> {
let global = match init {
GlobalInit::I32Const(x) => Value::I32(x as u32),
Expand Down Expand Up @@ -364,7 +364,7 @@ impl<'a> ModuleMod for WasmBinary<'a> {

fn drop_exports_and_names(&mut self, keep: &HashMap<&str, ExportKind>) {
self.exports
.retain(|name, ty| keep.get(name.as_str()).map_or(false, |x| *x == ty.1));
.retain(|name, ty| keep.get(name.as_str()).is_some_and(|x| *x == ty.1));
self.names.functions.clear();
}

Expand Down
10 changes: 5 additions & 5 deletions arbitrator/stylus/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub struct HostioInfo<'a, D: DataReader, E: EvmApi<D>> {
pub start_ink: Ink,
}

impl<'a, D: DataReader, E: EvmApi<D>> HostioInfo<'a, D, E> {
impl<D: DataReader, E: EvmApi<D>> HostioInfo<'_, D, E> {
pub fn config(&self) -> StylusConfig {
self.config.expect("no config")
}
Expand All @@ -172,7 +172,7 @@ impl<'a, D: DataReader, E: EvmApi<D>> HostioInfo<'a, D, E> {
}
}

impl<'a, D: DataReader, E: EvmApi<D>> MeteredMachine for HostioInfo<'a, D, E> {
impl<D: DataReader, E: EvmApi<D>> MeteredMachine for HostioInfo<'_, D, E> {
fn ink_left(&self) -> MachineMeter {
let vm = self.env.meter();
match vm.status() {
Expand All @@ -188,21 +188,21 @@ impl<'a, D: DataReader, E: EvmApi<D>> MeteredMachine for HostioInfo<'a, D, E> {
}
}

impl<'a, D: DataReader, E: EvmApi<D>> GasMeteredMachine for HostioInfo<'a, D, E> {
impl<D: DataReader, E: EvmApi<D>> GasMeteredMachine for HostioInfo<'_, D, E> {
fn pricing(&self) -> PricingParams {
self.config().pricing
}
}

impl<'a, D: DataReader, E: EvmApi<D>> Deref for HostioInfo<'a, D, E> {
impl<D: DataReader, E: EvmApi<D>> Deref for HostioInfo<'_, D, E> {
type Target = WasmEnv<D, E>;

fn deref(&self) -> &Self::Target {
self.env
}
}

impl<'a, D: DataReader, E: EvmApi<D>> DerefMut for HostioInfo<'a, D, E> {
impl<D: DataReader, E: EvmApi<D>> DerefMut for HostioInfo<'_, D, E> {
fn deref_mut(&mut self) -> &mut Self::Target {
self.env
}
Expand Down
2 changes: 1 addition & 1 deletion arbitrator/stylus/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::{
use user_host_trait::UserHost;
use wasmer::{MemoryAccessError, WasmPtr};

impl<'a, DR, A> UserHost<DR> for HostioInfo<'a, DR, A>
impl<DR, A> UserHost<DR> for HostioInfo<'_, DR, A>
where
DR: DataReader,
A: EvmApi<DR>,
Expand Down
1 change: 1 addition & 0 deletions arbitrator/stylus/tests/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ target = "wasm32-unknown-unknown"
rustflags = [
"-C", "target-cpu=mvp",
"-C", "link-arg=-zstack-size=8192",
"-C", "target-feature=-reference-types",
# "-C", "link-arg=--export=__heap_base",
# "-C", "link-arg=--export=__data_end",
]
16 changes: 16 additions & 0 deletions arbnode/dataposter/data_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"github.com/ethereum/go-ethereum/signer/core/apitypes"

"github.com/offchainlabs/nitro/arbnode/dataposter/dbstorage"
"github.com/offchainlabs/nitro/arbnode/dataposter/externalsignertest"
"github.com/offchainlabs/nitro/arbnode/dataposter/noop"
redisstorage "github.com/offchainlabs/nitro/arbnode/dataposter/redis"
"github.com/offchainlabs/nitro/arbnode/dataposter/slice"
Expand Down Expand Up @@ -1297,6 +1298,21 @@ type ExternalSignerCfg struct {
InsecureSkipVerify bool `koanf:"insecure-skip-verify"`
}

func ExternalSignerTestCfg(addr common.Address, url string) (*ExternalSignerCfg, error) {
cp, err := externalsignertest.CertPaths()
if err != nil {
return nil, fmt.Errorf("getting certificates path: %w", err)
}
return &ExternalSignerCfg{
Address: common.Bytes2Hex(addr.Bytes()),
URL: url,
Method: externalsignertest.SignerMethod,
RootCA: cp.ServerCert,
ClientCert: cp.ClientCert,
ClientPrivateKey: cp.ClientKey,
}, nil
}

type DangerousConfig struct {
// This should be used with caution, only when dataposter somehow gets in a
// bad state and we require clearing it.
Expand Down
18 changes: 1 addition & 17 deletions arbnode/dataposter/dataposter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package dataposter
import (
"context"
"errors"
"fmt"
"math/big"
"testing"
"time"
Expand All @@ -25,21 +24,6 @@ import (
"github.com/offchainlabs/nitro/util/arbmath"
)

func signerTestCfg(addr common.Address, url string) (*ExternalSignerCfg, error) {
cp, err := externalsignertest.CertPaths()
if err != nil {
return nil, fmt.Errorf("getting certificates path: %w", err)
}
return &ExternalSignerCfg{
Address: common.Bytes2Hex(addr.Bytes()),
URL: url,
Method: externalsignertest.SignerMethod,
RootCA: cp.ServerCert,
ClientCert: cp.ClientCert,
ClientPrivateKey: cp.ClientKey,
}, nil
}

var (
blobTx = types.NewTx(
&types.BlobTx{
Expand Down Expand Up @@ -80,7 +64,7 @@ func TestExternalSigner(t *testing.T) {
return
}
}()
signerCfg, err := signerTestCfg(srv.Address, srv.URL())
signerCfg, err := ExternalSignerTestCfg(srv.Address, srv.URL())
if err != nil {
t.Fatalf("Error getting signer test config: %v", err)
}
Expand Down
Loading

0 comments on commit aec3f68

Please sign in to comment.