How near/nearcore works
nearcore is the Rust reference implementation of the NEAR Protocol: node software for a sharded smart-contract blockchain. At a high level, users and applications submit transactions through RPC; nodes communicate over the peer network, obtain and process blocks and shard chunks, execute state transitions, and persist resulting chain state. The tree also identifies distinct subsystems for state sync, stateless validation, resharding, archival storage, and epoch/validator management. Only selected source relationships are evidenced in the excerpts and source index; dashed edges indicate the broader workflow where implementation-level calls were not sampled.
Main entry points: client.rs Client orchestration · chain.rs Chain processing · shards_manager_actor.rs Shard chunks · peer_manager_actor.rs Peer management
Components 22
User interfaces
- JSON-RPC APIs
chain/jsonrpc/src/api/mod.rs
Chain processing
- Client orchestration
chain/client/src/client.rs - Chain processing
chain/chain/src/chain.rs - Shard chunks
chain/chunks/src/shards_manager_actor.rs - Chunk cache
chain/chunks/src/chunk_cache.rs - Chunk processing logic
chain/chunks/src/logic.rs - Execution runtime
chain/chain/src/runtime/mod.rs - Epoch and validators
chain/epoch-manager/src/validator_selection.rs - Stateless validation
chain/chain/src/stateless_validation/state_witness.rs - State synchronization
chain/client/src/sync/state/downloader.rs
Peer networking
- Peer management
chain/network/src/peer_manager/peer_manager_actor.rs - Peer connections
chain/network/src/peer/peer_actor.rs - Network protocol
chain/network/src/network_protocol/mod.rs
State and storage
- Persistent store
core/store/src/adapter/trie_store.rs - Flat storage
core/store/src/flat/storage.rs - Trie storage
core/store/src/trie/trie_storage.rs - Cold archival storage
core/store/src/archive/cold_storage.rs - Flat-storage resharding
chain/chain/src/resharding/flat_storage_resharder.rs
Node operations
- Indexer
chain/indexer/src/streamer/fetchers.rs - Chain replay
chain/replay/src/controller.rs - Node process
neard/src/main.rs
Other components
- Applications
Connections 22
- Applications → JSON-RPC APIs: submit requests
- JSON-RPC APIs → Client orchestration: dispatches to
- Client orchestration → Chain processing: processes chain
- Peer management → Network protocol: uses protocol
chain/network/src/peer_manager/peer_manager_actor.rs - Peer management → Peer connections: manages peers
chain/network/src/peer_manager/peer_manager_actor.rs - Client orchestration → Peer management: exchanges messages
- Shard chunks → Chunk cache: reads and updates
chain/chunks/src/shards_manager_actor.rs - Shard chunks → Chunk processing logic: processes chunks
chain/chunks/src/shards_manager_actor.rs - Shard chunks → Client orchestration: uses client adapter
chain/chunks/src/shards_manager_actor.rs - Chain processing → Execution runtime: executes transitions
- Execution runtime → Persistent store: reads and writes state
- Chain processing → Epoch and validators: uses epoch data
- Client orchestration → State synchronization: downloads state
- Client orchestration → Stateless validation: coordinates validation
- Trie storage → Persistent store: reads trie data
core/store/src/trie/trie_storage.rs - Trie storage → Flat storage: uses flat adapter
- Flat-storage resharding → Flat storage: copies flat state
chain/chain/src/resharding/flat_storage_resharder.rs - Flat-storage resharding → Execution runtime: accesses runtime store
chain/chain/src/resharding/flat_storage_resharder.rs - Cold archival storage → Persistent store: copies archived data
core/store/src/archive/cold_storage.rs - Indexer → Chain processing: reads chain data
- Chain replay → Chain processing: replays blocks
- Node process → Client orchestration: starts node services