Skip to content

Database description

Olle Solens edited this page Jul 13, 2020 · 49 revisions

Intro

Throughout the description, we use specific terms such as object, MainNet, pulse. It seems appropriate to explain what some of them mean and how they relate to other.

While Insolar is a platform, Insolar MainNet is an instance of this platform that contains tested and well-implemented features. Insolar TestNet, another instance of Insolar Platform, has some experimental new features and is meant for safe testing of the Platform.

Insolar primarily operates through smart contracts. An object is an instance of a smart contract and serves a specific purpose: create a member, register a wallet, transfer funds from one wallet to another and so on.

A wallet belongs to a member. A current account and multiple deposit accounts all belong to a wallet.

A deposit account is used for swapping INS (ERC-20 Ethereum tokens) to XNS—this process is called "migration". The migrated XNS are released gradually during a specific vesting period.

A member can also transfer funds within Insolar MainNet or TestNet. A transfer is wrapped into a request that is processed by an object. When the processing is done, a result for this request is returned.

Saga is a type of request with with a guaranteed order of execution: if request #1 initiates a request #2 (a Saga) to another object, then request #2 is executed only after the request #1 has been completed.

Pulse ensures causality in a distributed system and serves as a time sync tool and source of randomness.

Table description

Observer database model

Below you can find description of each table and fields in it.

Table deposits

Table deposits holds data on all existing deposit accounts that belong to members- Insolar Wallet’s holders on Insolar MainNet. A deposit account is a member's account used for swapping INS to XNS. A member can have multiple deposit accounts.

Most of the tables are used by the read-only API.

