github.com/cosmos/cosmos-sdk@v0.50.10/x/slashing/simulation/proposals.go (about)

     1  package simulation
     2  
     3  import (
     4  	"math/rand"
     5  	"time"
     6  
     7  	sdkmath "cosmossdk.io/math"
     8  
     9  	sdk "github.com/cosmos/cosmos-sdk/types"
    10  	"github.com/cosmos/cosmos-sdk/types/address"
    11  	simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
    12  	"github.com/cosmos/cosmos-sdk/x/simulation"
    13  	"github.com/cosmos/cosmos-sdk/x/slashing/types"
    14  )
    15  
    16  // Simulation operation weights constants
    17  const (
    18  	DefaultWeightMsgUpdateParams int = 100
    19  
    20  	OpWeightMsgUpdateParams = "op_weight_msg_update_params"
    21  )
    22  
    23  // ProposalMsgs defines the module weighted proposals' contents
    24  func ProposalMsgs() []simtypes.WeightedProposalMsg {
    25  	return []simtypes.WeightedProposalMsg{
    26  		simulation.NewWeightedProposalMsg(
    27  			OpWeightMsgUpdateParams,
    28  			DefaultWeightMsgUpdateParams,
    29  			SimulateMsgUpdateParams,
    30  		),
    31  	}
    32  }
    33  
    34  // SimulateMsgUpdateParams returns a random MsgUpdateParams
    35  func SimulateMsgUpdateParams(r *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg {
    36  	// use the default gov module account address as authority
    37  	var authority sdk.AccAddress = address.Module("gov")
    38  
    39  	params := types.DefaultParams()
    40  	params.DowntimeJailDuration = time.Duration(simtypes.RandTimestamp(r).UnixNano())
    41  	params.SignedBlocksWindow = int64(simtypes.RandIntBetween(r, 1, 1000))
    42  	params.MinSignedPerWindow = sdkmath.LegacyNewDecWithPrec(int64(simtypes.RandIntBetween(r, 1, 100)), 2)
    43  	params.SlashFractionDoubleSign = sdkmath.LegacyNewDecWithPrec(int64(simtypes.RandIntBetween(r, 1, 100)), 2)
    44  	params.SlashFractionDowntime = sdkmath.LegacyNewDecWithPrec(int64(simtypes.RandIntBetween(r, 1, 100)), 2)
    45  
    46  	return &types.MsgUpdateParams{
    47  		Authority: authority.String(),
    48  		Params:    params,
    49  	}
    50  }