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

Move TxContext implementation via natives #21343

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 9
task 4, lines 39-41:
//# run Test::M1::delete_n_ids --args 2048 --gas-budget 100000000000000
mutated: object(0,0)
gas summary: computation_cost: 19000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
gas summary: computation_cost: 11000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 5, lines 42-44:
//# run Test::M1::delete_n_ids --args 2049 --gas-budget 100000000000000
Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::tx_context::derive_id (function index 6) at offset 0. Arithmetic error, stack overflow, max value depth, etc.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MovePrimitiveRuntimeError(MoveLocationOpt(Some(MoveLocation { module: ModuleId { address: sui, name: Identifier("tx_context") }, function: 6, instruction: 0, function_name: Some("derive_id") }))), source: Some(VMError { major_status: MEMORY_LIMIT_EXCEEDED, sub_status: Some(2), message: Some("Creating more than 2048 IDs is not allowed"), exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("tx_context") }), indices: [], offsets: [(FunctionDefinitionIndex(6), 0)] }), command: Some(0) } }
Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::tx_context::fresh_id (function index 10) at offset 0. Arithmetic error, stack overflow, max value depth, etc.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MovePrimitiveRuntimeError(MoveLocationOpt(Some(MoveLocation { module: ModuleId { address: sui, name: Identifier("tx_context") }, function: 10, instruction: 0, function_name: Some("fresh_id") }))), source: Some(VMError { major_status: MEMORY_LIMIT_EXCEEDED, sub_status: Some(2), message: Some("Creating more than 2048 IDs is not allowed"), exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("tx_context") }), indices: [], offsets: [(FunctionDefinitionIndex(10), 0)] }), command: Some(0) } }

task 6, line 45:
//# run Test::M1::delete_n_ids --args 4096 --gas-budget 100000000000000
Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::tx_context::derive_id (function index 6) at offset 0. Arithmetic error, stack overflow, max value depth, etc.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MovePrimitiveRuntimeError(MoveLocationOpt(Some(MoveLocation { module: ModuleId { address: sui, name: Identifier("tx_context") }, function: 6, instruction: 0, function_name: Some("derive_id") }))), source: Some(VMError { major_status: MEMORY_LIMIT_EXCEEDED, sub_status: Some(2), message: Some("Creating more than 2048 IDs is not allowed"), exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("tx_context") }), indices: [], offsets: [(FunctionDefinitionIndex(6), 0)] }), command: Some(0) } }
Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::tx_context::fresh_id (function index 10) at offset 0. Arithmetic error, stack overflow, max value depth, etc.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MovePrimitiveRuntimeError(MoveLocationOpt(Some(MoveLocation { module: ModuleId { address: sui, name: Identifier("tx_context") }, function: 10, instruction: 0, function_name: Some("fresh_id") }))), source: Some(VMError { major_status: MEMORY_LIMIT_EXCEEDED, sub_status: Some(2), message: Some("Creating more than 2048 IDs is not allowed"), exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("tx_context") }), indices: [], offsets: [(FunctionDefinitionIndex(10), 0)] }), command: Some(0) } }
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 9
task 4, lines 40-42:
//# run Test::M1::create_n_ids --args 2048 --gas-budget 100000000000000
mutated: object(0,0)
gas summary: computation_cost: 19000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880
gas summary: computation_cost: 11000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 5, lines 43-45:
//# run Test::M1::create_n_ids --args 2049 --gas-budget 100000000000000
Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::tx_context::derive_id (function index 6) at offset 0. Arithmetic error, stack overflow, max value depth, etc.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MovePrimitiveRuntimeError(MoveLocationOpt(Some(MoveLocation { module: ModuleId { address: sui, name: Identifier("tx_context") }, function: 6, instruction: 0, function_name: Some("derive_id") }))), source: Some(VMError { major_status: MEMORY_LIMIT_EXCEEDED, sub_status: Some(2), message: Some("Creating more than 2048 IDs is not allowed"), exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("tx_context") }), indices: [], offsets: [(FunctionDefinitionIndex(6), 0)] }), command: Some(0) } }
Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::tx_context::fresh_id (function index 10) at offset 0. Arithmetic error, stack overflow, max value depth, etc.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MovePrimitiveRuntimeError(MoveLocationOpt(Some(MoveLocation { module: ModuleId { address: sui, name: Identifier("tx_context") }, function: 10, instruction: 0, function_name: Some("fresh_id") }))), source: Some(VMError { major_status: MEMORY_LIMIT_EXCEEDED, sub_status: Some(2), message: Some("Creating more than 2048 IDs is not allowed"), exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("tx_context") }), indices: [], offsets: [(FunctionDefinitionIndex(10), 0)] }), command: Some(0) } }

