From a83ffef06a9782ff3096de0c7cbf78e698cfb324 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Fri, 19 Jan 2024 11:21:17 -0700 Subject: [PATCH] arbutil: rename Js->Requestor no longer js --- arbitrator/arbutil/src/evm/mod.rs | 2 +- arbitrator/arbutil/src/evm/{js.rs => req.rs} | 6 +++--- arbitrator/jit/src/stylus_backend.rs | 4 ++-- arbitrator/stylus/src/evm_api.rs | 2 +- arbitrator/stylus/src/lib.rs | 4 ++-- arbitrator/wasm-libraries/user-host/src/program.rs | 8 ++++---- 6 files changed, 13 insertions(+), 13 deletions(-) rename arbitrator/arbutil/src/evm/{js.rs => req.rs} (98%) diff --git a/arbitrator/arbutil/src/evm/mod.rs b/arbitrator/arbutil/src/evm/mod.rs index f974bd506..644ea0fa3 100644 --- a/arbitrator/arbutil/src/evm/mod.rs +++ b/arbitrator/arbutil/src/evm/mod.rs @@ -4,7 +4,7 @@ use crate::{Bytes20, Bytes32}; pub mod api; -pub mod js; +pub mod req; pub mod user; // params.SstoreSentryGasEIP2200 diff --git a/arbitrator/arbutil/src/evm/js.rs b/arbitrator/arbutil/src/evm/req.rs similarity index 98% rename from arbitrator/arbutil/src/evm/js.rs rename to arbitrator/arbutil/src/evm/req.rs index 6b6e56c98..6e1767038 100644 --- a/arbitrator/arbutil/src/evm/js.rs +++ b/arbitrator/arbutil/src/evm/req.rs @@ -10,7 +10,7 @@ use crate::{ }; use eyre::{bail, eyre, Result}; -pub struct JsEvmApi { +pub struct EvmApiRequestor { handler: T, last_call_result: Vec, } @@ -19,7 +19,7 @@ pub trait RequestHandler: Send + 'static { fn handle_request(&mut self, _req_type: EvmApiMethod, _req_data: &[u8]) -> (Vec, u64); } -impl JsEvmApi { +impl EvmApiRequestor { pub fn new(handler: T) -> Self { Self { handler, @@ -97,7 +97,7 @@ impl JsEvmApi { } } -impl EvmApi for JsEvmApi { +impl EvmApi for EvmApiRequestor { fn get_bytes32(&mut self, key: Bytes32) -> (Bytes32, u64) { let (res, cost) = self .handler diff --git a/arbitrator/jit/src/stylus_backend.rs b/arbitrator/jit/src/stylus_backend.rs index 925447ed1..7303a3e94 100644 --- a/arbitrator/jit/src/stylus_backend.rs +++ b/arbitrator/jit/src/stylus_backend.rs @@ -5,7 +5,7 @@ use crate::machine::{Escape, MaybeEscape}; use arbutil::evm::{ - api::EvmApiMethod, js::JsEvmApi, js::RequestHandler, user::UserOutcome, EvmData, + api::EvmApiMethod, req::EvmApiRequestor, req::RequestHandler, user::UserOutcome, EvmData, }; use eyre::{eyre, Result}; use prover::programs::prelude::*; @@ -128,7 +128,7 @@ pub fn exec_wasm( rx: tothread_rx, }; - let evm_api = JsEvmApi::new(cothread); + let evm_api = EvmApiRequestor::new(cothread); let mut instance = unsafe { NativeInstance::deserialize(&module, compile.clone(), evm_api, evm_data) }?; diff --git a/arbitrator/stylus/src/evm_api.rs b/arbitrator/stylus/src/evm_api.rs index e3eebbb46..54312c046 100644 --- a/arbitrator/stylus/src/evm_api.rs +++ b/arbitrator/stylus/src/evm_api.rs @@ -2,7 +2,7 @@ // For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE use crate::{RustBytes, RustSlice}; -use arbutil::evm::{api::EvmApiMethod, api::EvmApiStatus, js::RequestHandler}; +use arbutil::evm::{api::EvmApiMethod, api::EvmApiStatus, req::RequestHandler}; #[repr(C)] pub struct NativeRequestHandler { diff --git a/arbitrator/stylus/src/lib.rs b/arbitrator/stylus/src/lib.rs index bba1091dd..df8b1cfec 100644 --- a/arbitrator/stylus/src/lib.rs +++ b/arbitrator/stylus/src/lib.rs @@ -2,7 +2,7 @@ // For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE use arbutil::{ evm::{ - js::JsEvmApi, + req::EvmApiRequestor, user::{UserOutcome, UserOutcomeKind}, EvmData, }, @@ -168,7 +168,7 @@ pub unsafe extern "C" fn stylus_call( // Safety: module came from compile_user_wasm and we've paid for memory expansion let instance = unsafe { - NativeInstance::deserialize(module, compile, JsEvmApi::new(req_handler), evm_data) + NativeInstance::deserialize(module, compile, EvmApiRequestor::new(req_handler), evm_data) }; let mut instance = match instance { Ok(instance) => instance, diff --git a/arbitrator/wasm-libraries/user-host/src/program.rs b/arbitrator/wasm-libraries/user-host/src/program.rs index 1a7afefc8..7017b502a 100644 --- a/arbitrator/wasm-libraries/user-host/src/program.rs +++ b/arbitrator/wasm-libraries/user-host/src/program.rs @@ -2,7 +2,7 @@ // For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE use core::sync::atomic::{compiler_fence, Ordering}; use arbutil::{ - evm::{js::JsEvmApi, js::RequestHandler, EvmData, api::EvmApiMethod}, + evm::{req::EvmApiRequestor, req::RequestHandler, EvmData, api::EvmApiMethod}, wavm, Bytes20, Bytes32, Color, }; use eyre::{eyre, Result}; @@ -66,7 +66,7 @@ pub(crate) struct Program { /// Output generated by the program. pub outs: Vec, /// Mechanism for calling back into Geth. - pub evm_api: JsEvmApi, + pub evm_api: EvmApiRequestor, /// EVM Context info. pub evm_data: EvmData, /// WAVM module index. @@ -139,7 +139,7 @@ impl Program { let program = Self { args, outs: vec![], - evm_api: JsEvmApi::new(UserHostRequester::default()), + evm_api: EvmApiRequestor::new(UserHostRequester::default()), evm_data, module, config, @@ -181,7 +181,7 @@ impl Program { impl UserHost for Program { type Err = eyre::ErrReport; type MemoryErr = MemoryBoundsError; - type A = JsEvmApi; + type A = EvmApiRequestor; fn args(&self) -> &[u8] { &self.args