diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c203c35dd..aa749ed68 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -63,10 +63,10 @@ jobs: steps: - uses: actions/checkout@v3 - run: rustup update - - uses: stellar/binaries@v29 + - uses: stellar/binaries@v33 with: name: cargo-semver-checks - version: 0.35.0 + version: 0.37.0 - run: cargo semver-checks --exclude soroban-simulation build-and-test: diff --git a/soroban-env-common/src/env.rs b/soroban-env-common/src/env.rs index 34d9fedce..fa052acda 100644 --- a/soroban-env-common/src/env.rs +++ b/soroban-env-common/src/env.rs @@ -238,7 +238,6 @@ pub trait EnvBase: Sized + Clone { /// This trait is used by macro-generated dispatch and forwarding functions to /// check arguments being passed to the Env. The default implementations call /// through to the Env integrity-checking functions. - pub trait CheckedEnvArg: Sized { fn check_env_arg(self, _e: &E) -> Result { Ok(self) @@ -327,7 +326,7 @@ generate_call_macro_with_all_host_functions!("env.json"); /////////////////////////////////////////////////////////////////////////////// /// X-macro use: defining trait Env /////////////////////////////////////////////////////////////////////////////// - +// // This is a helper macro used only by generate_env_trait below. It consumes // a token-tree of the form: // diff --git a/soroban-env-common/src/object.rs b/soroban-env-common/src/object.rs index 5604b0465..eb1e41c20 100644 --- a/soroban-env-common/src/object.rs +++ b/soroban-env-common/src/object.rs @@ -115,7 +115,7 @@ impl<'a> From> for &'a ScVal { } } -impl<'a> AsRef for ScValObjRef<'a> { +impl AsRef for ScValObjRef<'_> { fn as_ref(&self) -> &ScVal { self.0 } diff --git a/soroban-env-common/src/storage_type.rs b/soroban-env-common/src/storage_type.rs index 2804a683d..d72886e3c 100644 --- a/soroban-env-common/src/storage_type.rs +++ b/soroban-env-common/src/storage_type.rs @@ -1,3 +1,4 @@ +#![allow(non_local_definitions)] use crate::{ declare_wasmi_marshal_for_enum, xdr::{ContractDataDurability, ScErrorCode, ScErrorType}, diff --git a/soroban-env-common/src/vmcaller_env.rs b/soroban-env-common/src/vmcaller_env.rs index 1b97d8bb4..933040a40 100644 --- a/soroban-env-common/src/vmcaller_env.rs +++ b/soroban-env-common/src/vmcaller_env.rs @@ -1,3 +1,4 @@ +#![allow(clippy::needless_lifetimes)] #[cfg(feature = "wasmi")] use crate::xdr::{ScErrorCode, ScErrorType}; @@ -24,7 +25,6 @@ use core::marker::PhantomData; /// allows code to import and use `Env` directly (such as the native /// contract) to call host methods without having to write `VmCaller::none()` /// everywhere. - #[cfg(feature = "wasmi")] pub struct VmCaller<'a, T>(pub Option>); #[cfg(feature = "wasmi")] @@ -68,7 +68,7 @@ impl<'a, T> VmCaller<'a, T> { /////////////////////////////////////////////////////////////////////////////// /// X-macro use: defining trait VmCallerEnv /////////////////////////////////////////////////////////////////////////////// - +// // This is a helper macro used only by generate_vmcaller_checked_env_trait // below. It consumes a token-tree of the form: // @@ -160,7 +160,7 @@ call_macro_with_all_host_functions! { generate_vmcaller_checked_env_trait } /////////////////////////////////////////////////////////////////////////////// /// X-macro use: impl Env for VmCallerEnv /////////////////////////////////////////////////////////////////////////////// - +// // This is a helper macro used only by // generate_impl_checked_env_for_vmcaller_checked_env below. It consumes a // token-tree of the form: diff --git a/soroban-env-common/tests/no_std/src/lib.rs b/soroban-env-common/tests/no_std/src/lib.rs index 6d3f2d792..8746dd56a 100644 --- a/soroban-env-common/tests/no_std/src/lib.rs +++ b/soroban-env-common/tests/no_std/src/lib.rs @@ -5,7 +5,7 @@ /// panic handler has been already linked in. If soroban_env_common imports /// libstd by accident then this crate will fail to build because there will be /// two panic hanlders. - +// // Import a type from soroban_env_common so that the compiler includes it in the // build. #[allow(unused_imports)] diff --git a/soroban-env-guest/src/guest.rs b/soroban-env-guest/src/guest.rs index 3f9283746..0e1430339 100644 --- a/soroban-env-guest/src/guest.rs +++ b/soroban-env-guest/src/guest.rs @@ -194,7 +194,7 @@ impl EnvBase for Guest { /////////////////////////////////////////////////////////////////////////////// /// X-macro use: impl Env for Guest /////////////////////////////////////////////////////////////////////////////// - +// // This is a helper macro used only by impl_env_for_guest below. It consumes a // token-tree of the form: // @@ -273,7 +273,7 @@ call_macro_with_all_host_functions! { impl_env_for_guest } /////////////////////////////////////////////////////////////////////////////// /// X-macro use: extern mod blocks /////////////////////////////////////////////////////////////////////////////// - +// // This is a helper macro used only by impl_env_for_guest below. It consumes a // token-tree of the form: // diff --git a/soroban-env-host/src/auth.rs b/soroban-env-host/src/auth.rs index 84bc96e23..a222eee81 100644 --- a/soroban-env-host/src/auth.rs +++ b/soroban-env-host/src/auth.rs @@ -2335,6 +2335,28 @@ impl Host { Ok(self.try_borrow_authorization_manager()?.clone()) } + /// Switches host to the recording authorization mode and inherits the + /// recording mode settings from the provided authorization manager settings + /// in case if it used the recording mode. + /// + /// This is similar to `switch_to_recording_auth`, but should be preferred + /// to use in conjunction with `snapshot_auth_manager`, such that the + /// recording mode settings are not overridden. + pub fn switch_to_recording_auth_inherited_from_snapshot( + &self, + auth_manager_snapshot: &AuthorizationManager, + ) -> Result<(), HostError> { + let disable_non_root_auth = match &auth_manager_snapshot.mode { + AuthorizationMode::Enforcing => true, + AuthorizationMode::Recording(recording_auth_info) => { + recording_auth_info.disable_non_root_auth + } + }; + *self.try_borrow_authorization_manager_mut()? = + AuthorizationManager::new_recording(disable_non_root_auth); + Ok(()) + } + /// Replaces authorization manager with the provided new instance. /// /// Use this in conjunction with `snapshot_auth_manager` to do authorized diff --git a/soroban-env-host/src/builtin_contracts/contract_error.rs b/soroban-env-host/src/builtin_contracts/contract_error.rs index 1f5345937..6ee435f2a 100644 --- a/soroban-env-host/src/builtin_contracts/contract_error.rs +++ b/soroban-env-host/src/builtin_contracts/contract_error.rs @@ -1,3 +1,4 @@ +#![allow(non_local_definitions)] use num_derive::FromPrimitive; use soroban_env_common::Error; diff --git a/soroban-env-host/src/builtin_contracts/stellar_asset_contract/balance.rs b/soroban-env-host/src/builtin_contracts/stellar_asset_contract/balance.rs index c13c0ebbf..3249ca95d 100644 --- a/soroban-env-host/src/builtin_contracts/stellar_asset_contract/balance.rs +++ b/soroban-env-host/src/builtin_contracts/stellar_asset_contract/balance.rs @@ -32,7 +32,7 @@ use super::storage_types::{BalanceValue, BALANCE_EXTEND_AMOUNT, BALANCE_TTL_THRE /// semantics have been implemented for these balances. If the asset issuer has /// the AUTH_REQUIRED flag set, then the non-account identifier must first be authorized /// by the issuer/admin before it's allowed to hold a balance. - +// // Metering: covered by components. pub(crate) fn read_balance(e: &Host, addr: Address) -> Result { match addr.to_sc_address()? { diff --git a/soroban-env-host/src/crypto/bls12_381.rs b/soroban-env-host/src/crypto/bls12_381.rs index 8b1c862fe..7580a11e4 100644 --- a/soroban-env-host/src/crypto/bls12_381.rs +++ b/soroban-env-host/src/crypto/bls12_381.rs @@ -36,7 +36,7 @@ pub(crate) const FR_SERIALIZED_SIZE: usize = 32; #[inline(always)] fn units_of_fp() -> u64 { - ((EXPECTED_SIZE + FP_SERIALIZED_SIZE - 1) / FP_SERIALIZED_SIZE) as u64 + EXPECTED_SIZE.div_ceil(FP_SERIALIZED_SIZE) as u64 } impl Host { diff --git a/soroban-env-host/src/e2e_invoke.rs b/soroban-env-host/src/e2e_invoke.rs index cae1d7675..d97fc920c 100644 --- a/soroban-env-host/src/e2e_invoke.rs +++ b/soroban-env-host/src/e2e_invoke.rs @@ -856,7 +856,7 @@ struct StorageMapSnapshotSource<'a> { map: &'a StorageMap, } -impl<'a> SnapshotSource for StorageMapSnapshotSource<'a> { +impl SnapshotSource for StorageMapSnapshotSource<'_> { fn get(&self, key: &Rc) -> Result, HostError> { if let Some(Some((entry, live_until_ledger))) = self.map.get::>(key, self.budget)? diff --git a/soroban-env-host/src/fees.rs b/soroban-env-host/src/fees.rs index 1ddbd486d..93c2c87cc 100644 --- a/soroban-env-host/src/fees.rs +++ b/soroban-env-host/src/fees.rs @@ -3,7 +3,7 @@ /// This is technically not part of the Soroban host and is provided here for /// the sake of sharing between the systems that run Soroban host (such as /// Stellar core or Soroban RPC service). - +/// /// Rough estimate of the base size of any transaction result in the archives /// (independent of the transaction envelope size). pub const TX_BASE_RESULT_SIZE: u32 = 300; diff --git a/soroban-env-host/src/host/invocation_metering.rs b/soroban-env-host/src/host/invocation_metering.rs index a49e1376a..ad968995c 100644 --- a/soroban-env-host/src/host/invocation_metering.rs +++ b/soroban-env-host/src/host/invocation_metering.rs @@ -195,7 +195,7 @@ pub(crate) struct InvocationMeterScope<'a> { host: &'a Host, } -impl<'a> Drop for InvocationMeterScope<'a> { +impl Drop for InvocationMeterScope<'_> { fn drop(&mut self) { self.meter.finish_invocation(self.host); } diff --git a/soroban-env-host/src/host/metered_xdr.rs b/soroban-env-host/src/host/metered_xdr.rs index 77aa77d8e..ec8ddf419 100644 --- a/soroban-env-host/src/host/metered_xdr.rs +++ b/soroban-env-host/src/host/metered_xdr.rs @@ -11,7 +11,7 @@ struct MeteredWrite<'a, W: Write> { w: &'a mut W, } -impl<'a, W> Write for MeteredWrite<'a, W> +impl Write for MeteredWrite<'_, W> where W: Write, { diff --git a/soroban-env-host/src/host/trace/fmt.rs b/soroban-env-host/src/host/trace/fmt.rs index da424327b..c70c1cc76 100644 --- a/soroban-env-host/src/host/trace/fmt.rs +++ b/soroban-env-host/src/host/trace/fmt.rs @@ -2,7 +2,7 @@ use super::{TraceEvent, TraceState}; use crate::{host::Frame, xdr::ContractExecutable, Symbol, SymbolObject, SymbolSmall, Val}; use core::fmt::{Debug, Display}; -impl<'a> Debug for TraceEvent<'a> { +impl Debug for TraceEvent<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { TraceEvent::Begin => write!(f, "TraceEvent::Begin"), @@ -86,7 +86,7 @@ impl Display for FrameId { } } -impl<'a> TraceEvent<'a> { +impl TraceEvent<'_> { pub fn is_begin(&self) -> bool { match self { TraceEvent::Begin => true, @@ -146,7 +146,7 @@ impl<'a> TraceEvent<'a> { } } -impl<'a> Display for TraceEvent<'a> { +impl Display for TraceEvent<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { TraceEvent::PushCtx(ctx) => { diff --git a/soroban-env-host/src/testutils.rs b/soroban-env-host/src/testutils.rs index ea33b04c0..68b7aab3f 100644 --- a/soroban-env-host/src/testutils.rs +++ b/soroban-env-host/src/testutils.rs @@ -297,7 +297,7 @@ impl Host { let prev_source_account = self.source_account_id()?; // Use recording auth to skip specifying the auth payload. let prev_auth_manager = self.snapshot_auth_manager()?; - self.switch_to_recording_auth(true)?; + self.switch_to_recording_auth_inherited_from_snapshot(&prev_auth_manager)?; let wasm_hash = self.upload_wasm(self.bytes_new_from_slice(contract_wasm)?)?; self.set_source_account(account.clone())?; diff --git a/soroban-env-host/src/vm.rs b/soroban-env-host/src/vm.rs index 5e7779a8c..10b52a188 100644 --- a/soroban-env-host/src/vm.rs +++ b/soroban-env-host/src/vm.rs @@ -281,7 +281,6 @@ impl Vm { /// With the introduction of the granular cost inputs this method /// should only be used for the one-off full parses of the new Wasms /// during the initial upload verification. - pub fn new(host: &Host, contract_id: Hash, wasm: &[u8]) -> Result, HostError> { let cost_inputs = VersionedContractCodeCostInputs::V0 { wasm_bytes: wasm.len(), diff --git a/soroban-env-host/src/vm/dispatch.rs b/soroban-env-host/src/vm/dispatch.rs index 460c4c28d..514e12cd9 100644 --- a/soroban-env-host/src/vm/dispatch.rs +++ b/soroban-env-host/src/vm/dispatch.rs @@ -129,7 +129,7 @@ impl RelativeObjectConversion for U32Val {} /////////////////////////////////////////////////////////////////////////////// /// X-macro use: dispatch functions /////////////////////////////////////////////////////////////////////////////// - +// // This is a callback macro that pattern-matches the token-tree passed by the // x-macro (call_macro_with_all_host_functions) and produces a suite of // dispatch-function definitions. diff --git a/soroban-env-host/src/vm/func_info.rs b/soroban-env-host/src/vm/func_info.rs index 647c478f8..d70d9faa5 100644 --- a/soroban-env-host/src/vm/func_info.rs +++ b/soroban-env-host/src/vm/func_info.rs @@ -85,7 +85,7 @@ macro_rules! host_function_info_helper { /////////////////////////////////////////////////////////////////////////////// /// X-macro use: static HOST_FUNCTIONS array of HostFuncInfo /////////////////////////////////////////////////////////////////////////////// - +// // This is a callback macro that pattern-matches the token-tree passed by the // x-macro (call_macro_with_all_host_functions) and produces a suite of // dispatch-function definitions. diff --git a/soroban-simulation/src/snapshot_source.rs b/soroban-simulation/src/snapshot_source.rs index f2eb15537..f177e904b 100644 --- a/soroban-simulation/src/snapshot_source.rs +++ b/soroban-simulation/src/snapshot_source.rs @@ -162,7 +162,7 @@ enum SnapshotSourceHolder<'a> { Rc(Rc), } -impl<'a> SnapshotSource for SnapshotSourceHolder<'a> { +impl SnapshotSource for SnapshotSourceHolder<'_> { fn get(&self, key: &Rc) -> Result, HostError> { match self { SnapshotSourceHolder::Ref(r) => r.get(key), @@ -216,7 +216,7 @@ impl<'a, T: SnapshotSourceWithArchive> SimulationSnapshotSourceWithArchive<'a, T } } -impl<'a> SnapshotSource for SimulationSnapshotSource<'a> { +impl SnapshotSource for SimulationSnapshotSource<'_> { fn get(&self, key: &Rc) -> Result, HostError> { Ok(self .entry_updater @@ -225,8 +225,8 @@ impl<'a> SnapshotSource for SimulationSnapshotSource<'a> { } } -impl<'a, T: SnapshotSourceWithArchive> SnapshotSourceWithArchive - for SimulationSnapshotSourceWithArchive<'a, T> +impl SnapshotSourceWithArchive + for SimulationSnapshotSourceWithArchive<'_, T> { fn get_including_archived( &self,