Skip to content

Commit

Permalink
chore: Analysis yaci store table and mapping them with ledger_sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Sotatek-QuanLeA committed May 21, 2024
1 parent 9bcbb59 commit 09c56e6
Showing 1 changed file with 303 additions and 0 deletions.
303 changes: 303 additions & 0 deletions docs/stores-analysis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,303 @@
# I. Assets store
## A. Analyze **assets** table
### 1. multi_asset - assets

| **Ledger_Sync**| **Yaci_Store**|**Note**|
|:---------------|:---------------| :- |
| finger_print | finger_print ||
| name_view | asset_name ||
| policy | policy ||
| unit | unit ||
| time | block_time ||
| name(uuid) | ||
| supply | |totalSupply|
### 2. ma_tx_mint - assets

| Ledger_Sync| Yaci_Store|Note|
|:-----------|:----------| :- |
| tx_id | tx_hash ||
| quantity | quantity ||
# II. Block store
## A. Analyze **block** table
### 1. block - block

| **Ledger_Sync** | **Yaci_Store** | **Note** |
|:------------------------|:------------------|:----------------------------------------------------------------------------------------------------------------------------------------|
| block_no | number | |
| epoch_no | epoch | |
| epoch_slot_no | epoch_slot | |
| hash | hash | |
| op_cert | op_cert_hot_vkey | |
| op_cert_counter | op_cert_seq_number| |
| proto_major, proto_minor| protocol_version | |
| size | body_size | |
| slot_leader_id | slot_leader | In ledger_sync, slot_leader_id là id trong bảng slot_leader |
| slot_no | slot | |
| time | block_time | |
| tx_count | no_of_txs | |
| vrf_key | vrf_vkey | <p>Bech32.encode(HexUtil.decodeHexString(headerBody.getVrfVkey()), ConsumerConstant.VRF_KEY_PREFIX)</p><p></p> |
| previous_id | prev_hash | |

### 2. ada_pots - block

| **Ledger_Sync**| **Yaci_Store**|**Note**|
|:--------------|:--------------| :- |
| fees | total_fees ||

### 3. slot_leader - block

| **Ledger_Sync**| **Yaci_Store**|**Note**|
|:---------------|:-------------| :- |
| slot_leader | hash ||
## B. Analyze **roll_back** table
- Not found in Ledger_sync
# III. Epoch store
## A. Analyze **local_protocol_params** table
- Not found in Ledger_sync
## B. Analyze **protocol_params_proposal** table
- param_proposal + cost model = protocol_params_proposal
### 1. param_proposal - protocol_params_proposal

|**Ledger_Sync**|**Yaci_Store**|**Note**|
| :- | :- | :- |
|epoch_no|epoch||
|key|key_hash||
|registered_tx_id|tx_hash||
|others|params||
### 2. cost_model - protocol_params_proposal

|**Ledger_Sync**|**Yaci_Store**|**Note**|
| :- | :- | :- |
||||
## C. Analyze **cost_model** table
### 1. cost_model - cost_model

|**Ledger_Sync**|**Yaci_Store**|**Note**|
| :- | :- | :- |
|costs|costs||
|hash|hash||
## D. Analyze **epoch_param** table
### 1. epoch_param - epoch_param

|**Ledger_Sync**|**Yaci_Store**|**Note**|
| :- | :- | :- |
|epoch_no|epoch||
|cost_model_id|cost_model_hash||
|others|params||
# IV. Govermane store
- Ledger_sync is using the entire table from yaci_store.
# V. Live store
# VI. Metadata store
## A. Analyze **transaction_metadata** table
- tx_metadata + tx_metadata_hash = transaction_metadata
### 1. tx_metadata - transaction_metadata

|**Ledger_Sync**|**Yaci_Store**|**Note**|
| :- | :- | :- |
|tx_id|tx_hash||
|json|body||
### 2. tx_metadata_hash - transaction_metadata

