cosmos-sdk/server/v2/stf
testinginprod e799965ec8
feat(stf): port simappv2 changes (#20587)
Co-authored-by: unknown unknown <unknown@unknown>
2024-06-10 07:55:23 +00:00
..
branch feat(stf): port simappv2 changes (#20587) 2024-06-10 07:55:23 +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: migrate sdk.Msg to transaction.type (#20273) 2024-05-10 10:23:22 +00:00
core_branch_service.go chore: upstream stf to main (#20286) 2024-05-08 14:50:52 +00:00
core_event_service.go chore: upstream stf to main (#20286) 2024-05-08 14:50:52 +00:00
core_gas_service.go chore: upstream stf to main (#20286) 2024-05-08 14:50:52 +00:00
core_header_service.go chore: migrate sdk.Msg to transaction.type (#20273) 2024-05-10 10:23:22 +00:00
core_router_service.go feat(stf): port simappv2 changes (#20587) 2024-06-10 07:55: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 build(deps): Bump github.com/cosmos/gogoproto from 1.4.12 to 1.5.0 (#20563) 2024-06-06 08:26:02 +00:00
go.sum build(deps): Bump github.com/cosmos/gogoproto from 1.4.12 to 1.5.0 (#20563) 2024-06-06 08:26:02 +00:00
README.md chore: upstream stf to main (#20286) 2024-05-08 14:50:52 +00:00
stf_router.go chore: upstream runtime/v2 (#20320) 2024-05-14 12:43:28 +00:00
stf_test.go chore: migrate sdk.Msg to transaction.type (#20273) 2024-05-10 10:23:22 +00:00
stf.go feat(stf): port simappv2 changes (#20587) 2024-06-10 07:55: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.