Skip to content

Commit

Permalink
Address lints
Browse files Browse the repository at this point in the history
  • Loading branch information
darthsiroftardis committed Nov 5, 2024
1 parent e6b2394 commit 2658d25
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 44 deletions.
5 changes: 0 additions & 5 deletions execution_engine/src/runtime_context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ pub enum AllowInstallUpgrade {
Forbidden,
}

enum PackageFootprint {
Package(Package),
ContractPackage(ContractPackage),
}

/// Holds information specific to the deployed contract.
pub struct RuntimeContext<'a, R> {
tracking_copy: Rc<RefCell<TrackingCopy<R>>>,
Expand Down
2 changes: 1 addition & 1 deletion execution_engine/src/runtime_context/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ fn remove_uref_works() {

let next_session_access_rights = footprint
.borrow()
.extract_access_rights(entity_hash.value(), &entity_named_keys);
.extract_access_rights(entity_hash.value());
let address_generator = AddressGenerator::new(&deploy_hash, Phase::Session);

let (runtime_context, _tempdir) = new_runtime_context(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,7 @@ where
self
}

/// Returns the `Account` if present.
pub fn get_account(&self, account_hash: AccountHash) -> Option<Account> {
let stored_value = self
.query(None, Key::Account(account_hash), &[])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,15 @@ fn execute_and_assert_result(
) {
if call_depth == 0 {
builder.exec(execute_request).commit().expect_success();
} else {
if is_invalid_context {
builder.exec(execute_request).commit().expect_failure();
let error = builder.get_error().expect("must have an error");
assert!(matches!(
error,
// Call chains have stored contract trying to call stored session which we don't
// support and is an actual error.
CoreError::Exec(ExecError::InvalidContext)
));
}
} else if is_invalid_context {
builder.exec(execute_request).commit().expect_failure();
let error = builder.get_error().expect("must have an error");
assert!(matches!(
error,
// Call chains have stored contract trying to call stored session which we don't
// support and is an actual error.
CoreError::Exec(ExecError::InvalidContext)
));
}
}

Expand Down
6 changes: 2 additions & 4 deletions execution_engine_testing/tests/src/test/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use casper_execution_engine::{engine_state::Error, execution::ExecError};
use casper_types::{
account::AccountHash,
contracts::{ContractPackageHash, CONTRACT_INITIAL_VERSION},
runtime_args, HoldBalanceHandling, Key, PackageHash, RuntimeArgs, Timestamp, U512,
runtime_args, Key, PackageHash, RuntimeArgs, U512,
};

use crate::{lmdb_fixture, wasm_utils};
use crate::wasm_utils;

const CONTRACT_GROUPS: &str = "groups.wasm";
const PACKAGE_HASH_KEY: &str = "package_hash_key";
Expand All @@ -34,8 +34,6 @@ const CALL_RESTRICTED_ENTRY_POINTS: &str = "call_restricted_entry_points";
const ARG_AMOUNT: &str = "amount";
const ARG_TARGET: &str = "target";

const GROUPS_FIXTURE: &str = "groups";

static TRANSFER_1_AMOUNT: Lazy<U512> =
Lazy::new(|| U512::from(MINIMUM_ACCOUNT_CREATION_BALANCE) + 1000);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use alloc::{boxed::Box, string::ToString, vec};

use casper_contract::contract_api::{runtime, storage};
use casper_types::{
AddressableEntityHash, CLType, EntryPoint, EntryPointAccess, EntryPointPayment, EntryPointType,
EntryPoints, Key, Parameter,
CLType, EntryPoint, EntryPointAccess, EntryPointPayment, EntryPointType, EntryPoints, Key,
Parameter,
};

use get_call_stack_recursive_subcall::{
Expand Down
2 changes: 1 addition & 1 deletion smart_contracts/contracts/test/manage-groups/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use casper_types::{
api_error,
bytesrepr::{self, ToBytes},
contracts::{ContractPackage, ContractPackageHash, NamedKeys},
ApiError, CLType, EntryPointPayment, Group, Key, Package, PackageHash, Parameter, URef,
ApiError, CLType, EntryPointPayment, Group, Key, Parameter, URef,
};

const PACKAGE_HASH_KEY: &str = "package_hash_key";
Expand Down
23 changes: 3 additions & 20 deletions storage/src/tracking_copy/ext_entity.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::collections::BTreeSet;
use tracing::{debug, error, info};
use tracing::{debug, error};

use casper_types::{
account::AccountHash,
Expand Down Expand Up @@ -160,27 +160,14 @@ where
&self,
entity_addr: EntityAddr,
) -> Result<RuntimeFootprint, Self::Error> {
let key = if self.enable_addressable_entity {
Key::AddressableEntity(entity_addr)
} else {
match entity_addr {
EntityAddr::System(system_hash_addr) => Key::Hash(system_hash_addr),
EntityAddr::Account(account_hash) => Key::Account(AccountHash::new(account_hash)),
EntityAddr::SmartContract(contract_hash_addr) => Key::Hash(contract_hash_addr),
}
};

let entity_key = match entity_addr {
EntityAddr::Account(account_addr) => {
let account_key = Key::Account(AccountHash::new(account_addr));
match self.read(&account_key)? {
Some(StoredValue::Account(account)) => {
return Ok(RuntimeFootprint::new_account_footprint(account))
}
Some(StoredValue::CLValue(cl_value)) => {
let key = cl_value.to_t::<Key>()?;
key
}
Some(StoredValue::CLValue(cl_value)) => cl_value.to_t::<Key>()?,
Some(other) => {
return Err(TrackingCopyError::TypeMismatch(
StoredValueTypeMismatch::new(
Expand Down Expand Up @@ -222,10 +209,7 @@ where
maybe_system_entity_type,
));
}
Some(StoredValue::CLValue(cl_value)) => {
let key = cl_value.to_t::<Key>()?;
key
}
Some(StoredValue::CLValue(cl_value)) => cl_value.to_t::<Key>()?,
Some(_) | None => Key::AddressableEntity(entity_addr),
}
}
Expand Down Expand Up @@ -406,7 +390,6 @@ where
}
};
let mint = self.runtime_footprint_by_hash_addr(mint_hash)?;
let mint_named_keys = mint.named_keys();
let mint_access_rights = mint.extract_access_rights(mint_hash);
(mint.take_named_keys(), mint_access_rights)
};
Expand Down

0 comments on commit 2658d25

Please sign in to comment.