clawchain/x/privacy/module/simulation.go
caelum0x ed1ed54ec3 feat(privacy): expand gRPC surface, batch transfers, view keys, state machine
Adds full QueryServer gRPC with gateway REST, batch private transfers,
view key registration, commitment index/merkle proof/root history queries,
MPC trusted setup ceremony code, state machine for shielded notes, and
comprehensive integration tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 22:13:53 +03:00

85 lines
2.8 KiB
Go

package privacy
import (
"math/rand"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/simulation"
privacysimulation "clawchain/x/privacy/simulation"
"clawchain/x/privacy/types"
)
// GenerateGenesisState creates a randomized GenState of the module.
func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
accs := make([]string, len(simState.Accounts))
for i, acc := range simState.Accounts {
accs[i] = acc.Address.String()
}
privacyGenesis := types.GenesisState{
Params: types.DefaultParams(),
}
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&privacyGenesis)
}
// RegisterStoreDecoder registers a decoder.
func (am AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) {}
// WeightedOperations returns the all the gov module operations with their respective weights.
func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
operations := make([]simtypes.WeightedOperation, 0)
const (
opWeightMsgPrivateTransfer = "op_weight_msg_private_transfer"
defaultWeightMsgPrivateTransfer int = 100
)
var weightMsgPrivateTransfer int
simState.AppParams.GetOrGenerate(opWeightMsgPrivateTransfer, &weightMsgPrivateTransfer, nil,
func(_ *rand.Rand) {
weightMsgPrivateTransfer = defaultWeightMsgPrivateTransfer
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgPrivateTransfer,
privacysimulation.SimulateMsgPrivateTransfer(am.authKeeper, am.bankKeeper, am.keeper, simState.TxConfig),
))
const (
opWeightMsgShield = "op_weight_msg_shield"
defaultWeightMsgShield int = 100
)
var weightMsgShield int
simState.AppParams.GetOrGenerate(opWeightMsgShield, &weightMsgShield, nil,
func(_ *rand.Rand) {
weightMsgShield = defaultWeightMsgShield
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgShield,
privacysimulation.SimulateMsgShield(am.authKeeper, am.bankKeeper, am.keeper, simState.TxConfig),
))
const (
opWeightMsgUnshield = "op_weight_msg_unshield"
defaultWeightMsgUnshield int = 100
)
var weightMsgUnshield int
simState.AppParams.GetOrGenerate(opWeightMsgUnshield, &weightMsgUnshield, nil,
func(_ *rand.Rand) {
weightMsgUnshield = defaultWeightMsgUnshield
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgUnshield,
privacysimulation.SimulateMsgUnshield(am.authKeeper, am.bankKeeper, am.keeper, simState.TxConfig),
))
return operations
}
// ProposalMsgs returns msgs used for governance proposals for simulations.
func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg {
return []simtypes.WeightedProposalMsg{}
}