zoobc / zoobc-core

Main node application to run the zoobc blockchain.
GNU General Public License v3.0
5 stars 3 forks source link

Enhance: explicit account types/binary encoding of addresses (pub keys) instead of encoded string in tx #1204

Closed iltoga closed 3 years ago

iltoga commented 4 years ago

Description

In order to allow multiple account types in transactions, we need to normalize the way account addresses are saved and exchanged with client apps. We propose to adopt similar logic of that in the previous core-node prototype, splitting account address (now an encoded/formatted string) into account type and account bytes.

to achieve that we will need to refactor the follwoing tables schema and all relative code: mempool:

Moreover, since all account addresses are now in bytes, that makes very hard to debug at db level, we need to think of a way to keep a reference in db to the string (formatted) version of every account.

  1. we can have two account fields in account_balance table (one in bytes and one in string) and join that table with any other that has only account in bytes to show a 'readable' account in query results (this will generate duplicates)
  2. we can add an unmanaged table containing:
    • acc type
    • acc (butes)
    • strAcc (formatted account) and use that one to show formatted account in query results (this adds extra complexity to the schema)

Breakdown

Expected behavior

After this, in db we should always have account addresses expressed in bytes + account type.

andy-shi88 commented 4 years ago

looks good and yes multisigInfo will be affected as well, as now the address of multisig is hashes of all account address ( in string), it'll need to be updated to use bytes form