|**Ledger_Sync**|**Yaci_Store**|**Note**|
| :- | :- | :- |
|hash|tx_hash||
# VII. Mir store
- Regarding reward.
# VIII. Script store
- script + redeemer +redeemer_data + datum = script + transaction_script + datum
## A. Analyze **script** table
### 1. script - script
- In yaci_store, the main records are mostly PLUTUS, with a small portion being about Native Script.
- The data is less compared to ledger_sync.

|**Ledger_Sync**|**Yaci_Store**| **Note** |
| :- | :- |:------------------------------------------------------------------|
|bytes|content| has bytes is plutus data |
|hash|script_hash| |
|json|content| hash json is timelock script |
|type|script_type| |
|serialised_size|| The size of the CBOR serialised script, if it is a Plutus script. |
|tx_id|| |
|verified|| All values are false. |
## B. Analyze **transaction_scripts** table
### 2. redeemer - transaction_scripts

|**Ledger_Sync**| **Yaci_Store** | **Note** |
| :- |:--------------------------------|:----------------------------------------|
|index| redeemer_index | |
|purpose| purpose | |
|script_hash| script_hash | |
|unit_mem| unit_mem | |
|unit_steps| unit_steps | |
|tx_id| tx_hash | |
|fee| | All values are null. |
|redeemer_data_id| redeemer_cbor, redeemer_index, redeemer_datahash ||
### 2. redeemer_data - transaction_scripts

|**Ledger_Sync**|**Yaci_Store**| **Note** |
| :- | :- |:------------------------------------------|
|hash|redeemer_datahash| |
|bytes|| Join with the datatum table in yaci_store |
|value|| |
## C. Analyze **datum** table
### 2. datum - datum

|**Ledger_Sync**|**Yaci_Store**|**Note**|
| :- | :- | :- |
|hash|hash||
|bytes|datum||
|tx_id|created_at_tx||
|value|||
# IX. Staking store
- stake_registration + stake_deregistration = stake_registration
- pool_hash + pool_metadata_ref + pool_owner + pool_relays + pool_update = delegation
## A. Analyze **stake_registration** table
### 1. stake_registration - stake_registration

|**Ledger_Sync**|**Yaci_Store**|**Note**|
| :- | :- | :- |
|cert_index|cert_index||
|epoch_no|epoch||
|addr_id|address||
|tx_id|tx_hash||
### 2. stake_deregistration - stake_registration

|**Ledger_Sync**|**Yaci_Store**| **Note** |
| :- | :- |:-----------------------------------------------------|
|cert_index|cert_index| |
|epoch_no|epoch| |
|addr_id|address| |
|tx_id|tx_hash| |
|redeemer_id|| Join with the transaction_script table in yaci_store |
##
## B. Analyze **delegation** table
### 1. delegation - delegation

|**Ledger_Sync**|**Yaci_Store**|**Note**|
| :- | :- | :- |
|active_epoch_no|epoch||
|cert_index|cert_index||
|slot_no|slot||
|addr_id|address||
|pool_hash_id|pool_id||
|tx_id|tx_hash||
|redeemer_id||Join with the transaction_script table in yaci_store|
## C. Analyze **pool_registration** table
### 1. pool_hash - pool_registration

|**Ledger_Sync**|**Yaci_Store**| **Note** |
| :- | :- |:--------------|
|hash_raw|pool_id| |
|epoch_no|epoch| |
|pool_size|| Hard-fix at 0 |
|view|| |
### 2. pool_metadata_ref - pool_registration

|**Ledger_Sync**|**Yaci_Store**|**Note**|
| :- | :- | :- |
|url|metadata_url||
|hash|metadata_hash||
|pool_id|pool_id||
|registered_tx_id|tx_hash||
### 3. pool_owner - pool_registration

|**Ledger_Sync**|**Yaci_Store**|**Note**|
| :- | :- | :- |
|addr_id|pool_owners||
|pool_update_id|||
### 4. pool_relay - pool_registration

|**Ledger_Sync**|**Yaci_Store**|**Note**|
| :- | :- | :- |
|dns_name, dns_srv_name, ipv4, ipv6, port|relays||
|update_id|||
### 5. pool_update - pool_registration

