Skip to content

Commit 9e8d0e3

Browse files
dariorussiamnnstefan-mysten
authored
Binary limits (MystenLabs#16684)
## Description Organize better several limits... ## Test Plan How did you test the new or updated feature? --- If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes --------- Co-authored-by: Ashok Menon <[email protected]> Co-authored-by: Stefan Stanciulescu <[email protected]>
1 parent 3de11db commit 9e8d0e3

File tree

319 files changed

+41979
-2691
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

319 files changed

+41979
-2691
lines changed

Cargo.lock

Lines changed: 117 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ exclude = [
6161
"external-crates/move/move-execution/v1/crates/move-bytecode-verifier",
6262
"external-crates/move/move-execution/v1/crates/move-stdlib",
6363
"external-crates/move/move-execution/v1/crates/move-vm-runtime",
64+
"external-crates/move/move-execution/v2/crates/move-bytecode-verifier",
65+
"external-crates/move/move-execution/v2/crates/move-stdlib",
66+
"external-crates/move/move-execution/v2/crates/move-vm-runtime",
6467
"sdk/move-bytecode-template",
6568
]
6669

@@ -183,6 +186,9 @@ members = [
183186
"sui-execution/v1/sui-adapter",
184187
"sui-execution/v1/sui-move-natives",
185188
"sui-execution/v1/sui-verifier",
189+
"sui-execution/v2/sui-adapter",
190+
"sui-execution/v2/sui-move-natives",
191+
"sui-execution/v2/sui-verifier",
186192
]
187193

188194
[workspace.package]

crates/sui-core/src/authority.rs

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use fastcrypto::encoding::Base58;
1313
use fastcrypto::encoding::Encoding;
1414
use fastcrypto::hash::MultisetHash;
1515
use itertools::Itertools;
16+
use move_binary_format::binary_config::BinaryConfig;
1617
use move_binary_format::CompiledModule;
1718
use move_core_types::annotated_value::MoveStructLayout;
1819
use move_core_types::language_storage::ModuleId;
@@ -156,6 +157,7 @@ use crate::transaction_manager::TransactionManager;
156157

157158
#[cfg(msim)]
158159
use sui_types::committee::CommitteeTrait;
160+
use sui_types::execution_config_utils::to_binary_config;
159161

160162
#[cfg(test)]
161163
#[path = "unit_tests/authority_tests.rs"]
@@ -4059,8 +4061,7 @@ impl AuthorityState {
40594061
/// compatible with the current versions of those packages on-chain.
40604062
pub async fn get_available_system_packages(
40614063
&self,
4062-
max_binary_format_version: u32,
4063-
no_extraneous_module_bytes: bool,
4064+
binary_config: &BinaryConfig,
40644065
) -> Vec<ObjectRef> {
40654066
let mut results = vec![];
40664067

@@ -4084,8 +4085,7 @@ impl AuthorityState {
40844085
system_package.id(),
40854086
&modules,
40864087
system_package.dependencies().to_vec(),
4087-
max_binary_format_version,
4088-
no_extraneous_module_bytes,
4088+
binary_config,
40894089
)
40904090
.await
40914091
else {
@@ -4113,8 +4113,7 @@ impl AuthorityState {
41134113
async fn get_system_package_bytes(
41144114
&self,
41154115
system_packages: Vec<ObjectRef>,
4116-
move_binary_format_version: u32,
4117-
no_extraneous_module_bytes: bool,
4116+
binary_config: &BinaryConfig,
41184117
) -> Option<Vec<(SequenceNumber, Vec<Vec<u8>>, Vec<ObjectID>)>> {
41194118
let ids: Vec<_> = system_packages.iter().map(|(id, _, _)| *id).collect();
41204119
let objects = self.get_objects(&ids).await.expect("read cannot fail");
@@ -4151,14 +4150,7 @@ impl AuthorityState {
41514150

41524151
let modules: Vec<_> = bytes
41534152
.iter()
4154-
.map(|m| {
4155-
CompiledModule::deserialize_with_config(
4156-
m,
4157-
move_binary_format_version,
4158-
no_extraneous_module_bytes,
4159-
)
4160-
.unwrap()
4161-
})
4153+
.map(|m| CompiledModule::deserialize_with_config(m, binary_config).unwrap())
41624154
.collect();
41634155

41644156
let new_object = Object::new_system_package(
@@ -4415,12 +4407,9 @@ impl AuthorityState {
44154407
// since system packages are created during the current epoch, they should abide by the
44164408
// rules of the current epoch, including the current epoch's max Move binary format version
44174409
let config = epoch_store.protocol_config();
4410+
let binary_config = to_binary_config(config);
44184411
let Some(next_epoch_system_package_bytes) = self
4419-
.get_system_package_bytes(
4420-
next_epoch_system_packages.clone(),
4421-
config.move_binary_format_version(),
4422-
config.no_extraneous_module_bytes(),
4423-
)
4412+
.get_system_package_bytes(next_epoch_system_packages.clone(), &binary_config)
44244413
.await
44254414
else {
44264415
error!(

crates/sui-core/src/transaction_outputs.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ impl TransactionOutputs {
3535
mutable_inputs,
3636
written,
3737
events,
38-
max_binary_format_version: _,
3938
loaded_runtime_objects: _,
40-
no_extraneous_module_bytes: _,
39+
binary_config: _,
4140
runtime_packages_loaded_from_db: _,
4241
lamport_version,
4342
} = inner_temporary_store;

crates/sui-core/src/unit_tests/move_package_upgrade_tests.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use sui_types::{
1818
use std::{collections::BTreeSet, path::PathBuf, str::FromStr, sync::Arc};
1919
use sui_types::effects::{TransactionEffects, TransactionEffectsAPI};
2020
use sui_types::error::{SuiError, UserInputError};
21+
use sui_types::execution_config_utils::to_binary_config;
2122
use sui_types::execution_status::{
2223
CommandArgumentError, ExecutionFailureStatus, ExecutionStatus, PackageUpgradeError,
2324
};
@@ -269,13 +270,8 @@ async fn test_upgrade_package_happy_path() {
269270
.unwrap()
270271
.unwrap();
271272
let config = ProtocolConfig::get_for_max_version_UNSAFE();
272-
let normalized_modules = package
273-
.move_package()
274-
.normalize(
275-
config.move_binary_format_version(),
276-
config.no_extraneous_module_bytes(),
277-
)
278-
.unwrap();
273+
let binary_config = to_binary_config(&config);
274+
let normalized_modules = package.move_package().normalize(&binary_config).unwrap();
279275
assert!(normalized_modules.contains_key("new_module"));
280276
assert!(normalized_modules["new_module"]
281277
.functions

crates/sui-framework-snapshot/tests/compatibility_tests.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mod compatibility_tests {
66
use sui_framework::{compare_system_package, BuiltInFramework};
77
use sui_framework_snapshot::{load_bytecode_snapshot, load_bytecode_snapshot_manifest};
88
use sui_protocol_config::{Chain, ProtocolConfig, ProtocolVersion};
9+
use sui_types::execution_config_utils::to_binary_config;
910

1011
#[tokio::test]
1112
async fn test_framework_compatibility() {
@@ -14,8 +15,7 @@ mod compatibility_tests {
1415
for (version, _snapshots) in load_bytecode_snapshot_manifest() {
1516
let config =
1617
ProtocolConfig::get_for_version(ProtocolVersion::new(version), Chain::Unknown);
17-
let max_binary_format_version = config.move_binary_format_version();
18-
let no_extraneous_module_bytes = config.no_extraneous_module_bytes();
18+
let binary_config = to_binary_config(&config);
1919
let framework = load_bytecode_snapshot(version).unwrap();
2020
let old_framework_store: BTreeMap<_, _> = framework
2121
.into_iter()
@@ -27,8 +27,7 @@ mod compatibility_tests {
2727
cur_package.id(),
2828
&cur_package.modules(),
2929
cur_package.dependencies().to_vec(),
30-
max_binary_format_version,
31-
no_extraneous_module_bytes,
30+
&binary_config,
3231
)
3332
.await
3433
.is_none()

crates/sui-framework/docs/deepbook/clob_v2.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,15 @@ do not have this capability:
11321132

11331133

11341134

1135+
<a name="0xdee9_clob_v2_EIncorrectPoolOwner"></a>
1136+
1137+
1138+
1139+
<pre><code><b>const</b> <a href="clob_v2.md#0xdee9_clob_v2_EIncorrectPoolOwner">EIncorrectPoolOwner</a>: u64 = 1;
1140+
</code></pre>
1141+
1142+
1143+
11351144
<a name="0xdee9_clob_v2_EInvalidFee"></a>
11361145

11371146

@@ -1310,7 +1319,7 @@ Accessor functions
13101319
Function to withdraw fees created from a pool
13111320

13121321

1313-
<pre><code><b>public</b> <b>fun</b> <a href="clob_v2.md#0xdee9_clob_v2_withdraw_fees">withdraw_fees</a>&lt;BaseAsset, QuoteAsset&gt;(_pool_owner_cap: &<a href="clob_v2.md#0xdee9_clob_v2_PoolOwnerCap">clob_v2::PoolOwnerCap</a>, pool: &<b>mut</b> <a href="clob_v2.md#0xdee9_clob_v2_Pool">clob_v2::Pool</a>&lt;BaseAsset, QuoteAsset&gt;, ctx: &<b>mut</b> <a href="dependencies/sui-framework/tx_context.md#0x2_tx_context_TxContext">tx_context::TxContext</a>): <a href="dependencies/sui-framework/coin.md#0x2_coin_Coin">coin::Coin</a>&lt;QuoteAsset&gt;
1322+
<pre><code><b>public</b> <b>fun</b> <a href="clob_v2.md#0xdee9_clob_v2_withdraw_fees">withdraw_fees</a>&lt;BaseAsset, QuoteAsset&gt;(pool_owner_cap: &<a href="clob_v2.md#0xdee9_clob_v2_PoolOwnerCap">clob_v2::PoolOwnerCap</a>, pool: &<b>mut</b> <a href="clob_v2.md#0xdee9_clob_v2_Pool">clob_v2::Pool</a>&lt;BaseAsset, QuoteAsset&gt;, ctx: &<b>mut</b> <a href="dependencies/sui-framework/tx_context.md#0x2_tx_context_TxContext">tx_context::TxContext</a>): <a href="dependencies/sui-framework/coin.md#0x2_coin_Coin">coin::Coin</a>&lt;QuoteAsset&gt;
13141323
</code></pre>
13151324

13161325

@@ -1320,10 +1329,11 @@ Function to withdraw fees created from a pool
13201329

13211330

13221331
<pre><code><b>public</b> <b>fun</b> <a href="clob_v2.md#0xdee9_clob_v2_withdraw_fees">withdraw_fees</a>&lt;BaseAsset, QuoteAsset&gt;(
1323-
_pool_owner_cap: &<a href="clob_v2.md#0xdee9_clob_v2_PoolOwnerCap">PoolOwnerCap</a>,
1332+
pool_owner_cap: &<a href="clob_v2.md#0xdee9_clob_v2_PoolOwnerCap">PoolOwnerCap</a>,
13241333
pool: &<b>mut</b> <a href="clob_v2.md#0xdee9_clob_v2_Pool">Pool</a>&lt;BaseAsset, QuoteAsset&gt;,
13251334
ctx: &<b>mut</b> TxContext,
13261335
): Coin&lt;QuoteAsset&gt; {
1336+
<b>assert</b>!(pool_owner_cap.owner == <a href="dependencies/sui-framework/object.md#0x2_object_uid_to_address">object::uid_to_address</a>(&pool.id), <a href="clob_v2.md#0xdee9_clob_v2_EIncorrectPoolOwner">EIncorrectPoolOwner</a>);
13271337
<b>let</b> quantity = <a href="clob_v2.md#0xdee9_clob_v2_quote_asset_trading_fees_value">quote_asset_trading_fees_value</a>(pool);
13281338
<b>let</b> to_withdraw = <a href="dependencies/sui-framework/balance.md#0x2_balance_split">balance::split</a>(&<b>mut</b> pool.quote_asset_trading_fees, quantity);
13291339
<a href="dependencies/sui-framework/coin.md#0x2_coin_from_balance">coin::from_balance</a>(to_withdraw, ctx)
@@ -1569,11 +1579,8 @@ Helper function that all the create pools now call to create pools.
15691579

15701580
// Creates the capability <b>to</b> mark a pool owner.
15711581
<b>let</b> id = <a href="dependencies/sui-framework/object.md#0x2_object_new">object::new</a>(ctx);
1572-
<b>let</b> owner = <a href="dependencies/sui-framework/object.md#0x2_object_uid_to_address">object::uid_to_address</a>(&id);
1573-
<b>let</b> pool_owner_cap = <a href="clob_v2.md#0xdee9_clob_v2_PoolOwnerCap">PoolOwnerCap</a> {
1574-
id,
1575-
owner
1576-
};
1582+
<b>let</b> owner = <a href="dependencies/sui-framework/object.md#0x2_object_uid_to_address">object::uid_to_address</a>(&pool_uid);
1583+
<b>let</b> pool_owner_cap = <a href="clob_v2.md#0xdee9_clob_v2_PoolOwnerCap">PoolOwnerCap</a> { id, owner };
15771584

15781585
<a href="dependencies/sui-framework/event.md#0x2_event_emit">event::emit</a>(<a href="clob_v2.md#0xdee9_clob_v2_PoolCreated">PoolCreated</a> {
15791586
pool_id,

0 commit comments

Comments
 (0)