task 6, line 46:
//# run Test::M1::create_n_ids --args 4096 --gas-budget 100000000000000
Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::tx_context::derive_id (function index 6) at offset 0. Arithmetic error, stack overflow, max value depth, etc.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MovePrimitiveRuntimeError(MoveLocationOpt(Some(MoveLocation { module: ModuleId { address: sui, name: Identifier("tx_context") }, function: 6, instruction: 0, function_name: Some("derive_id") }))), source: Some(VMError { major_status: MEMORY_LIMIT_EXCEEDED, sub_status: Some(2), message: Some("Creating more than 2048 IDs is not allowed"), exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("tx_context") }), indices: [], offsets: [(FunctionDefinitionIndex(6), 0)] }), command: Some(0) } }
Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::tx_context::fresh_id (function index 10) at offset 0. Arithmetic error, stack overflow, max value depth, etc.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MovePrimitiveRuntimeError(MoveLocationOpt(Some(MoveLocation { module: ModuleId { address: sui, name: Identifier("tx_context") }, function: 10, instruction: 0, function_name: Some("fresh_id") }))), source: Some(VMError { major_status: MEMORY_LIMIT_EXCEEDED, sub_status: Some(2), message: Some("Creating more than 2048 IDs is not allowed"), exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("tx_context") }), indices: [], offsets: [(FunctionDefinitionIndex(10), 0)] }), command: Some(0) } }
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ task 3, line 30:
//# run a::m::add_n_items --sender A --args 1000 --gas-budget 1000000000000 --summarize
created: 2000
mutated: 1
gas summary: computation_cost: 198000000, storage_cost: 2691388000, storage_rebate: 978120, non_refundable_storage_fee: 9880
gas summary: computation_cost: 199000000, storage_cost: 2691388000, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 4, line 32:
//# run a::m::add_n_items --sender A --args 1025 --gas-budget 1000000000000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ task 4, lines 39-41:
//# run Test::M1::transfer_n_ids --args 2048 --gas-budget 100000000000000 --summarize
created: 2048
mutated: 1
gas summary: computation_cost: 17000000, storage_cost: 2522485600, storage_rebate: 978120, non_refundable_storage_fee: 9880
gas summary: computation_cost: 14000000, storage_cost: 2522485600, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 5, lines 42-44:
//# run Test::M1::transfer_n_ids --args 2049 --gas-budget 100000000000000
Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::tx_context::derive_id (function index 6) at offset 0. Arithmetic error, stack overflow, max value depth, etc.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MovePrimitiveRuntimeError(MoveLocationOpt(Some(MoveLocation { module: ModuleId { address: sui, name: Identifier("tx_context") }, function: 6, instruction: 0, function_name: Some("derive_id") }))), source: Some(VMError { major_status: MEMORY_LIMIT_EXCEEDED, sub_status: Some(2), message: Some("Creating more than 2048 IDs is not allowed"), exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("tx_context") }), indices: [], offsets: [(FunctionDefinitionIndex(6), 0)] }), command: Some(0) } }
Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::tx_context::fresh_id (function index 10) at offset 0. Arithmetic error, stack overflow, max value depth, etc.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MovePrimitiveRuntimeError(MoveLocationOpt(Some(MoveLocation { module: ModuleId { address: sui, name: Identifier("tx_context") }, function: 10, instruction: 0, function_name: Some("fresh_id") }))), source: Some(VMError { major_status: MEMORY_LIMIT_EXCEEDED, sub_status: Some(2), message: Some("Creating more than 2048 IDs is not allowed"), exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("tx_context") }), indices: [], offsets: [(FunctionDefinitionIndex(10), 0)] }), command: Some(0) } }

