cosmos-sdk/server/v2/stf
2024-08-08 13:07:55 +00:00
..
branch refactor(stf/appmanager): remove the need of recurseStateChanges (#20911) 2024-07-18 11:22:25 +00:00
gas refactor(core,stf): complete gas service + simplify deps (#21166) 2024-08-08 07:30:09 +00:00
internal refactor(core): remove redundant ExecMode (#20322) 2024-05-29 16:27:07 +00:00
mock test(stf/mock): Unmarshal with knowing the message type (#21178) 2024-08-07 08:34:00 +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 refactor(core,stf): complete gas service + simplify deps (#21166) 2024-08-08 07:30:09 +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 refactor(core,stf): complete gas service + simplify deps (#21166) 2024-08-08 07:30:09 +00:00
README.md refactor(core,stf): complete gas service + simplify deps (#21166) 2024-08-08 07:30:09 +00:00
stf_router_test.go feat(stf/router): support backwards compat type URL in router (#21177) 2024-08-07 13:17:42 +00:00
stf_router.go feat(stf/router): support backwards compat type URL in router (#21177) 2024-08-07 13:17:42 +00:00
stf_test.go refactor(server/v2/stf): pass exec mode to validateTx (#21219) 2024-08-08 13:07:55 +00:00
stf.go refactor(server/v2/stf): pass exec mode to validateTx (#21219) 2024-08-08 13:07:55 +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.