Skip to content

Commit

Permalink
[sui-adapter] Resolve Move abort locations to package ID instead of r…
Browse files Browse the repository at this point in the history
…untime ID
  • Loading branch information
tzakian committed May 22, 2024
1 parent 14df90a commit 5584112
Show file tree
Hide file tree
Showing 12 changed files with 1,043 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
processed 7 tasks

init:
A: object(0,0)

task 1 'publish'. lines 6-11:
created: object(1,0), object(1,1)
mutated: object(0,0)
gas summary: computation_cost: 1000000, storage_cost: 5084400, storage_rebate: 0, non_refundable_storage_fee: 0

task 2 'upgrade'. lines 14-19:
created: object(2,0)
mutated: object(0,0), object(1,1)
gas summary: computation_cost: 1000000, storage_cost: 5084400, storage_rebate: 2595780, non_refundable_storage_fee: 26220

task 3 'upgrade'. lines 21-26:
created: object(3,0)
mutated: object(0,0), object(1,1)
gas summary: computation_cost: 1000000, storage_cost: 5084400, storage_rebate: 2595780, non_refundable_storage_fee: 26220

task 4 'run'. lines 28-30:
Error: Transaction Effects Status: Move Runtime Abort. Location: Test1::M1::f1 (function index 0) at offset 1, Abort Code: 0
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: Test1, name: Identifier("M1") }, function: 0, instruction: 1, function_name: Some("f1") }, 0), source: Some(VMError { major_status: ABORTED, sub_status: Some(0), message: Some("Test1::M1::f1 at offset 1"), exec_state: None, location: Module(ModuleId { address: Test1, name: Identifier("M1") }), indices: [], offsets: [(FunctionDefinitionIndex(0), 1)] }), command: Some(0) } }

task 5 'run'. lines 31-33:
Error: Transaction Effects Status: Move Runtime Abort. Location: Test2::M1::f1 (function index 0) at offset 1, Abort Code: 0
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: Test2, name: Identifier("M1") }, function: 0, instruction: 1, function_name: Some("f1") }, 0), source: Some(VMError { major_status: ABORTED, sub_status: Some(0), message: Some("Test1::M1::f1 at offset 1"), exec_state: None, location: Module(ModuleId { address: Test1, name: Identifier("M1") }), indices: [], offsets: [(FunctionDefinitionIndex(0), 1)] }), command: Some(0) } }

task 6 'run'. lines 34-34:
Error: Transaction Effects Status: Move Runtime Abort. Location: Test3::M1::f1 (function index 0) at offset 1, Abort Code: 0
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: Test3, name: Identifier("M1") }, function: 0, instruction: 1, function_name: Some("f1") }, 0), source: Some(VMError { major_status: ABORTED, sub_status: Some(0), message: Some("Test1::M1::f1 at offset 1"), exec_state: None, location: Module(ModuleId { address: Test1, name: Identifier("M1") }), indices: [], offsets: [(FunctionDefinitionIndex(0), 1)] }), command: Some(0) } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# init --addresses Test1=0x0 Test2=0x0 Test3=0x0 --accounts A

//# publish --upgradeable --sender A
module Test1::M1 {
public fun f1() {
abort 0
}
}


//# upgrade --package Test1 --upgrade-capability 1,1 --sender A
module Test2::M1 {
public fun f1() {
abort 0
}
}

//# upgrade --package Test2 --upgrade-capability 1,1 --sender A
module Test3::M1 {
public fun f1() {
abort 0
}
}

//# run Test1::M1::f1

// Location will show up as Test2::M1::f1 since the runtime module ID is resolved to the upgraded version
//# run Test2::M1::f1

// Location will show up as Test3::M1::f1 as the runtime module ID is resolved to the upgraded version
//# run Test3::M1::f1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
processed 7 tasks

init:
A: object(0,0)

task 1 'publish'. lines 6-11:
created: object(1,0), object(1,1)
mutated: object(0,0)
gas summary: computation_cost: 1000000, storage_cost: 5084400, storage_rebate: 0, non_refundable_storage_fee: 0

task 2 'upgrade'. lines 14-19:
created: object(2,0)
mutated: object(0,0), object(1,1)
gas summary: computation_cost: 1000000, storage_cost: 5084400, storage_rebate: 2595780, non_refundable_storage_fee: 26220

task 3 'upgrade'. lines 21-26:
created: object(3,0)
mutated: object(0,0), object(1,1)
gas summary: computation_cost: 1000000, storage_cost: 5084400, storage_rebate: 2595780, non_refundable_storage_fee: 26220

