testcase_gen

package
v0.0.0-...-4e93fa3 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// seed for the RNG
	SEED_FLAG  string = "seed"
	SEED_USAGE string = "required, integer, seed to use for the RNG"

	// chain-id
	CHAIN_ID_FLAG  string = "chainid"
	CHAIN_ID_USAGE string = "required, integer, the chainID of L2"

	// l2 bridge address
	L2_MESSAGE_SERVICE_CONTRACT_FLAG  string = "l2-bridge-address"
	L2_MESSAGE_SERVICE_CONTRACT_USAGE string = "l2-bridge-address: required, the 0x prefixed address of the bridge"

	// time stamp
	START_FROM_TIMESTAMP_FLAG  string = "start-from-timestamp"
	START_FROM_TIMESTAMP_USAGE string = "required, UNIX-timestamp, timestamp starting which we generate the blocks"

	// initial root hash
	START_FROM_ROOT_HASH_FLAG  string = "start-from-root-hash"
	START_FROM_ROOT_HASH_USAGE string = "root upon which we generate a proof"

	// final root hash
	END_WITH_ROOT_HASH_FLAG  string = "end-with-root-hash"
	END_WITH_ROOT_HASH_USAGE string = "optional, root hash at which the sequence of blocks should end"

	// output file
	OUTPUT_FILE_FLAG  string = "ofile"
	OUTPUT_FILE_USAGE string = "required, path, file where to write the testcase file"

	// max number of block
	NUM_BLOCKS_FLAG  string = "num-blocks"
	NUM_BLOCKS_USAGE string = "optional, integer, maximal number of block in the conflated batch"

	// bound on the number of tx per block
	MAX_TX_PER_BLOCK_FLAG  string = "max-tx-per-block"
	MAX_TX_PER_BLOCK_USAGE string = "optional, integer, maximal number of tx per block"

	// bound on the number of l2 msg logs per block
	// #nosec G101 -- Not a credential
	MAX_L2L1_LOGS_PER_BLOCKS_FLAG  string = "max-l2-l1-logs-per-block"
	MAX_L2L1_LOGS_PER_BLOCKS_USAGE string = "optional, int, maximal number of l2 msg emitted per block"

	// bound on the number of msg receipt confirmation
	MAX_L1L2_MSG_RECEIPT_PER_BLOCK_FLAG  string = "max-l1-l2-msg-receipt-per-block"
	MAX_L1L2_MSG_RECEIPT_PER_BLOCK_USAGE string = "optional, int, maximal number of l1 msg received per block (at most one batch per block)."

	// min tx size
	MIN_TX_BYTE_SIZE_FLAG  string = "min-tx-byte-size"
	MIN_TX_BYTE_SIZE_USAGE string = "optional, int, minimal size of an rlp encoded tx"

	// max-tx-size
	MAX_TX_BYTE_SIZE_FLAG  string = "max-tx-byte-size"
	MAX_TX_BYTE_SIZE_USAGE string = "optional, int, maximal size of an rlp encoded tx"

	// calldata-with-zero
	ZEROES_IN_CALLDATA_FLAG  string = "zeroes-in-calldata"
	ZEROES_IN_CALLDATA_USAGE string = "optional, bool, default to true. If set to true 75pc of the bytes of the calldata of the generated txs is set to zero"

	// start from block number
	START_FROM_BLOCK_NUMBER_FLAG  string = "start-from-block"
	START_FROM_BLOCK_NUMBER_USAGE string = "required, integer"
)

Variables

This section is empty.

Functions

func ChainID

func ChainID() *big.Int

func EndWithRootHash

func EndWithRootHash() types.Bytes32

func Initialize

func Initialize()

func L2BridgeAddress

func L2BridgeAddress() *common.Address

func MaxL1L2ReceiptPerBlock

func MaxL1L2ReceiptPerBlock() int

func MaxL2L1LogsPerBlock

func MaxL2L1LogsPerBlock() int

func MaxTxByteSize

func MaxTxByteSize() int

