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

Fix staking amount #2238

Merged
merged 2 commits into from
Apr 29, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ impl TransactionBuilder {
.cloned()
.collect::<Vec<_>>();

let mut new_amount = None;

if let Some(change) = self.transitions.as_ref().and_then(|t| t.accounts.get(&account_id)) {
match change {
AccountChange::BeginStaking {
Expand All @@ -83,6 +85,7 @@ impl TransactionBuilder {
self.protocol_parameters
.past_bounded_slot(self.latest_slot_commitment_id),
);
new_amount = Some(*staked_amount);
features.push(
StakingFeature::new(
*staked_amount,
Expand All @@ -101,6 +104,7 @@ impl TransactionBuilder {
.protocol_parameters
.future_bounded_epoch(self.latest_slot_commitment_id);
let staking_feature = feature.as_staking();
new_amount = Some(staking_feature.staked_amount());
// Just extend the end epoch if it's still possible
if future_bounded_epoch <= staking_feature.end_epoch() {
*feature = StakingFeature::new(
Expand Down Expand Up @@ -162,11 +166,14 @@ impl TransactionBuilder {
}

let mut builder = AccountOutputBuilder::from(input)
.with_minimum_amount(self.protocol_parameters.storage_score_parameters())
.with_mana(0)
.with_account_id(account_id)
.with_foundry_counter(u32::max(highest_foundry_serial_number, input.foundry_counter()))
.with_features(features);
match new_amount {
Some(amount) => builder = builder.with_amount(amount),
None => builder = builder.with_minimum_amount(self.protocol_parameters.storage_score_parameters()),
}

// Block issuers cannot move their mana elsewhere.
if input.is_block_issuer() {
Expand Down
Loading