Skip to content

Conversation

grarco
Copy link
Collaborator

@grarco grarco commented May 20, 2025

Describe your changes

Closes #4496.

Changes the base fee logic: burns it if the fee token is the native one and sends it to PGF otherwise. For now the base fees for non-native tokens is sent to the PGF internal account. An alternative would be to create a new internal account for this specific purpose, here's a list of possible pros of both solutions:

  • PGF account
    • less code required
    • pgf cannot spend non-native tokens, so for now this is safe
  • New internal account
    • better logical separation of funds (not really user-related, more for devs), especially useful if we wanted to keep track of the original block proposers from whom these fees are coming

Checklist before merging

  • If this PR has some consensus breaking changes, I added the corresponding breaking:: labels
    • This will require 2 reviewers to approve the changes
  • If this PR requires changes to the docs or specs, a corresponding PR is opened in the namada-docs repo
  • If this PR affects services such as namada-indexer or namada-masp-indexer, a corresponding PR is opened in that repo

@grarco grarco added the breaking:consensus Consensus breaking change that requires a hard-fork label May 20, 2025
@grarco grarco marked this pull request as ready for review May 21, 2025 09:24
@github-actions github-actions bot added the breaking:api public API breaking change label May 21, 2025
@grarco grarco requested review from brentstone, sug0 and tzemanovic May 21, 2025 13:49
@brentstone brentstone requested a review from cwgoes May 22, 2025 06:44
Comment on lines 1570 to 1576
let minimum_gas_price =
parameters::read_gas_cost(storage, &wrapper.fee.token)
.expect("Must be able to read gas cost parameter")
.ok_or(Error::TxApply(protocol::Error::FeeError(format!(
"The provided {} token is not allowed for fee payment",
wrapper.fee.token
))))?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need to recompute this? isn't it already passed to fee_data_check, which calls get_fee_components?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The issue is that fee_data_check is also called by prepare_proposal where the minimum gas price could be the one set locally by the block proposer and not the protocol one. We could pass the minimum gas price to fee_data_check as an Option and make sure that prepare_proposal passes in a None (or maybe a None only when a custom value overrides the protocol one), but it would make it slightly easier to misuse this function.

Actually, the protocol minimum is red even in prepare proposal to compare it with the custom local value, I'll try to see if there's a clean way to propagate that

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's an attempt in 1e7cdcf. It's slightly more complicated than I wanted to (an extra small trait) to ensure that the gas price coming from the local config of a block proposer does not leak to other modules/steps of comet consensus

};
shell_params.state.write_log_mut().emit_event(
TokenEvent {
descriptor: FEE_PAYMENT_DESCRIPTOR,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
descriptor: FEE_PAYMENT_DESCRIPTOR,
descriptor: FEE_PAYMENT_DESCRIPTOR,

should we use a different descriptor here? wrapper-fee-treasury or smth, idk

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can do that yes, should we also create a new one for when we burn the base fee (native token)? Maybe we can just create two descriptors, one for the tip and one for the base fee. It looks like no external tool is using these events so even changing them shouldn't require modifications anywhere else

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, I think one for tips and another for base fees is enough

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've split the event descriptor in 93de5ad. I've also changed the logic to emit the tip event only if a tip is present

@cwgoes
Copy link
Collaborator

cwgoes commented May 22, 2025

Can the internal PGF account receive ICS20 transfers? This is part of the requirements for #4496. Even if it should already work, I think it would be good to add a test-case for this.

@sug0
Copy link
Collaborator

sug0 commented May 22, 2025

Can the internal PGF account receive ICS20 transfers? This is part of the requirements for #4496. Even if it should already work, I think it would be good to add a test-case for this.

@cwgoes the pgf vp is quite permissive with respect to balance changes. it doesn't validate any balance key changes, so anyone is free to send money to the PGF account, whether it's through an ICS-20 transfer, or any other mechanism. the only checks to balances are performed by the multitoken vp, that verify if the changes balance out to 0

@brentstone
Copy link
Collaborator

BTW, I think we should hold off on merging this until a governance proposal approving these kinds of changes is passed by the mainnet community @grarco @cwgoes

@grarco grarco added the do-not-merge Do not merge for now label May 27, 2025
Copy link

codecov bot commented May 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (7734ce0) to head (1e7cdcf).
Report is 17 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #4644   +/-   ##
============================
============================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking:api public API breaking change breaking:consensus Consensus breaking change that requires a hard-fork do-not-merge Do not merge for now

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add "foreign reserve" account and change fee processing logic

4 participants