Neo: Dettach Native TokenAmount from TokenState (Neo 3)

Created on 14 Jun 2019  路  2Comments  路  Source: neo-project/neo

Native NEP5 is an amazing invention for Neo 3, and it would be nice to able to reuse it in several places as well.

  • One application, proposed on https://github.com/neo-project/neo/issues/772 is to be able to code a NEP5 in high-level languages and, at the same time, inherit basic functions from native NEP5. This is the best of all worlds: immutability of contract rules; maintainance and correctness of base NEP5 functions, ensured by network itself (remember that Neo and Gas is implemented there!).
    However, this "template" can only be reused easily, in its deepest level, if we manage to pass control over token amounts/transfers to the inherited functions. So, it would be nice to have token amount directly connected to user key (prefixed or not, doesn't matter).
  • Second application, is the ability to automatically garbage collect these keys, at the moment they become zero https://github.com/neo-project/neo/issues/824. This can also be connected to the template proposed above.

So, I propose to move TState structures to somewhere on Neo/Gas Nep5 implementations, but not directly on Nep5 template class. It could be implemented with prefixes in a dettached way, each field on a prefix, or all auxiliary fields in another prefix. It would be nice to have Neo votes on a separated prefix too.

Example (current one):
accountprefix + scripthash -> serialized TState with amount / or possibly many stuff

To allow further optimizations (such as key groupings on storage, if using MPT or any kind of tree), it's better to have a user scripthash _suffix_ for TState.

Example:

accountprefix + scripthash + amountssuffix -> amount
accountprefix + scripthash + votessuffix -> votes
etc.

So, no extra space is spent, and flexibility is much higher.

discussion enhancement ledger vm

Most helpful comment

Vote can not be 0, default to Red4Sec or NeoResearch node....ehauahheuah

All 2 comments

and if vote is 0, no extraspace is used

Vote can not be 0, default to Red4Sec or NeoResearch node....ehauahheuah

Was this page helpful?
0 / 5 - 0 ratings

Related issues

garrey332 picture garrey332  路  3Comments

canesin picture canesin  路  3Comments

lock9 picture lock9  路  4Comments

vncoelho picture vncoelho  路  3Comments

shargon picture shargon  路  3Comments