Skip to content

Commit

Permalink
[sui-framework] separate sui-framework into two packages (#9618)
Browse files Browse the repository at this point in the history
## Description 

This PR splits our `sui-framework` Move code into two packages, one for
modules in `governance` folder and one for the rest of the modules. Most
of the changes here are pretty mechanical, mostly about making sure we
use the right package(s) and correct path.

## Test Plan 

Existing tests should pass.

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [x] user-visible impact
- [x] breaking change for a client SDKs
- [x] breaking change for FNs (FN binary must upgrade)
- [x] breaking change for validators or node operators (must upgrade
binaries)
- [x] breaking change for on-chain data layout
- [x] necessitate either a data wipe or data migration

### Release notes
`sui-framework` Move package is split up into two packages,
`sui-framework` and `sui-system`. `sui-system` contains modules that
were in the `governance` folder.
  • Loading branch information
emmazzz authored and benr-ml committed Mar 22, 2023
1 parent 3dae400 commit 60127f2
Show file tree
Hide file tree
Showing 257 changed files with 2,949 additions and 4,743 deletions.
7 changes: 7 additions & 0 deletions .changeset/rich-rats-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@mysten/wallet-adapter-unsafe-burner": minor
"@mysten/wallet-standard": minor
"@mysten/sui.js": minor
---

Change the address of Move package for staking and validator related Move modules.
5 changes: 3 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ jobs:
command: build

- name: Prover Run
working-directory: crates/sui-framework
working-directory: crates/sui-framework/packages
run: |
set -o pipefail
DOTNET_ROOT="$HOME/.dotnet"
Expand All @@ -286,7 +286,8 @@ jobs:
export Z3_EXE="${BIN_DIR}/z3"
export CVC5_EXE="${BIN_DIR}/cvc5"
export BOOGIE_EXE="${DOTNET_ROOT}/tools/boogie"
/home/runner/.cargo/bin/cargo run -p sui -- move prove
/home/runner/.cargo/bin/cargo run -p sui -- move prove -p sui-framework
/home/runner/.cargo/bin/cargo run -p sui -- move prove -p sui-system
indexer:
name: indexer
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ storage/

# Move-related files
Move.lock
!crates/sui-framework/Move.lock
!crates/sui-framework/deps/move-stdlib/Move.lock
!crates/sui-framework/packages/move-stdlib/Move.lock
!crates/sui-framework/packages/sui-framework/Move.lock
!crates/sui-framework/packages/sui-system/Move.lock
.trace
.coverage_map.mvcov

Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/src/hooks/useGetValidatorsEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useRpcClient } from '@mysten/core';
import { type PaginatedEvents, type EventId } from '@mysten/sui.js';
import { useQuery, type UseQueryResult } from '@tanstack/react-query';

export const VALIDATORS_EVENTS_QUERY = '0x2::validator_set::ValidatorEpochInfo';
export const VALIDATORS_EVENTS_QUERY = '0x3::validator_set::ValidatorEpochInfo';

