Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/upstream/dev' into remove-…
Browse files Browse the repository at this point in the history
…lane-constants
  • Loading branch information
darthsiroftardis committed Feb 26, 2025
2 parents 3a475cc + e1835ca commit 601fa5f
Show file tree
Hide file tree
Showing 147 changed files with 1,348 additions and 1,052 deletions.
296 changes: 125 additions & 171 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion binary_port/src/binary_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use tokio_util::codec::{self};
use crate::error::Error;

type LengthEncoding = u32;
const LENGTH_ENCODING_SIZE_BYTES: usize = std::mem::size_of::<LengthEncoding>();
const LENGTH_ENCODING_SIZE_BYTES: usize = size_of::<LengthEncoding>();

#[derive(Clone, PartialEq, Debug)]
pub struct BinaryMessage(Bytes);
Expand Down
7 changes: 7 additions & 0 deletions binary_port/src/response_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,13 @@ impl PayloadEntity for AddressableEntityInformation {
const RESPONSE_TYPE: ResponseType = ResponseType::AddressableEntityInformation;
}

impl<T> PayloadEntity for Box<T>
where
T: PayloadEntity,
{
const RESPONSE_TYPE: ResponseType = T::RESPONSE_TYPE;
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
2 changes: 1 addition & 1 deletion execution_engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ itertools = "0.10.3"
linked-hash-map = "0.5.3"
log = { version = "0.4.8", features = ["std", "serde", "kv_unstable"] }
num = { version = "0.4.0", default-features = false }
num-derive = "0.3.0"
num-derive = "0.4.2"
num-rational = { version = "0.4.0", features = ["serde"] }
num-traits = "0.2.10"
num_cpus = "1"
Expand Down
2 changes: 1 addition & 1 deletion execution_engine/src/bin/run_wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ fn load_wasm_file<P: AsRef<Path>>(path: P) -> Vec<u8> {
let path = path.as_ref();
let bytes = fs::read(path).expect("valid file");
match path.extension() {
Some(ext) if ext.to_ascii_lowercase() == "wat" => {
Some(ext) if ext.eq_ignore_ascii_case("wat") => {
wat::parse_bytes(&bytes).expect("valid wat").into_owned()
}
None | Some(_) => bytes,
Expand Down
13 changes: 1 addition & 12 deletions execution_engine/src/engine_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ mod wasm_v1;
use std::{cell::RefCell, collections::BTreeSet, rc::Rc};

use casper_types::{
account::AccountHash, Gas, InitiatorAddr, Key, Phase, RuntimeArgs, StoredValue,
TransactionHash, U512,
account::AccountHash, Gas, InitiatorAddr, Key, Phase, RuntimeArgs, StoredValue, TransactionHash,
};
use once_cell::sync::Lazy;

use casper_storage::{
global_state::{
Expand All @@ -33,15 +31,6 @@ pub use wasm_v1::{
WasmV1Request, WasmV1Result,
};

/// The maximum amount of motes that payment code execution can cost.
pub const MAX_PAYMENT_AMOUNT: u64 = 2_500_000_000;
/// The maximum amount of gas a payment code can use.
///
/// This value also indicates the minimum balance of the main purse of an account when
/// executing payment code, as such amount is held as collateral to compensate for
/// code execution.
pub static MAX_PAYMENT: Lazy<U512> = Lazy::new(|| U512::from(MAX_PAYMENT_AMOUNT));

/// Gas/motes conversion rate of wasmless transfer cost is always 1 regardless of what user wants to
/// pay.
pub const WASMLESS_TRANSFER_FIXED_GAS_PRICE: u8 = 1;
Expand Down
2 changes: 1 addition & 1 deletion execution_engine/src/engine_state/wasm_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub enum SessionInputData<'a> {
},
}

impl<'a> SessionInputData<'a> {
impl SessionInputData<'_> {
/// Transaction hash for the session
pub fn transaction_hash(&self) -> TransactionHash {
match self {
Expand Down
1 change: 0 additions & 1 deletion execution_engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
trivial_numeric_casts,
unused_qualifications
)]
#![warn(missing_docs)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]

pub mod engine_state;
Expand Down
13 changes: 5 additions & 8 deletions execution_engine/src/runtime/auction_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl From<ExecError> for Option<Error> {
}
}

impl<'a, R> StorageProvider for Runtime<'a, R>
impl<R> StorageProvider for Runtime<'_, R>
where
R: StateReader<Key, StoredValue, Error = GlobalStateError>,
{
Expand Down Expand Up @@ -148,7 +148,7 @@ where
}
}

impl<'a, R> RuntimeProvider for Runtime<'a, R>
impl<R> RuntimeProvider for Runtime<'_, R>
where
R: StateReader<Key, StoredValue, Error = GlobalStateError>,
{
Expand Down Expand Up @@ -306,7 +306,7 @@ where
}
}

impl<'a, R> MintProvider for Runtime<'a, R>
impl<R> MintProvider for Runtime<'_, R>
where
R: StateReader<Key, StoredValue, Error = GlobalStateError>,
{
Expand Down Expand Up @@ -509,7 +509,7 @@ where
}
}

impl<'a, R> AccountProvider for Runtime<'a, R>
impl<R> AccountProvider for Runtime<'_, R>
where
R: StateReader<Key, StoredValue, Error = GlobalStateError>,
{
Expand Down Expand Up @@ -538,7 +538,4 @@ where
}
}

