cosmos-sdk/blockstm
2025-12-11 15:58:50 +00:00
..
tree feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
bench_test.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
condvar.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
executor.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
memdb_test.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
memdb.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
mergeiterator.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
mock_block.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
multimvview.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
mvdata_test.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
mvdata.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
mviterator.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
mvmemory_test.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
mvmemory.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
mvview_test.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
mvview.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
README.md docs: fix typos and wording in learn and README docs (#25668) 2025-12-11 15:58:50 +00:00
scheduler.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
status.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
stm_test.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
stm.go feat: OpenTelemetry configuration and BaseApp instrumentation (#25516) 2025-12-10 23:15:18 +00:00
txnrunner_test.go feat: allow dynamic retrieval of coin denom from multi store at runtime (#25600) 2025-11-26 03:44:23 +00:00
txnrunner.go feat: allow dynamic retrieval of coin denom from multi store at runtime (#25600) 2025-11-26 03:44:23 +00:00
types.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
utils_test.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00
utils.go docs: fix typos and wording in learn and README docs (#25668) 2025-12-11 15:58:50 +00:00
wrappers.go feat: Upstream BlockSTM Fork (#25483) 2025-10-24 15:51:57 +00:00

blockstm implements the block-stm algorithm, it follows the paper pseudocode pretty closely.

The main API is a simple function call ExecuteBlock:

type ExecuteFn func(TxnIndex, MultiStore)
func ExecuteBlock(
 ctx context.Context,           // context for cancellation
 blockSize int,                 // the number of the transactions to be executed
 stores []storetypes.StoreKey,  // the list of store keys to support
 storage MultiStore,            // the parent storage, after all transactions are executed, the whole change sets are written into parent storage at once
 executors int,                 // how many concurrent executors to spawn
 executeFn ExecuteFn,           // callback function to actually execute a transaction with a wrapped `MultiStore`.
) error

The main deviations from the paper are:

Optimisation

We applied the optimization described in section 4 of the paper:

Block-STM calls add_dependency from the VM itself, and can thus re-read and continue execution when false is returned.

When the VM execution reads an ESTIMATE mark, it'll hang on a CondVar, so it can resume execution after the dependency is resolved, much more efficient than abortion and rerun.

Support Deletion, Iteration, and MultiStore

These features are necessary for integration with cosmos-sdk.

The multi-version data structure is implemented with nested btree for easier iteration support, the WriteSet is also implemented with a btree, and it takes advantage of ordered property to optimize some logic.

The internal data structures are also adapted with multiple stores in mind.

Attribution

This package was originally authored in go-block-stm. We have brought the full source tree into the SDK so that we can natively incorporate the library and required changes into the SDK. Over time we expect to incorporate optimizations and deviations from the upstream implementation.