nano-node icon indicating copy to clipboard operation
nano-node copied to clipboard

Implement state block version 2

Open wezrule opened this issue 4 years ago • 3 comments

This adds 5 new fields to the state block:

  1. Height - The height of the block
  2. Signer - Who signed the block? Either account owner or epoch currently.
  3. Link interpretation - How should the link field be interpreted? either send, receive or noop (change/epoch)
  4. Upgrade - Whether this block is upgrading an account, always set for open blocks
  5. Version - The version of the block
  • Changes to existing blocks updated with refresh() now update the block signature and changed function to rebuild()
  • Encapsulate block::account/block::height with using the sideband too, rather than checking block followed by checking sideband if it doesn't exist.
  • Epoch upgrades not required to be sequential anymore
  • A new function simple_block_validation () is used in various places which can do some rudimentary checks on state v2 blocks, anything which doesn't require ledger processing (of previous/source blocks for instance).
  • Ledger - epoch_link has a bit of a different meaning now. Self-signed epoch blocks are allowed, and epoch links were, but now the epoch link can be an account (for self-signed epochs), so passing the whole block in to a new function has_epoch_link which can determine if the link field belongs to an epoch link or a self-signed epoch.
  • Updated flatbuffer definitions and block builder to support state v2 blocks.
  • RPC - block_create, if "type" == "state2" the only required field is "link_interpretation" (being either "send", "receive" or "noop"). The rest of the fields can be implicitly determined assuming the previous block is in the ledger, if using a pruned node this will only work for frontier blocks. Also "version" has been changed to "work_version".

(Bug) - The public key used when verifying a send to an epoch link is the epoch account, so it will always fail signature validation currently

TSAN run was clean.

I have made a diagram of the core test ledger.state_blocks_v2 here: State v2 (1)

wezrule avatar Aug 28 '20 17:08 wezrule

What's the plan for this change? Will it be included in v22 or v23?

rotilho avatar Mar 16 '21 18:03 rotilho

What's the plan for this change? Will it be included in v22 or v23?

It won't be in v22, on the right it states the milestone as v23 but it's possible to change.

wezrule avatar Mar 18 '21 23:03 wezrule

Crossing my fingers to be included in v23, this is one of the most positive additions IMO. I can see sooo many optimization after this change is deployed in the live net

Great job guys and @wezrule

rotilho avatar Mar 19 '21 19:03 rotilho