impl<'a, R> Auction for Runtime<'a, R> where
R: StateReader<Key, StoredValue, Error = GlobalStateError>
{
}
impl<R> Auction for Runtime<'_, R> where R: StateReader<Key, StoredValue, Error = GlobalStateError> {}
2 changes: 1 addition & 1 deletion execution_engine/src/runtime/externals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use casper_types::{
use super::{args::Args, ExecError, Runtime};
use crate::{resolvers::v1_function_index::FunctionIndex, runtime::cryptography};

impl<'a, R> Externals for Runtime<'a, R>
impl<R> Externals for Runtime<'_, R>
where
R: StateReader<Key, StoredValue, Error = GlobalStateError>,
{
Expand Down
8 changes: 4 additions & 4 deletions execution_engine/src/runtime/handle_payment_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl From<ExecError> for Option<Error> {
}
}

impl<'a, R> MintProvider for Runtime<'a, R>
impl<R> MintProvider for Runtime<'_, R>
where
R: StateReader<Key, StoredValue, Error = GlobalStateError>,
{
Expand Down Expand Up @@ -83,7 +83,7 @@ where
}
}

impl<'a, R> RuntimeProvider for Runtime<'a, R>
impl<R> RuntimeProvider for Runtime<'_, R>
where
R: StateReader<Key, StoredValue, Error = GlobalStateError>,
{
Expand Down Expand Up @@ -164,7 +164,7 @@ where
}
}

impl<'a, R> StorageProvider for Runtime<'a, R>
impl<R> StorageProvider for Runtime<'_, R>
where
R: StateReader<Key, StoredValue, Error = GlobalStateError>,
{
Expand All @@ -177,7 +177,7 @@ where
}
}

impl<'a, R> HandlePayment for Runtime<'a, R> where
impl<R> HandlePayment for Runtime<'_, R> where
R: StateReader<Key, StoredValue, Error = GlobalStateError>
{
}
10 changes: 5 additions & 5 deletions execution_engine/src/runtime/mint_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl From<ExecError> for Option<Error> {
}
}

impl<'a, R> RuntimeProvider for Runtime<'a, R>
impl<R> RuntimeProvider for Runtime<'_, R>
where
R: StateReader<Key, StoredValue, Error = GlobalStateError>,
{
Expand All @@ -42,7 +42,7 @@ where
}

fn get_immediate_caller(&self) -> Option<Caller> {
Runtime::<'a, R>::get_immediate_caller(self).cloned()
Runtime::<'_, R>::get_immediate_caller(self).cloned()
}

fn is_called_from_standard_payment(&self) -> bool {
Expand Down Expand Up @@ -104,7 +104,7 @@ where
}
}

impl<'a, R> StorageProvider for Runtime<'a, R>
impl<R> StorageProvider for Runtime<'_, R>
where
R: StateReader<Key, StoredValue, Error = GlobalStateError>,
{
Expand Down Expand Up @@ -169,7 +169,7 @@ where
}
}

impl<'a, R> SystemProvider for Runtime<'a, R>
impl<R> SystemProvider for Runtime<'_, R>
where
R: StateReader<Key, StoredValue, Error = GlobalStateError>,
{
Expand All @@ -188,7 +188,7 @@ where
}
}

impl<'a, R> Mint for Runtime<'a, R>
impl<R> Mint for Runtime<'_, R>
where
R: StateReader<Key, StoredValue, Error = GlobalStateError>,
{
Expand Down
10 changes: 3 additions & 7 deletions execution_engine/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1611,9 +1611,7 @@ where
}
};

let package_hash = footprint
.package_hash()
.ok_or_else(|| ExecError::InvalidContext)?;
let package_hash = footprint.package_hash().ok_or(ExecError::InvalidContext)?;
let package: Package = self.context.get_package(package_hash)?;

// System contract hashes are disabled at upgrade point
Expand Down Expand Up @@ -1793,7 +1791,7 @@ where

let context_entity_hash = context_entity_key
.into_entity_hash_addr()
.ok_or_else(|| ExecError::UnexpectedKeyVariant(context_entity_key))?;
.ok_or(ExecError::UnexpectedKeyVariant(context_entity_key))?;

