-
Notifications
You must be signed in to change notification settings - Fork 96
/
module_simulation.go
103 lines (87 loc) · 3.37 KB
/
module_simulation.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package clob
import (
"math/rand"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/simulation"
"github.com/dydxprotocol/v4-chain/protocol/testutil/sample"
clobsimulation "github.com/dydxprotocol/v4-chain/protocol/x/clob/simulation"
)
// avoid unused import issue
var (
_ = sample.AccAddress
_ = clobsimulation.FindAccount
_ = sims.StakePerAccount
_ = simulation.MsgEntryKind
_ = baseapp.Paramspace
)
const (
opWeightMsgProposedOperations = "op_weight_msg_temp_operations"
// TODO(DEC-571): Determine the simulation weight value
defaultWeightMsgProposedOperations int = 100
opWeightMsgPlaceOrder = "op_weight_msg_place_order"
// TODO(DEC-571): Determine the simulation weight value
defaultWeightMsgPlaceOrder int = 100
opWeightMsgCancelOrder = "op_weight_msg_cancel_order"
defaultWeightMsgCancelOrder int = 25
// this line is used by starport scaffolding # simapp/module/const
)
// GenerateGenesisState creates a randomized GenState of the module
func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
clobsimulation.RandomizedGenState(simState)
}
// ProposalMsgs doesn't return any content functions for governance proposals
func (AppModule) ProposalMsgs(_ module.SimulationState) []simtypes.WeightedProposalMsg {
return nil
}
// RegisterStoreDecoder registers a decoder
func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {}
// WeightedOperations returns the all the gov module operations with their respective weights.
func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
protoCdc := codec.NewProtoCodec(codectypes.NewInterfaceRegistry())
operations := make([]simtypes.WeightedOperation, 0)
var weightMsgProposedOperations int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgProposedOperations, &weightMsgProposedOperations, nil,
func(_ *rand.Rand) {
weightMsgProposedOperations = defaultWeightMsgProposedOperations
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgProposedOperations,
clobsimulation.SimulateMsgProposedOperations(am.accountKeeper, am.bankKeeper, *am.keeper),
))
var weightMsgPlaceOrder int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgPlaceOrder, &weightMsgPlaceOrder, nil,
func(_ *rand.Rand) {
weightMsgPlaceOrder = defaultWeightMsgPlaceOrder
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgPlaceOrder,
clobsimulation.SimulateMsgPlaceOrder(am.accountKeeper, am.bankKeeper, am.subaccountsKeeper, *am.keeper, protoCdc),
))
var weightMsgCancelOrder int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgCancelOrder, &weightMsgCancelOrder, nil,
func(_ *rand.Rand) {
weightMsgCancelOrder = defaultWeightMsgCancelOrder
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgCancelOrder,
clobsimulation.SimulateMsgCancelOrder(
am.accountKeeper,
am.bankKeeper,
am.subaccountsKeeper,
*am.keeper,
am.memClob,
protoCdc,
),
))
// this line is used by starport scaffolding # simapp/module/operation
return operations
}