cosmos-sdk/server/v2/appmanager
2025-01-16 08:53:49 +00:00
..
appmanager.go feat(sims): Integration with app v2 (#23013) 2025-01-09 08:19:35 +00:00
CHANGELOG.md chore: finish prep beta.2 (#23411) 2025-01-16 08:53:49 +00:00
config.go refactor(runtime/v2): simplify app manager (#22300) 2024-10-21 13:45:28 +00:00
genesis.go fix(runtime/v2): return genesis val updates (#22729) 2024-12-03 21:25:27 +00:00
go.mod build(deps): Bump cosmossdk.io/core from 1.0.0-alpha.6 to 1.0.0 in standalone packages (no sdk deps) (#23241) 2025-01-08 22:32:40 +00:00
go.sum build(deps): Bump cosmossdk.io/core from 1.0.0-alpha.6 to 1.0.0 in standalone packages (no sdk deps) (#23241) 2025-01-08 22:32:40 +00:00
README.md chore(docs): Appmanager readme (#23151) 2025-01-02 14:06:10 +00:00
stf.go feat(sims): Integration with app v2 (#23013) 2025-01-09 08:19:35 +00:00

AppManager Documentation

The AppManager serves as a high-level coordinator, delegating most operations to the STF while managing state access through the Store interface.

This document outlines the main external calls in the AppManager package, their execution flows, and dependencies.

Table of Contents

InitGenesis

InitGenesis initializes the genesis state of the application.

sequenceDiagram
participant Caller
participant AppManager
participant InitGenesisImpl
participant STF
participant State
Caller->>AppManager: InitGenesis(ctx, blockRequest, genesisJSON, decoder)
AppManager->>InitGenesisImpl: initGenesis(ctx, genesisJSON, txHandler)
loop For each genesis transaction
InitGenesisImpl->>InitGenesisImpl: Decode and collect transactions
end
InitGenesisImpl-->>AppManager: genesisState, validatorUpdates, error
AppManager->>STF: DeliverBlock(ctx, blockRequest, genesisState)
STF-->>AppManager: blockResponse, blockZeroState, error
AppManager->>State: Apply state changes
AppManager-->>Caller: blockResponse, genesisState, error

Dependencies

  • Required Input:
    • Context
    • BlockRequest
    • Genesis JSON
    • Transaction decoder
  • Required Components:
    • InitGenesis implementation
    • STF
    • Store interface

ExportGenesis

ExportGenesis exports the current application state as genesis state.

sequenceDiagram
participant Caller
participant AppManager
participant ExportGenesisImpl
Caller->>AppManager: ExportGenesis(ctx, version)
AppManager->>ExportGenesisImpl: exportGenesis(ctx, version)
ExportGenesisImpl-->>Caller: genesisJSON, error

Dependencies

  • Required Input:
    • Context
    • Version
  • Required Components:
    • ExportGenesis implementation
    • Store interface

DeliverBlock

DeliverBlock processes a block of transactions.

sequenceDiagram
participant Caller
participant AppManager
participant Store
participant STF
Caller->>AppManager: DeliverBlock(ctx, block)
AppManager->>Store: StateLatest()
Store-->>AppManager: version, currentState, error
AppManager->>STF: DeliverBlock(ctx, block, currentState)
STF-->>Caller: blockResponse, newState, error

Dependencies

  • Required Input:
    • Context
    • BlockRequest
  • Required Components:
    • Store interface
    • STF

ValidateTx

ValidateTx validates a transaction against the latest state.

sequenceDiagram
participant Caller
participant AppManager
participant Store
participant STF
Caller->>AppManager: ValidateTx(ctx, tx)
AppManager->>Store: StateLatest()
Store-->>AppManager: version, latestState, error
AppManager->>STF: ValidateTx(ctx, latestState, gasLimit, tx)
STF-->>Caller: TxResult, error

Dependencies

  • Required Input:
    • Context
    • Transaction
  • Required Components:
    • Store interface
    • STF
    • Configuration (for gas limits)

Simulate

Simulate executes a transaction simulation using the latest state.

sequenceDiagram
participant Caller
participant AppManager
participant Store
participant STF
Caller->>AppManager: Simulate(ctx, tx)
AppManager->>Store: StateLatest()
Store-->>AppManager: version, state, error
AppManager->>STF: Simulate(ctx, state, gasLimit, tx)
STF-->>Caller: TxResult, WriterMap, error

Dependencies

  • Required Input:
    • Context
    • Transaction
  • Required Components:
    • Store interface
    • STF
    • Configuration (for gas limits)

SimulateWithState

SimulateWithState executes a transaction simulation using provided state.

sequenceDiagram
participant Caller
participant AppManager
participant STF
Caller->>AppManager: SimulateWithState(ctx, state, tx)
AppManager->>STF: Simulate(ctx, state, gasLimit, tx)
STF-->>Caller: TxResult, WriterMap, error

Dependencies

  • Required Input:

    • Context
    • Transaction
    • State

    Query

Query executes a query at a specific version.

sequenceDiagram
participant Caller
participant AppManager
participant Store
participant STF
Caller->>AppManager: Query(ctx, version, request)
alt version == 0
AppManager->>Store: StateLatest()
else version > 0
AppManager->>Store: StateAt(version)
end
Store-->>AppManager: queryState, error
AppManager->>STF: Query(ctx, queryState, gasLimit, request)
STF-->>Caller: response, error

Dependencies

  • Required Input:

    • Context
    • Version (or 0 for latest)
    • Query request
  • Required Components:

    • Store interface
    • STF
    • Configuration (for gas limits)

    QueryWithState

QueryWithState executes a query using provided state.

sequenceDiagram
participant Caller
participant AppManager
participant STF
Caller->>AppManager: QueryWithState(ctx, state, request)
AppManager->>STF: Query(ctx, state, gasLimit, request)
STF-->>Caller: response, error

Dependencies

  • Required Input:
    • Context
    • ReaderMap state
    • Query request
  • Required Components:
    • STF
    • Configuration (for gas limits)

Common Dependencies

All operations depend on:

  • Context management
  • Error handling
  • Gas metering
  • State management (Store interface)
  • STF interface