|**Ledger_Sync**|**Yaci_Store**| **Note** |
| :- | :- |:----------------------------------------------------------------------------------------------------------------------------------------------------|
|cert_index|cert_index| |
|fixed_cost|cost| |
|margin|margin| |
|pledge|pledge| |
|vrf_key_hash|vrf_key| |
|meta_id|metadata_url, metadata_hash| |
|registered_tx_id|tx_hash| |
|reward_addr_id|reward_account| |
|active_epoch_no|| Ledger_sync logic:<br>epochActivationDelay + aggregatedBlock.getEpochNo()<br>epochActivationDelay: If the pool is first registered, return 2, else 3|
## D. Analyze **pool_retirement** table
### 1. pool_retire - pool_retirement

|**Ledger_Sync**|**Yaci_Store**|**Note**|
| :- | :- | :- |
|cert_index|cert_index||
|retiring_epoch|retirement_epoch||
|announced_tx_id|tx_hash||
|hash_id|pool_id||
# X. Transaction store
## A. Analyze **transaction** table
### 1. tx - transaction

|**Ledger_Sync**|**Yaci_Store**| **Note** |
| :- | :- |:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|block_id|block_hash| |
|fee|fee| |
|hash|tx_hash| |
|tx_metadata_hash_id|auxiliary_datahash| |
|block_index|| Index of transaction in block |
|deposit|| |
|invalid_before|| All values are null. |
|invalid_hereafter|| All values are null. |
|out_sum|| The sum of the transaction outputs (in Lovelace). |
|script_size|| Toàn Null |
|size|N/A| <p>Definition: The size of the transaction in bytes.<br>Logic in ledger_sync :<br>size là size của script<br>public void addScriptSize(int size) {</p><p>if (this.size == null) {</p><p>` `this.size = 0;</p><p>}</p><p>this.size += size;</p><p>}</p><p></p> |
|valid_contract|| Logic in ledger_sync:<br>validContract = !invalidTransactions.contains(txIdx);<br> |
## B. Analyze **transaction_witness** table
### 1. tx_witness - transaction_witness

|**Ledger_Sync**|**Yaci_Store**| **Note** |
| :- | :- |:----------------------------------------|
|tx_id|tx_hash| |
|key|pub_key| |
|signature|signature| |
|index_arr, index_arr_size|idx| |
|type|type| In Ledger_sync, the type is always null |
## C. Analyze **withdrawal** table
### 1. withdrawal - withdrawal

|**Ledger_Sync**|**Yaci_Store**|**Note**|
| :- | :- | :- |
|amount|amount||
|addr_id|address||
|tx_id|tx_hash||
|redeemer_id||Join with the transaction_script table in yaci_store|
## D. Analyze **invalid_transaction** table
- Not found in Ledger_sync
# XI. Utxo store
## A. Analyze **address_utxo** table
### 1. tx_out - address_utxo

|**Ledger_Sync**|**Yaci_Store**| **Note** |
| :- | :- |:---------------------------------------------------------------|
|address|owner_addr| |
|data_hash|data_hash| |
|index|output_index| |
|payment_cred|owner_payment_credential| |
|value|lovelace_amount| |
|reference_script_id|reference_script_hash| |
|stake_address_id|owner_stake_addr| |
|tx_id|tx_hash| |
|address_has_script|| |
|address_raw|| |
|token_type|| |
|inline_datum_id|inline_datum| Join with the transaction_script and datum table in yaci_store |
## B. Analyze **tx_input** table
### 1. tx_in - tx_input

|**Ledger_Sync**|**Yaci_Store**|**Note**|
| :- | :- | :- |
|tx_in_id|spent_tx_hash||
|tx_out_index|output_index||
|tx_out_id|tx_hash||
|redeemer_id||Join with the transaction_script table in yaci_store|
## C. Analyze **address** table
- Not found in ledger_sync

0 comments on commit 09c56e6

Please sign in to comment.