task 6, lines 45-47:
//# run Test::M1::transfer_n_ids --args 4096 --gas-budget 100000000000000
Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::tx_context::derive_id (function index 6) at offset 0. Arithmetic error, stack overflow, max value depth, etc.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MovePrimitiveRuntimeError(MoveLocationOpt(Some(MoveLocation { module: ModuleId { address: sui, name: Identifier("tx_context") }, function: 6, instruction: 0, function_name: Some("derive_id") }))), source: Some(VMError { major_status: MEMORY_LIMIT_EXCEEDED, sub_status: Some(2), message: Some("Creating more than 2048 IDs is not allowed"), exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("tx_context") }), indices: [], offsets: [(FunctionDefinitionIndex(6), 0)] }), command: Some(0) } }
Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::tx_context::fresh_id (function index 10) at offset 0. Arithmetic error, stack overflow, max value depth, etc.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MovePrimitiveRuntimeError(MoveLocationOpt(Some(MoveLocation { module: ModuleId { address: sui, name: Identifier("tx_context") }, function: 10, instruction: 0, function_name: Some("fresh_id") }))), source: Some(VMError { major_status: MEMORY_LIMIT_EXCEEDED, sub_status: Some(2), message: Some("Creating more than 2048 IDs is not allowed"), exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("tx_context") }), indices: [], offsets: [(FunctionDefinitionIndex(10), 0)] }), command: Some(0) } }

task 7, lines 48-50:
//# run Test::M1::transfer_n_ids --args 2049 --gas-budget 100000000000000
Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::tx_context::derive_id (function index 6) at offset 0. Arithmetic error, stack overflow, max value depth, etc.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MovePrimitiveRuntimeError(MoveLocationOpt(Some(MoveLocation { module: ModuleId { address: sui, name: Identifier("tx_context") }, function: 6, instruction: 0, function_name: Some("derive_id") }))), source: Some(VMError { major_status: MEMORY_LIMIT_EXCEEDED, sub_status: Some(2), message: Some("Creating more than 2048 IDs is not allowed"), exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("tx_context") }), indices: [], offsets: [(FunctionDefinitionIndex(6), 0)] }), command: Some(0) } }
Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::tx_context::fresh_id (function index 10) at offset 0. Arithmetic error, stack overflow, max value depth, etc.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MovePrimitiveRuntimeError(MoveLocationOpt(Some(MoveLocation { module: ModuleId { address: sui, name: Identifier("tx_context") }, function: 10, instruction: 0, function_name: Some("fresh_id") }))), source: Some(VMError { major_status: MEMORY_LIMIT_EXCEEDED, sub_status: Some(2), message: Some("Creating more than 2048 IDs is not allowed"), exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("tx_context") }), indices: [], offsets: [(FunctionDefinitionIndex(10), 0)] }), command: Some(0) } }

