Skip to content

Components

Bohdan Khorolets edited this page Sep 12, 2023 · 2 revisions

Components

Here, you can find a breakdown of the components of the Read RPC project.

rpc-server component

An actix-web HTTP server provides the entry point for JSON-RPC service. For now, it is the only component of the Read RPC exposed to the public.

Despite having a pretty complex logic, from the technical perspective, it is a simple web server providing a couple of endpoints:

  • JSON-RPC endpoint on the root
  • Prometheus-compatible metrics endpoint on the /metrics

We aim to keep the rpc-server README up-to-date with the most relevant info. Meanwhile, this doc should describe constant things and give an overall understanding of the component.

What does it do?

It implements the JSON RPC methods (more details on the methods breakdown page).

Includes the runtime from nearcore to serve the view calls (actually, it is included in the first point, but I wanted to highlight it)

Have some tools hidden under the feature flags that allow checking the data correctness, which is necessary to do before hitting production (shadow_data_consistency)

What does it require?

  • Connection to the database (ScyllaDB)
  • Access to the NEAR Lake S3 bucket(s)
  • URL to the NEAR Archival JSON-RPC (to proxy requests not implemented yet, send transactions to, etc.)

state-indexer component

An indexer processes the StateChanges and writes to the database in a specific format so the rpc-server can read it.

This indexer watches for StateChanges in each block and stores the data in different tables related to the specific change type in the database.

See the page Database Design

tx-indexer component

This indexer watches for every transaction on the chain and collects each transaction's related entities into a special structure, TransactionDetails.

It holds:

  • Transaction itself
  • ExecutionOutcome of the transaction
  • All the Receipts related to the transaction
  • All the ExecutionOutcomes of the Receipts related to the Transaction

Once the last execution outcome is observed and the TransactionDetails structure is collected, it is stored in the database and serialized with the borsh.

While collecting entities, every Receipt is also stored in the database on the fly.

For more details, see the page Database Design

database component

A crate/library defining the trait to interact with the database.

Currently, the database crate defines a trait ScyllaDBManager used in all the binaries.

We have extracted this trait into a separate crate so we can extend it later. For instance, we can abstract it to the StorageManager instead of ScyllaDBManager, and we can use a variety of databases.

readnode-primitives component

A crate/library defining the common/shared types for the Read RPC project

This is a dedicated crate to provide shared types for the Read RPC project and its components. Currently, it defines the TransactionDetails structure the tx-indexer writes to the database, and the rpc-server reads.