Skip to content

Commit

Permalink
[2/x][dynamic child loading] Use new object runtime (MystenLabs#4928)
Browse files Browse the repository at this point in the history
* [2/x][dynamic child loading] Use new object runtime

- Use a new runtime using native extensions for object transfers
- Necessitates an entirely new test_scenario module and implementation
- New ObjectRetrieval trait needed for the runtime and will be later used for dynamic child object fetching (the trait might change a bit for that PR)
  • Loading branch information
tnowacki authored Oct 11, 2022
1 parent fd73b22 commit 4dcea7f
Show file tree
Hide file tree
Showing 65 changed files with 3,033 additions and 3,425 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ written: object(106)

task 3 'run'. lines 43-43:
written: object(108)
deleted: object(107)
deleted: object(_), object(107)
3 changes: 2 additions & 1 deletion crates/sui-adapter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ anyhow = { version = "1.0.64", features = ["backtrace"] }
bcs = "0.1.3"
leb128 = "0.2.5"
once_cell = "1.14.0"
linked-hash-map = "0.5.6"

move-binary-format.workspace = true
move-core-types.workspace = true
move-vm-runtime.workspace = true

sui-framework = { path = "../sui-framework" }
sui-verifier = { path = "../sui-verifier" }
sui-json = { path = "../sui-json" }
sui-verifier = { path = "../sui-verifier" }
sui-types = { path = "../sui-types" }
workspace-hack.workspace = true

Expand Down
539 changes: 221 additions & 318 deletions crates/sui-adapter/src/adapter.rs

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions crates/sui-adapter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@
pub mod adapter;
pub mod bytecode_rewriter;
pub mod genesis;
pub mod in_memory_storage;
pub mod object_root_ancestor_map;
pub mod temporary_store;
4 changes: 2 additions & 2 deletions crates/sui-config/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ use std::convert::TryInto;
use std::{fs, path::Path};
use sui_adapter::adapter;
use sui_adapter::adapter::MoveVM;
use sui_adapter::in_memory_storage::InMemoryStorage;
use sui_adapter::temporary_store::{InnerTemporaryStore, TemporaryStore};
use sui_types::base_types::ObjectID;
use sui_types::base_types::TransactionDigest;
use sui_types::crypto::{AuthorityPublicKey, ToFromBytes};
use sui_types::crypto::{AuthorityPublicKeyBytes, AuthoritySignature};
use sui_types::gas::SuiGasStatus;
use sui_types::in_memory_storage::InMemoryStorage;
use sui_types::messages::CallArg;
use sui_types::messages::InputObjects;
use sui_types::messages::Transaction;
use sui_types::sui_serde::{Base64, Encoding};
use sui_types::sui_system_state::SuiSystemState;
use sui_types::temporary_store::{InnerTemporaryStore, TemporaryStore};
use sui_types::MOVE_STDLIB_ADDRESS;
use sui_types::SUI_FRAMEWORK_ADDRESS;
use sui_types::{
Expand Down

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ use std::{
},
};
use sui_adapter::adapter;
use sui_adapter::temporary_store::InnerTemporaryStore;
use sui_config::genesis::Genesis;
use sui_json_rpc_types::{SuiEventEnvelope, SuiTransactionEffects};
use sui_simulator::nondeterministic;
Expand All @@ -53,6 +52,7 @@ use sui_storage::{
IndexStore,
};
use sui_types::crypto::{AuthorityKeyPair, NetworkKeyPair};
use sui_types::temporary_store::InnerTemporaryStore;
use sui_types::{
base_types::*,
batch::{TxSequenceNumber, UpdateItem},
Expand Down Expand Up @@ -89,7 +89,7 @@ pub mod move_integration_tests;
#[path = "unit_tests/gas_tests.rs"]
mod gas_tests;

pub use sui_adapter::temporary_store::TemporaryStore;
pub use sui_types::temporary_store::TemporaryStore;

pub mod authority_store_tables;

Expand Down
8 changes: 4 additions & 4 deletions crates/sui-core/src/execution_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
use move_core_types::ident_str;
use move_core_types::identifier::Identifier;
use std::{collections::BTreeSet, sync::Arc};
#[cfg(test)]
use sui_adapter::temporary_store;
use sui_adapter::temporary_store::InnerTemporaryStore;
use sui_types::id::UID;
use sui_types::storage::{DeleteKind, ParentSync, WriteKind};
use sui_types::storage::{DeleteKind, ObjectResolver, ParentSync, WriteKind};
#[cfg(test)]
use sui_types::temporary_store;
use sui_types::temporary_store::InnerTemporaryStore;

use crate::authority::TemporaryStore;
use move_core_types::language_storage::ModuleId;
Expand Down
28 changes: 15 additions & 13 deletions crates/sui-core/src/unit_tests/data/hero/sources/hero.move
Original file line number Diff line number Diff line change
Expand Up @@ -303,42 +303,44 @@ module examples::hero {
let admin = ADMIN;
let player = @0x0;

let scenario = &mut test_scenario::begin(&admin);
let scenario_val = test_scenario::begin(admin);
let scenario = &mut scenario_val;
// Run the module initializers
{
let ctx = test_scenario::ctx(scenario);
trusted_coin::test_init(ctx);
init(ctx);
};
// Admin mints 500 coins and sends them to the Player so they can buy game items
test_scenario::next_tx(scenario, &admin);
test_scenario::next_tx(scenario, admin);
{
let treasury_cap = test_scenario::take_owned<TreasuryCap<EXAMPLE>>(scenario);
let treasury_cap = test_scenario::take_from_sender<TreasuryCap<EXAMPLE>>(scenario);
let ctx = test_scenario::ctx(scenario);
let coins = coin::mint(&mut treasury_cap, 500, ctx);
transfer::transfer(coins, copy player);
test_scenario::return_owned(scenario, treasury_cap);
test_scenario::return_to_sender(scenario, treasury_cap);
};
// Player purchases a hero with the coins
test_scenario::next_tx(scenario, &player);
test_scenario::next_tx(scenario, player);
{
let coin = test_scenario::take_owned<Coin<EXAMPLE>>(scenario);
let coin = test_scenario::take_from_sender<Coin<EXAMPLE>>(scenario);
acquire_hero(coin, test_scenario::ctx(scenario));
};
// Admin sends a boar to the Player
test_scenario::next_tx(scenario, &admin);
test_scenario::next_tx(scenario, admin);
{
let admin_cap = test_scenario::take_owned<GameAdmin>(scenario);
let admin_cap = test_scenario::take_from_sender<GameAdmin>(scenario);
send_boar(&mut admin_cap, 10, 10, player, test_scenario::ctx(scenario));
test_scenario::return_owned(scenario, admin_cap)
test_scenario::return_to_sender(scenario, admin_cap)
};
// Player slays the boar!
test_scenario::next_tx(scenario, &player);
test_scenario::next_tx(scenario, player);
{
let hero = test_scenario::take_owned<Hero>(scenario);
let boar = test_scenario::take_owned<Boar>(scenario);
let hero = test_scenario::take_from_sender<Hero>(scenario);
let boar = test_scenario::take_from_sender<Boar>(scenario);
slay(&mut hero, boar, test_scenario::ctx(scenario));
test_scenario::return_owned(scenario, hero)
test_scenario::return_to_sender(scenario, hero)
};
test_scenario::end(scenario_val);
}
}
2 changes: 1 addition & 1 deletion crates/sui-cost/src/estimator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use serde::{Deserialize, Serialize};
use std::sync::Arc;
use strum_macros::Display;
use strum_macros::EnumString;
use sui_adapter::temporary_store::TemporaryStore;
use sui_core::authority::AuthorityState;
use sui_core::test_utils::to_sender_signed_transaction;
use sui_core::transaction_input_checker;
Expand All @@ -24,6 +23,7 @@ use sui_types::gas_coin::GasCoin;
use sui_types::messages::SingleTransactionKind;
use sui_types::messages::TransactionData;
use sui_types::messages::TransactionKind;
use sui_types::temporary_store::TemporaryStore;

const DEFAULT_COMPUTATION_GAS_UNIT_PRICE: u64 = 1;
const DEFAULT_STORAGE_GAS_UNIT_PRICE: u64 = 1;
Expand Down
Loading

0 comments on commit 4dcea7f

Please sign in to comment.