task 8, line 51:
//# run Test::M1::transfer_n_ids --args 4096 --gas-budget 100000000000000
Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::tx_context::derive_id (function index 6) at offset 0. Arithmetic error, stack overflow, max value depth, etc.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MovePrimitiveRuntimeError(MoveLocationOpt(Some(MoveLocation { module: ModuleId { address: sui, name: Identifier("tx_context") }, function: 6, instruction: 0, function_name: Some("derive_id") }))), source: Some(VMError { major_status: MEMORY_LIMIT_EXCEEDED, sub_status: Some(2), message: Some("Creating more than 2048 IDs is not allowed"), exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("tx_context") }), indices: [], offsets: [(FunctionDefinitionIndex(6), 0)] }), command: Some(0) } }
Error: Transaction Effects Status: Move Primitive Runtime Error. Location: sui::tx_context::fresh_id (function index 10) at offset 0. Arithmetic error, stack overflow, max value depth, etc.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MovePrimitiveRuntimeError(MoveLocationOpt(Some(MoveLocation { module: ModuleId { address: sui, name: Identifier("tx_context") }, function: 10, instruction: 0, function_name: Some("fresh_id") }))), source: Some(VMError { major_status: MEMORY_LIMIT_EXCEEDED, sub_status: Some(2), message: Some("Creating more than 2048 IDs is not allowed"), exec_state: None, location: Module(ModuleId { address: sui, name: Identifier("tx_context") }), indices: [], offsets: [(FunctionDefinitionIndex(10), 0)] }), command: Some(0) } }
31 changes: 20 additions & 11 deletions crates/sui-core/src/unit_tests/authority_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1679,23 +1679,29 @@ async fn test_publish_dependent_module_ok() {
};

let authority = init_state_with_objects(vec![gas_payment_object]).await;
let epoch_store = authority.epoch_store_for_testing();
let protocol_config = epoch_store.protocol_config();
let rgp = authority.reference_gas_price_for_testing().unwrap();
let gas_price = rgp;
let gas_budget = gas_price * TEST_ONLY_GAS_UNIT_FOR_PUBLISH;
let data = TransactionData::new_module(
sender,
gas_payment_object_ref,
vec![dependent_module_bytes],
vec![ObjectID::from(*genesis_module.address())],
rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH,
rgp,
gas_budget,
gas_price,
);
let transaction = to_sender_signed_transaction(data, &sender_key);

let dependent_module_id = TxContext::new(
&sender,
transaction.digest(),
&EpochData::new_test(),
rgp,
gas_price,
gas_budget,
None,
protocol_config.move_native_context(),
)
.fresh_id();

Expand All @@ -1718,12 +1724,11 @@ async fn test_publish_module_no_dependencies_ok() {
let authority = init_state_with_objects(vec![]).await;
let rgp = authority.reference_gas_price_for_testing().unwrap();
let gas_payment_object_id = ObjectID::random();

let epoch_store = authority.epoch_store_for_testing();
let protocol_config = epoch_store.protocol_config();
// Use the max budget to avoid running out of gas.
let gas_balance = {
let epoch_store = authority.epoch_store_for_testing();
let protocol_config = epoch_store.protocol_config();
protocol_config.max_tx_gas()
};
let gas_balance = protocol_config.max_tx_gas();
let gas_payment_object =
Object::with_id_owner_gas_for_testing(gas_payment_object_id, sender, gas_balance);
let gas_payment_object_ref = gas_payment_object.compute_object_reference();
Expand All @@ -1736,21 +1741,25 @@ async fn test_publish_module_no_dependencies_ok() {
.unwrap();
let module_bytes = vec![module_bytes];
let dependencies = vec![]; // no dependencies
let gas_price = rgp;
let gas_budget = gas_price * TEST_ONLY_GAS_UNIT_FOR_PUBLISH;
let data = TransactionData::new_module(
sender,
gas_payment_object_ref,
module_bytes,
dependencies,
rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH,
rgp,
gas_budget,
gas_price,
);
let transaction = to_sender_signed_transaction(data, &sender_key);
let _module_object_id = TxContext::new(
&sender,
transaction.digest(),
&EpochData::new_test(),
rgp,
gas_price,
gas_budget,
None,
protocol_config.move_native_context(),
)
.fresh_id();
let signed_effects = send_and_confirm_transaction(&authority, transaction)
Expand Down
Loading
Loading