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

feat: add initial txfees logic #3956

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Conversation

gfanton
Copy link
Member

@gfanton gfanton commented Mar 17, 2025

address: #3782

This PR implements the foundation for transaction fee logic. Notably, it:

  • Creates a base system GNO package for fee distribution and collection.
  • Adds a FeeCollector parameter to the auth module and a proposal function to update it.
  • Updates the Deposit function to correctly transfer fees to the active fee collector address.

I'm unsure about the placement/name, but the proposal I made made sense to me based on the actual context of the Account Keeper and the placeholder for the fee collector.

NOTE: It was my first time using Params. It wasn't immediately clear where to set the initial value, and it seems that multiple sources of truth exist for some parameters. It seems a bit fastidious to add a new Param to the Params module. However, I assume modules are still missing or not implemented yet.

@gfanton gfanton requested a review from zivkovicmilos March 17, 2025 09:54
@gfanton gfanton requested a review from moul March 17, 2025 09:54
@github-actions github-actions bot added 🧾 package/realm Tag used for new Realms or Packages. 📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Mar 17, 2025
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Mar 17, 2025

🛠 PR Checks Summary

All Automated Checks passed. ✅

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
Read More

🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.

✅ Automated Checks (for Contributors):

🟢 Maintainers must be able to edit this pull request (more info)

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 The pull request was created from a fork (head branch repo: gfanton/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission

Copy link

codecov bot commented Mar 17, 2025

Codecov Report

Attention: Patch coverage is 78.09524% with 23 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
gno.land/pkg/gnoland/genesis.go 77.19% 10 Missing and 3 partials ⚠️
gno.land/pkg/integration/testscript_gnoland.go 79.31% 4 Missing and 2 partials ⚠️
tm2/pkg/sdk/auth/keeper.go 42.85% 3 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

genesis.VM.RealmParams = append(genesis.VM.RealmParams, tsGenesis.VM.RealmParams...)
genesis.Auth.Params.FeeCollector = tsGenesis.Auth.Params.FeeCollector
Copy link
Member Author

Choose a reason for hiding this comment

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

I should be able to set all the parameter values here, but the genesis toml file should then contain all the default values for the Auth module.

Copy link
Member

Choose a reason for hiding this comment

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

the more default values you can set in the genesis_params.toml file (with comments), the better. it's doc.

Copy link
Member Author

Choose a reason for hiding this comment

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

That makes sense. I like having this genesis_params as the source of truth for gno.land params. Should we apply them with a right merge? It would be better to have the file override the default values set in params.go files instead of having the file replace all the values, even empty one.

@Kouteki Kouteki added this to the 🚀 Mainnet beta launch milestone Mar 17, 2025
output += "# Fee Coinbase\n"
output += "Balance: " + balance + "\n\n"

// XXX: Get the actual param value
Copy link
Member

Choose a reason for hiding this comment

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

What do you mean?

Copy link
Member

Choose a reason for hiding this comment

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

we can't; is the info really useful? if yes, we can import a contract a get the value.

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you mean?

I simply want to show current fee collector address.
There is no way right now to get params values from the gno files perspective.

we can't; is the info really useful?

I think it can be useful; if updated, there is no easy and straightforward way from a user perspective to get this info (except with gnokey, which is not something I would call user-friendly).

if yes, we can import a contract a get the value.

wdym? If you mean setting the value while updating the param, I'm not a big fan of this idea because we cannot get the initial value of the param, and in specific, this context, the initial value can stay there for a while.

@@ -12,6 +12,9 @@
# TODO: chain_tz = "UTC"
# TODO: default_storage_allowance = ""

["auth"]
fee_collector = "g1najfm5t7dr4f2m38cg55xt6gh2lxsk92tgh0xy" # "gno.land/r/sys/txfees"
Copy link
Member

Choose a reason for hiding this comment

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

You should set this in the auth/params.go, this file (genesis_params.toml) is just for filetests (testing)

Copy link
Member

Choose a reason for hiding this comment

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

And I think the choice for the coinbase in auth is alright for now 👍
cc @moul

Copy link
Member Author

Choose a reason for hiding this comment

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

You should set this in the auth/params.go, this file (genesis_params.toml) is just for filetests (testing)

hmmm, that's a bit confusing. Maybe we should rename it then? But it made sense to have this file living in gno.land, setting all default parameter values for gno.land. For example, setting FeeCollector to sys/txfees is something only gno.land should be aware of, so it makes sense to have this file describing the default values of gno.land Params. (see my other comments)

Copy link
Member

Choose a reason for hiding this comment

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

auth/params.go is where you define the module's suggested default values for the chain it will run on.

genesis_params.toml is not intended for file tests; rather, it customizes the blockchain genesis for the gno.land chain. It may seem counterintuitive to have two default values. However:

  1. The values in */params.go and genesis_params.toml can differ. For example, we might expect most tm2 chains to have a block time of 8 seconds, but we may want gno.land-based chains to have a shorter default block time.
  2. The genesis_params.toml file in the monorepo acts as documentation, similar to the Tendermint default configuration file, which is filled with comments. This file usually contains default values that can be skipped but makes it easier for users to update a value without searching for a key.

Please specify in both locations.

func (ak AccountKeeper) FeeCollectorAddress(ctx sdk.Context) crypto.Address {
feeCollector := ak.GetParams(ctx).FeeCollector
if feeCollector.IsZero() {
feeCollector = crypto.AddressFromPreimage([]byte(DefaultFeeCollectorName))
Copy link
Member

Choose a reason for hiding this comment

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

Just panic if there is no fee collector. Your current implementation isn't caching the case of IsZero. Let's explicitly panic so that blockchain builders can define something custom or just keep the default value, which should work.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm fine with panicing, but I'm concerned about the fact that NewAccountKeeper doesn't initialize DefaultParam, which means that by default, calling FeeCollectorAddress on a fresh account keeper from NewAccountKeeper will panic.

Copy link
Member

@moul moul left a comment

Choose a reason for hiding this comment

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

It seems to be heading in a good direction. Please continue and let me know when you're finished.

(blocking so i can review)

@gfanton gfanton changed the title WIP: add initial txfees logic feat: add initial txfees logic Mar 22, 2025
@gfanton gfanton marked this pull request as ready for review March 23, 2025 20:22
@gfanton gfanton requested review from zivkovicmilos and moul March 24, 2025 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related 🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: In Progress
Status: In Review
Development

Successfully merging this pull request may close these issues.

5 participants