Field Data type Default value Mandatory Constraint Description
deposit_ref bytea Yes Primary key Reference to the deposit object.
status deposit_status Yes Status of the deposit (created for successful deposit creation, confirmed for successful deposit confirmation).
eth_hash varchar(256) Yes Hash of the migration transaction on Ethereum. Swapping INS ERC-20 tokens to XNS requires sending a transaction to a specific Ethereum smart contract commanding it to "migrate"—send Insolar information to put XNS in a specific member's Insolar Wallet according the swap rules.
member_ref bytea No Reference to the member (Insolar Wallet's holder) object.
transfer_date bigint No Deposit creation time in Unix format.
hold_release_date bigint 0 Yes Releasing funds time in Unix format (full release).
amount varchar(256) Yes Total swapped XNS amount. Used in counting released and on-hold funds, in combination with 'balance' and the current time.
balance varchar(256) Yes Total amount of funds currently on the deposit account. Used in counting released and on-hold funds, in combination with 'amount' and the current time.
deposit_state bytea Yes Reference of a record that contains the latest deposit state. Used internally.
deposit_number bigint No Sequence number of the deposit account. As a user can have multiple deposit accounts, this number for sorting them within a single user.
vesting bigint 0 Yes Vesting period—timespan to gradually release the swapped XNS. After the migration, the XNS Coins are subject to vesting according to rules of the swap. You can read more about vesting in Coin swap.
vesting_step bigint 0 Yes Duration of the vesting step.

Table gopg_migrations

Table holds database migration schema history and is used only in maintenance of Insolar Observer node.

Field Data type Default value Mandatory Constraint Description
id serial Yes Indexing ID.
version bigint No Sequence number of the migration
created_at timestamp No Migration date

Table members

Table holds details on members—Insolar Wallet’s holders on Insolar MainNet. Members can create accounts (deposit, current), so the members table has a direct connection with the deposits table.

Field Data type Default value Mandatory Constraint Description
member_ref bytea Yes Primary key Reference to the Insolar MainNet member object
balance varchar(256) No Unique Balance of the XNS account
migration_address varchar(256) No Migration address on Ethereum in the form of an Ethereum public key hash. Used for migrating INS onto Insolar and exchanging INS to XNS. You can read more about vesting in Coin swap
status varchar(256) No Status of the member: internal for genesis objects and success for non-genesis objects.
wallet_ref bytea No Reference to the member's Insolar Wallet object.
account_state bytea Yes Reference to a record that contains the latest state of the current account.
account_ref bytea No Reference to the member's current account object.
public_key varchar(1024) No Unique User's public key that identifies a user upon creation of a member object on Insolar MainNet and is used in the API to authenticate incoming requests from the user.

Table migration_addresses

Table holds data on migration addresses—Ethereum addresses for swapping INS (ERC-20) to XNS (Insolar coin).

Field Data type Default value Mandatory Constraint Description
id bigint No Indexing ID.
addr varchar(256) No Migration address. Value of this field is assigned to a migration_address of a member when said member is created.
timestamp bigint No Time the address was assigned to the member. Unix format.
wasted boolean No Address assignment marker. Value of field changes 1 an unused addr has been assigned, 0 otherwise.

Table pulses

Table holds data on existing pulses.

Field Data type Default value Mandatory Constraint Description
pulse bigint Yes Primary key Pulse number.
pulse_date bigint No Pulse date.
entropy varchar(256) No Pulse entropy.
nodes bigint No Number of nodes on the network in one pulse.

Table raw_requests

Table holds data on raw requests stored on a Heavy Material Node. A raw request is a serialized inter-smart-contract/API call. Table has a direct connection with the raw_results and raw_side_effects tables via the request_id field.

Field Data type Default value Mandatory Constraint Description
request_id varchar(256) Yes Primary key Reference to the request that is being processed by an object on Insolar MainNet.
reason_id varchar(256) Yes Reference to the request that caused processing (and creation) of the request referenced in requiest_id.
request_body bytea Yes Serialized body of the request.

Table raw_results

Table holds data on raw results for the corresponding requests stored on a Heavy Material Node. Table has a direct connection with the raw_requests and raw_side_effects tables via the request_id field.

Field Data type Default value Mandatory Constraint Description
request_id varchar(256) Yes Primary key Reference to the request that is being processed by an object on Insolar MainNet.
result_body bytea Yes Serialized body of the result.

Table raw_side_effects

Table contains time-related data (record activate, amends and deactivates) that hasn't been organized into request-result pairs in the current pulse. Table has a direct connection with the raw_requests and raw_results tables via the request_id field.

Field Data type Default value Mandatory Constraint Description
id varchar(256) Yes Primary key Reference to the object state.
request_id varchar(256) Yes Reference to the request that is being processed by an object on Insolar MainNet.
side_effect_body bytea Record body. Contains serialized object state value.

Table simple_transactions

Table holds data on existing transactions executed on Insolar MainNet. Pulse ensures causality in a distributed system, serves as a time sync tool and source of randomness.

Field Data type Default value Mandatory Constraint Description
id bigserial Yes Primary key Indexing ID.
tx_id bytea Yes Unique Reference to the transaction.
status_registered boolean No Transaction registration status.
type transaction_type No Transaction type (unknown, transfer, migration, release).
pulse_record bigint[] No Unique Pulse number + record number. Constitutes a transaction index that is used by Insolar API for pagination. Also used by Insolar API to determine Saga start time (by pulse number).
member_from_ref bytea No Reference to the sender of funds.
member_to_ref bytea No Reference to the receiver of funds.
deposit_to_ref bytea No Reference to the deposit funds are sent to.
deposit_from_ref bytea No Reference to the deposit funds are sent from.
amount text No Amount of transferred XNS.
status_sent boolean No Status for Saga request (true—sent).
status_finished boolean No Completion status for Saga request (true—completed).
finish_success boolean No Success status for Saga request (true—finished successfully).
finish_pulse_record bigint[] Unique Pulse number + record number. Constitutes a transaction index that is used by Insolar API for pagination. Also used by Insolar API to determine Saga completion time (by pulse number).
fee varchar(256) Transaction fee. Non-zero for transfers between users' and zero for migrations and deposit-to-current-account transfers.