Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce testnet Bonus amount by 15% #516

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bot/src/generic_stake_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub trait GenericStakePool {
client: &MultiClient,
dry_run: bool,
desired_validator_stake: &[ValidatorStake],
bonus_multiplier: Option<f64>,
) -> Result<
(
EpochStakeNotes,
Expand Down
5 changes: 5 additions & 0 deletions bot/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2576,6 +2576,11 @@ fn main() -> BoxResult<()> {
cluster_multi_client,
pre_run_dry_run || config.dry_run,
&desired_validator_stake,
if config.cluster == Testnet {
Some(0.85)
} else {
None
},
)?;

let mut summary_messages: Vec<String> = vec![format!(
Expand Down
1 change: 1 addition & 0 deletions bot/src/noop_stake_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ impl GenericStakePool for NoopStakePool {
_client: &MultiClient,
dry_run: bool,
desired_validator_stake: &[ValidatorStake],
_bonus_multiplier: Option<f64>,
) -> Result<
(
EpochStakeNotes,
Expand Down
18 changes: 11 additions & 7 deletions bot/src/stake_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ impl GenericStakePool for StakePoolOMatic {
client: &MultiClient,
dry_run: bool,
desired_validator_stake: &[ValidatorStake],
_bonus_multiplier: Option<f64>,
) -> Result<
(
EpochStakeNotes,
Expand Down Expand Up @@ -932,13 +933,13 @@ mod test {
.collect::<Vec<_>>();

stake_o_matic
.apply(client, false, &desired_validator_stake)
.apply(client, false, &desired_validator_stake, None)
.unwrap();

assert!(num_stake_accounts(client, pool_withdraw_authority) > 1 + validators.len());
let _epoch = wait_for_next_epoch(client).unwrap();
stake_o_matic
.apply(client, false, &desired_validator_stake)
.apply(client, false, &desired_validator_stake, None)
.unwrap();

assert_eq!(
Expand Down Expand Up @@ -1095,6 +1096,7 @@ mod test {
priority: false,
})
.collect::<Vec<_>>(),
None,
)
.unwrap();

Expand Down Expand Up @@ -1156,6 +1158,7 @@ mod test {
priority: false,
})
.collect::<Vec<_>>(),
None,
)
.unwrap();

Expand Down Expand Up @@ -1203,6 +1206,7 @@ mod test {
priority: false,
})
.collect::<Vec<_>>(),
None,
)
.unwrap();

Expand Down Expand Up @@ -1253,11 +1257,11 @@ mod test {
];

stake_o_matic
.apply(&client, false, &desired_validator_stake)
.apply(&client, false, &desired_validator_stake, None)
.unwrap();
let _epoch = wait_for_next_epoch(&client).unwrap();
stake_o_matic
.apply(&client, false, &desired_validator_stake)
.apply(&client, false, &desired_validator_stake, None)
.unwrap();

info!("Check after first epoch");
Expand Down Expand Up @@ -1285,7 +1289,7 @@ mod test {
info!("Check after second epoch");
let _epoch = wait_for_next_epoch(&client).unwrap();
stake_o_matic
.apply(&client, false, &desired_validator_stake)
.apply(&client, false, &desired_validator_stake, None)
.unwrap();

assert_eq!(
Expand All @@ -1310,11 +1314,11 @@ mod test {
// ===========================================================
info!("remove all validators");
// deactivate all validator stake and remove from pool
stake_o_matic.apply(&client, false, &[]).unwrap();
stake_o_matic.apply(&client, false, &[], None).unwrap();

// withdraw removed validator stake into the staker
let _epoch = wait_for_next_epoch(&client).unwrap();
stake_o_matic.apply(&client, false, &[]).unwrap();
stake_o_matic.apply(&client, false, &[], None).unwrap();
// all stake has been returned to the reserve account
assert_reserve_account_only(
min_reserve_stake_balance + stake_rent_exemption + total_stake_amount,
Expand Down
21 changes: 12 additions & 9 deletions bot/src/stake_pool_v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ impl GenericStakePool for StakePool {
client: &MultiClient,
dry_run: bool,
desired_validator_stake: &[ValidatorStake],
bonus_multiplier: Option<f64>,
) -> Result<
(
EpochStakeNotes,
Expand Down Expand Up @@ -210,10 +211,11 @@ impl GenericStakePool for StakePool {
Sol(total_bonus_stake_amount)
);

let bonus_stake_amount = if bonus_stake_node_count == 0 {
let bonus_stake_amount: u64 = if bonus_stake_node_count == 0 {
0
} else {
total_bonus_stake_amount / (bonus_stake_node_count as u64)
(bonus_multiplier.unwrap_or(1.0)
* ((total_bonus_stake_amount / bonus_stake_node_count) as f64)) as u64
};

info!("Bonus stake amount: {}", Sol(bonus_stake_amount));
Expand Down Expand Up @@ -900,7 +902,7 @@ mod test {
.collect::<Vec<_>>();

stake_pool
.apply(client, false, &desired_validator_stake)
.apply(client, false, &desired_validator_stake, None)
.unwrap();

assert_eq!(
Expand All @@ -909,7 +911,7 @@ mod test {
);
let _epoch = wait_for_next_epoch(client).unwrap();
stake_pool
.apply(client, false, &desired_validator_stake)
.apply(client, false, &desired_validator_stake, None)
.unwrap();

assert_eq!(
Expand Down Expand Up @@ -1034,6 +1036,7 @@ mod test {
priority: false,
})
.collect::<Vec<_>>(),
None,
)
.unwrap();

Expand Down Expand Up @@ -1107,11 +1110,11 @@ mod test {
];

stake_pool
.apply(&client, false, &desired_validator_stake)
.apply(&client, false, &desired_validator_stake, None)
.unwrap();
let _epoch = wait_for_next_epoch(&client).unwrap();
stake_pool
.apply(&client, false, &desired_validator_stake)
.apply(&client, false, &desired_validator_stake, None)
.unwrap();

// after the first epoch, validators 0 and 1 are at their target levels but validator 2
Expand Down Expand Up @@ -1142,7 +1145,7 @@ mod test {

let _epoch = wait_for_next_epoch(&client).unwrap();
stake_pool
.apply(&client, false, &desired_validator_stake)
.apply(&client, false, &desired_validator_stake, None)
.unwrap();

assert_eq!(
Expand Down Expand Up @@ -1173,10 +1176,10 @@ mod test {
info!("remove all validators");

// deactivate all validator stake
stake_pool.apply(&client, false, &[]).unwrap();
stake_pool.apply(&client, false, &[], None).unwrap();
let _epoch = wait_for_next_epoch(&client).unwrap();
// merge deactivated validator stake back into the reserve
stake_pool.apply(&client, false, &[]).unwrap();
stake_pool.apply(&client, false, &[], None).unwrap();
// all stake has returned to the reserve account
assert_reserve_account_only();
}
Expand Down
Loading