Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A component that follows the Cardano chain and stores blocks and transactions in PostgreSQL

License

NotificationsYou must be signed in to change notification settings

IntersectMBO/cardano-db-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Haskell CIDiscord

Cardano DB Sync

Note: Anyone wishing to build and run anything in this repository should avoid themaster branch and build/run from the latest release tag.

Purpose

The purpose of Cardano DB Sync is to follow the Cardano chain and take information from the chainand an internally maintained copy of ledger state. Data is then extracted from the chain andinserted into a PostgreSQL database. SQL queries can then be written directly against the databaseschema or as queries embedded in any language with libraries for interacting with an SQL database.

Examples of what someone would be able to do via an SQL query against a Cardano DB Syncinstance fully synced to a specific network is:

  • Look up any block, transaction, address, stake pool etc on that network, usually by the hash thatidentifies that item or the index into another table.
  • Look up the balance of any stake address for any Shelley or later epoch.
  • Look up the amount of ADA delegated to each pool for any Shelley or later epoch.

Documentation

Thedoc/ directory, offers essential resources for users, including guides for installation with and without Nix, configuration. Key files cover, Docker usage, PostgreSQL example queries, command-line options and database migrations. There's also a troubleshooting guide for common issues. These documents provide users with the necessary steps to effectively set up and maintain the Cardano DB Sync.

Architecture

The cardano-db-sync component consists of a set of components:

  • cardano-db which defines common data types and functions used by any application that needsto interact with the data base from Haskell. In particular, it defines the database schema.
  • cardano-db-tool a tool used to manage the databases of cardano-db-sync (createand run migrations, validate and analyse)
  • cardano-db-sync which acts as a Cardano node, following the chain and insertingdata from the chain into a PostgreSQL database.

The db-sync node is written in a highly modular fashion to allow it to be as flexible as possible.

Thecardano-db-sync node connects to a locally runningcardano-node (ie one connected to othernodes in the Cardano network over the internet with TCP/IP) using a Unix domain socket, retrievesblocks, updates its internal ledger state and stores parts of each block in a local PostgreSQLdatabase. The database does not store things like cryptographic signatures but does store enoughinformation to follow the chain of blocks and look at the transactions within blocks.

The PostgreSQL database is designed to be accessed in a read-only fashion from other applications.The database schema is highly normalised which helps prevent data inconsistencies (specificallywith the use of foreign keys from one table to another). More user friendly database queries can beimplemented usingPostgres Views to implement joins between tables.

System Requirements

Last update: May 2025

The system requirements forcardano-db-sync (with bothdb-sync and thenode runningon the same machine are:

  • Any of the big well known Linux distributions (eg, Debian, Ubuntu, RHEL, CentOS, Archetc).
  • 64 Gigabytes of RAM or more (formainnet).
  • 4 CPU cores or more.
  • Ensure that the machine has sufficient IOPS (Input/Output Operations per Second). Ie it should be60k IOPS or better. Lower IOPS ratings will result in slower sync times and/or falling behind thechain tip.
  • 700 Gigabytes or more of disk storage (preferably SSD which are 2-5 times faster thanelectro-mechanical disks).

Stats for configuration:

"insert_options": {"tx_cbor":"disable","tx_out": {"value":"enable","force_tx_in":false,"use_address_table":false    },"ledger":"enable","shelley": {"enable":true    },"multi_asset": {"enable":true    },"metadata": {"enable":true    },"plutus": {"enable":true    },"governance":"enable","offchain_pool_data":"enable","json_type":"text"  }

mainnet

Storage

  • cardano-node database size: 203 GB
  • cardano-db-sync total ledger state files size: ~ 10 GB
  • Postgres databasemainnet_13.6.0.5 total size: 438 GB

RAM

  • cardano-node RAM: 24 GB
  • cardano-db-sync RSS RAM: 21 GB

preprod

Storage

  • cardano-node database size: 12 GB
  • cardano-db-sync total ledger state files size: ~ 2 GB
  • Postgres databasepreprod_13.6.0.5 total size: 16 GB

RAM

  • cardano-node RSS RAM: 5,5 GB
  • cardano-db-sync RSS RAM: 3,5 GB

preview

Storage

  • cardano-node database size: 12 GB
  • cardano-db-sync total ledger state files size: ~ 2 GB
  • Postgres databasepreview_13.6.0.5 total size: 21 GB

RAM

  • cardano-node RSS RAM: 2,8 GB
  • cardano-db-sync RSS RAM: 3,5 GB

The recommended configuration is to have thedb-sync and the PostgreSQL server on the samemachine. During syncing (getting historical data from the blockchain) there is aHUGE amountof data traffic betweendb-sync and the database. Traffic to a local database is significantlyfaster than traffic to a database on the LAN or remotely to another location.

When building an application that will be querying the database, remember that for fast queries,low latency disk access is far more important than high throughput (assuming the minimal IOPSabove is met).

How to Contact the Cardano DB Sync Team

You can discuss development or find help at the following places:

Installation

Install db-sync with one of the following methods:

Once installed, start db-sync by following theRunning Guide.

Troubleshooting

If you have any issues with this project, consult theTroubleshooting page forpossible solutions.

Further Reading

About

A component that follows the Cardano chain and stores blocks and transactions in PostgreSQL

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

 
 
 

[8]ページ先頭

©2009-2025 Movatter.jp