Skip to content

Commit

Permalink
integrate non-native transaction into execution flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraser999 committed Feb 19, 2024
1 parent 6bbc2d2 commit 33f7688
Show file tree
Hide file tree
Showing 165 changed files with 3,283 additions and 4,174 deletions.
24 changes: 22 additions & 2 deletions execution_engine/src/engine_state/engine_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use num_rational::Ratio;
use num_traits::One;

use casper_types::{
account::AccountHash, FeeHandling, PublicKey, RefundHandling, SystemConfig, WasmConfig,
DEFAULT_REFUND_HANDLING,
account::AccountHash, FeeHandling, ProtocolVersion, PublicKey, RefundHandling, SystemConfig,
WasmConfig, DEFAULT_REFUND_HANDLING,
};

/// Default value for a maximum query depth configuration option.
Expand Down Expand Up @@ -43,6 +43,8 @@ pub const DEFAULT_ALLOW_UNRESTRICTED_TRANSFERS: bool = true;
pub const DEFAULT_FEE_HANDLING: FeeHandling = FeeHandling::PayToProposer;
/// Default compute rewards.
pub const DEFAULT_COMPUTE_REWARDS: bool = true;
/// Default protocol version.
pub const DEFAULT_PROTOCOL_VERSION: ProtocolVersion = ProtocolVersion::V1_0_0;

/// The runtime configuration of the execution engine
#[derive(Debug, Clone)]
Expand All @@ -62,6 +64,7 @@ pub struct EngineConfig {
max_delegators_per_validator: Option<u32>,
wasm_config: WasmConfig,
system_config: SystemConfig,
protocol_version: ProtocolVersion,
/// A private network specifies a list of administrative accounts.
pub(crate) administrative_accounts: BTreeSet<AccountHash>,
/// Auction entrypoints such as "add_bid" or "delegate" are disabled if this flag is set to
Expand Down Expand Up @@ -99,6 +102,7 @@ impl Default for EngineConfig {
refund_handling: DEFAULT_REFUND_HANDLING,
fee_handling: DEFAULT_FEE_HANDLING,
compute_rewards: DEFAULT_COMPUTE_REWARDS,
protocol_version: DEFAULT_PROTOCOL_VERSION,
}
}
}
Expand All @@ -123,6 +127,7 @@ impl EngineConfig {
max_delegators_per_validator: Option<u32>,
wasm_config: WasmConfig,
system_config: SystemConfig,
protocol_version: ProtocolVersion,
) -> EngineConfig {
Self {
max_query_depth,
Expand All @@ -134,6 +139,7 @@ impl EngineConfig {
max_delegators_per_validator,
wasm_config,
system_config,
protocol_version,
administrative_accounts: Default::default(),
allow_auction_bids: DEFAULT_ALLOW_AUCTION_BIDS,
allow_unrestricted_transfers: DEFAULT_ALLOW_UNRESTRICTED_TRANSFERS,
Expand Down Expand Up @@ -163,6 +169,11 @@ impl EngineConfig {
&self.system_config
}

/// Returns the current protocol version.
pub fn protocol_version(&self) -> ProtocolVersion {
self.protocol_version
}

/// Returns the minimum delegation amount in motes.
pub fn minimum_delegation_amount(&self) -> u64 {
self.minimum_delegation_amount
Expand Down Expand Up @@ -234,6 +245,7 @@ pub struct EngineConfigBuilder {
max_delegators_per_validator: Option<u32>,
wasm_config: Option<WasmConfig>,
system_config: Option<SystemConfig>,
protocol_version: Option<ProtocolVersion>,
administrative_accounts: Option<BTreeSet<PublicKey>>,
allow_auction_bids: Option<bool>,
allow_unrestricted_transfers: Option<bool>,
Expand Down Expand Up @@ -299,6 +311,12 @@ impl EngineConfigBuilder {
self
}

/// Sets the protocol version.
pub fn with_protocol_version(mut self, protocol_version: ProtocolVersion) -> Self {
self.protocol_version = Some(protocol_version);
self
}

/// Sets the maximum wasm stack height config option.
pub fn with_wasm_max_stack_height(mut self, wasm_stack_height: u32) -> Self {
let wasm_config = self.wasm_config.get_or_insert_with(WasmConfig::default);
Expand Down Expand Up @@ -374,6 +392,7 @@ impl EngineConfigBuilder {
.unwrap_or(DEFAULT_MINIMUM_DELEGATION_AMOUNT);
let wasm_config = self.wasm_config.unwrap_or_default();
let system_config = self.system_config.unwrap_or_default();
let protocol_version = self.protocol_version.unwrap_or(DEFAULT_PROTOCOL_VERSION);
let administrative_accounts = {
self.administrative_accounts
.unwrap_or_default()
Expand Down Expand Up @@ -406,6 +425,7 @@ impl EngineConfigBuilder {
minimum_delegation_amount,
wasm_config,
system_config,
protocol_version,
administrative_accounts,
allow_auction_bids,
allow_unrestricted_transfers,
Expand Down
9 changes: 6 additions & 3 deletions execution_engine/src/engine_state/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,15 @@ pub enum Error {
/// Invalid deploy item variant.
#[error("Unsupported deploy item variant: {0}")]
InvalidDeployItemVariant(String),
/// Empty module bytes cannot be used for custom payment.
#[error("empty module bytes cannot be used for custom payment")]
EmptyCustomPaymentModuleBytes,
/// Commit error.
#[error(transparent)]
CommitError(#[from] CommitError),
/// Missing system contract registry.
#[error("Missing system contract registry")]
MissingSystemContractRegistry,
/// Missing system entity registry.
#[error("Missing system entity registry")]
MissingSystemEntityRegistry,
/// Missing system contract hash.
#[error("Missing system contract hash: {0}")]
MissingSystemContractHash(String),
Expand Down
Loading

0 comments on commit 33f7688

Please sign in to comment.