Skip to content

Commit

Permalink
feat(server/v2): add SimulateWithState to AppManager (#22335)
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-rushakoff authored Oct 23, 2024
1 parent 98be2b8 commit 762fad2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions server/v2/appmanager/appmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ type AppManager[T transaction.Tx] interface {
// Simulate runs validation and execution flow of a Tx.
Simulate(ctx context.Context, tx T) (server.TxResult, corestore.WriterMap, error)

// SimulateWithState runs validation and execution flow of a Tx,
// using the provided state instead of loading the latest state from the underlying database.
SimulateWithState(ctx context.Context, state corestore.ReaderMap, tx T) (server.TxResult, corestore.WriterMap, error)

// Query queries the application at the provided version.
// CONTRACT: Version must always be provided, if 0, get latest
Query(ctx context.Context, version uint64, request transaction.Msg) (transaction.Msg, error)
Expand Down Expand Up @@ -193,6 +197,13 @@ func (a appManager[T]) Simulate(ctx context.Context, tx T) (server.TxResult, cor
return result, cs, nil
}

// SimulateWithState runs validation and execution flow of a Tx,
// using the provided state instead of loading the latest state from the underlying database.
func (a appManager[T]) SimulateWithState(ctx context.Context, state corestore.ReaderMap, tx T) (server.TxResult, corestore.WriterMap, error) {
result, cs := a.stf.Simulate(ctx, state, a.config.SimulationGasLimit, tx) // TODO: check if this is done in the antehandler
return result, cs, nil
}

// Query queries the application at the provided version.
// CONTRACT: Version must always be provided, if 0, get latest
func (a appManager[T]) Query(ctx context.Context, version uint64, request transaction.Msg) (transaction.Msg, error) {
Expand Down

0 comments on commit 762fad2

Please sign in to comment.