Skip to content

Commit dfe42fc

Browse files
committed
refactor: rename
1 parent f8acd4a commit dfe42fc

File tree

8 files changed

+36
-36
lines changed

8 files changed

+36
-36
lines changed

crates/e2e-tests/src/e2e_flow.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,17 +1323,17 @@ mod tests {
13231323
.wait_for_mpc_key(Duration::from_secs(60))
13241324
.await?;
13251325

1326-
use hashi::onchain::types::DEFAULT_MPC_THRESHOLD_BASIS_POINTS;
1326+
use hashi::onchain::types::DEFAULT_MPC_THRESHOLD_IN_BASIS_POINTS;
13271327
use hashi::onchain::types::DEFAULT_MPC_WEIGHT_REDUCTION_ALLOWED_DELTA;
13281328

13291329
let hashi = networks.hashi_network.nodes()[0].hashi();
1330-
let threshold_bps = hashi.onchain_state().mpc_threshold_basis_points();
1330+
let threshold_bps = hashi.onchain_state().mpc_threshold_in_basis_points();
13311331
let weight_reduction_allowed_delta =
13321332
hashi.onchain_state().mpc_weight_reduction_allowed_delta();
13331333

13341334
assert_eq!(
1335-
threshold_bps, DEFAULT_MPC_THRESHOLD_BASIS_POINTS,
1336-
"on-chain mpc_threshold_basis_points ({threshold_bps}) != Rust default ({DEFAULT_MPC_THRESHOLD_BASIS_POINTS})"
1335+
threshold_bps, DEFAULT_MPC_THRESHOLD_IN_BASIS_POINTS,
1336+
"on-chain mpc_threshold_in_basis_points ({threshold_bps}) != Rust default ({DEFAULT_MPC_THRESHOLD_IN_BASIS_POINTS})"
13371337
);
13381338
assert_eq!(
13391339
weight_reduction_allowed_delta, DEFAULT_MPC_WEIGHT_REDUCTION_ALLOWED_DELTA,

crates/hashi/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl Hashi {
219219
let state = self.onchain_state().state();
220220
let hashi = state.hashi();
221221
let committee_set = &hashi.committees;
222-
let threshold_basis_points = hashi.config.mpc_threshold_basis_points();
222+
let threshold_in_basis_points = hashi.config.mpc_threshold_in_basis_points();
223223
let weight_reduction_allowed_delta = hashi.config.mpc_weight_reduction_allowed_delta();
224224
let session_id = mpc::SessionId::new(self.config.sui_chain_id(), epoch, &protocol_type);
225225
let encryption_key = self.config.encryption_private_key()?;
@@ -261,7 +261,7 @@ impl Hashi {
261261
encryption_key,
262262
signing_key,
263263
store,
264-
threshold_basis_points,
264+
threshold_in_basis_points,
265265
weight_reduction_allowed_delta,
266266
chain_id,
267267
self.config.test_weight_divisor,

crates/hashi/src/mpc/mpc_except_signing.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl MpcManager {
121121
encryption_key: PrivateKey<EncryptionGroupElement>,
122122
signing_key: Bls12381PrivateKey,
123123
public_message_store: Box<dyn PublicMessagesStore>,
124-
threshold_basis_points: u16,
124+
threshold_in_basis_points: u16,
125125
weight_reduction_allowed_delta: u16,
126126
chain_id: &str,
127127
weight_divisor: Option<u16>,
@@ -145,7 +145,7 @@ impl MpcManager {
145145
.clone();
146146
let (nodes, threshold) = build_reduced_nodes(
147147
&committee,
148-
threshold_basis_points,
148+
threshold_in_basis_points,
149149
weight_reduction_allowed_delta,
150150
weight_divisor,
151151
)?;
@@ -204,7 +204,7 @@ impl MpcManager {
204204
Some(prev_committee) => {
205205
let (nodes, threshold) = build_reduced_nodes(
206206
prev_committee,
207-
threshold_basis_points,
207+
threshold_in_basis_points,
208208
weight_reduction_allowed_delta,
209209
weight_divisor,
210210
)?;
@@ -3591,7 +3591,7 @@ fn compute_messages_hash(messages: &Messages) -> MessageHash {
35913591

35923592
fn build_reduced_nodes(
35933593
committee: &Committee,
3594-
threshold_basis_points: u16,
3594+
threshold_in_basis_points: u16,
35953595
weight_reduction_allowed_delta: u16,
35963596
test_weight_divisor: u16,
35973597
) -> MpcResult<(Nodes<EncryptionGroupElement>, u16)> {
@@ -3607,7 +3607,7 @@ fn build_reduced_nodes(
36073607
.collect();
36083608
let total_weight: u16 = nodes_vec.iter().map(|n| n.weight).sum();
36093609
let threshold =
3610-
(total_weight as u32 * threshold_basis_points as u32).div_ceil(MAX_BASIS_POINTS) as u16;
3610+
(total_weight as u32 * threshold_in_basis_points as u32).div_ceil(MAX_BASIS_POINTS) as u16;
36113611
Nodes::new_reduced(nodes_vec, threshold, weight_reduction_allowed_delta, 1)
36123612
.map_err(|e| MpcError::CryptoError(e.to_string()))
36133613
}

crates/hashi/src/mpc/mpc_except_signing_tests.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use std::sync::Arc;
2424
use std::sync::atomic::AtomicUsize;
2525
use std::sync::atomic::Ordering;
2626

27-
const TEST_THRESHOLD_BASIS_POINTS: u16 = 3333;
27+
const TEST_THRESHOLD_IN_BASIS_POINTS: u16 = 3333;
2828
/// Use 0 for weight_reduction_allowed_delta in tests to disable weight reduction.
2929
const TEST_WEIGHT_REDUCTION_ALLOWED_DELTA: u16 = 0;
3030
/// Use 1 for test_weight_divisor in unit tests (they already use small weights).
@@ -288,7 +288,7 @@ impl TestSetup {
288288
self.encryption_keys[validator_index].clone(),
289289
self.signing_keys[validator_index].clone(),
290290
store,
291-
TEST_THRESHOLD_BASIS_POINTS,
291+
TEST_THRESHOLD_IN_BASIS_POINTS,
292292
TEST_WEIGHT_REDUCTION_ALLOWED_DELTA,
293293
TEST_CHAIN_ID,
294294
None,
@@ -902,7 +902,7 @@ fn test_mpc_manager_new_from_committee_set() {
902902
encryption_key,
903903
signing_key,
904904
Box::new(MockPublicMessagesStore),
905-
TEST_THRESHOLD_BASIS_POINTS,
905+
TEST_THRESHOLD_IN_BASIS_POINTS,
906906
TEST_WEIGHT_REDUCTION_ALLOWED_DELTA,
907907
TEST_CHAIN_ID,
908908
None,
@@ -966,7 +966,7 @@ fn test_mpc_manager_new_fails_if_no_committee_for_epoch() {
966966
encryption_keys[0].clone(),
967967
signing_keys[0].clone(),
968968
Box::new(MockPublicMessagesStore),
969-
TEST_THRESHOLD_BASIS_POINTS,
969+
TEST_THRESHOLD_IN_BASIS_POINTS,
970970
TEST_WEIGHT_REDUCTION_ALLOWED_DELTA,
971971
"test",
972972
None,
@@ -4959,7 +4959,7 @@ impl RotationTestSetup {
49594959
let committee = self.setup.committee();
49604960
let (nodes, threshold) = build_reduced_nodes(
49614961
committee,
4962-
TEST_THRESHOLD_BASIS_POINTS,
4962+
TEST_THRESHOLD_IN_BASIS_POINTS,
49634963
TEST_WEIGHT_REDUCTION_ALLOWED_DELTA,
49644964
TEST_WEIGHT_DIVISOR,
49654965
)
@@ -4985,7 +4985,7 @@ impl RotationTestSetup {
49854985
if let Some(ref prev) = previous_committee {
49864986
let (nodes, threshold) = build_reduced_nodes(
49874987
prev,
4988-
TEST_THRESHOLD_BASIS_POINTS,
4988+
TEST_THRESHOLD_IN_BASIS_POINTS,
49894989
TEST_WEIGHT_REDUCTION_ALLOWED_DELTA,
49904990
TEST_WEIGHT_DIVISOR,
49914991
)
@@ -6133,7 +6133,7 @@ async fn test_prepare_previous_output_for_new_member() {
61336133
new_member_encryption_key,
61346134
new_member_signing_key,
61356135
Box::new(InMemoryPublicMessagesStore::new()),
6136-
TEST_THRESHOLD_BASIS_POINTS,
6136+
TEST_THRESHOLD_IN_BASIS_POINTS,
61376137
TEST_WEIGHT_REDUCTION_ALLOWED_DELTA,
61386138
TEST_CHAIN_ID,
61396139
None,
@@ -7274,7 +7274,7 @@ fn test_reconstruct_from_dkg_certificates_with_shifted_party_ids() {
72747274
rotation_setup.setup.encryption_keys[shifted_member_index].clone(),
72757275
rotation_setup.setup.signing_keys[shifted_member_index].clone(),
72767276
Box::new(store),
7277-
TEST_THRESHOLD_BASIS_POINTS,
7277+
TEST_THRESHOLD_IN_BASIS_POINTS,
72787278
TEST_WEIGHT_REDUCTION_ALLOWED_DELTA,
72797279
TEST_CHAIN_ID,
72807280
None,
@@ -7437,7 +7437,7 @@ fn test_reconstruct_from_dkg_certificates_stops_at_threshold() {
74377437
setup.encryption_keys[target_index].clone(),
74387438
setup.signing_keys[target_index].clone(),
74397439
Box::new(store),
7440-
TEST_THRESHOLD_BASIS_POINTS,
7440+
TEST_THRESHOLD_IN_BASIS_POINTS,
74417441
TEST_WEIGHT_REDUCTION_ALLOWED_DELTA,
74427442
TEST_CHAIN_ID,
74437443
None,
@@ -7518,7 +7518,7 @@ fn test_reconstruct_from_rotation_certificates_with_shifted_party_ids() {
75187518
rotation_setup.setup.encryption_keys[dealer_idx].clone(),
75197519
rotation_setup.setup.signing_keys[dealer_idx].clone(),
75207520
Box::new(InMemoryPublicMessagesStore::new()),
7521-
TEST_THRESHOLD_BASIS_POINTS,
7521+
TEST_THRESHOLD_IN_BASIS_POINTS,
75227522
TEST_WEIGHT_REDUCTION_ALLOWED_DELTA,
75237523
TEST_CHAIN_ID,
75247524
None,
@@ -7550,7 +7550,7 @@ fn test_reconstruct_from_rotation_certificates_with_shifted_party_ids() {
75507550
rotation_setup.setup.encryption_keys[other_idx].clone(),
75517551
rotation_setup.setup.signing_keys[other_idx].clone(),
75527552
Box::new(InMemoryPublicMessagesStore::new()),
7553-
TEST_THRESHOLD_BASIS_POINTS,
7553+
TEST_THRESHOLD_IN_BASIS_POINTS,
75547554
TEST_WEIGHT_REDUCTION_ALLOWED_DELTA,
75557555
TEST_CHAIN_ID,
75567556
None,
@@ -7638,7 +7638,7 @@ fn test_reconstruct_from_rotation_certificates_with_shifted_party_ids() {
76387638
rotation_setup.setup.encryption_keys[shifted_member_index].clone(),
76397639
rotation_setup.setup.signing_keys[shifted_member_index].clone(),
76407640
Box::new(store),
7641-
TEST_THRESHOLD_BASIS_POINTS,
7641+
TEST_THRESHOLD_IN_BASIS_POINTS,
76427642
TEST_WEIGHT_REDUCTION_ALLOWED_DELTA,
76437643
TEST_CHAIN_ID,
76447644
None,

crates/hashi/src/onchain/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ impl OnchainState {
394394
self.state().hashi().config.bitcoin_confirmation_threshold()
395395
}
396396

397-
pub fn mpc_threshold_basis_points(&self) -> u16 {
398-
self.state().hashi().config.mpc_threshold_basis_points()
397+
pub fn mpc_threshold_in_basis_points(&self) -> u16 {
398+
self.state().hashi().config.mpc_threshold_in_basis_points()
399399
}
400400

401401
pub fn mpc_weight_reduction_allowed_delta(&self) -> u16 {

crates/hashi/src/onchain/types.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ pub struct Config {
470470
const DUST_RELAY_MIN_VALUE: u64 = 546;
471471

472472
// These mirror the defaults in mpc_config.move and must be kept in sync.
473-
pub const DEFAULT_MPC_THRESHOLD_BASIS_POINTS: u16 = 3333;
473+
pub const DEFAULT_MPC_THRESHOLD_IN_BASIS_POINTS: u16 = 3333;
474474
pub const DEFAULT_MPC_WEIGHT_REDUCTION_ALLOWED_DELTA: u16 = 800;
475475

476476
impl Config {
@@ -515,12 +515,12 @@ impl Config {
515515
}
516516
}
517517

518-
pub fn mpc_threshold_basis_points(&self) -> u16 {
519-
match self.config.get("mpc_threshold_basis_points") {
518+
pub fn mpc_threshold_in_basis_points(&self) -> u16 {
519+
match self.config.get("mpc_threshold_in_basis_points") {
520520
Some(ConfigValue::U64(v)) => {
521-
u16::try_from(*v).expect("mpc_threshold_basis_points exceeds u16::MAX")
521+
u16::try_from(*v).expect("mpc_threshold_in_basis_points exceeds u16::MAX")
522522
}
523-
_ => DEFAULT_MPC_THRESHOLD_BASIS_POINTS,
523+
_ => DEFAULT_MPC_THRESHOLD_IN_BASIS_POINTS,
524524
}
525525
}
526526

crates/internal-tools/src/key_recovery.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub async fn run(args: Args, onchain_state: &OnchainState, chain_id: &str) -> an
114114
let mut manager = {
115115
let state = onchain_state.state();
116116
let hashi = state.hashi();
117-
let threshold_basis_points = hashi.config.mpc_threshold_basis_points();
117+
let threshold_in_basis_points = hashi.config.mpc_threshold_in_basis_points();
118118
let weight_reduction_allowed_delta = hashi.config.mpc_weight_reduction_allowed_delta();
119119
MpcManager::new(
120120
validator_address,
@@ -123,7 +123,7 @@ pub async fn run(args: Args, onchain_state: &OnchainState, chain_id: &str) -> an
123123
encryption_key,
124124
dummy_signing_key.clone(),
125125
Box::new(store),
126-
threshold_basis_points,
126+
threshold_in_basis_points,
127127
weight_reduction_allowed_delta,
128128
chain_id,
129129
None, // weight_divisor

packages/hashi/sources/core/mpc_config.move

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module hashi::mpc_config;
55

66
use hashi::{config::Config, config_value};
77

8-
const DEFAULT_THRESHOLD_BASIS_POINTS: u64 = 3333;
8+
const DEFAULT_THRESHOLD_IN_BASIS_POINTS: u64 = 3333;
99

1010
const MAX_BPS: u64 = 10000;
1111

@@ -17,7 +17,7 @@ public(package) fun is_valid_config_entry(
1717
value: &config_value::Value,
1818
): bool {
1919
let k = key.as_bytes();
20-
if (k == &b"mpc_threshold_basis_points") {
20+
if (k == &b"mpc_threshold_in_basis_points") {
2121
value.is_u64() && (*value).as_u64() > 0 && (*value).as_u64() <= MAX_BPS
2222
} else if (k == &b"mpc_weight_reduction_allowed_delta") {
2323
value.is_u64() && (*value).as_u64() <= MAX_BPS
@@ -28,8 +28,8 @@ public(package) fun is_valid_config_entry(
2828

2929
public(package) fun init_defaults(config: &mut Config) {
3030
config.upsert(
31-
b"mpc_threshold_basis_points",
32-
config_value::new_u64(DEFAULT_THRESHOLD_BASIS_POINTS),
31+
b"mpc_threshold_in_basis_points",
32+
config_value::new_u64(DEFAULT_THRESHOLD_IN_BASIS_POINTS),
3333
);
3434
config.upsert(
3535
b"mpc_weight_reduction_allowed_delta",

0 commit comments

Comments
 (0)