Skip to content

Commit

Permalink
[move][natives] added batch bulletproof natives
Browse files Browse the repository at this point in the history
  • Loading branch information
dovgopoly committed Jan 29, 2025
1 parent 9986c83 commit 49abefc
Show file tree
Hide file tree
Showing 9 changed files with 695 additions and 75 deletions.
25 changes: 21 additions & 4 deletions aptos-move/aptos-gas-schedule/src/gas_schedule/aptos_framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,27 @@ crate::gas_schedule::macros::define_gas_parameters!(
[hash_keccak256_per_byte: InternalGasPerByte, { 1.. => "hash.keccak256.per_byte" }, 165],

// Bulletproofs gas parameters begin.
// Generated at time 1683148919.0628748 by `scripts/algebra-gas/update_bulletproofs_gas_params.py` with gas_per_ns=10.0.
[bulletproofs_base: InternalGas, { 11.. => "bulletproofs.base" }, 11794651],
[bulletproofs_per_bit_rangeproof_verify: InternalGasPerArg, { 11.. => "bulletproofs.per_bit_rangeproof_verify" }, 1004253],
[bulletproofs_per_byte_rangeproof_deserialize: InternalGasPerByte, { 11.. => "bulletproofs.per_byte_rangeproof_deserialize" }, 121],
// Generated at time 1738158053.7406907 by `scripts/algebra-gas/update_bulletproofs_gas_params.py` with gas_per_ns=10.0.
[bulletproofs_verify_base_1: InternalGas, { 11.. => "bulletproofs.verify.base_1" }, 1_966_039],
[bulletproofs_verify_base_2: InternalGas, { 11.. => "bulletproofs.verify.base_2" }, 2_992_994],
[bulletproofs_verify_base_4: InternalGas, { 11.. => "bulletproofs.verify.base_4" }, 6_362_208],
[bulletproofs_verify_base_8: InternalGas, { 11.. => "bulletproofs.verify.base_8" }, 8_565_140],
[bulletproofs_verify_base_16: InternalGas, { 11.. => "bulletproofs.verify.base_16" }, 12_538_560],
[bulletproofs_verify_per_bit_1: InternalGasPerByte, { 11.. => "bulletproofs.verify.per_bit_1" }, 130_096],
[bulletproofs_verify_per_bit_2: InternalGasPerByte, { 11.. => "bulletproofs.verify.per_bit_2" }, 228_691],
[bulletproofs_verify_per_bit_4: InternalGasPerByte, { 11.. => "bulletproofs.verify.per_bit_4" }, 359_323],
[bulletproofs_verify_per_bit_8: InternalGasPerByte, { 11.. => "bulletproofs.verify.per_bit_8" }, 658_527],
[bulletproofs_verify_per_bit_16: InternalGasPerByte, { 11.. => "bulletproofs.verify.per_bit_16" }, 1_212_581],
[bulletproofs_deserialize_base_1: InternalGas, { 11.. => "bulletproofs.deserialize.base_1" }, 3_253],
[bulletproofs_deserialize_base_2: InternalGas, { 11.. => "bulletproofs.deserialize.base_2" }, 3_226],
[bulletproofs_deserialize_base_4: InternalGas, { 11.. => "bulletproofs.deserialize.base_4" }, 3_155],
[bulletproofs_deserialize_base_8: InternalGas, { 11.. => "bulletproofs.deserialize.base_8" }, 3_647],
[bulletproofs_deserialize_base_16: InternalGas, { 11.. => "bulletproofs.deserialize.base_16" }, 2_496],
[bulletproofs_deserialize_per_byte_1: InternalGasPerByte, { 11.. => "bulletproofs.deserialize.per_byte_1" }, 34],
[bulletproofs_deserialize_per_byte_2: InternalGasPerByte, { 11.. => "bulletproofs.deserialize.per_byte_2" }, 44],
[bulletproofs_deserialize_per_byte_4: InternalGasPerByte, { 11.. => "bulletproofs.deserialize.per_byte_4" }, 39],
[bulletproofs_deserialize_per_byte_8: InternalGasPerByte, { 11.. => "bulletproofs.deserialize.per_byte_8" }, 28],
[bulletproofs_deserialize_per_byte_16: InternalGasPerByte, { 11.. => "bulletproofs.deserialize.per_byte_16" }, 59],
// Bulletproofs gas parameters end.

[type_info_type_of_base: InternalGas, "type_info.type_of.base", 1102],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ pub enum FeatureFlag {
PermissionedSigner,
AccountAbstraction,
VMBinaryFormatV8,
BulletproofsBatchNatives,
}

fn generate_features_blob(writer: &CodeWriter, data: &[u64]) {
Expand Down Expand Up @@ -367,6 +368,7 @@ impl From<FeatureFlag> for AptosFeatureFlag {
},
FeatureFlag::PermissionedSigner => AptosFeatureFlag::PERMISSIONED_SIGNER,
FeatureFlag::AccountAbstraction => AptosFeatureFlag::ACCOUNT_ABSTRACTION,
FeatureFlag::BulletproofsBatchNatives => AptosFeatureFlag::BULLETPROOFS_BATCH_NATIVES,
}
}
}
Expand Down Expand Up @@ -523,6 +525,7 @@ impl From<AptosFeatureFlag> for FeatureFlag {
},
AptosFeatureFlag::PERMISSIONED_SIGNER => FeatureFlag::PermissionedSigner,
AptosFeatureFlag::ACCOUNT_ABSTRACTION => FeatureFlag::AccountAbstraction,
AptosFeatureFlag::BULLETPROOFS_BATCH_NATIVES => FeatureFlag::BulletproofsBatchNatives,
}
}
}
Expand Down

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions aptos-move/framework/move-stdlib/sources/configs/features.move
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,16 @@ module std::features {
is_enabled(ACCOUNT_ABSTRACTION)
}

/// Whether the batch Bulletproofs native functions are available. This is needed because of the introduction of a new native function.
/// Lifetime: transient
const BULLETPROOFS_BATCH_NATIVES: u64 = 87;

public fun get_bulletproofs_batch_feature(): u64 { BULLETPROOFS_BATCH_NATIVES }

public fun bulletproofs_batch_enabled(): bool acquires Features {
is_enabled(BULLETPROOFS_BATCH_NATIVES)
}

// ============================================================================================
// Feature Flag Implementation

Expand Down
Loading

0 comments on commit 49abefc

Please sign in to comment.