cosmos-sdk/server/v2/stf
2024-07-31 20:21:23 +00:00
..
branch refactor(stf/appmanager): remove the need of recurseStateChanges (#20911) 2024-07-18 11:22:25 +00:00
gas chore: upstream stf to main (#20286) 2024-05-08 14:50:52 +00:00
internal refactor(core): remove redundant ExecMode (#20322) 2024-05-29 16:27:07 +00:00
mock refactor(x/**): rewrite ante handlers as tx validators (#20488) 2024-06-03 16:47:58 +00:00
core_branch_service_test.go chore(all): replace all fmt.Errorf without paramters with errors.New (#21068) 2024-07-25 14:54:49 +02:00
core_branch_service.go chore: upstream stf to main (#20286) 2024-05-08 14:50:52 +00:00
core_event_service.go fix(stf): fixes to make init genesis pass (#21088) 2024-07-27 18:11:24 +00:00
core_gas_service.go chore: make function comment match function names (#20666) 2024-06-13 21:45:49 +00:00
core_header_service.go chore: set empty hash to hash of nothing (#20775) 2024-07-02 14:15:44 +00:00
core_router_service.go chore: migrate core to gogoproto.Message (#20781) 2024-06-28 09:34:23 +00:00
core_store_service.go chore: upstream stf to main (#20286) 2024-05-08 14:50:52 +00:00
export_test.go chore: upstream runtime/v2 (#20320) 2024-05-14 12:43:28 +00:00
go.mod chore: various cleanup (#20864) 2024-07-18 09:12:58 +00:00
go.sum chore: various cleanup (#20864) 2024-07-18 09:12:58 +00:00
README.md chore: upstream stf to main (#20286) 2024-05-08 14:50:52 +00:00
stf_router.go chore: migrate core to gogoproto.Message (#20781) 2024-06-28 09:34:23 +00:00
stf_test.go chore(all): replace all fmt.Errorf without paramters with errors.New (#21068) 2024-07-25 14:54:49 +02:00
stf.go refactor: remove comet info from consensus as it will be stored in context for v2 (#21120) 2024-07-31 20:21:23 +00:00

State Transition Function (STF)

STF is a function that takes a state and an action as input and returns the next state. It does not assume the execution model of the application nor consensus.

The state transition function receives a read only instance of state. It does not directly write to disk, instead it will return the state changes which has undergone within the application. The state transition function is deterministic, meaning that given the same input, it will always produce the same output.

BranchDB

BranchDB is a cache of all the reads done within a block, simulation or transaction validation. It takes a read-only instance of state and creates its own write instance using a btree. After all state transitions are done, the new change sets are returned to the caller.

The BranchDB can be replaced and optimized for specific use cases. The implementation is as follows

   type branchdb func(state store.ReaderMap) store.WriterMap

GasMeter

GasMeter is a utility that keeps track of the gas consumed by the state transition function. It is used to limit the amount of computation that can be done within a block.

The GasMeter can be replaced and optimized for specific use cases. The implementation is as follows:

type (
	// gasMeter is a function type that takes a gas limit as input and returns a gas.Meter.
	// It is used to measure and limit the amount of gas consumed during the execution of a function.
	gasMeter func(gasLimit uint64) gas.Meter

	// wrapGasMeter is a function type that wraps a gas meter and a store writer map.
	wrapGasMeter func(meter gas.Meter, store store.WriterMap) store.WriterMap
)

THe wrappGasMeter is used in order to consume gas. Application developers can seamlsessly replace the gas meter with their own implementation in order to customize consumption of gas.