refactor(sims)!: Remove Baseapp from sims (#21039)

This commit is contained in:
Alexander Peters
2024-07-24 12:40:01 +00:00
committed by GitHub
parent b536d11532
commit 1f0ce2f5b5
36 changed files with 140 additions and 255 deletions
+15 -6
View File
@@ -1,6 +1,7 @@
package simulation
import (
"context"
"encoding/json"
"fmt"
"math/rand"
@@ -10,11 +11,15 @@ import (
"cosmossdk.io/core/address"
"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/kv"
)
// AppEntrypoint defines the method for delivering simulation TX to the app. This is implemented by *Baseapp
type AppEntrypoint interface {
SimDeliver(_txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, *sdk.Result, error)
}
// Deprecated: Use WeightedProposalMsg instead.
type WeightedProposalContent interface {
AppParamsKey() string // key used to retrieve the value of the weight from the simulation application params
@@ -36,12 +41,16 @@ type Content interface {
}
type WeightedProposalMsg interface {
AppParamsKey() string // key used to retrieve the value of the weight from the simulation application params
DefaultWeight() int // default weight
MsgSimulatorFn() MsgSimulatorFn // msg simulator function
AppParamsKey() string // key used to retrieve the value of the weight from the simulation application params
DefaultWeight() int // default weight
MsgSimulatorFn() MsgSimulatorFnX // msg simulator function
}
type MsgSimulatorFn func(r *rand.Rand, accs []Account, cdc address.Codec) (sdk.Msg, error)
type (
// Deprecated: use MsgSimulatorFnX
MsgSimulatorFn func(r *rand.Rand, accs []Account, cdc address.Codec) (sdk.Msg, error)
MsgSimulatorFnX func(ctx context.Context, r *rand.Rand, accs []Account, cdc address.Codec) (sdk.Msg, error)
)
type SimValFn func(r *rand.Rand) string
@@ -66,7 +75,7 @@ type WeightedOperation interface {
//
// Operations can optionally provide a list of "FutureOperations" to run later
// These will be ran at the beginning of the corresponding block.
type Operation func(r *rand.Rand, app *baseapp.BaseApp,
type Operation func(r *rand.Rand, app AppEntrypoint,
ctx sdk.Context, accounts []Account, chainID string) (
OperationMsg OperationMsg, futureOps []FutureOperation, err error)