Skip to content

Commit

Permalink
Merge branch 'express-lane-timeboost' into improve-timeboost-code
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshvanahalli authored Jan 8, 2025
2 parents 7df81a4 + c9b61ce commit 3a1f91c
Show file tree
Hide file tree
Showing 40 changed files with 760 additions and 195 deletions.
23 changes: 16 additions & 7 deletions .github/workflows/arbitrator-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,29 @@ 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: Install rust stable
id: install-rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: '1.80.1'
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
2 changes: 1 addition & 1 deletion .github/workflows/submodule-pin-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
#TODO Rachel to check these are the intended branches.
[arbitrator/langs/c]=origin/vm-storage-cache
[arbitrator/tools/wasmer]=origin/adopt-v4.2.8
[arbitrator/tools/wasmer]=origin/stylus
)
divergent=0
for mod in `git submodule --quiet foreach 'echo $name'`; do
Expand Down
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -446,54 +446,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",
]
Loading

0 comments on commit 3a1f91c

Please sign in to comment.