Skip to content

feat(core): fee token creation#1255

Merged
raul-oliveira merged 2 commits intomasterfrom
raul-oliveira/dynamic-transaction-model
Sep 9, 2025
Merged

feat(core): fee token creation#1255
raul-oliveira merged 2 commits intomasterfrom
raul-oliveira/dynamic-transaction-model

Conversation

@raul-oliveira
Copy link
Contributor

@raul-oliveira raul-oliveira commented Apr 2, 2025

Motivation

According to the docs:

Dozer suggested an alternative to the HTR deposit requirement when minting tokens. The idea is to create a new type of custom token where tokens would be minted for free (i.e., no deposits) and fees would be charged for transactions.

This PR adds the fee logic, either by creating a new token version (TokenInfoVersion.FEE) to be and by the refactor of verify_sum.It will add the fee.py file containing calculate_fee() and should_charge_fee() methods. It also change the transaction_verifier.verify_sum() method to receive the entire tx and orchestrate the fee.

Acceptance Criteria

  • Adds a new TokenInfoVersion enum containing a new option FEE should be created.
  • Refactor the TokenInfo and TokenInfoVersion to a new file token_info.py.
  • All the references to the previous TOKEN_INFO_VERSION constant should be updated to the new TokenInfoVersion enum.
  • Adds a FEE_FEATURE_FLAG with False as the default value, True only for testing.
  • Adds the fee.py file with both calculate_fee and should_charge_fee methods.
  • Adds the get_token_creation_transaction method in the transaction_storage.py.
  • Adds the token_info_version parameter to the token_creation_tx.py constructor.
    • Refact in __str__ method to write the token_info_version.
    • Updates the serialize_token_info to accept the created parameter.
    • Adds a validation to the deserialize_token_info method to accept only the values in the TokenInfoVersion.
    • Adds a new version field to TokenInfo to be used in the dicts.
    • Refactored the get_token_info_from_inputs fetch the token_info_version from the token creation tx.
  • Adds get_spent_outputs, get_spent_outputs_grouped_by_token_uid, and get_outputs_grouped_by_token_uid methods in the transaction class.
  • Renamed get_withdraw_amount and get_deposit_amount from transaction/utilsto get_deposit_token_witndraw_amount and get_deposit_token_withdraw_amount.
  • Adds get_deposit_token_amount_from_htr in test/utils.
  • Updates the token_creation_tx_verifier.verify_token_info to check if the fee feature is enabled before accepting the new token_info_version.
  • Updates the verify_sum to match the reference level implementation in the rfc.
  • Adds a method for creating fee tokens in the blueprint environment. This one will be addressed in another PR, on this one we'll only raise a not implemented exception.

Checklist

  • If you are requesting a merge into master, confirm this code is production-ready and can be included in future releases as soon as it gets merged

@raul-oliveira raul-oliveira requested a review from glevco April 2, 2025 16:11
@raul-oliveira raul-oliveira moved this to In Review (WIP) in Hathor Network Apr 2, 2025
@raul-oliveira raul-oliveira changed the title feat(hathor-core): fee calculation mechanism feat(core): fee calculation mechanism Apr 2, 2025
@raul-oliveira raul-oliveira self-assigned this Apr 2, 2025
@raul-oliveira raul-oliveira removed the status in Hathor Network Apr 2, 2025
@raul-oliveira raul-oliveira moved this to In Review (WIP) in Hathor Network Apr 2, 2025
@github-actions
Copy link

github-actions bot commented Apr 2, 2025

🐰 Bencher Report

Branchraul-oliveira/dynamic-transaction-model
Testbedubuntu-22.04
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
minutes (m)
(Result Δ%)
Lower Boundary
minutes (m)
(Limit %)
Upper Boundary
minutes (m)
(Limit %)
sync-v2 (up to 20000 blocks)📈 view plot
🚷 view threshold
1.82 m
(+8.30%)Baseline: 1.68 m
1.51 m
(83.10%)
2.02 m
(90.25%)
🐰 View full continuous benchmarking report in Bencher

@raul-oliveira raul-oliveira moved this from In Review (WIP) to In Progress (WIP) in Hathor Network Apr 2, 2025
@raul-oliveira raul-oliveira changed the title feat(core): fee calculation mechanism feat(core): fee token creation Apr 2, 2025
@raul-oliveira raul-oliveira moved this from In Progress (WIP) to In Review (WIP) in Hathor Network Apr 3, 2025
@raul-oliveira raul-oliveira moved this from In Review (WIP) to In Progress (WIP) in Hathor Network Apr 7, 2025
@raul-oliveira raul-oliveira moved this from In Progress (WIP) to In Progress (Done) in Hathor Network Apr 10, 2025
@raul-oliveira raul-oliveira marked this pull request as ready for review April 11, 2025 14:40
@codecov
Copy link

codecov bot commented Apr 11, 2025

Codecov Report

❌ Patch coverage is 93.18182% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.90%. Comparing base (12464d2) to head (9318567).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
hathor/verification/transaction_verifier.py 90.19% 3 Missing and 2 partials ⚠️
hathor/indexes/rocksdb_tokens_index.py 81.81% 3 Missing and 1 partial ⚠️
hathor/transaction/storage/transaction_storage.py 66.66% 1 Missing and 1 partial ⚠️
hathor/transaction/transaction.py 92.00% 2 Missing ⚠️
hathor/nanocontracts/runner/runner.py 88.88% 1 Missing ⚠️
hathor/transaction/token_creation_tx.py 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1255      +/-   ##
==========================================
- Coverage   85.91%   85.90%   -0.01%     
==========================================
  Files         430      431       +1     
  Lines       32570    32688     +118     
  Branches     5072     5093      +21     
==========================================
+ Hits        27981    28081     +100     
- Misses       3575     3589      +14     
- Partials     1014     1018       +4     

☔ 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.

@raul-oliveira raul-oliveira moved this from In Progress (Done) to In Review (WIP) in Hathor Network Apr 11, 2025
glevco
glevco previously approved these changes Aug 14, 2025
@raul-oliveira raul-oliveira force-pushed the raul-oliveira/dynamic-transaction-model branch 3 times, most recently from 5fa1d7e to 9a7648b Compare August 14, 2025 16:34
@raul-oliveira raul-oliveira requested a review from glevco August 19, 2025 14:55
glevco
glevco previously approved these changes Aug 20, 2025
@raul-oliveira raul-oliveira force-pushed the raul-oliveira/dynamic-transaction-model branch 2 times, most recently from 5285725 to b12c1e1 Compare August 25, 2025 23:39
jansegre
jansegre previously approved these changes Aug 26, 2025
glevco
glevco previously approved these changes Aug 26, 2025
msbrogli
msbrogli previously approved these changes Aug 28, 2025
@raul-oliveira raul-oliveira dismissed stale reviews from msbrogli, glevco, and jansegre via fb9fe3a September 4, 2025 16:28
@raul-oliveira raul-oliveira force-pushed the raul-oliveira/dynamic-transaction-model branch 3 times, most recently from b79ee26 to 64d840a Compare September 4, 2025 17:43
msbrogli
msbrogli previously approved these changes Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants