Skip to content

refactor(nano): simplify index records#1460

Merged
jansegre merged 1 commit intomasterfrom
refactor/nano/index-records
Oct 15, 2025
Merged

refactor(nano): simplify index records#1460
jansegre merged 1 commit intomasterfrom
refactor/nano/index-records

Conversation

@glevco
Copy link
Contributor

@glevco glevco commented Oct 13, 2025

Motivation

This PR addresses a few shortcomings of the current index update records model used in the nano Runner to update indexes after a nano is executed. The use cases evolved and the model became outdated. It addresses these:

  1. The fee charge of an action was using a type that was named after a syscall, not an action.
  2. The fee charge was using the MELT type, but it's not a melt.
  3. Both token creation and balance update were using the same type, but they're handled differently.

In a subsequent PR, the syscall token balance rules which are used for token fees will also be simplified.

Acceptance Criteria

  • Move index update types from the runner/types.py file to their own file, runner/index_records.py.
  • Rename the runner/types.py file to runner/call_info.py, because now it only contains call info-related types.
  • Remodel the index update types to simplify them and make them clearer in intent:
    • IndexUpdateRecordType -> becomes IndexRecordType, and its options are updated to better reflect the intentions.
    • UpdateAuthoritiesRecordType -> is removed and included in IndexRecordType for simplification.
    • SyscallCreateContractRecord -> becomes CreateContractRecord
    • UpdateAuthoritiesRecord doesn't change.
    • SyscallUpdateTokenRecord -> is now broken into two types, CreateTokenRecord and UpdateTokenBalanceRecord. It was a single type encompassing two different intentions.
    • The name Syscall is removed from type names because now we also have actions that affect indexes. Removing it is more generic.
    • __post_init__ validations are improved.

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

@glevco glevco self-assigned this Oct 13, 2025
@glevco glevco moved this from Todo to In Progress (WIP) in Hathor Network Oct 13, 2025
@codecov
Copy link

codecov bot commented Oct 13, 2025

Codecov Report

❌ Patch coverage is 89.03226% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.04%. Comparing base (ae485dd) to head (5a52530).
⚠️ Report is 11 commits behind head on raul-oliveira/fee-token-verification.

Files with missing lines Patch % Lines
hathor/nanocontracts/runner/index_records.py 78.57% 18 Missing ⚠️
hathor/indexes/manager.py 69.23% 1 Missing and 3 partials ⚠️
hathor/wallet/resources/thin_wallet/send_tokens.py 50.00% 3 Missing ⚠️
hathor/indexes/rocksdb_tokens_index.py 60.00% 1 Missing and 1 partial ⚠️
hathor/nanocontracts/balance_rules.py 77.77% 1 Missing and 1 partial ⚠️
hathor/transaction/transaction.py 92.85% 1 Missing and 1 partial ⚠️
hathor/verification/transaction_verifier.py 94.28% 2 Missing ⚠️
hathor/transaction/types.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                           Coverage Diff                            @@
##           raul-oliveira/fee-token-verification    #1460      +/-   ##
========================================================================
+ Coverage                                 86.02%   86.04%   +0.01%     
========================================================================
  Files                                       435      437       +2     
  Lines                                     33918    34015      +97     
  Branches                                   5297     5317      +20     
========================================================================
+ Hits                                      29179    29269      +90     
+ Misses                                     3693     3692       -1     
- Partials                                   1046     1054       +8     

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

@glevco glevco moved this from In Progress (WIP) to In Progress (Done) in Hathor Network Oct 14, 2025
@glevco glevco force-pushed the refactor/nano/index-records branch from 5b7b536 to 5a52530 Compare October 14, 2025 19:16
msbrogli
msbrogli previously approved these changes Oct 14, 2025
@github-project-automation github-project-automation bot moved this from In Progress (Done) to In Review (WIP) in Hathor Network Oct 14, 2025
jansegre
jansegre previously approved these changes Oct 14, 2025
raul-oliveira
raul-oliveira previously approved these changes Oct 14, 2025
@glevco glevco mentioned this pull request Oct 14, 2025
2 tasks
@glevco glevco moved this from In Review (WIP) to In Review (Done) in Hathor Network Oct 14, 2025
@glevco glevco force-pushed the raul-oliveira/fee-token-verification branch from ecacbad to c92032e Compare October 14, 2025 22:06
@glevco glevco force-pushed the refactor/nano/index-records branch 2 times, most recently from 9dcdd3b to e9acc21 Compare October 15, 2025 13:36
@glevco glevco force-pushed the raul-oliveira/fee-token-verification branch from fbc7ceb to 72e231a Compare October 15, 2025 15:54
@glevco glevco force-pushed the refactor/nano/index-records branch from e9acc21 to f36b075 Compare October 15, 2025 16:03
@glevco glevco force-pushed the raul-oliveira/fee-token-verification branch from 72e231a to dca477b Compare October 15, 2025 16:32
@glevco glevco force-pushed the refactor/nano/index-records branch from f36b075 to 3d06cf1 Compare October 15, 2025 16:33
@jansegre jansegre deleted the branch master October 15, 2025 17:30
@jansegre jansegre closed this Oct 15, 2025
@github-project-automation github-project-automation bot moved this from In Review (Done) to Waiting to be deployed in Hathor Network Oct 15, 2025
@glevco glevco moved this from Waiting to be deployed to In Review (Done) in Hathor Network Oct 15, 2025
@glevco glevco reopened this Oct 15, 2025
@glevco glevco changed the base branch from raul-oliveira/fee-token-verification to master October 15, 2025 17:33
@glevco glevco dismissed raul-oliveira’s stale review October 15, 2025 17:33

The base branch was changed.

@glevco glevco dismissed stale reviews from jansegre and msbrogli October 15, 2025 17:33

The base branch was changed.

@glevco glevco force-pushed the refactor/nano/index-records branch from 3d06cf1 to 81f19e7 Compare October 15, 2025 17:34
@github-project-automation github-project-automation bot moved this from In Review (Done) to In Review (WIP) in Hathor Network Oct 15, 2025
@glevco glevco moved this from In Review (WIP) to In Review (Done) in Hathor Network Oct 15, 2025
@glevco glevco force-pushed the refactor/nano/index-records branch from 81f19e7 to a39327b Compare October 15, 2025 18:13
@jansegre jansegre merged commit 0d26af9 into master Oct 15, 2025
5 of 7 checks passed
@jansegre jansegre deleted the refactor/nano/index-records branch October 15, 2025 19:06
@github-project-automation github-project-automation bot moved this from In Review (Done) to Waiting to be deployed in Hathor Network Oct 15, 2025
@jansegre jansegre moved this from Waiting to be deployed to Done in Hathor Network Oct 16, 2025
@jansegre jansegre mentioned this pull request Oct 16, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants