lite-rpc/docs/architecture.md

338 lines
9.5 KiB
Markdown
Raw Normal View History

2023-08-25 07:50:53 -07:00
# Architecture
## Domains
2023-08-25 07:50:53 -07:00
### Validator
2023-08-25 07:50:53 -07:00
Manage real time generated data by the validator.
2023-09-22 07:37:32 -07:00
Implements these RPC calls:
2023-08-25 07:50:53 -07:00
* GetVoteAccounts
* getLeaderSchedule
* getEpochInfo
* getSlot
* getSignatureStatuses at process commitment.
2023-08-25 08:11:21 -07:00
* new tx sent: call by the SendTx module when a Tx is processed by sendTx module.
2023-08-25 07:50:53 -07:00
2023-09-22 07:37:32 -07:00
#### Subdomain Validator subscription
Implements these RPC subscriptions
* programSubscribe
* slotSubscribe
* blockSubscribe
* transactionSubscribe
* logsSubscribe
* signatureSubscribe
* slotsUpdatesSubscribe
* voteSubscribe
#### Sub domain Cluster
Manage cluster information.
Implement the call: getClusterNodes
Provide the subscription: cluster info.
#### Inter module messages notification (Stream)
Provides these inter module message notification:
2023-08-25 07:50:53 -07:00
* Full block
* BLock info
* Slots
* Leader schedule
2023-09-22 07:37:32 -07:00
* sent Tx at confirmed and / or finalized: notify when a Tx sent is confirmed or finalized. Use by RPC transactionSubscribe
2023-08-25 07:50:53 -07:00
A new subscription is added: Sent Tx confirmed/ finalized. SendTx module send Tx signature to the Validator domain and when a Tx sent is confirmed (or finalized), it is notified on this subscription.
2023-08-25 07:50:53 -07:00
It avoids to call getSignatureStatuses in a pull mode.
### SendTx
Manage the whole send Tx process. Represent the current Lite RPC process.
Implements the sendTx call.
### History
2023-09-22 07:37:32 -07:00
Manage history function like getBlock/getBlocks/getTransaction.
2023-08-25 07:50:53 -07:00
2023-09-22 07:37:32 -07:00
A special use case is the getSignatureStatuses because on process its the Validator domain that provide the data.
2023-08-25 07:50:53 -07:00
### RPC
It's an entry point for all call and dispatch the call to the right function.
2023-09-05 03:50:13 -07:00
## Summary diagram
```mermaid
flowchart TD
subgraph History Domain
History("History Domain
2023-09-05 03:50:13 -07:00
at confirm/finalized
getBlock()
getBlocks()
getSignaturesForAddress()
getSignatureStatuses()
getTransaction()")
Faithfull["Faithfull Service"]
Storage["2 epoch Storage"]
end
2023-09-22 07:37:32 -07:00
subgraph Send Tx Domain
SendTx("SendTx Domain
send_transaction()")
end
2023-09-05 03:50:13 -07:00
subgraph Validator Host
Validator["Solana Validator
2023-09-05 03:50:13 -07:00
Validator process
+ GRPC Geyser"]
Consensus("Validator Domain
2023-09-22 07:37:32 -07:00
RPC calls:
2023-09-05 03:50:13 -07:00
getVoteAccounts()
getLeaderSchedule()
getEpochInfo()
getSlot()...
At process:
getSignaturesForAddress()
getSignatureStatuses()
")
2023-09-22 07:37:32 -07:00
Subscription("Subscription Sub Domain
programSubscribe
slotSubscribe
blockSubscribe
transactionSubscribe
logsSubscribe
signatureSubscribe
slotsUpdatesSubscribe
voteSubscribe
")
Cluster("Cluster Sub Domain
2023-09-05 03:50:13 -07:00
getClusterNodes()")
end
Validator-- "geyser data" -->Consensus
2023-09-22 07:37:32 -07:00
Validator-- "geyser data" -->Subscription
2023-09-05 03:50:13 -07:00
Validator-- "Cluster info" -->Cluster
Consensus-- "Block Info/Slot/Leader Schedule" -->SendTx
2023-09-05 03:50:13 -07:00
Consensus-- "confirmed Tx" -->SendTx
2023-09-22 07:37:32 -07:00
Consensus-- "confirmed Tx" -->Subscription
2023-09-05 03:50:13 -07:00
Cluster-- "Cluster info" -->SendTx
Consensus-- "Full Block/Slot/Epoch" -->History
2023-09-05 03:50:13 -07:00
History<-. "old data" .-> Faithfull
History<-. "recent data" .-> Storage
classDef consensus fill:#1168bd,stroke:#0b4884,color:#ffffff
classDef history fill:#666,stroke:#0b4884,color:#ffffff
classDef sendtx fill:#08427b,stroke:#052e56,color:#ffffff
classDef redgray fill:#62524F, color:#fff
classDef greengray fill:#4F625B, color:#fff
class SendTx sendtx
class History redgray
class Consensus consensus
class Cluster greengray
```
2023-08-25 07:50:53 -07:00
## Interaction diagram
```mermaid
flowchart TD
SendTx("Send Tx
[Domain]
Send Tx to cluster")
2023-09-07 03:10:27 -07:00
subgraph History
2023-08-25 07:50:53 -07:00
History("History
[Domain]
Get Block and Tx")
Faithfull["Faithfull Service"]
Storage["2 epoch Storage"]
end
subgraph Validator Host
Validator["Solana Validator
2023-08-25 07:50:53 -07:00
Validator process
+ GRPC Geyser"]
Consensus("Validator
2023-08-25 07:50:53 -07:00
[Domain]
Manage realtime produced data
by the validator")
2023-09-22 07:37:32 -07:00
Subscription("Subscription Sub Domain
All RPC subscriptions
")
Cluster("Cluster Info
[SubDomain]
Cluster data")
2023-08-25 07:50:53 -07:00
end
subgraph RPC Entry point
RPC["RPC API
RPC Entry point"]
2023-08-01 08:21:20 -07:00
end
2023-08-25 07:50:53 -07:00
Validator-- "geyser FullBlock/Slots Sub" -->Consensus
Validator-- "geyser Stakes and Votes account Sub" -->Consensus
Validator== "geyser getBlockHeight" ==>RPC
Validator-- "geyser Cluster info Sub" -->Cluster
2023-09-22 07:37:32 -07:00
Validator-- "geyser Sub" -->Subscription
2023-08-26 02:41:07 -07:00
Consensus<== "getVoteAccounts/getLeaderSchedule/getEpochInfo/getSlot" ==>RPC
2023-08-25 07:50:53 -07:00
Consensus<== "At Process getSignaturesForAddress/getSignatureStatuses" ==>RPC
Consensus-- "Block Info Sub" -->SendTx
Consensus-- "Leader Schedule Sub" -->SendTx
2023-08-25 08:11:21 -07:00
Consensus-- "Sent Tx confirmed Sub" -->SendTx
2023-09-22 07:37:32 -07:00
Consensus-- "Sent Tx confirmed Sub" -->Subscription
2023-08-25 07:50:53 -07:00
Cluster-- "Cluster info Sub" -->SendTx
2023-08-26 02:41:07 -07:00
Consensus-- "Full Block / Epoch Sub" -->History
2023-08-25 07:50:53 -07:00
RPC== "SendTx" ==> SendTx
2023-08-25 08:11:21 -07:00
SendTx== "A new Tx to send" ==> Consensus
2023-08-25 07:50:53 -07:00
History<== "At confirm getBlock(s)/getSignaturesForAddress/getSignatureStatuses" ==> RPC
History<-. "getBlock(s)/getSignaturesForAddress" .-> Faithfull
History<-. "Store Blocks + Txs" .-> Storage
Cluster<== "getClusterNodes" ==> RPC
classDef consensus fill:#1168bd,stroke:#0b4884,color:#ffffff
classDef history fill:#666,stroke:#0b4884,color:#ffffff
classDef sendtx fill:#08427b,stroke:#052e56,color:#ffffff
classDef redgray fill:#62524F, color:#fff
classDef greengray fill:#4F625B, color:#fff
class SendTx sendtx
class History redgray
class Consensus consensus
2023-09-22 07:37:32 -07:00
class Subscription consensus
2023-08-25 07:50:53 -07:00
class Cluster greengray
2023-08-01 08:21:20 -07:00
```
2023-08-25 07:50:53 -07:00
## Message stream
Module organization can change depending on the deployment needed. For example several validator node can be started to add reliability. To ease this association between module and server installation, module communication will be done mostly via asynchronous message. This message propagation and routing will done by the Stream module.
Module register to it to get notifified and send new message to specific entry point.
The logic organization will be.
```mermaid
flowchart TD
SendTx("Send Tx")
History("History")
subgraph Validator_Domain
Cluster("Cluster Info")
2023-08-25 07:50:53 -07:00
Consensus("Validator")
2023-09-22 07:37:32 -07:00
Subscription("Subscription")
end
2023-08-25 07:50:53 -07:00
Stream("Stream
Manage message routing
between module.")
Consensus-- "Send [Full&Info Block, Slot, Leader Schedule, Epoch info, Tx confirmed]" -->Stream
2023-08-25 07:50:53 -07:00
Cluster-- "Send Cluster Info" -->Stream
SendTx-- "Sent sendTx" -->Stream
2023-08-25 07:50:53 -07:00
Stream-- "[Slot, Leader Schedule, Block and Epoch info, Tx confirmed] sub" -->SendTx
Stream-- "[Sent Tx] sub" -->Consensus
2023-09-22 07:37:32 -07:00
Stream-- "[Sent Tx] sub" -->Subscription
Stream-- "[Full Block, Slot, Epoch info] sub" -->History
2023-08-25 07:50:53 -07:00
classDef consensus fill:#1168bd,stroke:#0b4884,color:#ffffff
classDef history fill:#666,stroke:#0b4884,color:#ffffff
classDef sendtx fill:#08427b,stroke:#052e56,color:#ffffff
classDef redgray fill:#62524F, color:#fff
classDef greengray fill:#4F625B, color:#fff
class SendTx sendtx
class History redgray
class Consensus consensus
2023-09-22 07:37:32 -07:00
class Subscription consensus
2023-08-25 07:50:53 -07:00
class Cluster greengray
```
## Bootstrap architecture
Each domain implements its own bootsrap. A domain impl running can send boostrap data to a starting one.
2023-08-25 07:50:53 -07:00
## Deployment example
2023-08-25 07:50:53 -07:00
```mermaid
flowchart TD
subgraph SendTx Host1
SendTx1("Send Tx impl")
2023-08-25 07:50:53 -07:00
end
subgraph SendTx Host2
SendTx2("Send Tx impl")
2023-08-25 07:50:53 -07:00
end
subgraph History Host1
History1("History impl")
end
subgraph History Host2
History2("History impl")
end
subgraph History Host3
History3("History impl")
2023-08-25 07:50:53 -07:00
end
subgraph Validator Host1
Validator1["Solana Validator"]
Consensus1("Validator impl")
2023-09-22 07:37:32 -07:00
Subscription1("Subscription impl")
Cluster1("Cluster impl")
2023-08-25 07:50:53 -07:00
end
subgraph Validator Host2
Validator2["Solana Validator"]
Consensus2("Validator impl")
2023-09-22 07:37:32 -07:00
Subscription2("Subscription impl")
Cluster2("Cluster impl")
2023-08-25 07:50:53 -07:00
end
2023-08-25 08:11:21 -07:00
RPC["RPC entry point
dispatch on started servers"]
2023-08-25 07:50:53 -07:00
RPC== "Send sendTx" ==>SendTx1
RPC== "Send sendTx" ==>SendTx2
RPC== "getVoteAccounts" ==>Consensus1
RPC== "getVoteAccounts" ==>Consensus2
2023-09-22 07:37:32 -07:00
RPC== "Subscription" ==>Subscription1
RPC== "Subscription" ==>Subscription2
RPC== "getBlock" ==>History1
RPC== "getBlock" ==>History2
RPC== "getBlock" ==>History3
RPC== "getClusterNodes" ==>Cluster1
RPC== "getClusterNodes" ==>Cluster2
2023-08-25 07:50:53 -07:00
classDef consensus fill:#1168bd,stroke:#0b4884,color:#ffffff
classDef history fill:#666,stroke:#0b4884,color:#ffffff
classDef sendtx fill:#08427b,stroke:#052e56,color:#ffffff
classDef redgray fill:#62524F, color:#fff
classDef greengray fill:#4F625B, color:#fff
2023-08-25 08:11:21 -07:00
class SendTx1 sendtx
class SendTx2 sendtx
class Cluster1 greengray
class Cluster2 greengray
2023-09-22 07:37:32 -07:00
class Subscription1 consensus
class Subscription2 consensus
class Consensus1 consensus
class Consensus2 consensus
class History1 redgray
class History2 redgray
class History3 redgray