func MaxTxPerBlock

func MaxTxPerBlock() int

func MinTxByteSize

func MinTxByteSize() int

func NumBlock

func NumBlock() int

func Ofile

func Ofile() string

func Seed

func Seed() int64

func StartFromBlock

func StartFromBlock() int

func StartFromRootHash

func StartFromRootHash() string

func StartFromTimeStamp

func StartFromTimeStamp() uint64

func ZeroesInCalldata

func ZeroesInCalldata() bool

Types

type RandGen

type RandGen struct {
	rand.Rand
	Params struct {
		SupTxPerBlock         int
		SupL2L1LogsPerBlock   int
		SupMsgReceiptPerBlock int
	}
}

Random number generator

func MakeGeneratorFromCLI

func MakeGeneratorFromCLI() (res RandGen)

Create a generator from the CLI

func (*RandGen) Address

func (g *RandGen) Address() *common.Address

Generates a random address

func (*RandGen) AnyTypeTxRlp

func (g *RandGen) AnyTypeTxRlp() (res string)

Generates a tx of any type

func (*RandGen) AppendAddress

func (g *RandGen) AppendAddress(s string) string

The input string is an hex encoded string representing a transaction RLP.

func (*RandGen) BigInt

func (g *RandGen) BigInt(n int64) *big.Int

Generate a random big int

func (*RandGen) Bytes

func (g *RandGen) Bytes(nb int) []byte

func (*RandGen) CallData

func (g *RandGen) CallData() []byte

Generate call data for a transaction

func (*RandGen) DynFeeTx

func (g *RandGen) DynFeeTx() string

Generates a dynamic fee tx

func (*RandGen) EIP2930Tx

func (g *RandGen) EIP2930Tx() string

Generate an access list tx

func (*RandGen) FromAddresses

func (g *RandGen) FromAddresses(numTxs int) (fromAddresses []types.EthAddress)

Returns a list of addresses with the given size

func (*RandGen) Gas

func (g *RandGen) Gas() uint64

Generate a random tx gas limit

func (*RandGen) HexStringForNBytes

func (g *RandGen) HexStringForNBytes(numBytes int) string

Returns a random hex string representing n bytes

func (*RandGen) HexStringForVaryingNBytes

func (g *RandGen) HexStringForVaryingNBytes(min, sup int) string

Returns an hex string with a varying length in [start, stop)

func (*RandGen) IntRange

func (g *RandGen) IntRange(start, stop int) int

Returns an integer in the range

func (*RandGen) L2L1MsgHashes

func (g *RandGen) L2L1MsgHashes() (hashes []types.FullBytes32)

Generates a list of L2 msg logs

func (*RandGen) LegacyTxRLP

func (g *RandGen) LegacyTxRLP() string

Generate a legacy tx

func (*RandGen) ListOfBytes32

func (g *RandGen) ListOfBytes32(size int) []string

Create the Log hashes

func (*RandGen) MsgReceiptConfirmationTx

func (g *RandGen) MsgReceiptConfirmationTx() string

Generates an L1 messages batch receipt

func (*RandGen) Nonce

func (g *RandGen) Nonce() uint64

Generate a random tx nonce

func (*RandGen) PopulateBlockData

func (g *RandGen) PopulateBlockData(
	pbi *execution.BlockData,
	prevTimeStamp uint64,
) (nextTimeStamp uint64)

Populate the json with random functional inputs

func (*RandGen) PopulateCoordOutput

func (g *RandGen) PopulateCoordOutput(p *execution.Response)

Populate the json with random data

func (*RandGen) PositiveInt

func (g *RandGen) PositiveInt(sup int) int

Returns an non-zero integer in the range

func (*RandGen) TxRlp

func (g *RandGen) TxRlp(numTxs int) ([]string, []uint16)

Create t transactions RLP. Returns a uint16 indicating the position of the batch L1 Msg reception transactions.

func (*RandGen) Value

func (g *RandGen) Value() *big.Int

Generates a random tx value

Jump to

Keyboard shortcuts

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