Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a flag for enabling msm API in Move (on only in devnet) #16838

Merged
merged 2 commits into from
Mar 25, 2024
Merged
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
1 change: 1 addition & 0 deletions crates/sui-open-rpc/spec/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,7 @@
"disallow_change_struct_type_params_on_upgrade": false,
"enable_coin_deny_list": false,
"enable_effects_v2": false,
"enable_group_ops_native_function_msm": false,
"enable_group_ops_native_functions": false,
"enable_jwk_consensus_updates": false,
"enable_poseidon": false,
Expand Down
13 changes: 11 additions & 2 deletions crates/sui-protocol-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const MAX_PROTOCOL_VERSION: u64 = 42;
// Version 39: Allow skipped epochs for randomness updates.
// Extra version to fix `test_upgrade_compatibility` simtest.
// Version 40:
// Version 41: Enable group operations native functions in testnet and mainnet.
// Version 41: Enable group operations native functions in testnet and mainnet (without msm).
// Version 42: Migrate sui framework and related code to Move 2024
#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub struct ProtocolVersion(u64);
Expand Down Expand Up @@ -386,6 +386,10 @@ struct FeatureFlags {
#[serde(skip_serializing_if = "is_false")]
enable_group_ops_native_functions: bool,

// Enable native function for msm.
#[serde(skip_serializing_if = "is_false")]
enable_group_ops_native_function_msm: bool,

// Reject functions with mutable Random.
#[serde(skip_serializing_if = "is_false")]
reject_mutable_random_on_entry_functions: bool,
Expand Down Expand Up @@ -1175,6 +1179,10 @@ impl ProtocolConfig {
self.feature_flags.enable_group_ops_native_functions
}

pub fn enable_group_ops_native_function_msm(&self) -> bool {
self.feature_flags.enable_group_ops_native_function_msm
}

pub fn reject_mutable_random_on_entry_functions(&self) -> bool {
self.feature_flags.reject_mutable_random_on_entry_functions
}
Expand Down Expand Up @@ -1905,6 +1913,7 @@ impl ProtocolConfig {
// Only enable group ops on devnet
if chain != Chain::Mainnet && chain != Chain::Testnet {
cfg.feature_flags.enable_group_ops_native_functions = true;
cfg.feature_flags.enable_group_ops_native_function_msm = true;
// Next values are arbitrary in a similar way as the other crypto native functions.
cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
cfg.group_ops_bls12381_decode_g1_cost = Some(52);
Expand Down Expand Up @@ -1981,7 +1990,7 @@ impl ProtocolConfig {
}
40 => {}
41 => {
// Enable group ops and all networks
// Enable group ops and all networks (but not msm)
cfg.feature_flags.enable_group_ops_native_functions = true;
// Next values are arbitrary in a similar way as the other crypto native functions.
cfg.group_ops_bls12381_decode_scalar_cost = Some(52);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ feature_flags:
enable_poseidon: true
enable_coin_deny_list: true
enable_group_ops_native_functions: true
enable_group_ops_native_function_msm: true
max_tx_size_bytes: 131072
max_input_objects: 2048
max_size_written_objects: 5000000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ feature_flags:
enable_poseidon: true
enable_coin_deny_list: true
enable_group_ops_native_functions: true
enable_group_ops_native_function_msm: true
reject_mutable_random_on_entry_functions: true
max_tx_size_bytes: 131072
max_input_objects: 2048
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ feature_flags:
enable_poseidon: true
enable_coin_deny_list: true
enable_group_ops_native_functions: true
enable_group_ops_native_function_msm: true
reject_mutable_random_on_entry_functions: true
max_tx_size_bytes: 131072
max_input_objects: 2048
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ feature_flags:
enable_poseidon: true
enable_coin_deny_list: true
enable_group_ops_native_functions: true
enable_group_ops_native_function_msm: true
reject_mutable_random_on_entry_functions: true
max_tx_size_bytes: 131072
max_input_objects: 2048
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ feature_flags:
enable_poseidon: true
enable_coin_deny_list: true
enable_group_ops_native_functions: true
enable_group_ops_native_function_msm: true
reject_mutable_random_on_entry_functions: true
max_tx_size_bytes: 131072
max_input_objects: 2048
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ feature_flags:
enable_poseidon: true
enable_coin_deny_list: true
enable_group_ops_native_functions: true
enable_group_ops_native_function_msm: true
reject_mutable_random_on_entry_functions: true
max_tx_size_bytes: 131072
max_input_objects: 2048
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ feature_flags:
enable_poseidon: true
enable_coin_deny_list: true
enable_group_ops_native_functions: true
enable_group_ops_native_function_msm: true
reject_mutable_random_on_entry_functions: true
max_tx_size_bytes: 131072
max_input_objects: 2048
Expand Down
10 changes: 9 additions & 1 deletion sui-execution/latest/sui-move-natives/src/crypto/group_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ fn is_supported(context: &NativeContext) -> bool {
.enable_group_ops_native_functions()
}

fn is_msm_supported(context: &NativeContext) -> bool {
context
.extensions()
.get::<ObjectRuntime>()
.protocol_config
.enable_group_ops_native_function_msm()
}

// Gas related structs and functions.

#[derive(Clone)]
Expand Down Expand Up @@ -639,7 +647,7 @@ pub fn internal_multi_scalar_mul(
debug_assert!(args.len() == 3);

let cost = context.gas_used();
if !is_supported(context) {
if !is_msm_supported(context) {
benr-ml marked this conversation as resolved.
Show resolved Hide resolved
return Ok(NativeResult::err(cost, NOT_SUPPORTED_ERROR));
}

Expand Down
Loading