Skip to content

Add GasToken extension GetAccounts for Governance token#4424

Closed
cschuchardt88 wants to merge 4 commits intoneo-project:masterfrom
cschuchardt88:add/gastrokenextension-back
Closed

Add GasToken extension GetAccounts for Governance token#4424
cschuchardt88 wants to merge 4 commits intoneo-project:masterfrom
cschuchardt88:add/gastrokenextension-back

Conversation

@cschuchardt88
Copy link
Member

@cschuchardt88 cschuchardt88 commented Jan 11, 2026

Description

Note: Not Having breaks all neo-node repo and RestServer plugin.

GasTokenExtensions.cs file was deleted. This PR adds back the the extensions the renamed GasToken as Governance token. Also I switch the placement of the storage key for TokenManagement's account state prefix for easier and fast storage lookups for the token asset accounts.

Change Log

  • Add GovernanceExtensions.cs file

Type of change

  • Optimization (the change is only an optimization)
  • Style (the change is only a code style for better maintenance or standard purpose)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Unit Testing
  • Run Application
  • Local Computer Tests
  • No Testing

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@cschuchardt88 cschuchardt88 added Critical Issues (bugs) that need to be fixed ASAP Waiting for Review labels Jan 11, 2026
@github-actions github-actions bot added the N4 label Jan 11, 2026
@cschuchardt88 cschuchardt88 added the Downstream Needed for downstream repos label Jan 11, 2026
Copy link
Member

@erikzhang erikzhang left a comment

Choose a reason for hiding this comment

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

First, this implementation is unreasonable. If a GetAccounts method is needed, it should be added to TokenManagement. Secondly, returning all accounts at once is a very expensive operation, considering that the number of accounts could be very large; an iterator should be used instead. Therefore, I'm not sure why this method was added in the first place.

if (!snapshot.Contains(key))
throw new InvalidOperationException("The asset id does not exist.");
key = CreateStorageKey(Prefix_AccountState, account, assetId);
key = CreateStorageKey(Prefix_AccountState, assetId, account);
Copy link
Member

Choose a reason for hiding this comment

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

Putting "account" first is a more logical approach. This is because finding all assets in a wallet is a common operation, while finding all accounts for a specific token is a very rare operation.

Copy link
Member Author

Choose a reason for hiding this comment

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

If its done this way than you can't lookup the storage key without knowing an account that has a balance of the asset. So without the account you wont find any assets for a given token. This is basic relational data/database techniques and standard data/database normalization

@cschuchardt88
Copy link
Member Author

cschuchardt88 commented Jan 11, 2026

Think about it.... blocks explorers or governments or financial firms or accounting firm or neo foundation must and will want to know for accounting or metrics or report. These entities will want to know who has the assets and for other reasons. We must be able to NOT have un-accountable assets be unreferenced/undocumented or in other pretty much disappeared. Entities need to be able to trace these assets for market adjustment's and accountability.

Keep in mind
Note: Not Having breaks all neo-node repo and RestServer plugin. THIS IS CURRENTLY BROKEN.

@erikzhang
Copy link
Member

We need to return IIterator just like #4425

@erikzhang
Copy link
Member

Also, we have two options to achieve this:

  1. We have GetAccounts return all accounts, regardless of the asset id;
  2. We have GetAccounts return accounts for a specific asset, which would require adding an extra index.

@erikzhang
Copy link
Member

After some further investigation, I found that GetAccounts is only used by the RestServer plugin, specifically by the ShowNeoAccounts and ShowGasAccounts methods within that plugin.

From my understanding, these two methods are primarily intended for use by block explorers. However, if a block explorer aims to support explicitly listing all accounts holding an arbitrary asset, these two methods alone are insufficient. The reason is that other NEP-17 assets do not provide a corresponding GetAccounts method.

As a result, a block explorer still has to scan all NEP-17 transfer notifications in order to reconstruct the complete set of accounts. Under this assumption, the existence of ShowNeoAccounts and ShowGasAccounts becomes largely redundant.

Copy link
Member

@vncoelho vncoelho left a comment

Choose a reason for hiding this comment

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

Why not giving RestServer Plugin read-only access to do it the way it wants? Thus, avoiding implementing it here.

@shargon shargon mentioned this pull request Jan 14, 2026
18 tasks
@erikzhang erikzhang closed this Jan 22, 2026
@shargon shargon deleted the add/gastrokenextension-back branch January 22, 2026 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Critical Issues (bugs) that need to be fixed ASAP Downstream Needed for downstream repos N4 Waiting for Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants