Introduction to ABCIx: An eXtension of ABCI with greater flexibility and security

Application BlockChain Interface eXtension (ABCIx)

Overview

ABCIx is an extension of ABCI that offers:

  • greater flexibility in block production: when creating a new block, instead of including the transactions from the mempool in an FIFO manner, ABCIx allows the application to decide which transactions from the mempool will be included and the order; and
  • greater security: when creating a block, ABCIx allows the application to detect conflicting transactions and remove them from the mempool. This ensures that all transactions in a block are valid, while ABCI allows invalid transactions in a block and defers to the application to handle such transactions; and
  • more applications: for example, one application is to use TendermintX+ABCIx to serve as a finality gadget of another chain (such as PoW chain); and
  • backward compatible with ABCI: ABCIx can easily support existing ABCI applications by using ABCI adapter, which is an ABCIx application and provides ABCI to the underly ABCI applications.

Similar to ABCI, ABCIx provides the methods in the following ABCIx connections:

  • Consensus connection: InitChain, DeliverBlock, CreateBlock
  • Validation connection: CheckTx, CheckBlock
  • Info connection: Info, SetOption, Query
  • Snapshot connection: ListSnapshots, LoadSnapshotChunk, OfferSnapshot, ApplySnapshotChunk

where

  • CheckTx will return an extra field Priority (int64) to indicate how to order the tx in mempool.
  • CreateBlock allows the application to iterate the transactions from mempool ordered by priority and select the ones to be included in the block.
  • CheckBlock will be called after a proposed block is received and before the nodes votes for the block. CheckBlock will return Code to determine whether the block is valid or not. For example,
    • The block contains invalid transactions; or
    • The block’s app hash does not match the app hash determined by application;
    • The block’s result hash does not match the results emitted by application;
    • The block’s gas usage exceeds the gas limit.
      If the block is invalid, TendermintX will not vote for the block in the following pre-vote phase.
  • DeliverBlock behaves similar to the combination of ABCI.BeginBlock, a list of ABCI.DeliverBlock, ABCI.EndBlock, and ABCI.Commit methods. Note that a block may be delivered without being checked.
  • The rest of ABCIx methods should behave the same as those of ABCI.

Methods

CheckTx

  • Input:
  • Output:
    • Output of ABCI.CheckTx.
    • Priority (int64): The priority of the tx in mempool.
  • Note
    • The priority determines the order the tx that will be fed to CreateBlock.
    • If some txs have the same priority in the mempool, they will be ordered in an FIFO manner.

CreateBlock

  • Input
    • Height (int64): Height of the block to be created.
    • LastCommitInfo (LastCommitInfo): Info about the last commit, including the
      round, and the list of validators and which ones signed the last block.
    • ByzantineValidators ([]Evidence): List of evidence of
      validators that acted maliciously.
    • MempoolIterator (interface{}): Iterator to iterate all txs in the mempool. It provides a function Next(maxBytes int64, maxGas int64) []byte, which returns a tx ordered by priority with size <= maxBytes and GasWanted <= maxGas or nil if no such tx is found.
  • Output
    • TxList ([][]byte): A list of txs will be included in the block.
    • InvalidTxList ([][]byte): A list of txs should be removed from mempool.
    • AppHash ([]byte): App hash after executing the transactions.
    • Tags ([]kv.Pair): A list of tags (events) emitted by the block.

DeliverBlock

  • Input
    • Input of ABCI.EndBlock.
    • A list of the inputs of ABCI.DeliverTx.
    • Input of ABCI.BeginBlock.
    • Input of ABCI.Commit.
  • Output
    • Output of ABCI.BeginBlock.
    • A list of the outputs of ABCI.DeliverTx
    • Output of ABCI.EndBlock.
    • Output of ABCI.Commit.
  • Note
    • ABCIx will compare the hash of the returned Tags with LastResultHash in header (LastResultHash will be renamed to ResultHash in TendermintX). If the comparison fails, the BFT consensus is broken and TendermintX will stop working.

CheckBlock

  • Input
    • Input of ABCI.EndBlock.
    • A list of the input of ABCI.DeliverTx.
    • Input of ABCI.BeginBlock.
    • Input of ABCI.Commit.
  • Output
    • Code (uint32): Response code.
    • Output of ABCI.BeginBlock.
    • A list of the output of ABCI.DeliverTx
    • Output of ABCI.EndBlock.
    • Output of ABCI.Commit.
  • Note
    • The method will be called after a proposed block is received and before a vote is sent for the block.
    • If Code is non-zero, the block is treated as invalid.
    • ABCIx will compare the hash of the returned Tags with LastResultHash in header (LastResultHash will be renamed to ResultHash in TendermintX). If the comparison fails, TendermintX will treat the block as invalid.

ABCI Adapter

ABCI adapter implements ABCIx and translates all ABCIx methods to ABCI methods. Basically, ABCI adaptor implements the ABCIx methods as:

  • CheckTx: call and return ABCI.CheckTx with Priority 0.
  • CreateBlock: iterate and include txs from mempool until maxGas or maxBytes limits is reached without executing any txs. Return AppHash and Tags of the previous block that are stored in the application DB.
  • CheckBlock: compare whether header.AppHash equals to the AppHash of the previous block stored in the application. Return the Tags of the previous block stored in the application DB.
  • DeliverBlock: call ABCI.DeliverBlock. Store ABCI.DeliverBlock.Data and ABCI.DeliverBlock.Tags in application DB. Return the Tags of the previous block stored in the applicaiton DB.

Wanna Contribute?

Please check out the repo at https://github.com/QuarkChain/tendermintx/blob/master/abcix that we start a few days ago :slight_smile:

3 Likes

The cosmos team is very interested in some the changes to ABCI and would be interested in collaborating.

Especially CreateBlock.

3 Likes

Excellent! We would love to collaborate with cosmos team! Do you have any idea of the form of the collaboration?

We are currently reading the TM code and planning the tasks/resources/timeline. We will come up with a itemized tasks soon and probably commit the changes to the forked repo in a few weeks.

hey I’m Junjia, chiming in here as a QuarkChain engineer.
we are exploring the possibility of using ABCIx as a finality gadget, thus we plan to implement a quick prototype.

in the meantime, @zaki_iqlusion it would be fantastic if cosmos team could help us do architecture reviews, or something like regular status sync / Q&A for implementation progress. is it possible we can have a point of contact for the future efforts?

fwiw here’s our tentative eng effort scoping / planning


Week of 7/27 + 8/03

  1. Implement DeliverBlock and CheckBlock handling in tendermint
  2. Scaffold CreateBlock code flow
  3. Implement mempool iterator
  4. Implement a dummy ABCIx blockchain app

Week of 8/10 + 8/17

  1. Add priority handling to CheckTx
  2. Finish CreateBlock implementation
  3. Implement ABCIx adaptor

week of 8/24

  1. ABCIx adaptor testing
  2. all the remaining end-to-end testing
1 Like

I suspect this is a more complex feature than your engineering estimates make it out to be.

The Tendermint engineering seems to be busy with other things.

I’m willing to help out. Hit me up on Telegram or the Discord.

1 Like