simulation

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2022 License: LGPL-3.0 Imports: 28 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 added in v0.14.0

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 added in v0.14.0

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

EstimateGas estimates the gas used by quering the keeper.

func GetSignedTx added in v0.14.0

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 added in v0.14.0

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 added in v0.14.0

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

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

func RandomTransferableAmount added in v0.14.0

func RandomTransferableAmount(ctx *simulateContext, address common.Address, gasLimit 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 nft

func SimulateEthCreateContract added in v0.14.0

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 added in v0.14.0

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 added in v0.14.0

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 added in v0.14.0

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