Skip to content

Commit 89c4188

Browse files
Merge #4760
4760: Keep minimum/maximum delegation amounts when updating bids r=fizyk20 a=fizyk20 Currently, the `global-state-update-gen` tool would reset the minimum/maximum delegation amount of any updated bid to `0` and `u64::MAX`, respectively. This PR changes it so that the limits remain unchanged. We should also consider whether we want to be able to specify new limits in an update (currently not possible). Co-authored-by: Bartłomiej Kamiński <[email protected]>
2 parents 29697a3 + 19834c6 commit 89c4188

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

utils/global-state-update-gen/src/generic.rs

+18-6
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,15 @@ pub fn add_and_remove_bids<T: StateReader>(
308308
public_key.clone(),
309309
*bid.bonding_purse(),
310310
))),
311-
BidKind::Validator(validator_bid) => BidKind::Validator(Box::new(
312-
ValidatorBid::empty(public_key.clone(), *validator_bid.bonding_purse()),
313-
)),
311+
BidKind::Validator(validator_bid) => {
312+
let mut new_bid =
313+
ValidatorBid::empty(public_key.clone(), *validator_bid.bonding_purse());
314+
new_bid.set_delegation_amount_boundaries(
315+
validator_bid.minimum_delegation_amount(),
316+
validator_bid.maximum_delegation_amount(),
317+
);
318+
BidKind::Validator(Box::new(new_bid))
319+
}
314320
BidKind::Delegator(delegator_bid) => {
315321
BidKind::Delegator(Box::new(Delegator::empty(
316322
public_key.clone(),
@@ -425,6 +431,8 @@ fn create_or_update_bid<T: StateReader>(
425431
*bid.delegation_rate(),
426432
delegator_stake,
427433
),
434+
0,
435+
u64::MAX,
428436
)
429437
}
430438
BidKind::Validator(validator_bid) => {
@@ -444,13 +452,17 @@ fn create_or_update_bid<T: StateReader>(
444452
*validator_bid.delegation_rate(),
445453
delegator_stake,
446454
),
455+
validator_bid.minimum_delegation_amount(),
456+
validator_bid.maximum_delegation_amount(),
447457
)
448458
}
449459
_ => unreachable!(),
450460
});
451461

452462
// existing bid
453-
if let Some((bonding_purse, existing_recipient)) = maybe_existing_recipient {
463+
if let Some((bonding_purse, existing_recipient, min_delegation_amount, max_delegation_amount)) =
464+
maybe_existing_recipient
465+
{
454466
if existing_recipient == *updated_recipient {
455467
return; // noop
456468
}
@@ -524,8 +536,8 @@ fn create_or_update_bid<T: StateReader>(
524536
*bonding_purse,
525537
*updated_recipient.stake(),
526538
*updated_recipient.delegation_rate(),
527-
0,
528-
u64::MAX,
539+
min_delegation_amount,
540+
max_delegation_amount,
529541
);
530542

531543
state.set_bid(

0 commit comments

Comments
 (0)