Skip to content

Commit 49d95e9

Browse files
authored
[v1.60] Cherry pick 23913 (#24198)
## Description - Cherry pick #23913 - Let's start logging any issues with the new reference safety verifier ## Test plan - Just a signing check - ran tests (had to remove some old global storage ones) --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] gRPC: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK:
1 parent 58f2c2f commit 49d95e9

File tree

31 files changed

+1461
-67
lines changed

31 files changed

+1461
-67
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.

crates/sui-config/src/verifier_signing_config.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ pub const DEFAULT_MAX_PER_PKG_METER_UNITS: usize = 2_200_000;
1212
pub const DEFAULT_MAX_BACK_EDGES_PER_FUNCTION: usize = 10_000;
1313
pub const DEFAULT_MAX_BACK_EDGES_PER_MODULE: usize = 10_000;
1414

15+
pub const DEFAULT_SANITY_CHECK_WITH_REGEX_REFERENCE_SAFETY_UNITS: usize = 2_200_000;
16+
1517
/// This holds limits that are only set and used by the verifier during signing _only_. There are
1618
/// additional limits in the `MeterConfig` and `VerifierConfig` that are used during both signing
1719
/// and execution, however those limits cannot be set here and must be protocol versioned.
@@ -29,6 +31,9 @@ pub struct VerifierSigningConfig {
2931
max_back_edges_per_function: Option<usize>,
3032
#[serde(default)]
3133
max_back_edges_per_module: Option<usize>,
34+
35+
#[serde(default)]
36+
pub sanity_check_with_regex_reference_safety: Option<usize>,
3237
}
3338

3439
impl VerifierSigningConfig {
@@ -57,11 +62,17 @@ impl VerifierSigningConfig {
5762
.unwrap_or(DEFAULT_MAX_BACK_EDGES_PER_MODULE)
5863
}
5964

65+
pub fn sanity_check_with_regex_reference_safety(&self) -> usize {
66+
self.sanity_check_with_regex_reference_safety
67+
.unwrap_or(DEFAULT_SANITY_CHECK_WITH_REGEX_REFERENCE_SAFETY_UNITS)
68+
}
69+
6070
/// Return sign-time only limit for back edges for the verifier.
61-
pub fn limits_for_signing(&self) -> (usize, usize) {
71+
pub fn limits_for_signing(&self) -> (usize, usize, usize) {
6272
(
6373
self.max_back_edges_per_function(),
6474
self.max_back_edges_per_module(),
75+
self.sanity_check_with_regex_reference_safety(),
6576
)
6677
}
6778

crates/sui-protocol-config/src/lib.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4246,20 +4246,29 @@ impl ProtocolConfig {
42464246
cfg
42474247
}
42484248

4249-
// Extract the bytecode verifier config from this protocol config. `for_signing` indicates
4250-
// whether this config is used for verification during signing or execution.
4251-
pub fn verifier_config(&self, signing_limits: Option<(usize, usize)>) -> VerifierConfig {
4252-
let (max_back_edges_per_function, max_back_edges_per_module) = if let Some((
4249+
// Extract the bytecode verifier config from this protocol config.
4250+
// If used during signing, `signing_limits` should be set.
4251+
// The third limit configures`sanity_check_with_regex_reference_safety`,
4252+
// which runs the new regex-based reference safety check to check that it is strictly more
4253+
// permissive than the current implementation.
4254+
pub fn verifier_config(&self, signing_limits: Option<(usize, usize, usize)>) -> VerifierConfig {
4255+
let (
42534256
max_back_edges_per_function,
42544257
max_back_edges_per_module,
4258+
sanity_check_with_regex_reference_safety,
4259+
) = if let Some((
4260+
max_back_edges_per_function,
4261+
max_back_edges_per_module,
4262+
sanity_check_with_regex_reference_safety,
42554263
)) = signing_limits
42564264
{
42574265
(
42584266
Some(max_back_edges_per_function),
42594267
Some(max_back_edges_per_module),
4268+
Some(sanity_check_with_regex_reference_safety),
42604269
)
42614270
} else {
4262-
(None, None)
4271+
(None, None, None)
42634272
};
42644273

42654274
let additional_borrow_checks = if signing_limits.is_some() {
@@ -4295,6 +4304,8 @@ impl ProtocolConfig {
42954304
additional_borrow_checks,
42964305
better_loader_errors: self.better_loader_errors(),
42974306
private_generics_verifier_v2: self.private_generics_verifier_v2(),
4307+
sanity_check_with_regex_reference_safety: sanity_check_with_regex_reference_safety
4308+
.map(|limit| limit as u128),
42984309
}
42994310
}
43004311

crates/sui-swarm-config/tests/snapshots/snapshot_tests__network_config_snapshot_matches.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ validator_configs:
162162
max-per-pkg-meter-units: ~
163163
max-back-edges-per-function: ~
164164
max-back-edges-per-module: ~
165+
sanity-check-with-regex-reference-safety: ~
165166
transaction-driver-config:
166167
enable-early-validation: true
167168
- protocol-key-pair:
@@ -323,6 +324,7 @@ validator_configs:
323324
max-per-pkg-meter-units: ~
324325
max-back-edges-per-function: ~
325326
max-back-edges-per-module: ~
327+
sanity-check-with-regex-reference-safety: ~
326328
transaction-driver-config:
327329
enable-early-validation: true
328330
- protocol-key-pair:
@@ -484,6 +486,7 @@ validator_configs:
484486
max-per-pkg-meter-units: ~
485487
max-back-edges-per-function: ~
486488
max-back-edges-per-module: ~
489+
sanity-check-with-regex-reference-safety: ~
487490
transaction-driver-config:
488491
enable-early-validation: true
489492
- protocol-key-pair:
@@ -645,6 +648,7 @@ validator_configs:
645648
max-per-pkg-meter-units: ~
646649
max-back-edges-per-function: ~
647650
max-back-edges-per-module: ~
651+
sanity-check-with-regex-reference-safety: ~
648652
transaction-driver-config:
649653
enable-early-validation: true
650654
- protocol-key-pair:
@@ -806,6 +810,7 @@ validator_configs:
806810
max-per-pkg-meter-units: ~
807811
max-back-edges-per-function: ~
808812
max-back-edges-per-module: ~
813+
sanity-check-with-regex-reference-safety: ~
809814
transaction-driver-config:
810815
enable-early-validation: true
811816
- protocol-key-pair:
@@ -967,6 +972,7 @@ validator_configs:
967972
max-per-pkg-meter-units: ~
968973
max-back-edges-per-function: ~
969974
max-back-edges-per-module: ~
975+
sanity-check-with-regex-reference-safety: ~
970976
transaction-driver-config:
971977
enable-early-validation: true
972978
- protocol-key-pair:
@@ -1128,6 +1134,7 @@ validator_configs:
11281134
max-per-pkg-meter-units: ~
11291135
max-back-edges-per-function: ~
11301136
max-back-edges-per-module: ~
1137+
sanity-check-with-regex-reference-safety: ~
11311138
transaction-driver-config:
11321139
enable-early-validation: true
11331140
account_keys:

crates/sui/src/client_commands.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,8 @@ impl SuiClientCommands {
11611161
}
11621162
};
11631163

1164-
let signing_limits = Some(VerifierSigningConfig::default().limits_for_signing());
1164+
let limits = VerifierSigningConfig::default();
1165+
let signing_limits = Some(limits.limits_for_signing());
11651166
let mut verifier = sui_execution::verifier(
11661167
&protocol_config,
11671168
signing_limits,

external-crates/move/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.

external-crates/move/crates/bytecode-verifier-tests/src/unit_tests/binary_samples.rs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -32,42 +32,7 @@ macro_rules! do_test {
3232
}};
3333
}
3434

35-
#[test]
36-
fn aptosd_swap() {
37-
do_test!("aptosd_swap");
38-
}
39-
40-
#[test]
41-
fn coin_store() {
42-
do_test!("coin_store");
43-
}
44-
45-
#[test]
46-
fn farming() {
47-
do_test!("farming");
48-
}
49-
50-
#[test]
51-
fn liquidity_pool() {
52-
do_test!("liquidity_pool");
53-
}
54-
55-
#[test]
56-
fn price_oracle() {
57-
do_test!("price_oracle");
58-
}
59-
60-
#[test]
61-
fn pool() {
62-
do_test!("pool");
63-
}
64-
6535
#[test]
6636
fn router() {
6737
do_test!("router");
6838
}
69-
70-
#[test]
71-
fn whitelist() {
72-
do_test!("whitelist");
73-
}

external-crates/move/crates/bytecode-verifier-tests/src/unit_tests/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ pub(crate) fn production_config() -> (VerifierConfig, MeterConfig) {
5656
additional_borrow_checks: true,
5757
better_loader_errors: true,
5858
private_generics_verifier_v2: false,
59+
sanity_check_with_regex_reference_safety: Some(2_200_000),
5960
},
6061
MeterConfig::old_default(),
6162
)

external-crates/move/crates/bytecode-verifier-tests/src/unit_tests/reference_safety_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ fn test_merge_state() {
360360
);
361361
assert_eq!(
362362
result.unwrap_err().major_status(),
363-
StatusCode::CONSTRAINT_NOT_SATISFIED
363+
StatusCode::PROGRAM_TOO_COMPLEX
364364
);
365365
}
366366

external-crates/move/crates/bytecode-verifier-tests/tests/binaries/aptosd_swap.bytes

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)