Skip to content

Commit 00828a9

Browse files
committed
Add configs to trigger any of the three vm+adapter setups
1 parent 5eb00c9 commit 00828a9

File tree

2 files changed

+66
-44
lines changed

2 files changed

+66
-44
lines changed

crates/sui-protocol-config/src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,14 @@ struct FeatureFlags {
778778
#[serde(skip_serializing_if = "is_false")]
779779
enable_ptb_execution_v2: bool,
780780

781+
// Enable the new VM
782+
#[serde(skip_serializing_if = "is_false")]
783+
enable_vm_v2: bool,
784+
785+
// Enable the new adapter
786+
#[serde(skip_serializing_if = "is_false")]
787+
enable_adapter_v2: bool,
788+
781789
// Provide better type resolution errors in the adapter.
782790
#[serde(skip_serializing_if = "is_false")]
783791
better_adapter_type_resolution_errors: bool,
@@ -2525,6 +2533,13 @@ impl ProtocolConfig {
25252533
ProtocolConfig::get_for_version(ProtocolVersion::MAX, Chain::Unknown)
25262534
}
25272535

2536+
pub fn get_use_vm_v2(&self) -> bool {
2537+
self.feature_flags.enable_vm_v2
2538+
}
2539+
pub fn get_use_adapter_v2(&self) -> bool {
2540+
self.feature_flags.enable_adapter_v2
2541+
}
2542+
25282543
fn get_for_version_impl(version: ProtocolVersion, chain: Chain) -> Self {
25292544
#[cfg(msim)]
25302545
{

sui-execution/src/latest.rs

Lines changed: 51 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -98,33 +98,12 @@ impl executor::Executor for Executor {
9898
Result<(), ExecutionError>,
9999
) {
100100
use sui_adapter_replay_cut as replay_cut;
101-
// old vm + old adapter
102-
let current_main = replay_cut::execution_engine::execute_transaction_to_effects::<
103-
replay_cut::execution_mode::Normal,
104-
>(
105-
store,
106-
input_objects.clone(),
107-
gas.clone(),
108-
gas_status.clone(),
109-
transaction_kind.clone(),
110-
transaction_signer,
111-
transaction_digest,
112-
&self.current_main_runtime,
113-
epoch_id,
114-
epoch_timestamp_ms,
115-
protocol_config,
116-
metrics.clone(),
117-
enable_expensive_checks,
118-
execution_params.clone(),
119-
trace_builder_opt,
120-
);
101+
let new_vm = protocol_config.get_use_vm_v2();
102+
let new_adapter = protocol_config.get_use_adapter_v2();
121103

122-
let mut ptb_v2_protocol_config = protocol_config.clone();
123-
ptb_v2_protocol_config.set_enable_ptb_execution_v2_for_testing(true);
124-
125-
// old vm + new adapter
126-
let (m_inner_temporary_store, m_sui_gas_status, m_transaction_effects, _, _) =
127-
replay_cut::execution_engine::execute_transaction_to_effects::<
104+
if !new_vm && !new_adapter {
105+
// old vm + old adapter
106+
let current_main = replay_cut::execution_engine::execute_transaction_to_effects::<
128107
replay_cut::execution_mode::Normal,
129108
>(
130109
store,
@@ -137,13 +116,50 @@ impl executor::Executor for Executor {
137116
&self.current_main_runtime,
138117
epoch_id,
139118
epoch_timestamp_ms,
140-
&ptb_v2_protocol_config,
119+
protocol_config,
141120
metrics.clone(),
142121
enable_expensive_checks,
143122
execution_params.clone(),
144123
trace_builder_opt,
145124
);
125+
return current_main;
126+
}
127+
128+
let mut ptb_v2_protocol_config = protocol_config.clone();
129+
ptb_v2_protocol_config.set_enable_ptb_execution_v2_for_testing(true);
146130

131+
if !new_vm && new_adapter {
132+
// old vm + new adapter
133+
let (m_inner_temporary_store, m_sui_gas_status, m_transaction_effects, _, _) =
134+
replay_cut::execution_engine::execute_transaction_to_effects::<
135+
replay_cut::execution_mode::Normal,
136+
>(
137+
store,
138+
input_objects.clone(),
139+
gas.clone(),
140+
gas_status.clone(),
141+
transaction_kind.clone(),
142+
transaction_signer,
143+
transaction_digest,
144+
&self.current_main_runtime,
145+
epoch_id,
146+
epoch_timestamp_ms,
147+
&ptb_v2_protocol_config,
148+
metrics.clone(),
149+
enable_expensive_checks,
150+
execution_params.clone(),
151+
trace_builder_opt,
152+
);
153+
return (
154+
m_inner_temporary_store,
155+
m_sui_gas_status,
156+
m_transaction_effects,
157+
vec![],
158+
Ok(()),
159+
);
160+
}
161+
162+
// New VM + New Adapter
147163
let (b_inner_temporary_store, b_sui_gas_status, b_transaction_effects, _, _) =
148164
execute_transaction_to_effects::<execution_mode::Normal>(
149165
store,
@@ -162,23 +178,13 @@ impl executor::Executor for Executor {
162178
execution_params,
163179
trace_builder_opt,
164180
);
165-
166-
tracing::debug!("Executed transaction in three configurations");
167-
168-
compare_effects(
169-
&(
170-
m_inner_temporary_store,
171-
m_sui_gas_status,
172-
m_transaction_effects,
173-
),
174-
&(
175-
b_inner_temporary_store,
176-
b_sui_gas_status,
177-
b_transaction_effects,
178-
),
179-
);
180-
181-
current_main
181+
(
182+
b_inner_temporary_store,
183+
b_sui_gas_status,
184+
b_transaction_effects,
185+
vec![],
186+
Ok(()),
187+
)
182188
}
183189

184190
fn dev_inspect_transaction(
@@ -317,6 +323,7 @@ pub fn init_vm_for_msim() {
317323
identifier_interner::init_interner();
318324
}
319325

326+
#[allow(unused)]
320327
fn compare_effects(
321328
normal_effects: &(InnerTemporaryStore, SuiGasStatus, TransactionEffects),
322329
new_effects: &(InnerTemporaryStore, SuiGasStatus, TransactionEffects),

0 commit comments

Comments
 (0)