# FlexBFT: A Flexible and Effective Optimistic Asynchronous BFT Protocol
## 4 FlexBFT Design
### Fast Mode Protocol  
The fast mode of FlexBFT consists of two components: snw-ABC and pace-sync. snw-ABC and pace-sync play roles similar to HotStuff's chain-based consensus and view-change mechanisms. They enable fast consensus that can tolerate up to \(N\geqslant 3f+1\) faults and provide some support for asynchronous environments. One of the innovations in FlexBFT lies in efficiently utilizing the properties of AVID to avoid bandwidth waste caused by traditional consensus mechanisms that require downloading and agreeing on entire blocks. The entry point of the fast mode protocol is snw-ABC, as shown in Algorithm 1. Initially, all nodes activate snw-ABC instances. As depicted in the figure, snw-ABC in this paper is implemented using AVID and threshold signatures. However, snw-ABC does not achieve consensus on an entire block; instead, it focuses on the data availability of the block. Therefore, snw-ABC will output the availability proof of the transaction, denoted as BAP (block availability proof). Following the ideas of DispersedLedger [28], snw-ABC has nodes voting on the hash value or Merkle root of the transactions rather than the block itself. Then download the block parallelly. Utilizing AVID in snw-ABCThe key to decoupling consensus from block downloads lies in AVID, as introduced before. AVID consists of two steps: disperse and retrieve. Disperse divides a block into multiple parts using RS encoding and sends them to other replica nodes. This reliable broadcast ensures message delivery even in asynchronous environments. Each AVID instance emits a complete event, indicating the completion of dispersion. Retrieve, on the other hand, retrieves these partial data pieces from different nodes and combines them into a complete block. AVID effectively distributes the network bandwidth burden in consensus scenarios (compared with centralized broadcasting) and supports a workflow where dispersion and proof acquisition precede block assembly. Figure 2: The total framework of FlexBFT. ```
1:\(//\) variable Declarations
2:let \(id\) be the identification of the epoch
3:let \(buf\) be a FIFO queue of input
4:let \(B\) be the batch parameter
5:let \(P_{t}\) be the leader where \(\ell=(id\mod n)+1\)
6:\(P_{i}\) initializes \(s=1\), \(\sigma_{0}=\bot\), and runs the protocol in consecutive slot number \(s\) as: // during the Dispersal phase
7:if\(P_{i}\) is the leader \(P_{\ell}\)then
8: activate \(\text{AVID}[(\dot{id},s)].dispersal()\) with input \(TXs_{s}\gets buf[:B]\)
9:else
10: activate \(\text{AVID}[(\dot{id},s)].dispersal()\) as nonleader party
11:endif
12://during the Vote phase after dispersal is completed
13:upon \(\text{AVID}[(\dot{id},s)]\) returns \(\mathcal{H}(TXs_{s})\):
14: let \(\sigma_{s,j}\) be the partial signature for \(\langle id,s,\mathcal{H}(TXs_{s})\rangle\)
15: send \(Vote(id,s,\sigma_{s,i})\) to \(P_{j}\) for each \(j\in[N]\) // during the Commit phase after received enough vote
16:upon receiving \(2f+1\)\(Vote(id,s,\sigma_{s,i})\) from distinct parties \(P_{i}\):
17: let \(\sigma_{s}\) be the valid full signature that aggregates different \(2f+1\)\(\sigma_{s,i}\)
18: let \(Proof_{s}:=\langle H(TXs_{s}),\sigma_{s}\rangle\)
19:output \(BAP:=\langle id,s,Proof_{s}\rangle\)
20: let \(s\gets s+1\) //exit condition for the algorithm
21:upon \(abandon(id)\) is invoked:
22: abort the above execution
```  
**Algorithm 1** snw_ABC  
In the implementation, as shown in Algorithm 1, the first step of snw-ABC is to broadcast transactions proposed by the leader invoking AVID. The leader acts as an AVID server, while other nodes act as clients, initiating AVID dispersal. Simultaneously, they perform threshold signatures on \(\langle id,s,\mathcal{H}(TXs)\rangle\) to cast votes, indicating that the data for TXs are available. When a node receives \(2f+1\) votes, it aggregates them into a complete signature, which, from the perspective of the partially synchronous network's consensus protocol, represents a QC (quorum certificate).