Skip to content

Commit 8c4624d

Browse files
authored
[vm] Supress paranoid checks for trusted code (#17461)
* [vm] Suppress paranoid checks for trusted code This introduces the concept of 'trusted code' in the VM. For now this is defined as code at a 'special' address (0x1-0xf), but this can later be extended. This also adds nmew transactional tests. Adding transactional tests. We also need to move existing tests out of the default trusted 'domain' (0x1-0xf), so refactoring some test files. * Addressing reviewer comments. * Ensuring that during tests, no code is trusted. Also adds a mechanism to have different feature flag sets during testing and in prod. * Addressing reviewer comments * Reverting change of feature flags for test genesis. * Updating calibration values for aptos-move/e2e-benchmark and testsuite/single_node_performance.
1 parent d791af3 commit 8c4624d

File tree

161 files changed

+1346
-802
lines changed

Some content is hidden

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

161 files changed

+1346
-802
lines changed

Cargo.lock

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

aptos-move/aptos-release-builder/src/components/feature_flags.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ pub enum FeatureFlag {
150150
CalculateTransactionFeeForDistribution,
151151
DistributeTransactionFee,
152152
MonotonicallyIncreasingCounter,
153+
EnableTrustedCode,
153154
}
154155

155156
fn generate_features_blob(writer: &CodeWriter, data: &[u64]) {
@@ -399,6 +400,7 @@ impl From<FeatureFlag> for AptosFeatureFlag {
399400
FeatureFlag::MonotonicallyIncreasingCounter => {
400401
AptosFeatureFlag::MONOTONICALLY_INCREASING_COUNTER
401402
},
403+
FeatureFlag::EnableTrustedCode => AptosFeatureFlag::ENABLE_TRUSTED_CODE,
402404
}
403405
}
404406
}
@@ -575,6 +577,7 @@ impl From<AptosFeatureFlag> for FeatureFlag {
575577
AptosFeatureFlag::MONOTONICALLY_INCREASING_COUNTER => {
576578
FeatureFlag::MonotonicallyIncreasingCounter
577579
},
580+
AptosFeatureFlag::ENABLE_TRUSTED_CODE => FeatureFlag::EnableTrustedCode,
578581
}
579582
}
580583
}

aptos-move/aptos-vm-environment/src/prod_configs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ pub fn aptos_prod_vm_config(
189189
.is_call_tree_and_instruction_vm_cache_enabled(),
190190
enable_lazy_loading: features.is_lazy_loading_enabled(),
191191
enable_depth_checks,
192+
optimize_trusted_code: features.is_trusted_code_enabled(),
192193
paranoid_ref_checks,
193194
};
194195

