diff --git a/Makefile b/Makefile index ec8846e68..c9bf2316b 100644 --- a/Makefile +++ b/Makefile @@ -94,15 +94,16 @@ stylus_test_dir = arbitrator/stylus/tests stylus_cargo = arbitrator/stylus/tests/.cargo/config.toml rust_sdk = arbitrator/langs/rust +c_sdk = arbitrator/langs/c stylus_lang_rust = $(wildcard $(rust_sdk)/*/src/*.rs $(rust_sdk)/*/src/*/*.rs $(rust_sdk)/*/*.toml) -stylus_lang_c = $(wildcard arbitrator/langs/c/*.c arbitrator/langs/c/*.h) +stylus_lang_c = $(wildcard $(c_sdk)/*/*.c $(c_sdk)/*/*.h) stylus_lang_bf = $(wildcard arbitrator/langs/bf/src/*.* arbitrator/langs/bf/src/*.toml) cargo_nightly = cargo +nightly build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort get_stylus_test_wasm = $(stylus_test_dir)/$(1)/$(wasm32_unknown)/$(1).wasm get_stylus_test_rust = $(wildcard $(stylus_test_dir)/$(1)/*.toml $(stylus_test_dir)/$(1)/src/*.rs) $(stylus_cargo) $(stylus_lang_rust) -get_stylus_test_c = $(wildcard $(stylus_test_dir)/$(1)/*.c $(stylus_test_dir)/$(1)/*.h) $(stylus_lang_c) +get_stylus_test_c = $(wildcard $(c_sdk)/examples/$(1)/*.c $(c_sdk)/examples/$(1)/*.h) $(stylus_lang_c) stylus_test_bfs = $(wildcard $(stylus_test_dir)/bf/*.b) stylus_test_keccak_wasm = $(call get_stylus_test_wasm,keccak) @@ -127,10 +128,8 @@ stylus_test_erc20_wasm = $(call get_stylus_test_wasm,erc20) stylus_test_erc20_src = $(call get_stylus_test_rust,erc20) stylus_test_read-return-data_wasm = $(call get_stylus_test_wasm,read-return-data) stylus_test_read-return-data_src = $(call get_stylus_test_rust,read-return-data) -stylus_test_siphash_wasm = $(stylus_test_dir)/siphash/siphash.wasm -stylus_test_siphash_src = $(call get_stylus_test_c,siphash) -stylus_test_wasms = $(stylus_test_keccak_wasm) $(stylus_test_keccak-100_wasm) $(stylus_test_fallible_wasm) $(stylus_test_storage_wasm) $(stylus_test_siphash_wasm) $(stylus_test_multicall_wasm) $(stylus_test_log_wasm) $(stylus_test_create_wasm) $(stylus_test_sdk-storage_wasm) $(stylus_test_erc20_wasm) $(stylus_test_read-return-data_wasm) $(stylus_test_evm-data_wasm) $(stylus_test_bfs:.b=.wasm) +stylus_test_wasms = $(stylus_test_keccak_wasm) $(stylus_test_keccak-100_wasm) $(stylus_test_fallible_wasm) $(stylus_test_storage_wasm) $(stylus_test_multicall_wasm) $(stylus_test_log_wasm) $(stylus_test_create_wasm) $(stylus_test_sdk-storage_wasm) $(stylus_test_erc20_wasm) $(stylus_test_read-return-data_wasm) $(stylus_test_evm-data_wasm) $(stylus_test_bfs:.b=.wasm) stylus_benchmarks = $(wildcard $(stylus_dir)/*.toml $(stylus_dir)/src/*.rs) $(stylus_test_wasms) stylus_files = $(wildcard $(stylus_dir)/*.toml $(stylus_dir)/src/*.rs) $(rust_prover_files) @@ -410,9 +409,6 @@ $(stylus_test_erc20_wasm): $(stylus_test_erc20_src) $(cargo_nightly) --manifest-path $< --release --config $(stylus_cargo) @touch -c $@ # cargo might decide to not rebuild the binary -$(stylus_test_siphash_wasm): $(stylus_test_siphash_src) - clang $(filter %.c, $^) -o $@ --target=wasm32 --no-standard-libraries -Wl,--no-entry -Oz - contracts/test/prover/proofs/float%.json: $(arbitrator_cases)/float%.wasm $(prover_bin) $(output_latest)/soft-float.wasm $(prover_bin) $< -l $(output_latest)/soft-float.wasm -o $@ -b --allow-hostapi --require-success --always-merkleize diff --git a/arbitrator/arbutil/src/evm/api.rs b/arbitrator/arbutil/src/evm/api.rs index b0449980c..b3189c2bb 100644 --- a/arbitrator/arbutil/src/evm/api.rs +++ b/arbitrator/arbutil/src/evm/api.rs @@ -135,5 +135,5 @@ pub trait EvmApi: Send + 'static { fn add_pages(&mut self, pages: u16) -> u64; /// Captures tracing information for hostio invocations during native execution. - fn capture_hostio(&self, name: &str, args: &[u8], outs: &[u8], ink: u64); + fn capture_hostio(&self, name: &str, args: &[u8], outs: &[u8], start_ink: u64, end_ink: u64); } diff --git a/arbitrator/arbutil/src/evm/js.rs b/arbitrator/arbutil/src/evm/js.rs index 849a9fac4..de9069f00 100644 --- a/arbitrator/arbutil/src/evm/js.rs +++ b/arbitrator/arbutil/src/evm/js.rs @@ -314,11 +314,11 @@ impl EvmApi for JsEvmApi { cost.assert_u64() } - fn capture_hostio(&self, name: &str, args: &[u8], outs: &[u8], ink: u64) { + fn capture_hostio(&self, name: &str, args: &[u8], outs: &[u8], start_ink: u64, _end_ink: u64) { let args = hex::encode(args); let outs = hex::encode(outs); println!( - "Error: unexpected hostio tracing info for {name} while proving: {args}, {outs}, {ink}" + "Error: unexpected hostio tracing info for {name} while proving: {args}, {outs}, {start_ink}" ); } } diff --git a/arbitrator/langs/bf b/arbitrator/langs/bf index 8bad93059..c7e6ab1d1 160000 --- a/arbitrator/langs/bf +++ b/arbitrator/langs/bf @@ -1 +1 @@ -Subproject commit 8bad93059ff9fc4bbc3a3fc1ccc164017133c921 +Subproject commit c7e6ab1d149c30eaf06bf14c690ac9c3ff54bccd diff --git a/arbitrator/langs/c b/arbitrator/langs/c index 45c70019b..9fb51373f 160000 --- a/arbitrator/langs/c +++ b/arbitrator/langs/c @@ -1 +1 @@ -Subproject commit 45c70019bd135a4bf809ba6cec0090ad10e6fb85 +Subproject commit 9fb51373f96c74c1bed18d4a1aa5bb699c50ecba diff --git a/arbitrator/langs/rust b/arbitrator/langs/rust index f3d8d9dc1..39abd9ced 160000 --- a/arbitrator/langs/rust +++ b/arbitrator/langs/rust @@ -1 +1 @@ -Subproject commit f3d8d9dc1cf7d7e14fbf63a6e701a2b1441e7395 +Subproject commit 39abd9cedfbde2e0e515ed59ed592646d5450bb4 diff --git a/arbitrator/stylus/src/env.rs b/arbitrator/stylus/src/env.rs index df160da23..7a1b2c097 100644 --- a/arbitrator/stylus/src/env.rs +++ b/arbitrator/stylus/src/env.rs @@ -70,15 +70,24 @@ impl WasmEnv { env: &'a mut WasmEnvMut<'_, E>, ink: u64, ) -> Result, Escape> { - let mut info = Self::start_free(env); + let mut info = Self::start_free(env)?; info.buy_ink(pricing::HOSTIO_INK + ink)?; Ok(info) } - pub fn start_free<'a>(env: &'a mut WasmEnvMut<'_, E>) -> HostioInfo<'a, E> { + pub fn start_free<'a>(env: &'a mut WasmEnvMut<'_, E>) -> Result, Escape> { let (env, store) = env.data_and_store_mut(); let memory = env.memory.clone().unwrap(); - HostioInfo { env, memory, store } + let mut info = HostioInfo { + env, + memory, + store, + start_ink: 0, + }; + if info.env.evm_data.tracing { + info.start_ink = info.ink_ready()?; + } + Ok(info) } pub fn meter(&mut self) -> &mut MeterData { @@ -125,6 +134,7 @@ pub struct HostioInfo<'a, E: EvmApi> { pub env: &'a mut WasmEnv, pub memory: Memory, pub store: StoreMut<'a>, + pub start_ink: u64, } impl<'a, E: EvmApi> HostioInfo<'a, E> { @@ -199,8 +209,9 @@ impl<'a, E: EvmApi> HostioInfo<'a, E> { Ok(()) } - pub fn trace(&self, name: &str, args: &[u8], outs: &[u8], ink: u64) { - self.evm_api.capture_hostio(name, args, outs, ink); + pub fn trace(&self, name: &str, args: &[u8], outs: &[u8], start_ink: u64, end_ink: u64) { + self.evm_api + .capture_hostio(name, args, outs, start_ink, end_ink); } } diff --git a/arbitrator/stylus/src/evm_api.rs b/arbitrator/stylus/src/evm_api.rs index 75f98d1a9..8cda407fc 100644 --- a/arbitrator/stylus/src/evm_api.rs +++ b/arbitrator/stylus/src/evm_api.rs @@ -71,7 +71,8 @@ pub struct GoEvmApi { name: *mut RustVec, args: *mut RustSlice, outs: *mut RustSlice, - ink: u64, + start_ink: u64, + end_ink: u64, ), pub id: usize, } @@ -258,14 +259,15 @@ impl EvmApi for GoEvmApi { call!(self, add_pages, pages) } - fn capture_hostio(&self, name: &str, args: &[u8], outs: &[u8], ink: u64) { + fn capture_hostio(&self, name: &str, args: &[u8], outs: &[u8], start_ink: u64, end_ink: u64) { call!( self, capture_hostio, ptr!(RustVec::new(name.as_bytes().to_vec())), ptr!(RustSlice::new(args)), ptr!(RustSlice::new(outs)), - ink + start_ink, + end_ink ) } } diff --git a/arbitrator/stylus/src/host.rs b/arbitrator/stylus/src/host.rs index 689a5d486..43d01f55e 100644 --- a/arbitrator/stylus/src/host.rs +++ b/arbitrator/stylus/src/host.rs @@ -22,12 +22,13 @@ macro_rules! be { macro_rules! trace { ($name:expr, $env:expr, [$($args:expr),+], [$($outs:expr),+], $ret:expr) => {{ if $env.evm_data.tracing { - let ink = $env.ink_ready()?; + let start_ink = $env.start_ink; + let end_ink = $env.ink_ready()?; let mut args = vec![]; $(args.extend($args);)* let mut outs = vec![]; $(outs.extend($outs);)* - $env.trace($name, &args, &outs, ink); + $env.trace($name, &args, &outs, start_ink, end_ink); } Ok($ret) }}; @@ -49,14 +50,14 @@ pub(crate) fn read_args(mut env: WasmEnvMut, ptr: u32) -> MaybeEsc let mut env = WasmEnv::start(&mut env, 0)?; env.pay_for_write(env.args.len() as u64)?; env.write_slice(ptr, &env.args)?; - trace!("read_args", env, &env.args, &[]) + trace!("read_args", env, &[], &env.args) } pub(crate) fn write_result(mut env: WasmEnvMut, ptr: u32, len: u32) -> MaybeEscape { let mut env = WasmEnv::start(&mut env, 0)?; env.pay_for_read(len.into())?; env.outs = env.read_slice(ptr, len)?; - trace!("write_result", env, &[], &env.outs) + trace!("write_result", env, &env.outs, &[]) } pub(crate) fn storage_load_bytes32( @@ -150,6 +151,8 @@ where { let mut env = WasmEnv::start(&mut env, 3 * PTR_INK + EVM_API_INK)?; env.pay_for_read(calldata_len.into())?; + + let gas_passed = gas; gas = gas.min(env.gas_left()?); // provide no more than what the user has let contract = env.read_bytes20(contract)?; @@ -166,10 +169,11 @@ where if env.evm_data.tracing { let underscore = (!name.is_empty()).then_some("_").unwrap_or_default(); let name = format!("{name}{underscore}call_contract"); + let value = value.into_iter().flatten(); return trace!( &name, env, - [contract, &input, be!(gas), value.unwrap_or_default()], + [contract, be!(gas_passed), value, &input], [be!(outs_len), be!(status)], status ); @@ -261,12 +265,12 @@ where env.write_u32(revert_data_len, ret_len)?; env.write_bytes20(contract, result)?; - let salt = salt.into_iter().flat_map(|x| x); + let salt = salt.into_iter().flatten(); trace!( name, env, - [code_copy.unwrap(), endowment, salt, be!(gas)], - [result, be!(ret_len), be!(gas_cost)], + [endowment, salt, code_copy.unwrap()], + [result, be!(ret_len)], () ) } @@ -285,7 +289,7 @@ pub(crate) fn read_return_data( env.write_slice(dest, &data)?; let len = data.len() as u32; - trace!("read_return_data", env, [be!(dest), be!(offset)], data, len) + trace!("read_return_data", env, [be!(offset), be!(size)], data, len) } pub(crate) fn return_data_size(mut env: WasmEnvMut) -> Result { @@ -309,7 +313,7 @@ pub(crate) fn emit_log( let data = env.read_slice(data, len)?; env.evm_api.emit_log(data.clone(), topics)?; - trace!("emit_log", env, [data, be!(topics)], &[]) + trace!("emit_log", env, [be!(topics), data], &[]) } pub(crate) fn account_balance( @@ -323,7 +327,7 @@ pub(crate) fn account_balance( let (balance, gas_cost) = env.evm_api.account_balance(address); env.buy_gas(gas_cost)?; env.write_bytes32(ptr, balance)?; - trace!("account_balance", env, &[], balance) + trace!("account_balance", env, address, balance) } pub(crate) fn account_codehash( @@ -337,19 +341,7 @@ pub(crate) fn account_codehash( let (hash, gas_cost) = env.evm_api.account_codehash(address); env.buy_gas(gas_cost)?; env.write_bytes32(ptr, hash)?; - trace!("account_codehash", env, &[], hash) -} - -pub(crate) fn evm_gas_left(mut env: WasmEnvMut) -> Result { - let mut env = WasmEnv::start(&mut env, 0)?; - let gas = env.gas_left()?; - trace!("evm_gas_left", env, be!(gas), &[], gas) -} - -pub(crate) fn evm_ink_left(mut env: WasmEnvMut) -> Result { - let mut env = WasmEnv::start(&mut env, 0)?; - let ink = env.ink_ready()?; - trace!("evm_ink_left", env, be!(ink), &[], ink) + trace!("account_codehash", env, address, hash) } pub(crate) fn block_basefee(mut env: WasmEnvMut, ptr: u32) -> MaybeEscape { @@ -394,6 +386,18 @@ pub(crate) fn contract_address(mut env: WasmEnvMut, ptr: u32) -> M trace!("contract_address", env, &[], env.evm_data.contract_address) } +pub(crate) fn evm_gas_left(mut env: WasmEnvMut) -> Result { + let mut env = WasmEnv::start(&mut env, 0)?; + let gas = env.gas_left()?; + trace!("evm_gas_left", env, be!(gas), &[], gas) +} + +pub(crate) fn evm_ink_left(mut env: WasmEnvMut) -> Result { + let mut env = WasmEnv::start(&mut env, 0)?; + let ink = env.ink_ready()?; + trace!("evm_ink_left", env, be!(ink), &[], ink) +} + pub(crate) fn msg_reentrant(mut env: WasmEnvMut) -> Result { let mut env = WasmEnv::start(&mut env, 0)?; let reentrant = env.evm_data.reentrant; @@ -446,7 +450,7 @@ pub(crate) fn tx_origin(mut env: WasmEnvMut, ptr: u32) -> MaybeEsc } pub(crate) fn memory_grow(mut env: WasmEnvMut, pages: u16) -> MaybeEscape { - let mut env = WasmEnv::start_free(&mut env); + let mut env = WasmEnv::start_free(&mut env)?; if pages == 0 { env.buy_ink(HOSTIO_INK)?; return Ok(()); @@ -461,7 +465,7 @@ pub(crate) fn console_log_text( ptr: u32, len: u32, ) -> MaybeEscape { - let mut env = WasmEnv::start_free(&mut env); + let mut env = WasmEnv::start_free(&mut env)?; let text = env.read_slice(ptr, len)?; env.say(String::from_utf8_lossy(&text)); trace!("console_log_text", env, text, &[]) @@ -471,7 +475,7 @@ pub(crate) fn console_log>( mut env: WasmEnvMut, value: T, ) -> MaybeEscape { - let mut env = WasmEnv::start_free(&mut env); + let mut env = WasmEnv::start_free(&mut env)?; let value = value.into(); env.say(value); trace!("console_log", env, [format!("{value}").as_bytes()], &[]) @@ -481,7 +485,7 @@ pub(crate) fn console_tee + Copy>( mut env: WasmEnvMut, value: T, ) -> Result { - let env = WasmEnv::start_free(&mut env); + let env = WasmEnv::start_free(&mut env)?; env.say(value.into()); Ok(value) } diff --git a/arbitrator/stylus/src/run.rs b/arbitrator/stylus/src/run.rs index 559ee73b7..f50ba161a 100644 --- a/arbitrator/stylus/src/run.rs +++ b/arbitrator/stylus/src/run.rs @@ -78,8 +78,9 @@ impl RunProgram for NativeInstance { env.config = Some(config); if env.evm_data.tracing { + let args_len = args.len() as u32; env.evm_api - .capture_hostio(STYLUS_ENTRY_POINT, &args.len().to_be_bytes(), &[], ink); + .capture_hostio(STYLUS_ENTRY_POINT, &args_len.to_be_bytes(), &[], ink, ink); } let exports = &self.instance.exports; @@ -109,7 +110,7 @@ impl RunProgram for NativeInstance { let env = self.env(); if env.evm_data.tracing { env.evm_api - .capture_hostio("user_returned", &[], &status.to_be_bytes(), ink); + .capture_hostio("user_returned", &[], &status.to_be_bytes(), ink, ink); } let outs = self.env().outs.clone(); diff --git a/arbitrator/stylus/src/test/api.rs b/arbitrator/stylus/src/test/api.rs index 05fe7557d..d68d3aa1a 100644 --- a/arbitrator/stylus/src/test/api.rs +++ b/arbitrator/stylus/src/test/api.rs @@ -176,7 +176,14 @@ impl EvmApi for TestEvmApi { model.gas_cost(new, open, ever) } - fn capture_hostio(&self, _name: &str, _args: &[u8], _outs: &[u8], _ink: u64) { + fn capture_hostio( + &self, + _name: &str, + _args: &[u8], + _outs: &[u8], + _start_ink: u64, + _end_ink: u64, + ) { unimplemented!() } } diff --git a/arbitrator/stylus/src/test/native.rs b/arbitrator/stylus/src/test/native.rs index ff403f865..d74e1b802 100644 --- a/arbitrator/stylus/src/test/native.rs +++ b/arbitrator/stylus/src/test/native.rs @@ -310,50 +310,6 @@ fn test_rust() -> Result<()> { check_instrumentation(native, machine) } -#[test] -fn test_c() -> Result<()> { - // in siphash.c - // the inputs are a hash, key, and plaintext - // the output is whether the hash was valid - - let filename = "tests/siphash/siphash.wasm"; - let (compile, config, ink) = test_configs(); - - let text: Vec = (0..63).collect(); - let key: Vec = (0..16).collect(); - let key: [u8; 16] = key.try_into().unwrap(); - let hash = crypto::siphash(&text, &key); - - let mut args = hash.to_le_bytes().to_vec(); - args.extend(key); - args.extend(text); - let args_string = hex::encode(&args); - - let mut native = TestInstance::new_linked(filename, &compile, config)?; - let output = run_native(&mut native, &args, ink)?; - assert_eq!(hex::encode(output), args_string); - - let mut machine = Machine::from_user_path(Path::new(filename), &compile)?; - let output = run_machine(&mut machine, &args, config, ink)?; - assert_eq!(hex::encode(output), args_string); - - check_instrumentation(native, machine) -} - -#[test] -fn test_bf() -> Result<()> { - // in cat.b - // the output is the input - - let (compile, config, ink) = test_configs(); - let args = "Hello world!".as_bytes(); - - let mut native = TestInstance::new_linked("tests/bf/cat.wasm", &compile, config)?; - let output = run_native(&mut native, args, ink)?; - assert_eq!(output, args); - Ok(()) -} - #[test] fn test_fallible() -> Result<()> { // in fallible.rs diff --git a/arbitrator/stylus/tests/create/Cargo.lock b/arbitrator/stylus/tests/create/Cargo.lock index ad49f9d3d..4b4e93f44 100644 --- a/arbitrator/stylus/tests/create/Cargo.lock +++ b/arbitrator/stylus/tests/create/Cargo.lock @@ -436,7 +436,7 @@ dependencies = [ [[package]] name = "stylus-proc" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -453,7 +453,7 @@ dependencies = [ [[package]] name = "stylus-sdk" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", diff --git a/arbitrator/stylus/tests/erc20/Cargo.lock b/arbitrator/stylus/tests/erc20/Cargo.lock index 4a4180559..a27c1c6c0 100644 --- a/arbitrator/stylus/tests/erc20/Cargo.lock +++ b/arbitrator/stylus/tests/erc20/Cargo.lock @@ -646,7 +646,7 @@ dependencies = [ [[package]] name = "stylus-proc" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -663,7 +663,7 @@ dependencies = [ [[package]] name = "stylus-sdk" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", diff --git a/arbitrator/stylus/tests/evm-data/Cargo.lock b/arbitrator/stylus/tests/evm-data/Cargo.lock index f2921a545..8f0dbc8f2 100644 --- a/arbitrator/stylus/tests/evm-data/Cargo.lock +++ b/arbitrator/stylus/tests/evm-data/Cargo.lock @@ -436,7 +436,7 @@ dependencies = [ [[package]] name = "stylus-proc" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -453,7 +453,7 @@ dependencies = [ [[package]] name = "stylus-sdk" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", diff --git a/arbitrator/stylus/tests/evm-data/src/main.rs b/arbitrator/stylus/tests/evm-data/src/main.rs index 29bf69a0e..5df2b9b6b 100644 --- a/arbitrator/stylus/tests/evm-data/src/main.rs +++ b/arbitrator/stylus/tests/evm-data/src/main.rs @@ -61,9 +61,9 @@ fn user_main(input: Vec) -> Result, Vec> { output.extend(origin.into_word()); output.extend(coinbase.into_word()); - output.extend(contract_codehash.unwrap_or_default()); - output.extend(arb_precompile_codehash.unwrap_or_default()); - output.extend(eth_precompile_codehash.unwrap_or_default()); + output.extend(contract_codehash); + output.extend(arb_precompile_codehash); + output.extend(eth_precompile_codehash); output.extend(ink_price.to_be_bytes()); output.extend(gas_left_before.to_be_bytes()); diff --git a/arbitrator/stylus/tests/fallible/Cargo.lock b/arbitrator/stylus/tests/fallible/Cargo.lock index ddac62822..d327d283c 100644 --- a/arbitrator/stylus/tests/fallible/Cargo.lock +++ b/arbitrator/stylus/tests/fallible/Cargo.lock @@ -435,7 +435,7 @@ dependencies = [ [[package]] name = "stylus-proc" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -452,7 +452,7 @@ dependencies = [ [[package]] name = "stylus-sdk" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", diff --git a/arbitrator/stylus/tests/keccak-100/Cargo.lock b/arbitrator/stylus/tests/keccak-100/Cargo.lock index 7ca4ccfcb..72d5774ae 100644 --- a/arbitrator/stylus/tests/keccak-100/Cargo.lock +++ b/arbitrator/stylus/tests/keccak-100/Cargo.lock @@ -436,7 +436,7 @@ dependencies = [ [[package]] name = "stylus-proc" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -453,7 +453,7 @@ dependencies = [ [[package]] name = "stylus-sdk" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", diff --git a/arbitrator/stylus/tests/keccak/Cargo.lock b/arbitrator/stylus/tests/keccak/Cargo.lock index 6447452c4..295c8582d 100644 --- a/arbitrator/stylus/tests/keccak/Cargo.lock +++ b/arbitrator/stylus/tests/keccak/Cargo.lock @@ -436,7 +436,7 @@ dependencies = [ [[package]] name = "stylus-proc" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -453,7 +453,7 @@ dependencies = [ [[package]] name = "stylus-sdk" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", diff --git a/arbitrator/stylus/tests/log/Cargo.lock b/arbitrator/stylus/tests/log/Cargo.lock index a882dcd0f..cde7adb5d 100644 --- a/arbitrator/stylus/tests/log/Cargo.lock +++ b/arbitrator/stylus/tests/log/Cargo.lock @@ -436,7 +436,7 @@ dependencies = [ [[package]] name = "stylus-proc" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -453,7 +453,7 @@ dependencies = [ [[package]] name = "stylus-sdk" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", diff --git a/arbitrator/stylus/tests/multicall/Cargo.lock b/arbitrator/stylus/tests/multicall/Cargo.lock index 9f1c4756a..2fc12810e 100644 --- a/arbitrator/stylus/tests/multicall/Cargo.lock +++ b/arbitrator/stylus/tests/multicall/Cargo.lock @@ -436,7 +436,7 @@ dependencies = [ [[package]] name = "stylus-proc" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -453,7 +453,7 @@ dependencies = [ [[package]] name = "stylus-sdk" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", diff --git a/arbitrator/stylus/tests/read-return-data/Cargo.lock b/arbitrator/stylus/tests/read-return-data/Cargo.lock index 4a3e0fbdc..5d8aeadba 100644 --- a/arbitrator/stylus/tests/read-return-data/Cargo.lock +++ b/arbitrator/stylus/tests/read-return-data/Cargo.lock @@ -436,7 +436,7 @@ dependencies = [ [[package]] name = "stylus-proc" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -453,7 +453,7 @@ dependencies = [ [[package]] name = "stylus-sdk" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", diff --git a/arbitrator/stylus/tests/sdk-storage/Cargo.lock b/arbitrator/stylus/tests/sdk-storage/Cargo.lock index 83735cbd7..3d7e5acc2 100644 --- a/arbitrator/stylus/tests/sdk-storage/Cargo.lock +++ b/arbitrator/stylus/tests/sdk-storage/Cargo.lock @@ -449,7 +449,7 @@ dependencies = [ [[package]] name = "stylus-proc" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -466,7 +466,7 @@ dependencies = [ [[package]] name = "stylus-sdk" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", diff --git a/arbitrator/stylus/tests/siphash/.gitignore b/arbitrator/stylus/tests/siphash/.gitignore deleted file mode 100644 index 19e1bced9..000000000 --- a/arbitrator/stylus/tests/siphash/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.wasm diff --git a/arbitrator/stylus/tests/siphash/main.c b/arbitrator/stylus/tests/siphash/main.c deleted file mode 100644 index 60bae5632..000000000 --- a/arbitrator/stylus/tests/siphash/main.c +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2022, Offchain Labs, Inc. -// For license information, see https://github.com/nitro/blob/master/LICENSE -// -// You can compile this file with stock clang as follows -// clang *.c -o siphash.wasm --target=wasm32 --no-standard-libraries -mbulk-memory -Wl,--no-entry -Oz -// -// For C programs reliant on the standard library, cross compile clang with wasi -// https://github.com/WebAssembly/wasi-sdk - -#include "../../../langs/c/stylus.h" - -extern uint64_t siphash24(const void *src, unsigned long len, const uint8_t key[16]); - -ArbResult user_main(const uint8_t * args, size_t args_len) { - const uint64_t hash = *(uint64_t *) args; - const uint8_t * key = args + 8; - const uint8_t * plaintext = args + 24; - const uint64_t length = args_len - 24; - - uint8_t valid = siphash24(plaintext, length, key) == hash ? 0 : 1; - - return (ArbResult) { - .status = valid, - .output = args, - .output_len = args_len, - }; -} - -ENTRYPOINT(user_main); diff --git a/arbitrator/stylus/tests/siphash/siphash.c b/arbitrator/stylus/tests/siphash/siphash.c deleted file mode 100644 index 73cff9d07..000000000 --- a/arbitrator/stylus/tests/siphash/siphash.c +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2022, Offchain Labs, Inc. -// For license information, see https://github.com/nitro/blob/master/LICENSE -// -// Note for just this file: an MIT variant of this program may be found at -// https://github.com/majek/csiphash/ -// - -#include - -// wasm is always little endian -#define _le64toh(x) ((uint64_t)(x)) - -#define ROTATE(x, b) (uint64_t)( ((x) << (b)) | ( (x) >> (64 - (b))) ) - -#define HALF_ROUND(a,b,c,d,s,t) \ - a += b; c += d; \ - b = ROTATE(b, s) ^ a; \ - d = ROTATE(d, t) ^ c; \ - a = ROTATE(a, 32); - -#define DOUBLE_ROUND(v0,v1,v2,v3) \ - HALF_ROUND(v0,v1,v2,v3,13,16); \ - HALF_ROUND(v2,v1,v0,v3,17,21); \ - HALF_ROUND(v0,v1,v2,v3,13,16); \ - HALF_ROUND(v2,v1,v0,v3,17,21); - - -uint64_t siphash24(const void *src, unsigned long len, const uint8_t key[16]) { - const uint64_t *_key = (uint64_t *)key; - uint64_t k0 = _le64toh(_key[0]); - uint64_t k1 = _le64toh(_key[1]); - uint64_t b = (uint64_t)len << 56; - const uint64_t *in = (uint64_t*)src; - - uint64_t v0 = k0 ^ 0x736f6d6570736575ULL; - uint64_t v1 = k1 ^ 0x646f72616e646f6dULL; - uint64_t v2 = k0 ^ 0x6c7967656e657261ULL; - uint64_t v3 = k1 ^ 0x7465646279746573ULL; - - while (len >= 8) { - uint64_t mi = _le64toh(*in); - in += 1; len -= 8; - v3 ^= mi; - DOUBLE_ROUND(v0,v1,v2,v3); - v0 ^= mi; - } - - uint64_t t = 0; uint8_t *pt = (uint8_t *)&t; uint8_t *m = (uint8_t *)in; - switch (len) { - case 7: pt[6] = m[6]; - case 6: pt[5] = m[5]; - case 5: pt[4] = m[4]; - case 4: *((uint32_t*)&pt[0]) = *((uint32_t*)&m[0]); break; - case 3: pt[2] = m[2]; - case 2: pt[1] = m[1]; - case 1: pt[0] = m[0]; - } - b |= _le64toh(t); - - v3 ^= b; - DOUBLE_ROUND(v0,v1,v2,v3); - v0 ^= b; v2 ^= 0xff; - DOUBLE_ROUND(v0,v1,v2,v3); - DOUBLE_ROUND(v0,v1,v2,v3); - return (v0 ^ v1) ^ (v2 ^ v3); -} diff --git a/arbitrator/stylus/tests/storage/Cargo.lock b/arbitrator/stylus/tests/storage/Cargo.lock index 951b03823..e26b2332c 100644 --- a/arbitrator/stylus/tests/storage/Cargo.lock +++ b/arbitrator/stylus/tests/storage/Cargo.lock @@ -435,7 +435,7 @@ dependencies = [ [[package]] name = "stylus-proc" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -452,7 +452,7 @@ dependencies = [ [[package]] name = "stylus-sdk" -version = "0.4.0" +version = "0.4.1" dependencies = [ "alloy-primitives", "alloy-sol-types", diff --git a/arbos/programs/api.go b/arbos/programs/api.go index ff09fc57b..93377dd0c 100644 --- a/arbos/programs/api.go +++ b/arbos/programs/api.go @@ -44,7 +44,7 @@ type emitLogType func(data []byte, topics uint32) error type accountBalanceType func(address common.Address) (value common.Hash, cost uint64) type accountCodehashType func(address common.Address) (value common.Hash, cost uint64) type addPagesType func(pages uint16) (cost uint64) -type captureHostioType func(name string, args, outs []byte, ink uint64) +type captureHostioType func(name string, args, outs []byte, startInk, endInk uint64) type goClosures struct { getBytes32 getBytes32Type @@ -271,8 +271,8 @@ func newApiClosures( open, ever := db.AddStylusPages(pages) return memoryModel.GasCost(pages, open, ever) } - captureHostio := func(name string, args, outs []byte, ink uint64) { - tracingInfo.Tracer.CaptureStylusHostio(name, args, outs, ink) + captureHostio := func(name string, args, outs []byte, startInk, endInk uint64) { + tracingInfo.Tracer.CaptureStylusHostio(name, args, outs, startInk, endInk) } return &goClosures{ diff --git a/arbos/programs/native.go b/arbos/programs/native.go index 12d5d370a..4f613c7d2 100644 --- a/arbos/programs/native.go +++ b/arbos/programs/native.go @@ -257,9 +257,9 @@ func addPagesImpl(api usize, pages u16) u64 { } //export captureHostioImpl -func captureHostioImpl(api usize, name *rustSlice, args *rustSlice, outs *rustSlice, ink u64) { +func captureHostioImpl(api usize, name *rustSlice, args *rustSlice, outs *rustSlice, startInk, endInk u64) { closures := getApi(api) - closures.captureHostio(string(name.read()), args.read(), outs.read(), uint64(ink)) + closures.captureHostio(string(name.read()), args.read(), outs.read(), uint64(startInk), uint64(endInk)) } func (value bytes20) toAddress() common.Address { diff --git a/arbos/programs/native_api.go b/arbos/programs/native_api.go index 70abf4d21..6956d493b 100644 --- a/arbos/programs/native_api.go +++ b/arbos/programs/native_api.go @@ -76,9 +76,9 @@ u64 addPagesWrap(usize api, u16 pages) { return addPagesImpl(api, pages); } -void captureHostioImpl(usize api, RustSlice * name, RustSlice * data, u64 ink); -void captureHostioWrap(usize api, RustSlice * name, RustSlice * data, u64 ink) { - return captureHostioImpl(api, name, data, ink); +void captureHostioImpl(usize api, RustSlice * name, RustSlice * data, u64 startInk, u64 endInk); +void captureHostioWrap(usize api, RustSlice * name, RustSlice * data, u64 startInk, u64 endInk) { + return captureHostioImpl(api, name, data, startInk, endInk); } */ import "C" diff --git a/go-ethereum b/go-ethereum index 5c95759ac..35fead93e 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 5c95759ac7d257a0423f4843c7e39feb0fda2081 +Subproject commit 35fead93eece0bccf4998360657f02d10155eccc diff --git a/system_tests/program_test.go b/system_tests/program_test.go index 2c743732d..a07f37510 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -1003,9 +1003,7 @@ func setupProgramTest(t *testing.T, jit bool) ( ctx, cancel := context.WithCancel(context.Background()) rand.Seed(time.Now().UTC().UnixNano()) - // TODO: track latest ArbOS version chainConfig := params.ArbitrumDevTestChainConfig() - chainConfig.ArbitrumChainParams.InitialArbOSVersion = 10 l2config := arbnode.ConfigDefaultL1Test() l2config.BlockValidator.Enable = false