simulation

package
v1.20.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SanctionAddresses   = "sanction-addresses"
	SanctionTempEntries = "sanction-temp-entries"
	SanctionParams      = "sanction-params"
)
View Source
const (
	OpWeightSanction            = "op_weight_sanction"             //nolint:gosec
	OpWeightSanctionImmediate   = "op_weight_sanction_immediate"   //nolint:gosec
	OpWeightUnsanction          = "op_weight_unsanction"           //nolint:gosec
	OpWeightUnsanctionImmediate = "op_weight_unsanction_immediate" //nolint:gosec
	OpWeightUpdateParams        = "op_weight_update_params"        //nolint:gosec

	DefaultWeightSanction            = 10
	DefaultWeightSanctionImmediate   = 10
	DefaultWeightUnsanction          = 10
	DefaultWeightUnsanctionImmediate = 10
	DefaultWeightUpdateParams        = 10
)

Variables

This section is empty.

Functions

func MaxCoins

func MaxCoins(a, b sdk.Coins) sdk.Coins

MaxCoins combines a and b taking the max of each denom. The result will have all the denoms from a and all the denoms from b. The amount of each denom is the max between a and b for that denom.

func NewDecodeStore

func NewDecodeStore(_ codec.Codec) func(kvA, kvB kv.Pair) string

func OperationMsgVote

func OperationMsgVote(args *WeightedOpsArgs, voter simtypes.Account, govPropID uint64, vote govv1.VoteOption, comment string) simtypes.Operation

OperationMsgVote returns an operation that casts a yes vote on a gov prop from an account.

func RandomParams

func RandomParams(r *rand.Rand) *sanction.Params

RandomParams generates randomized parameters for the sanction module.

ImmediateSanctionMinDeposit and ImmediateUnsanctionMinDeposit are decided individually. Each has a: * 20% chance of being empty/zero. * 80% chance of being between 1 and 1000 (inclusive) of the default bond denom.

func RandomSanctionedAddresses

func RandomSanctionedAddresses(r *rand.Rand, accounts []simtypes.Account) []string

RandomSanctionedAddresses randomly selects accounts to be sanctioned.

Each account has a: * 20% chance of being sanctioned, * 80% chance of being ignored.

func RandomTempEntries

func RandomTempEntries(r *rand.Rand, accounts []simtypes.Account) []*sanction.TemporaryEntry

RandomTempEntries randomly selects accounts to be temporarily sanctioned/unsanctioned.

Each account has a: * 10% chance of having a temp sanction, * 10% chance of having a temp unsanction, * 80% chance of being ignored.

func RandomizedGenState

func RandomizedGenState(simState *module.SimulationState)

RandomizedGenState creates a randomized sanction genesis state and adds it to the provided simState's GenState map.

func SendGovMsg

func SendGovMsg(args *SendGovMsgArgs) (bool, simtypes.OperationMsg, error)

SendGovMsg sends a msg as a gov prop. It returns whether to skip the rest, an operation message, and any error encountered.

func SimulateGovMsgSanction

func SimulateGovMsgSanction(args *WeightedOpsArgs) simtypes.Operation

func SimulateGovMsgSanctionImmediate

func SimulateGovMsgSanctionImmediate(args *WeightedOpsArgs) simtypes.Operation

func SimulateGovMsgUnsanction

func SimulateGovMsgUnsanction(args *WeightedOpsArgs) simtypes.Operation

func SimulateGovMsgUnsanctionImmediate

func SimulateGovMsgUnsanctionImmediate(args *WeightedOpsArgs) simtypes.Operation

func SimulatePropMsgUpdateParams

func SimulatePropMsgUpdateParams(args *WeightedOpsArgs) simtypes.MsgSimulatorFn

Types

type SendGovMsgArgs

type SendGovMsgArgs struct {
	WeightedOpsArgs

	R       *rand.Rand
	App     *baseapp.BaseApp
	Ctx     sdk.Context
	Accs    []simtypes.Account
	ChainID string

	Sender  simtypes.Account
	Msg     sdk.Msg
	Deposit sdk.Coins
	Comment string
}

SendGovMsgArgs holds all the args available and needed for sending a gov msg.

type WeightedOpsArgs

type WeightedOpsArgs struct {
	SimState   module.SimulationState
	ProtoCodec *codec.ProtoCodec
	AK         sanction.AccountKeeper
	BK         sanction.BankKeeper
	GK         govkeeper.Keeper
	SK         *keeper.Keeper
}

WeightedOpsArgs holds all the args provided to WeightedOperations so that they can be passed on later more easily.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL