Light SPV Mode Technical Workflow
The technical workflow for the light-SPV mode in Ergo is designed to efficiently synchronize with the network using PoPoW proofs and maintain a lightweight state while ensuring security.
Bootstrap
Step 1: Send GetPoPoWProof
Send GetPoPoWProof for all connections to request proof-of-proof-of-work from connected peers.
Step 2: Process PoPoWProof
On receiving PoPoWProof, apply it to History. History should determine whether this PoPoWProof is better than its current best header chain.
Step 3: Transition to Regular Mode
GOTO regular regime once bootstrap is complete.
Regular
Step 1: Send ErgoSyncInfo
Send ErgoSyncInfo message to connected peers to inform them about the current state of your node.
Step 2: Receive INV Message
Get a response with an INV message containing the ids of blocks that are better than our best block.
Step 3: Request Headers
Request headers for all ids from step 2 to download the necessary block headers.
Step 4: Process Headers
On receiving Header, follow this logic:
if(History.apply(header).isSuccess) {
State.apply(header) // just change state roothash
if(!isInitialBootstrapping) Broadcast INV for this header
} else {
blacklist peer
}Technical Explanation
History.apply(header)
This function attempts to apply the received header to the node's history. If successful, it means the header is valid and can be integrated into the blockchain.
State.apply(header)
Updates the node's state by changing the state roothash. This is a lightweight operation that doesn't require storing the full block data.
Broadcast INV
If not in initial bootstrapping mode, broadcast an INV message for this header to inform other peers about the new block.
Blacklist Peer
If the header application fails, the peer is blacklisted to prevent receiving invalid data from that source.