Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ versions = "4.1.0"
linked-hash-map = "0.5.6"
shlex = "1.3.0"
starlark = "0.13.0"
lz4_flex = "0.10.0"

# Move dependencies
move-binary-format = { path = "external-crates/move/crates/move-binary-format" }
Expand Down
30 changes: 30 additions & 0 deletions crates/sui-protocol-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4560,6 +4560,36 @@ impl ProtocolConfig {
self.feature_flags.consensus_batched_block_sync = val;
}

/// NB: We are setting a number of feature flags and protocol config fields here to to
/// facilitate testing of PTB execution v2. These feature flags and config fields should be set
/// with or before enabling PTB execution v2 in a real protocol upgrade.
pub fn set_enable_ptb_execution_v2_for_testing(&mut self, val: bool) {
self.feature_flags.enable_ptb_execution_v2 = val;
// Remove this and set these fields when we move this to be set for a specific protocol
// version.
if val {
self.translation_per_command_base_charge = Some(1);
self.translation_per_input_base_charge = Some(1);
self.translation_pure_input_per_byte_charge = Some(1);
self.translation_per_type_node_charge = Some(1);
self.translation_per_reference_node_charge = Some(1);
self.translation_per_linkage_entry_charge = Some(10);
self.gas_model_version = Some(11);
self.feature_flags.abstract_size_in_object_runtime = true;
self.feature_flags.object_runtime_charge_cache_load_gas = true;
self.dynamic_field_hash_type_and_key_cost_base = Some(52);
self.dynamic_field_add_child_object_cost_base = Some(52);
self.dynamic_field_add_child_object_value_cost_per_byte = Some(1);
self.dynamic_field_borrow_child_object_cost_base = Some(52);
self.dynamic_field_borrow_child_object_child_ref_cost_per_byte = Some(1);
self.dynamic_field_remove_child_object_cost_base = Some(52);
self.dynamic_field_remove_child_object_child_cost_per_byte = Some(1);
self.dynamic_field_has_child_object_cost_base = Some(52);
self.dynamic_field_has_child_object_with_ty_cost_base = Some(52);
self.feature_flags.enable_ptb_execution_v2 = true;
}
}

pub fn set_record_time_estimate_processed_for_testing(&mut self, val: bool) {
self.feature_flags.record_time_estimate_processed = val;
}
Expand Down
8 changes: 7 additions & 1 deletion crates/sui-types/src/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub mod checked {

/// Version aware enum for gas status.
#[enum_dispatch(SuiGasStatusAPI)]
#[derive(Debug)]
#[derive(Debug, Clone)]
pub enum SuiGasStatus {
// V1 does not exists any longer as it was a pre mainnet version.
// So we start the enum from V2
Expand Down Expand Up @@ -121,6 +121,12 @@ pub mod checked {
Self::V2(status) => status.gas_price(),
}
}

pub fn set_inner_gas_model_version(&mut self, version: u64) {
match self {
Self::V2(status) => status.gas_status.gas_model_version = version,
}
}
}

/// Summary of the charges in a transaction.
Expand Down
4 changes: 3 additions & 1 deletion crates/sui-types/src/gas_model/gas_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ mod checked {
/// After execution a call to `GasStatus::bucketize` will round the computation
/// cost to `cost` for the bucket ([`min`, `max`]) the gas used falls into.
#[allow(dead_code)]
#[derive(Clone)]
pub(crate) struct ComputationBucket {
min: u64,
max: u64,
Expand Down Expand Up @@ -81,6 +82,7 @@ mod checked {
}

/// A list of constant costs of various operations in Sui.
#[derive(Clone)]
pub struct SuiCostTable {
/// A flat fee charged for every transaction. This is also the minimum amount of
/// gas charged for a transaction.
Expand Down Expand Up @@ -167,7 +169,7 @@ mod checked {
}

#[allow(dead_code)]
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct SuiGasStatus {
// GasStatus as used by the VM, that is all the VM sees
pub gas_status: GasStatus,
Expand Down
26 changes: 25 additions & 1 deletion crates/sui-types/src/gas_model/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub static INITIAL_COST_SCHEDULE: Lazy<CostTable> = Lazy::new(initial_cost_sched
///
/// Every client must use an instance of this type to interact with the Move VM.
#[allow(dead_code)]
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct GasStatus {
pub gas_model_version: u64,
cost_table: CostTable,
Expand All @@ -70,6 +70,15 @@ pub struct GasStatus {
instructions_current_tier_mult: u64,

pub num_native_calls: u64,
pub transl_gas: u64,
}

#[derive(Debug)]
pub struct GasDetails {
pub instructions_executed: u64,
pub stack_height: u64,
pub memory_allocated: u64,
pub transl_gas_used: u64,
}

impl GasStatus {
Expand Down Expand Up @@ -106,6 +115,7 @@ impl GasStatus {
stack_size_next_tier_start,
instructions_next_tier_start,
num_native_calls: 0,
transl_gas: 0,
}
}

Expand Down Expand Up @@ -133,6 +143,20 @@ impl GasStatus {
stack_size_next_tier_start: None,
instructions_next_tier_start: None,
num_native_calls: 0,
transl_gas: 0,
}
}

pub fn set_transl_gas(&mut self, transl_gas: u64) {
self.transl_gas = transl_gas
}

pub fn gas_details(&self) -> GasDetails {
GasDetails {
instructions_executed: self.instructions_executed,
stack_height: self.stack_height_high_water_mark,
memory_allocated: self.stack_size_high_water_mark,
transl_gas_used: self.transl_gas,
}
}

Expand Down
5 changes: 5 additions & 0 deletions sui-execution/latest/sui-adapter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ tracing.workspace = true
serde.workspace = true
indexmap.workspace = true
serde_json.workspace = true
once_cell.workspace = true
csv.workspace = true
lz4_flex = "0.10.0"

move-binary-format.workspace = true
move-bytecode-utils.workspace = true
Expand All @@ -37,6 +40,8 @@ sui-verifier = { path = "../sui-verifier", package = "sui-verifier-latest" }
move-vm-types = { path = "../../../external-crates/move/crates/move-vm-types" }
move-regex-borrow-graph = { path = "../../../external-crates/move/crates/move-regex-borrow-graph" }

similar.workspace = true

sui-macros.workspace = true
sui-protocol-config.workspace = true
sui-types.workspace = true
Expand Down
Loading
Loading