let (should_attenuate_urefs, should_validate_urefs) = {
// Determines if this call originated from the system account based on a first
Expand Down Expand Up @@ -1929,9 +1927,7 @@ where
}

let module: Module = {
let byte_code_addr = footprint
.wasm_hash()
.ok_or_else(|| ExecError::InvalidContext)?;
let byte_code_addr = footprint.wasm_hash().ok_or(ExecError::InvalidContext)?;

let byte_code_key = match footprint.entity_kind() {
EntityKind::System(_) | EntityKind::Account(_) => {
Expand Down
55 changes: 22 additions & 33 deletions execution_engine/src/runtime/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,89 +187,78 @@ fn rewrite_urefs(cl_value: CLValue, mut func: impl FnMut(&mut URef)) -> Result<C
}
(CLType::Key, CLType::Bool) => {
let mut res: Result<Key, bool> = cl_value.to_owned().into_t()?;
match &mut res {
Ok(Key::URef(uref)) => func(uref),
Ok(_) | Err(_) => {}
if let Ok(Key::URef(uref)) = &mut res {
func(uref);
}
CLValue::from_t(res)?
}
(CLType::Key, CLType::I32) => {
let mut res: Result<Key, i32> = cl_value.to_owned().into_t()?;
match &mut res {
Ok(Key::URef(uref)) => func(uref),
Ok(_) | Err(_) => {}
if let Ok(Key::URef(uref)) = &mut res {
func(uref);
}
CLValue::from_t(res)?
}
(CLType::Key, CLType::I64) => {
let mut res: Result<Key, i64> = cl_value.to_owned().into_t()?;
match &mut res {
Ok(Key::URef(uref)) => func(uref),
Ok(_) | Err(_) => {}
if let Ok(Key::URef(uref)) = &mut res {
func(uref);
}
CLValue::from_t(res)?
}
(CLType::Key, CLType::U8) => {
let mut res: Result<Key, u8> = cl_value.to_owned().into_t()?;
match &mut res {
Ok(Key::URef(uref)) => func(uref),
Ok(_) | Err(_) => {}
if let Ok(Key::URef(uref)) = &mut res {
func(uref);
}
CLValue::from_t(res)?
}
(CLType::Key, CLType::U32) => {
let mut res: Result<Key, u32> = cl_value.to_owned().into_t()?;
match &mut res {
Ok(Key::URef(uref)) => func(uref),
Ok(_) | Err(_) => {}
if let Ok(Key::URef(uref)) = &mut res {
func(uref);
}
CLValue::from_t(res)?
}
(CLType::Key, CLType::U64) => {
let mut res: Result<Key, u64> = cl_value.to_owned().into_t()?;
match &mut res {
Ok(Key::URef(uref)) => func(uref),
Ok(_) | Err(_) => {}
if let Ok(Key::URef(uref)) = &mut res {
func(uref);
}
CLValue::from_t(res)?
}
(CLType::Key, CLType::U128) => {
let mut res: Result<Key, U128> = cl_value.to_owned().into_t()?;
match &mut res {
Ok(Key::URef(uref)) => func(uref),
Ok(_) | Err(_) => {}
if let Ok(Key::URef(uref)) = &mut res {
func(uref);
}
CLValue::from_t(res)?
}
(CLType::Key, CLType::U256) => {
let mut res: Result<Key, U256> = cl_value.to_owned().into_t()?;
match &mut res {
Ok(Key::URef(uref)) => func(uref),
Ok(_) | Err(_) => {}
if let Ok(Key::URef(uref)) = &mut res {
func(uref);
}
CLValue::from_t(res)?
}
(CLType::Key, CLType::U512) => {
let mut res: Result<Key, U512> = cl_value.to_owned().into_t()?;
match &mut res {
Ok(Key::URef(uref)) => func(uref),
Ok(_) | Err(_) => {}
if let Ok(Key::URef(uref)) = &mut res {
func(uref);
}
CLValue::from_t(res)?
}
(CLType::Key, CLType::Unit) => {
let mut res: Result<Key, ()> = cl_value.to_owned().into_t()?;
match &mut res {
Ok(Key::URef(uref)) => func(uref),
Ok(_) | Err(_) => {}
if let Ok(Key::URef(uref)) = &mut res {
func(uref);
}
CLValue::from_t(res)?
}
(CLType::Key, CLType::String) => {
let mut res: Result<Key, String> = cl_value.to_owned().into_t()?;
match &mut res {
Ok(Key::URef(uref)) => func(uref),
Ok(_) | Err(_) => {}
if let Ok(Key::URef(uref)) = &mut res {
func(uref);
}
CLValue::from_t(res)?
}
Expand Down
Loading

0 comments on commit 601fa5f

Please sign in to comment.