type GetValidatorsEvent = {
cursor?: EventId | null;
Expand Down
4 changes: 2 additions & 2 deletions apps/wallet/src/ui/app/components/receipt-card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ function ReceiptCard({ txn, activeAddress }: ReceiptCardProps) {
const showGasSummary = isSuccessful && isSender && gasTotal;
const showSponsorInfo = !isSuccessful && isSender && isSponsoredTransaction;
const stakedTxn = events?.find(
({ type }) => type === '0x2::validator::StakingRequestEvent'
({ type }) => type === '0x3::validator::StakingRequestEvent'
);

const unstakeTxn = events?.find(
({ type }) => type === '0x2::validator::UnstakingRequestEvent'
({ type }) => type === '0x3::validator::UnstakingRequestEvent'
);

let txnGasSummary: JSX.Element | undefined;
Expand Down
4 changes: 2 additions & 2 deletions apps/wallet/src/ui/app/staking/stake/utils/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function createStakeTransaction(amount: bigint, validator: string) {
const tx = new Transaction();
const stakeCoin = tx.splitCoins(tx.gas, [tx.pure(amount)]);
tx.moveCall({
target: '0x2::sui_system::request_add_stake',
target: '0x3::sui_system::request_add_stake',
arguments: [
tx.object(SUI_SYSTEM_STATE_OBJECT_ID),
stakeCoin,
Expand All @@ -20,7 +20,7 @@ export function createStakeTransaction(amount: bigint, validator: string) {
export function createUnstakeTransaction(stakedSuiId: string) {
const tx = new Transaction();
tx.moveCall({
target: '0x2::sui_system::request_withdraw_stake',
target: '0x3::sui_system::request_withdraw_stake',
arguments: [
tx.object(SUI_SYSTEM_STATE_OBJECT_ID),
tx.object(stakedSuiId),
Expand Down
6 changes: 3 additions & 3 deletions crates/sui-adapter/src/execution_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use sui_types::{
};
use sui_types::{
is_system_package, SUI_CLOCK_OBJECT_ID, SUI_CLOCK_OBJECT_SHARED_VERSION,
SUI_FRAMEWORK_OBJECT_ID, SUI_SYSTEM_STATE_OBJECT_SHARED_VERSION,
SUI_FRAMEWORK_OBJECT_ID, SUI_SYSTEM_PACKAGE_ID, SUI_SYSTEM_STATE_OBJECT_SHARED_VERSION,
};

use sui_types::temporary_store::TemporaryStore;
Expand Down Expand Up @@ -367,7 +367,7 @@ pub fn construct_advance_epoch_pt(
);

let storage_rebates = builder.programmable_move_call(
SUI_FRAMEWORK_OBJECT_ID,
SUI_SYSTEM_PACKAGE_ID,
SUI_SYSTEM_MODULE_NAME.to_owned(),
ADVANCE_EPOCH_FUNCTION_NAME.to_owned(),
vec![],
Expand Down Expand Up @@ -432,7 +432,7 @@ fn advance_epoch<S: BackingPackageStore + ParentSync + ChildObjectResolver>(
});
// TODO: Rewards should be kept in safe mode too.
let res = builder.move_call(
SUI_FRAMEWORK_OBJECT_ID,
SUI_SYSTEM_PACKAGE_ID,
SUI_SYSTEM_MODULE_NAME.to_owned(),
function,
vec![],
Expand Down
27 changes: 13 additions & 14 deletions crates/sui-config/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::convert::TryInto;
use std::{fs, path::Path};
use sui_adapter::adapter::MoveVM;
use sui_adapter::{adapter, execution_mode, programmable_transactions};
use sui_framework::{MoveStdlib, SuiFramework, SystemPackage};
use sui_framework::{MoveStdlib, SuiFramework, SuiSystem, SystemPackage};
use sui_protocol_config::ProtocolConfig;
use sui_types::base_types::{ExecutionDigests, TransactionDigest};
use sui_types::base_types::{ObjectID, SequenceNumber, SuiAddress};
Expand Down Expand Up @@ -48,14 +48,13 @@ use sui_types::sui_system_state::{
SuiSystemStateInnerGenesis, SuiSystemStateTrait, SuiSystemStateWrapper, SuiValidatorGenesis,
};
use sui_types::temporary_store::{InnerTemporaryStore, TemporaryStore};
use sui_types::MOVE_STDLIB_ADDRESS;
use sui_types::SUI_FRAMEWORK_ADDRESS;
use sui_types::{
base_types::TxContext,
committee::{Committee, EpochId, ProtocolVersion},
error::SuiResult,
object::Object,
};
use sui_types::{SUI_FRAMEWORK_ADDRESS, SUI_SYSTEM_ADDRESS};
use tracing::trace;

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -878,6 +877,7 @@ fn create_genesis_context(
token_distribution_schedule: &TokenDistributionSchedule,
move_framework: Vec<Vec<u8>>,
sui_framework: Vec<Vec<u8>>,
sui_system_package: Vec<Vec<u8>>,
) -> TxContext {
let mut hasher = DefaultHash::default();
hasher.update(b"sui-genesis");
Expand All @@ -886,6 +886,7 @@ fn create_genesis_context(
hasher.update(&bcs::to_bytes(token_distribution_schedule).unwrap());
hasher.update(&bcs::to_bytes(&move_framework).unwrap());
hasher.update(&bcs::to_bytes(&sui_framework).unwrap());
hasher.update(&bcs::to_bytes(&sui_system_package).unwrap());

let hash = hasher.finalize();
let genesis_transaction_digest = TransactionDigest::new(hash.into());
Expand Down Expand Up @@ -928,6 +929,7 @@ fn build_unsigned_genesis_data(
token_distribution_schedule,
MoveStdlib::as_bytes(),
SuiFramework::as_bytes(),
SuiSystem::as_bytes(),
);

// Get Move and Sui Framework
Expand All @@ -940,6 +942,10 @@ fn build_unsigned_genesis_data(
SuiFramework::as_modules(),
SuiFramework::transitive_dependencies(),
),
(
SuiSystem::as_modules(),
SuiSystem::transitive_dependencies(),
),
];

let objects = create_genesis_objects(
Expand Down Expand Up @@ -1040,10 +1046,7 @@ fn create_genesis_transaction(
protocol_config,
);

let native_functions = sui_framework::natives::all_natives(
sui_types::MOVE_STDLIB_ADDRESS,
sui_types::SUI_FRAMEWORK_ADDRESS,
);
let native_functions = sui_framework::natives::all_natives();
let move_vm = std::sync::Arc::new(
adapter::new_move_vm(native_functions, protocol_config)
.expect("We defined natives to not fail here"),
Expand Down Expand Up @@ -1098,8 +1101,7 @@ fn create_genesis_objects(
let protocol_config =
ProtocolConfig::get_for_version(ProtocolVersion::new(parameters.protocol_version));

let native_functions =
sui_framework::natives::all_natives(MOVE_STDLIB_ADDRESS, SUI_FRAMEWORK_ADDRESS);
let native_functions = sui_framework::natives::all_natives();
let move_vm = adapter::new_move_vm(native_functions.clone(), &protocol_config)
.expect("We defined natives to not fail here");

Expand Down Expand Up @@ -1274,7 +1276,7 @@ pub fn generate_genesis_system_object(
.collect::<Result<_, _>>()?;
arguments.append(&mut call_arg_arguments);
builder.programmable_move_call(
SUI_FRAMEWORK_ADDRESS.into(),
SUI_SYSTEM_ADDRESS.into(),
ident_str!("genesis").to_owned(),
ident_str!("create").to_owned(),
vec![],
Expand Down Expand Up @@ -1547,10 +1549,7 @@ mod test {
&protocol_config,
);

let native_functions = sui_framework::natives::all_natives(
sui_types::MOVE_STDLIB_ADDRESS,
sui_types::SUI_FRAMEWORK_ADDRESS,
);
let native_functions = sui_framework::natives::all_natives();
let move_vm = std::sync::Arc::new(
adapter::new_move_vm(native_functions, &protocol_config)
.expect("We defined natives to not fail here"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,56 +240,56 @@ validators:
next_epoch_worker_address: ~
extra_fields:
id:
id: "0x167315569601bdeb70f634167ae1c960471542c1b6cc5286bac7de081d255ce0"
id: "0x03838f7b4ae40ab0b2291040509974ee2c8264adce8c08748fcc663491d2cd6d"
size: 0
voting_power: 10000
operation_cap_id: "0x2739d4d0af3a2cb109e0b2a08939332d1f999f1afa39be5e8c7ddaa78b1e8fd9"
operation_cap_id: "0xe880b8b1085e5cf3fde5ba88684311ac8b8ea43f6a99feb0a52c206d0c720d62"
gas_price: 1
staking_pool:
id: "0x35a83139b9dadd55519d02ba20d896464b8ddefafc1845b7d56867317ac307f0"
id: "0x21710d064e393974914a2b0dcc572d8d96c55bc3b4da9c3a80b0dc37c47516f8"
activation_epoch: 0
deactivation_epoch: ~
sui_balance: 25000000000000000
rewards_pool:
value: 0
pool_token_balance: 25000000000000000
exchange_rates:
id: "0x02c783dd3f318aa9284563373fdea4bcbd5eb26ae0b242bf7a6871ee5d1c1200"
id: "0x91d84ed6dc0105a32ea1ea5806b2454fdaa784e8eea5aaa62ab29d4932870b0d"
size: 1
pending_stake: 0
pending_total_sui_withdraw: 0
pending_pool_token_withdraw: 0
extra_fields:
id:
id: "0x3d1865e02970a149abae893b243c8f86cb517a303725a4c32d1d5547a0d4db61"
id: "0x75824803e2a4c17ee0b3712f88693ac9fbce096eca6f1fc2b70d8f8426ea2af6"
size: 0
commission_rate: 0
next_epoch_stake: 25000000000000000
next_epoch_gas_price: 1
next_epoch_commission_rate: 0
extra_fields:
id:
id: "0x2da8c3f5ce601839a8be248bed245fbc4f14f46ff1755575ba95a7c1c98e3a3c"
id: "0x7365155b04cefa5b2941dfc20fb1c2ae86888a0679a64ff25bac3d20b01e4026"
size: 0
pending_active_validators:
contents:
id: "0xb9ca6e9f3db76b8c4299308e37085a20ae85f5787d80b16c7a7ff078f9d38a3d"
id: "0x56053be2d34ea8e9f8763f90df844ede5d0a8f1d1dc65d81457b43416a1a8899"
size: 0
pending_removals: []
staking_pool_mappings:
id: "0x26ad8a1b44c6eb5b5518b378922accddfea3559849bfbda43b26d62f7f763c76"
id: "0x22b9215b1c6804e1796c90df7ac728a3f2ba53ed711e63e88d7516fc846c92f5"
size: 1
inactive_validators:
id: "0xe0bcd17fcc63855a1bb7eef673f518ca6eb6e292e0a0ad7e7b93499780bfa619"
id: "0x68e07ec6a578e119f45c182fc5a4817138a3644420d0747cd04bd75de6248b0e"
size: 0
validator_candidates:
id: "0xf4b38704e3b7c84bb24c6b3a6fa975b4249f851f835664169db1fe70f1704866"
id: "0x50f83cf7c9541d9a1268ed2f1be646b3c83e9c6ee6dbd28c254667fe87b2911d"
size: 0
at_risk_validators:
contents: []
extra_fields:
id:
id: "0x0e6d99a9ae47109cf4ff39b777faaa89fa7968426e840fae629251a813824038"
id: "0xbffb7fb481053445f00c0d104f86ff6a02b96a5e3b22f2e4129093a17914320c"
size: 0
storage_fund:
value: 0
Expand All @@ -298,7 +298,7 @@ parameters:
epoch_duration_ms: 86400000
extra_fields:
id:
id: "0x9447cfacf04ab5bab1d4a75cbf1a55c41aeb2d175c0b6da69c4868189ef57323"
id: "0x1a349a6f387c0ff82d7ac3080c2e3db3c658cd1fda602e59e5593fe0043d1061"
size: 0
reference_gas_price: 1
validator_report_records:
Expand All @@ -312,12 +312,12 @@ stake_subsidy:
stake_subsidy_decrease_rate: 10000
extra_fields:
id:
id: "0xbb63b4a95561b7bd597b990563bea5afc09b64f00d2a6f45cb87677d872b622d"
id: "0xdf827f61fb4c1a584e14428b796468b0d2c04a132b6713f83db4c9ca691ac0fa"
size: 0
safe_mode: false
epoch_start_timestamp_ms: 10
extra_fields:
id:
id: "0x76c4a4e51b0ef0b3947c4284b2fba510c3cc0a6d9e79581c541058cc992a75a2"
id: "0xc8e8268db32f8fbaf610b8241a63ca23807b3d295a683a74406a868da62cdb7a"
size: 0

Loading

0 comments on commit 60127f2

Please sign in to comment.