Skip to content
24 changes: 22 additions & 2 deletions execution_engine/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1769,7 +1769,7 @@ where

let maybe_system_entity_type = self.maybe_system_type(contract_hash);

RuntimeFootprint::new_contract_footprint(
RuntimeFootprint::new_vm1_contract_footprint(
ContractHash::new(contract_hash),
contract,
maybe_system_entity_type,
Expand Down Expand Up @@ -1869,7 +1869,7 @@ where
self.migrate_contract_and_contract_package(hash_addr)?;
};
let maybe_system_entity_type = self.maybe_system_type(hash_addr);
RuntimeFootprint::new_contract_footprint(
RuntimeFootprint::new_vm1_contract_footprint(
ContractHash::new(hash_addr),
contract,
maybe_system_entity_type,
Expand Down Expand Up @@ -2144,6 +2144,26 @@ where
ByteCode::new(ByteCodeKind::V1CasperWasm, wasm.take_bytes())
}
Some(StoredValue::ByteCode(byte_code)) => byte_code,
Some(StoredValue::CLValue(key_as_cl_value)) => {
let byte_code_key =
key_as_cl_value.to_t::<Key>().map_err(ExecError::CLValue)?;
if let Key::ByteCode(_) = byte_code_key {
match self.context.read_gs(&byte_code_key)? {
Some(StoredValue::ByteCode(byte_code)) => match byte_code.kind() {
ByteCodeKind::Empty | ByteCodeKind::V1CasperWasm => byte_code,
ByteCodeKind::V2CasperWasm => {
return Err(ExecError::IncompatibleRuntime(
ContractRuntimeTag::VmCasperV2,
))
}
},
Some(_) => return Err(ExecError::UnexpectedStoredValueVariant),
None => return Err(ExecError::KeyNotFound(byte_code_key)),
}
} else {
return Err(ExecError::UnexpectedKeyVariant(byte_code_key));
}
}
Some(_) => {
return Err(ExecError::InvalidByteCode(ByteCodeHash::new(
byte_code_addr,
Expand Down
6 changes: 5 additions & 1 deletion executor/wasm/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use casper_storage::{
global_state::error::Error as GlobalStateError, AddressGenerator, RuntimeNativeConfig,
};
use casper_types::{
account::AccountHash, execution::Effects, BlockHash, BlockTime, Digest, TransactionHash,
account::AccountHash, execution::Effects, BlockHash, BlockTime, CLValueError, Digest,
TransactionHash,
};
use parking_lot::RwLock;
use thiserror::Error;
Expand Down Expand Up @@ -239,4 +240,7 @@ pub enum InstallContractError {

#[error("failed building BuildingExecuteRequest: {0}")]
FailedBuildingExecuteRequest(&'static str),

#[error("CLValue error: {0}")]
CLValueError(CLValueError),
}
Loading