task 4 'run'. lines 28-30:
Error: Transaction Effects Status: Move Runtime Abort. Location: Test1::M1::f1 (function index 0) at offset 1, Abort Code: 0
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: Test1, name: Identifier("M1") }, function: 0, instruction: 1, function_name: Some("f1") }, 0), source: Some(VMError { major_status: ABORTED, sub_status: Some(0), message: Some("Test1::M1::f1 at offset 1"), exec_state: None, location: Module(ModuleId { address: Test1, name: Identifier("M1") }), indices: [], offsets: [(FunctionDefinitionIndex(0), 1)] }), command: Some(0) } }

task 5 'run'. lines 31-33:
Error: Transaction Effects Status: Move Runtime Abort. Location: Test1::M1::f1 (function index 0) at offset 1, Abort Code: 0
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: Test1, name: Identifier("M1") }, function: 0, instruction: 1, function_name: Some("f1") }, 0), source: Some(VMError { major_status: ABORTED, sub_status: Some(0), message: Some("Test1::M1::f1 at offset 1"), exec_state: None, location: Module(ModuleId { address: Test1, name: Identifier("M1") }), indices: [], offsets: [(FunctionDefinitionIndex(0), 1)] }), command: Some(0) } }

task 6 'run'. lines 34-34:
Error: Transaction Effects Status: Move Runtime Abort. Location: Test1::M1::f1 (function index 0) at offset 1, Abort Code: 0
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: Test1, name: Identifier("M1") }, function: 0, instruction: 1, function_name: Some("f1") }, 0), source: Some(VMError { major_status: ABORTED, sub_status: Some(0), message: Some("Test1::M1::f1 at offset 1"), exec_state: None, location: Module(ModuleId { address: Test1, name: Identifier("M1") }), indices: [], offsets: [(FunctionDefinitionIndex(0), 1)] }), command: Some(0) } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# init --addresses Test1=0x0 Test2=0x0 Test3=0x0 --accounts A --protocol-version 46

//# publish --upgradeable --sender A
module Test1::M1 {
public fun f1() {
abort 0
}
}


//# upgrade --package Test1 --upgrade-capability 1,1 --sender A
module Test2::M1 {
public fun f1() {
abort 0
}
}

//# upgrade --package Test2 --upgrade-capability 1,1 --sender A
module Test3::M1 {
public fun f1() {
abort 0
}
}

//# run Test1::M1::f1

// Location will show up as Test1::M1::f1 since the module ID is not resolved to the upgraded version
//# run Test2::M1::f1

// Location will show up as Test1::M1::f1 since the module ID is not resolved to the upgraded version
//# run Test3::M1::f1
15 changes: 14 additions & 1 deletion crates/sui-protocol-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tracing::{info, warn};

/// The minimum and maximum protocol versions supported by this build.
const MIN_PROTOCOL_VERSION: u64 = 1;
const MAX_PROTOCOL_VERSION: u64 = 46;
const MAX_PROTOCOL_VERSION: u64 = 47;

// Record history of protocol version allocations here:
//
Expand Down Expand Up @@ -129,6 +129,7 @@ const MAX_PROTOCOL_VERSION: u64 = 46;
// Enable Leader Scoring & Schedule Change for Mysticeti consensus.
// Version 46: Enable native bridge in testnet
// Enable resharing at the same initial shared version.
// Version 47: Resolve Move abort locations to the package id instead of the runtime module ID.

#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub struct ProtocolVersion(u64);
Expand Down Expand Up @@ -436,6 +437,10 @@ struct FeatureFlags {
// Enable resharing of shared objects using the same initial shared version
#[serde(skip_serializing_if = "is_false")]
reshare_at_same_initial_version: bool,

// Resolve Move abort locations to the package id instead of the runtime module ID.
#[serde(skip_serializing_if = "is_false")]
resolve_abort_locations_to_package_id: bool,
}

fn is_false(b: &bool) -> bool {
Expand Down Expand Up @@ -1321,6 +1326,10 @@ impl ProtocolConfig {
pub fn reshare_at_same_initial_version(&self) -> bool {
self.feature_flags.reshare_at_same_initial_version
}

pub fn resolve_abort_locations_to_package_id(&self) -> bool {
self.feature_flags.resolve_abort_locations_to_package_id
}
}

#[cfg(not(msim))]
Expand Down Expand Up @@ -2203,6 +2212,10 @@ impl ProtocolConfig {
// Enable resharing at same initial version
cfg.feature_flags.reshare_at_same_initial_version = true;
}
47 => {
// Enable resolving abort code IDs to package ID instead of runtime module ID
cfg.feature_flags.resolve_abort_locations_to_package_id = true;
}
// Use this template when making changes:
//
// // modify an existing constant.
Expand Down
Loading

0 comments on commit 5584112

Please sign in to comment.