aptos-move/aptos-vm/src/aptos_vm.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2823,9 +2823,9 @@ impl AptosVM {
28232823
speculative_error!(
28242824
log_context,
28252825
format!(
2826-
"[aptos_vm] Transaction breaking invariant violation. txn: {:?}, status: {:?}",
2826+
"[aptos_vm] Transaction breaking invariant violation: {:?}\ntxn: {:?}",
2827+
vm_status,
28272828
bcs::to_bytes::<SignedTransaction>(txn),
2828-
vm_status
28292829
),
28302830
);
28312831
},
@@ -2836,9 +2836,9 @@ impl AptosVM {
28362836
{
28372837
error!(
28382838
*log_context,
2839-
"[aptos_vm] Transaction breaking paranoid mode. txn: {:?}, status: {:?}",
2840-
bcs::to_bytes::<SignedTransaction>(txn),
2839+
"[aptos_vm] Transaction breaking paranoid mode: {:?}\ntxn: {:?}",
28412840
vm_status,
2841+
bcs::to_bytes::<SignedTransaction>(txn),
28422842
);
28432843
},
28442844
// Paranoid mode failure but with reference counting
@@ -2848,9 +2848,9 @@ impl AptosVM {
28482848
{
28492849
error!(
28502850
*log_context,
2851-
"[aptos_vm] Transaction breaking paranoid mode. txn: {:?}, status: {:?}",
2852-
bcs::to_bytes::<SignedTransaction>(txn),
2851+
"[aptos_vm] Transaction breaking paranoid mode: {:?}\ntxn: {:?}",
28532852
vm_status,
2853+
bcs::to_bytes::<SignedTransaction>(txn),
28542854
);
28552855
},
28562856
// Paranoid mode failure but with reference safety checks
@@ -2873,9 +2873,9 @@ impl AptosVM {
28732873
_ => {
28742874
error!(
28752875
*log_context,
2876-
"[aptos_vm] Transaction breaking invariant violation. txn: {:?}, status: {:?}",
2877-
bcs::to_bytes::<SignedTransaction>(txn),
2876+
"[aptos_vm] Transaction breaking invariant violation: {:?}\ntxn: {:?}, ",
28782877
vm_status,
2878+
bcs::to_bytes::<SignedTransaction>(txn),
28792879
);
28802880
},
28812881
}
Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
Loop { loop_count: Some(100000), loop_type: NoOp } 6 0.994 1.022 38997.7
2-
Loop { loop_count: Some(10000), loop_type: Arithmetic } 6 0.997 1.028 23625.0
3-
CreateObjects { num_objects: 10, object_payload_size: 0 } 6 0.989 1.018 125.9
4-
CreateObjects { num_objects: 10, object_payload_size: 10240 } 6 0.997 1.005 8315.4
5-
CreateObjects { num_objects: 100, object_payload_size: 0 } 6 0.988 1.010 1185.0
6-
CreateObjects { num_objects: 100, object_payload_size: 10240 } 6 0.995 1.020 9858.5
7-
InitializeVectorPicture { length: 128 } 6 0.991 1.015 147.0
8-
VectorPicture { length: 128 } 6 0.989 1.031 33.3
9-
VectorPictureRead { length: 128 } 6 0.984 1.038 32.4
10-
InitializeVectorPicture { length: 30720 } 6 0.998 1.017 25053.1
11-
VectorPicture { length: 30720 } 6 0.989 1.018 4573.0
12-
VectorPictureRead { length: 30720 } 6 0.987 1.017 4581.7
13-
SmartTablePicture { length: 30720, num_points_per_txn: 200 } 6 0.997 1.012 31537.5
14-
SmartTablePicture { length: 1048576, num_points_per_txn: 300 } 6 0.998 1.067 55284.8
15-
ResourceGroupsSenderWriteTag { string_length: 1024 } 6 0.989 1.011 16.1
16-
ResourceGroupsSenderMultiChange { string_length: 1024 } 6 0.987 1.005 30.7
17-
TokenV1MintAndTransferFT 6 0.992 1.020 439.8
18-
TokenV1MintAndTransferNFTSequential 6 0.997 1.021 625.3
19-
TokenV2AmbassadorMint { numbered: true } 6 0.985 1.016 408.5
20-
LiquidityPoolSwap { is_stable: true } 6 0.987 1.012 623.0
21-
LiquidityPoolSwap { is_stable: false } 6 0.998 1.011 574.9
22-
CoinInitAndMint 6 0.982 1.013 625.3
23-
FungibleAssetMint 6 0.969 1.008 198.2
24-
IncGlobalMilestoneAggV2 { milestone_every: 1 } 6 0.993 1.012 27.8
25-
IncGlobalMilestoneAggV2 { milestone_every: 2 } 6 0.983 1.004 16.3
26-
EmitEvents { count: 1000 } 6 0.994 1.019 6726.6
27-
APTTransferWithPermissionedSigner 6 0.994 1.013 788.5
28-
APTTransferWithMasterSigner 6 0.994 1.017 83.0
29-
VectorTrimAppend { vec_len: 3000, element_len: 1, index: 0, repeats: 0 } 6 0.998 1.009 4660.5
30-
VectorTrimAppend { vec_len: 3000, element_len: 1, index: 100, repeats: 1000 } 6 0.995 1.061 21446.3
31-
VectorTrimAppend { vec_len: 3000, element_len: 1, index: 2990, repeats: 1000 } 6 0.994 1.007 12415.7
32-
VectorRemoveInsert { vec_len: 3000, element_len: 1, index: 100, repeats: 1000 } 6 0.995 1.008 19462.7
33-
VectorRemoveInsert { vec_len: 3000, element_len: 1, index: 2998, repeats: 1000 } 6 0.998 1.014 13261.8
34-
VectorRangeMove { vec_len: 3000, element_len: 1, index: 1000, move_len: 500, repeats: 1000 } 6 0.997 1.003 21836.7
35-
VectorTrimAppend { vec_len: 100, element_len: 100, index: 0, repeats: 0 } 6 0.985 1.011 246.9
36-
VectorTrimAppend { vec_len: 100, element_len: 100, index: 10, repeats: 1000 } 6 0.983 1.027 8481.4
37-
VectorRangeMove { vec_len: 100, element_len: 100, index: 50, move_len: 10, repeats: 1000 } 6 0.996 1.023 3996.1
38-
MapInsertRemove { len: 100, repeats: 100, map_type: OrderedMap } 6 0.986 1.004 9840.3
39-
MapInsertRemove { len: 100, repeats: 100, map_type: SimpleMap } 6 0.995 1.017 32347.9
40-
MapInsertRemove { len: 100, repeats: 100, map_type: BigOrderedMap { inner_max_degree: 4, leaf_max_degree: 4 } } 6 0.994 1.008 76269.3
41-
MapInsertRemove { len: 100, repeats: 100, map_type: BigOrderedMap { inner_max_degree: 1024, leaf_max_degree: 1024 } } 6 0.994 1.004 14760.4
42-
MapInsertRemove { len: 1000, repeats: 100, map_type: OrderedMap } 6 0.996 1.011 49048.5
43-
OrderBook { state: OrderBookState { order_idx: 0 }, num_markets: 1, overlap_ratio: 0.0, buy_frequency: 0.5, max_sell_size: 1, max_buy_size: 1 } 6 0.994 1.010 468.2
1+
Loop { loop_count: Some(100000), loop_type: NoOp } 3 0.999 1.006 34260.4
2+
Loop { loop_count: Some(10000), loop_type: Arithmetic } 3 0.999 1.003 21485.1
3+
CreateObjects { num_objects: 10, object_payload_size: 0 } 3 0.991 1.011 104.5
4+
CreateObjects { num_objects: 10, object_payload_size: 10240 } 3 0.987 1.002 7764.2
5+
CreateObjects { num_objects: 100, object_payload_size: 0 } 3 1.000 1.004 965.0
6+
CreateObjects { num_objects: 100, object_payload_size: 10240 } 3 0.990 1.003 9059.1
7+
InitializeVectorPicture { length: 128 } 3 0.988 1.003 138.1
8+
VectorPicture { length: 128 } 3 0.993 1.002 39.3
9+
VectorPictureRead { length: 128 } 3 0.988 1.217 32.6
10+
InitializeVectorPicture { length: 30720 } 3 0.986 1.001 23541.0
11+
VectorPicture { length: 30720 } 3 0.998 1.000 4486.4
12+
VectorPictureRead { length: 30720 } 3 0.999 1.004 4486.4
13+
SmartTablePicture { length: 30720, num_points_per_txn: 200 } 3 0.997 1.006 18783.0
14+
SmartTablePicture { length: 1048576, num_points_per_txn: 300 } 3 1.000 1.003 32998.0
15+
ResourceGroupsSenderWriteTag { string_length: 1024 } 3 0.977 1.003 16.0
16+
ResourceGroupsSenderMultiChange { string_length: 1024 } 3 0.993 1.000 29.8
17+
TokenV1MintAndTransferFT 3 0.990 1.007 358.8
18+
TokenV1MintAndTransferNFTSequential 3 0.994 1.014 503.4
19+
TokenV2AmbassadorMint { numbered: true } 3 0.998 1.012 315.6
20+
LiquidityPoolSwap { is_stable: true } 3 0.997 1.005 495.6
21+
LiquidityPoolSwap { is_stable: false } 3 0.989 1.002 460.4
22+
CoinInitAndMint 3 0.996 1.007 503.4
23+
FungibleAssetMint 3 0.998 1.029 160.4
24+
IncGlobalMilestoneAggV2 { milestone_every: 1 } 3 0.995 1.009 24.1
25+
IncGlobalMilestoneAggV2 { milestone_every: 2 } 3 0.968 1.010 14.5
26+
EmitEvents { count: 1000 } 3 0.998 1.011 5420.0
27+
APTTransferWithPermissionedSigner 3 0.991 1.002 553.3
28+
APTTransferWithMasterSigner 3 0.998 0.999 67.2
29+
VectorTrimAppend { vec_len: 3000, element_len: 1, index: 0, repeats: 0 } 3 0.994 1.032 4529.6
30+
VectorTrimAppend { vec_len: 3000, element_len: 1, index: 100, repeats: 1000 } 3 0.985 1.003 18889.3
31+
VectorTrimAppend { vec_len: 3000, element_len: 1, index: 2990, repeats: 1000 } 3 0.994 1.009 9462.4
32+
VectorRemoveInsert { vec_len: 3000, element_len: 1, index: 100, repeats: 1000 } 3 0.995 1.006 15009.6
33+
VectorRemoveInsert { vec_len: 3000, element_len: 1, index: 2998, repeats: 1000 } 3 0.997 1.004 10454.4
34+
VectorRangeMove { vec_len: 3000, element_len: 1, index: 1000, move_len: 500, repeats: 1000 } 3 0.992 1.004 21330.2
35+
VectorTrimAppend { vec_len: 100, element_len: 100, index: 0, repeats: 0 } 3 0.994 1.007 235.4
36+
VectorTrimAppend { vec_len: 100, element_len: 100, index: 10, repeats: 1000 } 3 0.990 1.009 5658.7
37+
VectorRangeMove { vec_len: 100, element_len: 100, index: 50, move_len: 10, repeats: 1000 } 3 0.993 1.005 3845.3
38+
MapInsertRemove { len: 100, repeats: 100, map_type: OrderedMap } 3 0.994 1.003 5689.1
39+
MapInsertRemove { len: 100, repeats: 100, map_type: SimpleMap } 3 0.992 1.005 18641.9
40+
MapInsertRemove { len: 100, repeats: 100, map_type: BigOrderedMap { inner_max_degree: 4, leaf_max_degree: 4 } } 3 0.997 1.004 33261.7
41+
MapInsertRemove { len: 100, repeats: 100, map_type: BigOrderedMap { inner_max_degree: 1024, leaf_max_degree: 1024 } } 3 0.999 1.008 7719.9
42+
MapInsertRemove { len: 1000, repeats: 100, map_type: OrderedMap } 3 0.993 1.001 29088.2
43+
OrderBook { state: OrderBookState { order_idx: 0 }, num_markets: 1, overlap_ratio: 0.0, buy_frequency: 0.5, max_sell_size: 1, max_buy_size: 1 } 3 0.996 1.011 399.2
Lines changed: 50 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,50 @@
1-
no-op 1 VM 6 0.975 1.007 35206.7
2-
no-op-orderless 1 VM 1 0.7 1.3 35206.7
3-
no-op 1000 VM 6 0.982 1.022 32347.9
4-
apt-fa-transfer 1 VM 6 0.993 1.012 25008.6
5-
apt-fa-transfer 1 NativeVM 6 0.956 1.021 40094.5
6-
account-generation 1 VM 6 0.969 1.025 19826.7
7-
account-generation 1 NativeVM 6 0.982 1.007 34596.7
8-
account-resource32-b 1 VM 6 0.987 1.009 31782.9
9-
modify-global-resource 1 VM 6 0.984 1.018 2675.9
10-
modify-global-resource 100 VM 6 0.996 1.020 30646.3
11-
publish-package 1 VM 6 0.987 1.015 2208.9
12-
mix_publish_transfer 1 VM 6 0.992 1.041 21291.6
13-
batch100-transfer 1 VM 6 0.990 1.026 941.6
14-
batch100-transfer 1 NativeVM 6 0.983 1.050 1699.9
15-
vector-picture30k 1 VM 6 0.991 1.012 133.0
16-
vector-picture30k 100 VM 6 0.972 1.023 1828.1
17-
smart-table-picture30-k-with200-change 1 VM 6 0.976 1.009 20.1
18-
smart-table-picture30-k-with200-change 100 VM 6 0.989 1.041 233.7
19-
modify-global-resource-agg-v2 1 VM 6 0.989 1.011 32284.2
20-
modify-global-flag-agg-v2 1 VM 6 0.981 1.034 4141.2
21-
modify-global-bounded-agg-v2 1 VM 6 0.990 1.046 7312.3
22-
modify-global-milestone-agg-v2 1 VM 6 0.995 1.015 25776.8
23-
resource-groups-global-write-tag1-kb 1 VM 6 0.977 1.066 8039.4
24-
resource-groups-global-write-and-read-tag1-kb 1 VM 6 0.980 1.032 5980.3
25-
resource-groups-sender-write-tag1-kb 1 VM 6 0.941 1.018 19790.1
26-
resource-groups-sender-multi-change1-kb 1 VM 6 0.982 1.078 16433.3
27-
token-v1ft-mint-and-transfer 1 VM 6 0.993 1.010 1207.4
28-
token-v1ft-mint-and-transfer 100 VM 6 0.987 1.015 14358.6
29-
token-v1nft-mint-and-transfer-sequential 1 VM 6 0.993 1.011 812.7
30-
token-v1nft-mint-and-transfer-sequential 100 VM 6 0.996 1.020 10938.0
31-
coin-init-and-mint 1 VM 6 0.996 1.016 16466.1
32-
coin-init-and-mint 100 VM 6 0.964 1.017 13997.3
33-
fungible-asset-mint 1 VM 6 0.971 1.015 20719.3
34-
fungible-asset-mint 100 VM 6 0.990 1.010 18187.6
35-
no-op5-signers 1 VM 6 0.995 1.009 35548.1
36-
token-v2-ambassador-mint 1 VM 6 0.990 1.007 13846.2
37-
token-v2-ambassador-mint 100 VM 6 1.000 1.015 13623.4
38-
liquidity-pool-swap 1 VM 6 0.993 1.009 831.8
39-
liquidity-pool-swap 100 VM 6 0.985 1.017 9426.9
40-
liquidity-pool-swap-stable 1 VM 6 0.997 1.014 799.8
41-
liquidity-pool-swap-stable 100 VM 6 0.994 1.031 9163.3
42-
deserialize-u256 1 VM 6 0.998 1.019 33394.0
43-
no-op-fee-payer 1 VM 6 0.986 1.004 2317.1
44-
no-op-fee-payer 100 VM 6 0.986 1.017 27943.9
45-
simple-script 1 VM 6 0.991 1.012 35002.7
46-
vector-trim-append-len3000-size1 1 VM 6 0.974 1.012 812.7
47-
vector-remove-insert-len3000-size1 1 VM 6 0.986 1.013 939.9
48-
order-book-no-matches1-market 1 VM 6 0.963 1.029 1811.3
49-
order-book-balanced-matches25-pct1-market 1 VM 6 0.983 1.019 1117.3
50-
order-book-balanced-matches80-pct1-market 1 VM 6 0.986 1.034 601.4
51-
order-book-balanced-size-skewed80-pct1-market 1 VM 6 0.963 1.105 1278.5
52-
order-book-no-matches50-markets 1 VM 6 0.996 1.013 5429.7
53-
order-book-balanced-matches25-pct50-markets 1 VM 6 0.997 1.010 5709.5
54-
order-book-balanced-matches80-pct50-markets 1 VM 6 0.989 1.009 6341.8
55-
order-book-balanced-size-skewed80-pct50-markets 1 VM 6 0.972 1.020 5170.4
56-
no_commit_apt-fa-transfer 1 VM 6 0.978 1.017 26381.7
57-
no_commit_apt-fa-transfer 1 NativeVM 6 0.979 1.014 44067.9
58-
no_commit_apt-fa-transfer 1 AptosVMSpeculative 6 0.990 1.016 9462.4
59-
no_commit_apt-fa-transfer 1 NativeSpeculative 6 0.992 1.020 97922.8
1+
no-op 1 VM 3 0.988 1.007 37992.0
2+
no-op 1000 VM 3 1.000 1.026 34799.4
3+
apt-fa-transfer 1 VM 3 0.993 1.009 28822.5
4+
apt-fa-transfer 1 NativeVM 3 0.985 1.012 40390.5
5+
account-generation 1 VM 3 0.995 1.006 23207.8
6+
account-generation 1 NativeVM 3 0.916 1.052 40168.4
7+
account-resource32-b 1 VM 3 0.990 1.006 34529.3
8+
modify-global-resource 1 VM 3 0.989 1.011 2953.1
9+
modify-global-resource 100 VM 3 0.995 1.006 33792.4
10+
publish-package 1 VM 3 0.992 1.021 2251.8
11+
mix_publish_transfer 1 VM 3 0.990 1.007 24480.7
12+
batch100-transfer 1 VM 3 0.996 1.048 1193.9
13+
batch100-transfer 1 NativeVM 3 0.973 1.011 1841.6
14+
vector-picture30k 1 VM 3 0.997 1.010 136.2
15+
vector-picture30k 100 VM 3 0.989 1.046 1851.9
16+
smart-table-picture30-k-with200-change 1 VM 3 0.995 1.008 31.0
17+
smart-table-picture30-k-with200-change 100 VM 3 0.985 1.015 369.8
18+
modify-global-resource-agg-v2 1 VM 3 0.978 1.010 34394.7
19+
modify-global-flag-agg-v2 1 VM 3 0.984 1.023 4731.2
20+
modify-global-bounded-agg-v2 1 VM 3 0.980 1.006 8348.5
21+
modify-global-milestone-agg-v2 1 VM 3 0.994 1.007 28404.4
22+
resource-groups-global-write-tag1-kb 1 VM 3 0.994 1.012 8464.8
23+
resource-groups-global-write-and-read-tag1-kb 1 VM 3 0.997 1.000 6548.5
24+
resource-groups-sender-write-tag1-kb 1 VM 3 0.981 1.020 19535.1
25+
resource-groups-sender-multi-change1-kb 1 VM 3 0.979 1.029 16564.9
26+
token-v1ft-mint-and-transfer 1 VM 3 0.995 1.009 1389.5
27+
token-v1ft-mint-and-transfer 100 VM 3 0.997 0.999 16110.4
28+
token-v1nft-mint-and-transfer-sequential 1 VM 3 0.995 1.006 970.5
29+
token-v1nft-mint-and-transfer-sequential 100 VM 3 0.993 1.013 12774.1
30+
coin-init-and-mint 1 VM 3 0.997 1.004 19426.5
31+
coin-init-and-mint 100 VM 3 0.990 1.003 17063.2
32+
fungible-asset-mint 1 VM 3 0.978 1.002 23042.7
33+
fungible-asset-mint 100 VM 3 0.997 1.009 20493.5
34+
no-op5-signers 1 VM 3 0.998 1.010 37992.0
35+
token-v2-ambassador-mint 1 VM 3 0.991 1.010 15829.9
36+
token-v2-ambassador-mint 100 VM 3 0.992 1.019 15498.8
37+
liquidity-pool-swap 1 VM 3 0.996 1.008 966.8
38+
liquidity-pool-swap 100 VM 3 0.990 1.002 11076.5
39+
liquidity-pool-swap-stable 1 VM 3 0.999 1.005 927.7
40+
liquidity-pool-swap-stable 100 VM 3 0.989 1.003 10761.9
41+
deserialize-u256 1 VM 3 0.998 1.003 36932.7
42+
no-op-fee-payer 1 VM 3 0.997 1.001 2604.1
43+
no-op-fee-payer 100 VM 3 0.998 1.012 28875.4
44+
simple-script 1 VM 3 0.983 1.002 38492.8
45+
vector-trim-append-len3000-size1 1 VM 3 0.978 1.012 902.4
46+
vector-remove-insert-len3000-size1 1 VM 3 0.991 1.012 1070.6
47+
order-book-no-matches50-markets 1 VM 3 0.995 1.004 5011.8
48+
order-book-balanced-matches25-pct50-markets 1 VM 3 0.992 1.000 5410.2
49+
order-book-balanced-matches80-pct50-markets 1 VM 3 0.988 1.019 6196.8
50+
order-book-balanced-size-skewed80-pct50-markets 1 VM 3 0.994 1.044 5361.6

third_party/move/move-vm/runtime/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ claims = { workspace = true }
1919
fail = { workspace = true }
2020
fxhash = { workspace = true }
2121
hashbrown = { workspace = true }
22+
itertools = { workspace = true }
2223
lazy_static = { workspace = true }
2324
lru = { workspace = true }
2425
move-binary-format = { workspace = true }
@@ -38,7 +39,7 @@ hex = { workspace = true }
3839
legacy-move-compiler = { workspace = true }
3940
move-binary-format = { workspace = true, features = ["fuzzing"] }
4041
move-ir-compiler = { workspace = true }
41-
move-vm-test-utils ={ workspace = true }
42+
move-vm-test-utils = { workspace = true }
4243
move-vm-types = { workspace = true, features = ["testing"] }
4344
proptest = { workspace = true }
4445
smallbitvec = { workspace = true }

third_party/move/move-vm/runtime/src/config.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ pub struct VMConfig {
1616
pub verifier_config: VerifierConfig,
1717
pub deserializer_config: DeserializerConfig,
1818
/// When this flag is set to true, MoveVM will perform type checks at every instruction
19-
/// execution to ensure that type safety cannot be violated at runtime.
19+
/// execution to ensure that type safety cannot be violated at runtime. Note: these
20+
/// are more than type checks, for example, stack balancing, visibility, but the name
21+
/// is kept for historical reasons.
2022
pub paranoid_type_checks: bool,
2123
pub check_invariant_in_swap_loc: bool,
2224
/// Maximum value nest depth for structs.
@@ -34,6 +36,9 @@ pub struct VMConfig {
3436
pub use_call_tree_and_instruction_cache: bool,
3537
pub enable_lazy_loading: bool,
3638
pub enable_depth_checks: bool,
39+
/// Whether trusted code should be optimized, for example, excluding it from expensive
40+
/// paranoid checks.
41+
pub optimize_trusted_code: bool,
3742
/// When this flag is set to true, Move VM will perform additional checks to ensure that
3843
/// reference safety is maintained during execution.
3944
pub paranoid_ref_checks: bool,
@@ -57,6 +62,7 @@ impl Default for VMConfig {
5762
use_call_tree_and_instruction_cache: true,
5863
enable_lazy_loading: true,
5964
enable_depth_checks: true,
65+
optimize_trusted_code: false,
6066
paranoid_ref_checks: false,
6167
}
6268
}

third_party/move/move-vm/runtime/src/frame.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub(crate) struct Frame {
4747
call_type: CallType,
4848
// Locals for this execution context and their instantiated types.
4949
pub(crate) locals: Locals,
50-
local_tys: Vec<Type>,
50+
pub(crate) local_tys: Vec<Type>,
5151
// Cache of types accessed in this frame, to improve performance when accessing
5252
// and constructing types.
5353
pub(crate) frame_cache: Rc<RefCell<FrameTypeCache>>,
@@ -146,7 +146,7 @@ impl Frame {
146146
}
147147

148148
let ty_builder = vm_config.ty_builder.clone();
149-
let local_tys = if RTTCheck::should_perform_checks() {
149+
let local_tys = if RTTCheck::should_perform_checks(&function.function) {
150150
if ty_args.is_empty() {
151151
function.local_tys().to_vec()
152152
} else {
@@ -192,6 +192,11 @@ impl Frame {
192192
Ok(())
193193
}
194194

195+
#[inline(always)]
196+
pub(crate) fn untrusted_code(&self) -> bool {
197+
!self.function.function.is_trusted
198+
}
199+
195200
pub(crate) fn constant_at(&self, idx: ConstantPoolIndex) -> &Constant {
196201
use LoadedFunctionOwner::*;
197202
match self.function.owner() {

0 commit comments

Comments
 (0)