Skip to content

Commit

Permalink
Merge branch 'feat-2.0' into fix_cancel_reservations_args
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Wójcik committed Dec 11, 2024
2 parents 980b4a5 + 73b3205 commit 9f1282a
Show file tree
Hide file tree
Showing 41 changed files with 762 additions and 590 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ lint-smart-contracts:

.PHONY: audit-rs
audit-rs:
$(CARGO) audit --ignore RUSTSEC-2024-0344 --ignore RUSTSEC-2024-0367 --ignore RUSTSEC-2024-0371
$(CARGO) audit --ignore RUSTSEC-2024-0344 --ignore RUSTSEC-2024-0367 --ignore RUSTSEC-2024-0371 --ignore RUSTSEC-2024-0421

.PHONY: audit-as
audit-as:
Expand Down
4 changes: 2 additions & 2 deletions execution_engine/src/execution/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use casper_types::{
bytesrepr,
execution::TransformError,
system, AccessRights, AddressableEntityHash, ApiError, ByteCodeHash, CLType, CLValueError,
EntityVersionKey, Key, PackageHash, StoredValueTypeMismatch, TransactionRuntime, URef,
ContractRuntimeTag, EntityVersionKey, Key, PackageHash, StoredValueTypeMismatch, URef,
};
use casper_wasm::elements;

Expand Down Expand Up @@ -191,7 +191,7 @@ pub enum Error {
InvalidUtf8Encoding(Utf8Error),
/// Incompatible transaction runtime.
#[error("Incompatible runtime: {0}")]
IncompatibleRuntime(TransactionRuntime),
IncompatibleRuntime(ContractRuntimeTag),
}

