Skip to content

fix(nano): authority handling on indexes with contracts#1337

Merged
glevco merged 1 commit intomasterfrom
fix/nano/token-authorities
Jul 29, 2025
Merged

fix(nano): authority handling on indexes with contracts#1337
glevco merged 1 commit intomasterfrom
fix/nano/token-authorities

Conversation

@glevco
Copy link
Contributor

@glevco glevco commented Jul 28, 2025

Motivation

This PR resolves https://github.com/HathorNetwork/nano-hathor-core/issues/251: the tokens API doesn't account for authorities stored in Nano Contracts, only in UTXOs.

ATTENTION: We also have to update the clients after this PR. The issue above lists the required changes. This can be done incrementally because the existing keys are kept in the response.

Acceptance Criteria

  1. Rename NCSyscallRecord to NCIndexUpdateRecord to reflect the fact that now it can include updates caused by actions (not just syscalls).
  2. Add new UpdateAuthoritiesRecord index update record and its respective handling.
  3. Add counters for contracts holding token authorities in the tokens index.
  4. Refactor usages of list[NCAction] to Sequence[NCAction] across syscalls and internal methods — since our usage is immutable we can use Sequence which is more flexible because it's covariant over its items, so we don't need to explicitly type the list when writing blueprints.
  5. Add new rule preventing a revoke_authorities syscall when contracts don't hold the respective authority. Before, such revoke would simply be a no-op — this change is more consistent, prevents mistakes, and is easier to account for in the indexes.
  6. Update /thin_wallet/tokens API so it also returns bools can_mint/can_melt which include contract authorities.
  7. NOTE: even though the internal schema of the tokens index is changed, no migration is necessary because nano is disabled on mainnet and testnet, and there are no blueprints with authorities handling in bravo-nano-testnet.

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 Jul 28, 2025
@glevco glevco requested review from jansegre and msbrogli as code owners July 28, 2025 16:19
@glevco glevco moved this from Todo to In Review (Done) in Hathor Network Jul 28, 2025
@github-actions
Copy link

🐰 Bencher Report

Branchfix/nano/token-authorities
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.65 m
(+0.48%)Baseline: 1.64 m
1.47 m
(89.57%)
1.80 m
(91.35%)
🐰 View full continuous benchmarking report in Bencher

@codecov
Copy link

codecov bot commented Jul 28, 2025

Codecov Report

❌ Patch coverage is 78.48101% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.59%. Comparing base (1d13b1e) to head (2497168).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
hathor/nanocontracts/runner/types.py 68.75% 9 Missing and 1 partial ⚠️
hathor/indexes/manager.py 71.42% 3 Missing and 5 partials ⚠️
hathor/indexes/rocksdb_tokens_index.py 83.33% 5 Missing and 2 partials ⚠️
hathor/nanocontracts/runner/runner.py 86.66% 3 Missing and 1 partial ⚠️
hathor/wallet/resources/thin_wallet/tokens.py 42.85% 2 Missing and 2 partials ⚠️
hathor/transaction/types.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1337      +/-   ##
==========================================
- Coverage   85.68%   85.59%   -0.09%     
==========================================
  Files         424      424              
  Lines       31989    32095     +106     
  Branches     4967     4994      +27     
==========================================
+ Hits        27411    27473      +62     
- Misses       3586     3616      +30     
- Partials      992     1006      +14     

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

@github-project-automation github-project-automation bot moved this from In Review (Done) to In Review (WIP) in Hathor Network Jul 29, 2025
@glevco glevco merged commit 5c883a7 into master Jul 29, 2025
8 checks passed
@glevco glevco deleted the fix/nano/token-authorities branch July 29, 2025 16:11
@github-project-automation github-project-automation bot moved this from In Review (WIP) to Waiting to be deployed in Hathor Network Jul 29, 2025
@jansegre jansegre moved this from Waiting to be deployed to Done in Hathor Network Aug 5, 2025
This was referenced Aug 5, 2025
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.

3 participants