Categorygithub.com/crypto-org-chain/go-block-stm
modulepackage
0.0.0-20241213061541-7afe924fb4a6
Repository: https://github.com/crypto-org-chain/go-block-stm.git
Documentation: pkg.go.dev

# README

go-block-stm 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.

# Functions

No description provided by the author
BytesBeyond returns if a is beyond b in specified iteration order.
No description provided by the author
No description provided by the author
DecrAtomic decreases the atomic value by 1.
callback arguments: (value, is_new).
No description provided by the author
No description provided by the author
FetchIncr increaes the atomic value by 1 and returns the old value.
IncrAtomic increases the atomic value by 1.
No description provided by the author
No description provided by the author
NewBTree returns a new BTree.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewGMemDBNonConcurrent returns a new BTree which is not concurrency safe.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NoopTx verifies a signature and increases the nonce of the sender.
No description provided by the author
No description provided by the author
StoreMin implements a compare-and-swap operation that stores the minimum of the current value and the given value.

# Constants

No description provided by the author
Since we do copy-on-write a lot, smaller degree means smaller allocations.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author
No description provided by the author

# Structs

BTree wraps an atomic pointer to an unsafe btree.BTreeG.
BTreeIteratorG iterates over btree.
No description provided by the author
No description provided by the author
Executor fields are not mutated during execution.
No description provided by the author
No description provided by the author
No description provided by the author
GMVMemoryView[V] wraps `MVMemory` for execution of a single transaction.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
MultiMVMemoryView don't need to be thread-safe, there's a dedicated instance for each tx execution.
MVIterator is an iterator for a multi-versioned store.
MVMemory implements `Algorithm 2 The MVMemory module`.
No description provided by the author
No description provided by the author
Scheduler implements the scheduler for the block-stm ref: `Algorithm 4 The Scheduler module, variables, utility APIs and next task logic`.
StatusEntry is a state machine for the status of a transaction, all the transitions are atomic protected by a mutex.
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author
MVStore is a value type agnostic interface for `MVData`, to keep `MVMemory` value type agnostic.
MVView is a value type agnostic interface for `MVMemoryView`, to keep `MultiMVMemoryView` value type agnostic.

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
TxExecutor executes transactions on top of a multi-version memory view.
No description provided by the author