Go to file
2023-08-15 18:44:57 -04:00
.github feat(ITS): [ENG-1627]: Moving ITS from release branch to main (#236) 2023-08-11 18:22:39 +00:00
abci readmes for all the lanes 2023-08-15 18:34:36 -04:00
api/pob lints 2023-08-15 18:04:35 -04:00
block readmes for all the lanes 2023-08-15 18:34:36 -04:00
contrib/images feat(ITS): [ENG-1627]: Moving ITS from release branch to main (#236) 2023-08-11 18:22:39 +00:00
lanes readmes for all the lanes 2023-08-15 18:34:36 -04:00
proto feat(ITS): [ENG-1627]: Moving ITS from release branch to main (#236) 2023-08-11 18:22:39 +00:00
scripts [ENG-731]: Support for Dependencies Injection (#65) 2023-04-18 16:45:31 -04:00
tests rename of constructor to base 2023-08-15 18:01:49 -04:00
testutils default re-factor with constructor 2023-08-14 18:02:08 -04:00
x/builder rename of constructor to base 2023-08-15 18:01:49 -04:00
.gitignore feat: [ENG-792] Implement E2E Testing Framework (#107) 2023-05-08 14:45:17 -04:00
.golangci.yml feat(BB): Creating a chain decorator for process lanes (#162) 2023-06-05 16:18:06 +00:00
.goreleaser.yml chore: remove license 2023-04-14 09:19:36 -05:00
.markdownlint.json [ENG-711]: First write through of the spec (#57) 2023-04-18 19:46:43 +00:00
.markdownlintignore [ENG-711]: First write through of the spec (#57) 2023-04-18 19:46:43 +00:00
.mergify.yml chore(v2): Backport patch (#226) 2023-07-28 15:06:50 +00:00
go.mod base app fix 2023-08-14 19:20:13 -04:00
go.sum base app fix 2023-08-14 19:20:13 -04:00
go.work feat(ITS): [ENG-1627]: Moving ITS from release branch to main (#236) 2023-08-11 18:22:39 +00:00
go.work.sum rename tob lane to mev lane 2023-08-15 09:44:11 -04:00
LICENSE chore: Create Apache 2.0 LICENSE (#158) 2023-05-31 15:04:49 +00:00
Makefile feat(ITS): [ENG-1627]: Moving ITS from release branch to main (#236) 2023-08-11 18:22:39 +00:00
README.md main readme 2023-08-15 18:44:57 -04:00
SPEC.md rename tob lane to mev lane 2023-08-15 09:44:11 -04:00

Block SDK 🧱

Project Status: Active – The project has reached a stable, usable state and is being actively developed. GoDoc Go Report Card Version License: Apache-2.0 Lines Of Code

📖 Overview

The Block SDK is a set of Cosmos SDK and ABCI++ primitives that allow chains to fully customize blocks to specific use cases. It turns your chain's blocks into a transaction highway consisting of individual lanes with their own special functionality.

🤔 How does it work

🔁 Transaction Lifecycle

The best way to understand how lanes work is to first understand the lifecycle of a transaction. A transaction begins its lifecycle when it is first signed and broadcasted to a chain. After it is broadcasted to a validator, it will be checked in CheckTx by the base application. If the transaction is valid, it will be inserted into the applications mempool.

The transaction then waits in the mempool until a new block needs to be proposed. When a new block needs to be proposed, the application will call PrepareProposal (which is a new ABCI++ addition) to request a new block from the current proposer. The proposer will look at what transactions currently waiting to be included in a block by looking at their mempool. The proposer will then iteratively select transactions until the block is full. The proposer will then send the block to other validators in the network.

When a validator receives a proposed block, the validator will first want to verify the contents of the block before signing off on it. The validator will call ProcessProposal to verify the contents of the block. If the block is valid, the validator will sign off on the block and broadcast their vote to the network. If the block is invalid, the validator will reject the block. Once a block is accepted by the network, it is committed and the transactions that were included in the block are removed from the validator's mempool (as they no longer need to be considered).

🛣️ Lane Lifecycle

After a transaction is verified in CheckTx, it will attempt to be inserted into the LanedMempool. A LanedMempool is composed of several distinct Lanes that have the ability to store their own transactions. The LanedMempool will insert the transaction into all lanes that will accept it. The criteria for whether a lane will accept a transaction is defined by the lane's MatchHandler. The default implementation of a MatchHandler will accept all transactions.

When a new block is proposed, the PrepareProposalHandler will iteratively call PrepareLane on each lane (in the order in which they are defined in the LanedMempool). The PrepareLane method is anaolgous to PrepareProposal. Calling PrepareLane on a lane will trigger the lane to reap transactions from its mempool and add them to the proposal (given they are valid respecting the verification rules of the lane).

When proposals need to be verified in ProcessProposal, the ProcessProposalHandler defined in abci/abci.go will call ProcessLane on each lane in the same order as they were called in the PrepareProposalHandler. Each subsequent call to ProcessLane will filter out transactions that belong to previous lanes. A given lane's ProcessLane will only verify transactions that belong to that lane.

Scenario

Let's say we have a LanedMempool composed of two lanes: LaneA and LaneB. LaneA is defined first in the LanedMempool and LaneB is defined second. LaneA contains transactions Tx1 and Tx2 and LaneB contains transactions Tx3 and Tx4.

When a new block needs to be proposed, the PrepareProposalHandler will call PrepareLane on LaneA first and LaneB second. When PrepareLane is called on LaneA, LaneA will reap transactions from its mempool and add them to the proposal. Same applies for LaneB. Say LaneA reaps transactions Tx1 and Tx2 and LaneB reaps transactions Tx3 and Tx4. This gives us a proposal composed of the following:

  • Tx1, Tx2, Tx3, Tx4

When the ProcessProposalHandler is called, it will call ProcessLane on LaneA with the proposal composed of Tx1, Tx2, Tx3, and Tx4. LaneA will then verify Tx1 and Tx2 and return the remaining transactions - Tx3 and Tx4. The ProcessProposalHandler will then call ProcessLane on LaneB with the remaining transactions - Tx3 and Tx4. LaneB will then verify Tx3 and Tx4 and return no remaining transactions.