impl From<PreprocessingError> for Error {
Expand Down
17 changes: 8 additions & 9 deletions execution_engine/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ use casper_types::{
},
addressable_entity::{
self, ActionThresholds, ActionType, AddressableEntity, AddressableEntityHash,
AssociatedKeys, EntityKindTag, EntryPoint, EntryPointAccess, EntryPointType, EntryPoints,
MessageTopicError, MessageTopics, NamedKeyAddr, NamedKeyValue, Parameter, Weight,
DEFAULT_ENTRY_POINT_NAME,
AssociatedKeys, ContractRuntimeTag, EntityKindTag, EntryPoint, EntryPointAccess,
EntryPointType, EntryPoints, MessageTopicError, MessageTopics, NamedKeyAddr, NamedKeyValue,
Parameter, Weight, DEFAULT_ENTRY_POINT_NAME,
},
bytesrepr::{self, Bytes, FromBytes, ToBytes},
contract_messages::{
Expand All @@ -60,9 +60,8 @@ use casper_types::{
ByteCodeKind, CLTyped, CLValue, ContextAccessRights, Contract, ContractWasm, EntityAddr,
EntityKind, EntityVersion, EntityVersionKey, EntityVersions, Gas, GrantedAccess, Group, Groups,
HashAddr, HostFunction, HostFunctionCost, InitiatorAddr, Key, NamedArg, Package, PackageHash,
PackageStatus, Phase, PublicKey, RuntimeArgs, RuntimeFootprint, StoredValue,
TransactionRuntime, Transfer, TransferResult, TransferV2, TransferredTo, URef,
DICTIONARY_ITEM_KEY_MAX_LENGTH, U512,
PackageStatus, Phase, PublicKey, RuntimeArgs, RuntimeFootprint, StoredValue, Transfer,
TransferResult, TransferV2, TransferredTo, URef, DICTIONARY_ITEM_KEY_MAX_LENGTH, U512,
};

use crate::{
Expand Down Expand Up @@ -1893,14 +1892,14 @@ where
EntityKind::System(_) | EntityKind::Account(_) => {
Key::ByteCode(ByteCodeAddr::Empty)
}
EntityKind::SmartContract(TransactionRuntime::VmCasperV1) => {
EntityKind::SmartContract(ContractRuntimeTag::VmCasperV1) => {
if self.context.engine_config().enable_entity {
Key::ByteCode(ByteCodeAddr::new_wasm_addr(byte_code_addr))
} else {
Key::Hash(byte_code_addr)
}
}
EntityKind::SmartContract(runtime @ TransactionRuntime::VmCasperV2) => {
EntityKind::SmartContract(runtime @ ContractRuntimeTag::VmCasperV2) => {
return Err(ExecError::IncompatibleRuntime(runtime));
}
};
Expand Down Expand Up @@ -2576,7 +2575,7 @@ where
main_purse,
associated_keys,
action_thresholds,
EntityKind::SmartContract(TransactionRuntime::VmCasperV1),
EntityKind::SmartContract(ContractRuntimeTag::VmCasperV1),
);
let entity_key = Key::AddressableEntity(entity_addr);
self.context.metered_write_gs_unsafe(entity_key, entity)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use casper_types::{
bytesrepr::{Bytes, ToBytes},
ApiError, BlockTime, Digest, EraId, InitiatorAddr, Key, PricingMode, ProtocolVersion,
PublicKey, RuntimeArgs, SecretKey, TimeDiff, Timestamp, Transaction, TransactionArgs,
TransactionEntryPoint, TransactionRuntime, TransactionScheduling, TransactionTarget,
TransactionEntryPoint, TransactionRuntimeParams, TransactionScheduling, TransactionTarget,
TransactionV1, TransactionV1Payload,
};

Expand Down Expand Up @@ -49,8 +49,7 @@ fn try_add_contract_version(
let txn = new_transaction_v1_session(
is_install_upgrade,
module_bytes,
casper_types::TransactionRuntime::VmCasperV1,
0,
TransactionRuntimeParams::VmCasperV1,
&DEFAULT_ACCOUNT_SECRET_KEY,
);

Expand Down Expand Up @@ -111,8 +110,7 @@ fn try_add_contract_version(
pub fn new_transaction_v1_session(
is_install_upgrade: bool,
module_bytes: Bytes,
runtime: TransactionRuntime,
transferred_value: u64,
runtime: TransactionRuntimeParams,
secret_key: &SecretKey,
) -> TransactionV1 {
let timestamp = Timestamp::now();
Expand All @@ -121,8 +119,6 @@ pub fn new_transaction_v1_session(
is_install_upgrade,
module_bytes,
runtime,
transferred_value,
seed: None,
};
let args = TransactionArgs::Named(RuntimeArgs::new());
let entry_point = TransactionEntryPoint::Call;
Expand Down
4 changes: 2 additions & 2 deletions execution_engine_testing/tests/src/test/regression/ee_1174.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ use casper_types::{
self,
auction::{self, DelegationRate},
},
ApiError, U512,
ApiError, DEFAULT_MINIMUM_BID_AMOUNT, U512,
};

const LARGE_DELEGATION_RATE: DelegationRate = 101;

#[ignore]
#[test]
fn should_run_ee_1174_delegation_rate_too_high() {
let bid_amount = U512::one();
let bid_amount = U512::from(DEFAULT_MINIMUM_BID_AMOUNT);

let mut builder = LmdbWasmTestBuilder::default();
builder.run_genesis(LOCAL_GENESIS_REQUEST.clone());
Expand Down
24 changes: 13 additions & 11 deletions execution_engine_testing/tests/src/test/regression/ee_1217.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use casper_execution_engine::{
engine_state::{engine_config::DEFAULT_MINIMUM_DELEGATION_AMOUNT, Error as CoreError},
execution::ExecError,
};
use casper_types::{runtime_args, system::auction, ApiError, PublicKey, SecretKey, U512};
use casper_types::{
runtime_args, system::auction, ApiError, PublicKey, SecretKey, DEFAULT_MINIMUM_BID_AMOUNT, U512,
};
use once_cell::sync::Lazy;

const CONTRACT_REGRESSION: &str = "ee_1217_regression.wasm";
Expand Down Expand Up @@ -123,7 +125,7 @@ fn should_fail_to_withdraw_bid_from_stored_session_code() {
*DEFAULT_ACCOUNT_ADDR,
CONTRACT_ADD_BID,
runtime_args! {
auction::ARG_AMOUNT => U512::one(), // zero results in Error::BondTooSmall
auction::ARG_AMOUNT => U512::from(DEFAULT_MINIMUM_BID_AMOUNT), // smaller amount results in Error::BondTooSmall
auction::ARG_PUBLIC_KEY => default_public_key_arg.clone(),
auction::ARG_DELEGATION_RATE => 0u8,
},
Expand Down Expand Up @@ -178,7 +180,7 @@ fn should_fail_to_withdraw_bid_from_stored_contract_code() {
*DEFAULT_ACCOUNT_ADDR,
CONTRACT_ADD_BID,
runtime_args! {
auction::ARG_AMOUNT => U512::one(), // zero results in Error::BondTooSmall
auction::ARG_AMOUNT => U512::from(DEFAULT_MINIMUM_BID_AMOUNT), // smaller amount results in Error::BondTooSmall
auction::ARG_PUBLIC_KEY => default_public_key_arg.clone(),
auction::ARG_DELEGATION_RATE => 0u8,
},
Expand Down Expand Up @@ -252,7 +254,7 @@ fn should_fail_to_delegate_from_stored_session_code() {
VALIDATOR_PUBLIC_KEY.to_account_hash(),
CONTRACT_ADD_BID,
runtime_args! {
auction::ARG_AMOUNT => U512::one(), // zero results in Error::BondTooSmall
auction::ARG_AMOUNT => U512::from(DEFAULT_MINIMUM_BID_AMOUNT), // smaller amount results in Error::BondTooSmall
auction::ARG_PUBLIC_KEY => validator_public_key_arg.clone(),
auction::ARG_DELEGATION_RATE => 0u8,
},
Expand Down Expand Up @@ -332,7 +334,7 @@ fn should_fail_to_delegate_from_stored_contract_code() {
VALIDATOR_PUBLIC_KEY.to_account_hash(),
CONTRACT_ADD_BID,
runtime_args! {
auction::ARG_AMOUNT => U512::one(), // zero results in Error::BondTooSmall
auction::ARG_AMOUNT => U512::from(DEFAULT_MINIMUM_BID_AMOUNT), // smaller amount results in Error::BondTooSmall
auction::ARG_PUBLIC_KEY => validator_public_key_arg.clone(),
auction::ARG_DELEGATION_RATE => 0u8,
},
Expand Down Expand Up @@ -412,7 +414,7 @@ fn should_fail_to_undelegate_from_stored_session_code() {
VALIDATOR_PUBLIC_KEY.to_account_hash(),
CONTRACT_ADD_BID,
runtime_args! {
auction::ARG_AMOUNT => U512::one(), // zero results in Error::BondTooSmall
auction::ARG_AMOUNT => U512::from(DEFAULT_MINIMUM_BID_AMOUNT), // smaller amount results in Error::BondTooSmall
auction::ARG_PUBLIC_KEY => validator_public_key_arg.clone(),
auction::ARG_DELEGATION_RATE => 0u8,
},
Expand Down Expand Up @@ -506,7 +508,7 @@ fn should_fail_to_undelegate_from_stored_contract_code() {
VALIDATOR_PUBLIC_KEY.to_account_hash(),
CONTRACT_ADD_BID,
runtime_args! {
auction::ARG_AMOUNT => U512::one(), // zero results in Error::BondTooSmall
auction::ARG_AMOUNT => U512::from(DEFAULT_MINIMUM_BID_AMOUNT), // smaller amount results in Error::BondTooSmall
auction::ARG_PUBLIC_KEY => validator_public_key_arg.clone(),
auction::ARG_DELEGATION_RATE => 0u8,
},
Expand Down Expand Up @@ -581,7 +583,7 @@ fn should_fail_to_activate_bid_from_stored_session_code() {
*DEFAULT_ACCOUNT_ADDR,
CONTRACT_ADD_BID,
runtime_args! {
auction::ARG_AMOUNT => U512::one(), // zero results in Error::BondTooSmall
auction::ARG_AMOUNT => U512::from(DEFAULT_MINIMUM_BID_AMOUNT), // smaller amount results in Error::BondTooSmall
auction::ARG_PUBLIC_KEY => default_public_key_arg.clone(),
auction::ARG_DELEGATION_RATE => 0u8,
},
Expand All @@ -592,7 +594,7 @@ fn should_fail_to_activate_bid_from_stored_session_code() {
*DEFAULT_ACCOUNT_ADDR,
CONTRACT_WITHDRAW_BID,
runtime_args! {
auction::ARG_AMOUNT => U512::one(), // zero results in Error::BondTooSmall
auction::ARG_AMOUNT => U512::from(DEFAULT_MINIMUM_BID_AMOUNT), // smaller amount results in Error::BondTooSmall
auction::ARG_PUBLIC_KEY => default_public_key_arg.clone(),
},
)
Expand Down Expand Up @@ -647,7 +649,7 @@ fn should_fail_to_activate_bid_from_stored_contract_code() {
*DEFAULT_ACCOUNT_ADDR,
CONTRACT_ADD_BID,
runtime_args! {
auction::ARG_AMOUNT => U512::one(), // zero results in Error::BondTooSmall
auction::ARG_AMOUNT => U512::from(DEFAULT_MINIMUM_BID_AMOUNT), // smaller amount results in Error::BondTooSmall
auction::ARG_PUBLIC_KEY => default_public_key_arg.clone(),
auction::ARG_DELEGATION_RATE => 0u8,
},
Expand All @@ -658,7 +660,7 @@ fn should_fail_to_activate_bid_from_stored_contract_code() {
*DEFAULT_ACCOUNT_ADDR,
CONTRACT_WITHDRAW_BID,
runtime_args! {
auction::ARG_AMOUNT => U512::one(), // zero results in Error::BondTooSmall
auction::ARG_AMOUNT => U512::from(DEFAULT_MINIMUM_BID_AMOUNT), // smaller amount results in Error::BondTooSmall
auction::ARG_PUBLIC_KEY => default_public_key_arg.clone(),
},
)
Expand Down
7 changes: 4 additions & 3 deletions execution_engine_testing/tests/src/test/regression/gh_3208.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ use casper_types::{
auction::{self, BidAddr, DelegationRate},
standard_payment,
},
ApiError, GenesisAccount, GenesisValidator, Key, Motes, StoredValue, U512,
ApiError, GenesisAccount, GenesisValidator, Key, Motes, StoredValue,
DEFAULT_MINIMUM_BID_AMOUNT, U512,
};

use crate::lmdb_fixture;
Expand Down Expand Up @@ -188,7 +189,7 @@ fn should_immediatelly_unbond_genesis_validator_with_zero_day_vesting_schedule()
auction::METHOD_ADD_BID,
runtime_args! {
auction::ARG_PUBLIC_KEY => DEFAULT_ACCOUNT_PUBLIC_KEY.clone(),
auction::ARG_AMOUNT => U512::from(1u64),
auction::ARG_AMOUNT => U512::from(DEFAULT_MINIMUM_BID_AMOUNT),
auction::ARG_DELEGATION_RATE => 10 as DelegationRate,
},
)
Expand Down Expand Up @@ -316,7 +317,7 @@ fn should_immediatelly_unbond_genesis_validator_with_zero_day_vesting_schedule_a
auction::METHOD_ADD_BID,
runtime_args! {
auction::ARG_PUBLIC_KEY => DEFAULT_ACCOUNT_PUBLIC_KEY.clone(),
auction::ARG_AMOUNT => U512::from(1u64),
auction::ARG_AMOUNT => U512::from(DEFAULT_MINIMUM_BID_AMOUNT),
auction::ARG_DELEGATION_RATE => 10 as DelegationRate,
},
)
Expand Down
5 changes: 3 additions & 2 deletions execution_engine_testing/tests/src/test/regression/gov_116.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ use casper_storage::data_access_layer::GenesisRequest;
use casper_types::{
runtime_args,
system::auction::{self, DelegationRate, EraValidators, VESTING_SCHEDULE_LENGTH_MILLIS},
GenesisAccount, GenesisValidator, Motes, PublicKey, SecretKey, U256, U512,
GenesisAccount, GenesisValidator, Motes, PublicKey, SecretKey, DEFAULT_MINIMUM_BID_AMOUNT,
U256, U512,
};

const MINIMUM_BONDED_AMOUNT: u64 = 1_000;

/// Validator with smallest stake will withdraw most of his stake to ensure we did move time forward
/// to unlock his whole vesting schedule.
const WITHDRAW_AMOUNT: u64 = MINIMUM_BONDED_AMOUNT - 1;
const WITHDRAW_AMOUNT: u64 = MINIMUM_BONDED_AMOUNT - DEFAULT_MINIMUM_BID_AMOUNT;

/// Initial lockup period
const VESTING_BASE: u64 = DEFAULT_GENESIS_TIMESTAMP_MILLIS + DEFAULT_LOCKED_FUNDS_PERIOD_MILLIS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const CONTRACT_TRANSFER_TO_ACCOUNT_U512: &str = "transfer_to_account_u512.wasm";

// This value is not systemic, as code is added the size of WASM will increase,
// you can change this value to reflect the increase in WASM size.
const HOST_FUNCTION_METRICS_STANDARD_SIZE: usize = 132_461;
const HOST_FUNCTION_METRICS_STANDARD_SIZE: usize = 143_164;
const HOST_FUNCTION_METRICS_STANDARD_GAS_COST: u64 = 422_402_224_490;

/// Acceptable size regression/improvement in percentage.
Expand Down
Loading

0 comments on commit 9f1282a

Please sign in to comment.