How does NIS store UTXO database locally?

Is there something like merkle patricia tree in the ethereum? or world-state in hyperledger?
If not, are there any plan to implement?
Is this silly question? if so, please tell me why.

Thanks in advance!!

There’s not really notion of inputs and outputs in nem, as it’s not btc based. There’s an account state.
Nis itself stores only blocks and those blocks are re-analyzed when started and state is obtained.

Catapult right now also have state saving, that significantly speeds up start time.
(It could be done in nis as well, but I’m not sure if we’ll be doing that)

1 Like

State saving is a great idea! I love how NEM devs are regularly thinking about these things.

1 Like

Thanks a lot! I also really like to know what devs are thinking about how to implement it in Catapult if it’s possible.

implement what exactly?

What I understood from your reply is that

Nis does not store transactions in block, but rather “state” (i.e. account balance, importance score, etc) for each account. And each time the account is updated every state information is included in a block.
But this will cause a block-size issue since it’s redundant. Catapult employ better way to represent an account state, so the start time (blockchain synchronization) will be more efficient.

so what is that “better way” ? how it is implemented ? what are the choices for data structure available and why Catapult has chosen that data structure ? what is the future direction ? and so on.

That’s not what I meant.

  1. Transactions are stored inside blocks, blocks are exchanged via P2P, those blocks are stored on your HDD/SDD
  2. when nis is starting it is loading and executing blocks, by executing blocks, account state is obtained

In catapult we also save that (obtained) state, not to re-load all the blocks during every start as it’s waste of the time.

2 Likes

Now I understand perfectly. So I suppose simple Key-Value database is good enough for that purpose. How large that state database will be ? Is it small enough comparing to its blockchain?

If when talking about Key-Value, you’re thinking about account-balance relation, it’s bit more complicated as you need to store some metadata as well.
Storage size obviously depends on number of accounts, In catapult you need at least 141 bytes per account (and that is really a minimum).
So to store 10M accounts you need ca 1.3GB of space

That might sound like a lot, but…

To actually create 10M accounts you need:

  1. inside catapult, we currently cap blocks to 70k txes,
  • so you need at least 143 full blocks
  • minimal transaction is 165 bytes, so for transactions itself you need 1.5G
  • you need also block headers (that is negligable compared to number above), currently minimal block header is 192 bytes, so 26k for those 143 blocks
2 Likes

grate answer! thanx.