Skip to content

Fee foreign reserve #380

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
22 changes: 22 additions & 0 deletions shared/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,11 +703,33 @@ impl Block {
.flatten()
.collect();

// Push the balance change of the gas payer
balance_changes.push(BalanceChange::new(
wrapper_tx.fee.gas_payer.clone(),
Token::Native(wrapper_tx.fee.gas_token.clone()),
));

// If the token is not the native one also push the balance
// change of PGF (fee reserve) and the block proposer (the
// balance change for the native token is pushed by default)
if &wrapper_tx.fee.gas_token != native_token {
balance_changes.push(BalanceChange::new(
Id::from(namada_sdk::address::Address::Internal(
namada_sdk::address::InternalAddress::Pgf,
)),
Token::Native(wrapper_tx.fee.gas_token.clone()),
));

if let Some(block_proposer) =
&self.header.proposer_address_namada
{
balance_changes.push(BalanceChange::new(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better approach would be to request this balance update only if the gas price of this tx exceeds the minimum price imposed by the protocol. The problem is that we'd need the updated gas costs for this check and this would introduce a dependency between the parameters and the chain microservices

Id::Account(block_proposer.to_owned()),
Token::Native(wrapper_tx.fee.gas_token.clone()),
));
}
}

balance_changes
})
.collect()
Expand Down