Technical Workflow Details

Detailed technical documentation outlining the complete workflow for the full archival node mode in Ergo.

Technical Overview

This document outlines the technical workflow for the full archival node mode in Ergo. The process involves multiple stages of synchronization, validation, and state management to ensure complete blockchain integrity and security.

Initial Synchronization Process

The archival node begins its synchronization process through the following steps:

  1. Send an ErgoSyncInfo message to connected peers.
  2. Receive a response with an INV message containing the IDs of blocks that are better than our best block.
  3. Request headers for all the block IDs received in step 2.

Header Processing

Upon receiving a header, the following operations are performed:

if(history.apply(header).isSuccess) {
    if(!isInitialBootstrapping) Broadcast INV for this Header
    Request transaction ids from this block
} else {
    blacklist peer
}

This step validates the header and requests transaction IDs if the header is valid.

Transaction ID Processing

When transaction IDs from the Header are received, the following operations are performed:

transactionIdsForHeader.filter(txId => !MemPool.contains(txId)).foreach { txId =>
    request transaction with txId
}

This filters out transactions already in the mempool and requests missing transactions.

Transaction Processing

Upon receiving a transaction, the following operations are performed:

if(Mempool.apply(transaction).isSuccess) {
    if(!isInitialBootstrapping) Broadcast INV for this transaction
    Mempool.getHeadersWithAllTransactions { BlockTransactions =>
        GOTO 7
    }
}

This validates and applies transactions to the mempool, then processes complete blocks.

Block Transactions Processing

Now we have BlockTransactions: all transactions corresponding to some Header

if(History.apply(BlockTransactions) == Success(ProgressInfo)) {

    if(!isInitialBootstrapping) Broadcast INV for BlockTransactions

    /*We should notify our neighbours that now we have all the transactions
    State apply modifiers (may be empty for a block in a forked chain)
    and generate ADProofs for them.
    TODO requires a different interface from scorex-core,
    because it should return ADProofs
    TODO when minimal state apply Progress info,
    it may also create UTXOSnapshot
    (e.g. every 30000 blocks like in Ethereum).
    This UTXOSnapshot should be required for mining by Rollerchain*/
    
    if(State().apply(ProgressInfo) == Success((newState, ADProofs))) {
        if("mode"="full" || "mode"=="pruned-full") ADProofs.foreach ( ADProof => History.apply(ADProof))
        if("mode"=="pruned-full" || "mode"=="light-full") drop BlockTransactions and ADProofs older than BlocksToKeep
    } else {
        //Drop Header from history because its transaction sequence is not valid
        History.drop(BlockTransactions.headerId)
    }
} else {
    blacklist peer who sent Header
}

This is the final step where complete blocks are validated and applied to the blockchain state.

Additional Resources

For more detailed information about the bootstrapping process and modifiers processing, please refer to the following resources:

Technical Notes

Important Considerations

  • The archival node requires significant computational resources and storage space.
  • Initial synchronization can take several days depending on network conditions.
  • All transactions and blocks are validated for maximum security.
  • The complete UTXO set is maintained for full validation capabilities.
  • ADProofs are generated and stored for all blocks in archival mode.