simulation

package
v1.1.12 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2022 License: LGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	/* #nosec */
	OpWeightMsgEthSimpleTransfer = "op_weight_msg_eth_simple_transfer"
	/* #nosec */
	OpWeightMsgEthCreateContract = "op_weight_msg_eth_create_contract"
	/* #nosec */
	OpWeightMsgEthCallContract = "op_weight_msg_eth_call_contract"
)
View Source
const (
	WeightMsgEthSimpleTransfer = 50
	WeightMsgEthCreateContract = 50
)

Variables

View Source
var ErrNoEnoughBalance = fmt.Errorf("no enough balance")

Functions

func CreateRandomValidEthTx

func CreateRandomValidEthTx(ctx *simulateContext, from, to *common.Address, amount *big.Int, data *hexutil.Bytes) (ethTx *types.MsgEthereumTx, err error)

CreateRandomValidEthTx create the ethereum tx with valid random values

func EstimateGas

func EstimateGas(ctx *simulateContext, from, to *common.Address, data *hexutil.Bytes, gasCap uint64) (gas uint64, err error)

EstimateGas estimates the gas used by quering the keeper.

func GenEnableCall

func GenEnableCall(r *rand.Rand) bool

GenEnableCall enables the EnableCall param with 80% probability

func GenEnableCreate

func GenEnableCreate(r *rand.Rand) bool

GenEnableCreate enables the EnableCreate param with 80% probability

func GenExtraEIPs

func GenExtraEIPs(r *rand.Rand) []int64

GenExtraEIPs defines a set of extra EIPs with 50% probability

func GetSignedTx

func GetSignedTx(ctx *simulateContext, txBuilder client.TxBuilder, msg *types.MsgEthereumTx, prv cryptotypes.PrivKey) (signedTx signing.Tx, err error)

GetSignedTx sign the ethereum tx and packs it as a signing.Tx .

func NewDecodeStore

func NewDecodeStore() func(kvA, kvB kv.Pair) string

NewDecodeStore returns a decoder function closure that unmarshals the KVPair's value to the corresponding EVM type.

func ParamChanges

func ParamChanges(r *rand.Rand) []simtypes.ParamChange

ParamChanges defines the parameters that can be modified by param change proposals on the simulation.

func RandomTransferableAmount

func RandomTransferableAmount(ctx *simulateContext, address common.Address, estimateGas uint64, gasFeeCap *big.Int) (amount *big.Int, err error)

RandomTransferableAmount generates a random valid transferable amount. Transferable amount is between the range [0, spendable), spendable = balance - gasFeeCap * GasLimit.

func RandomizedGenState

func RandomizedGenState(simState *module.SimulationState)

RandomizedGenState generates a random GenesisState for the EVM module

func SimulateEthCreateContract

func SimulateEthCreateContract(ak types.AccountKeeper, k *keeper.Keeper) simtypes.Operation

SimulateEthCreateContract simulate create an ERC20 contract. It makes operationSimulateEthCallContract the future operations of SimulateEthCreateContract to ensure valid contract call.

func SimulateEthSimpleTransfer

func SimulateEthSimpleTransfer(ak types.AccountKeeper, k *keeper.Keeper) simtypes.Operation

SimulateEthSimpleTransfer simulate simple eth account transferring gas token. It randomly choose sender, recipient and transferable amount. Other tx details like nonce, gasprice, gaslimit are calculated to get valid value.

func SimulateEthTx

func SimulateEthTx(
	ctx *simulateContext, from, to *common.Address, amount *big.Int, data *hexutil.Bytes, prv cryptotypes.PrivKey, fops []simtypes.FutureOperation,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error)

SimulateEthTx creates valid ethereum tx and pack it as cosmos tx, and deliver it.

func WeightedOperations

func WeightedOperations(
	appParams simtypes.AppParams, cdc codec.JSONCodec, ak types.AccountKeeper, k *keeper.Keeper,
) simulation.WeightedOperations

WeightedOperations generate Two kinds of operations: SimulateEthSimpleTransfer, SimulateEthCreateContract. Contract call operations work as the future operations of SimulateEthCreateContract.

Types

This section is empty.

Jump to

Keyboard shortcuts

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