chainload

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

README

ChainLoad

CircleCI

chainload is a GoChain/Ethereum blockchain load generator.

How to use

By default, simply executing chainload will fire 1 transaction per second at http://localhost:8545 with chain id 1234. Reports are logged every 30s, with pprof and other metrics available via expvar.

The target url(s), transaction rate, chain id, and more can be set via flags:

chainload --help

Usage of chainload:
  -amount uint
    	tx amount (approximate) (default 10)
  -cycle duration
    	how often to cycle a sender's account (default 5m0s)
  -dur duration
    	duration to run - omit for unlimited
  -gas uint
    	gas (approximate) (default 200000)
  -id uint
    	id (default 1234)
  -pass string
    	passphrase to unlock accounts (default "#go@chain42")
  -pprof string
    	pprof addr (default ":6060")
  -senders int
    	total number of concurrent senders/accounts - defaults to tps
  -tps int
    	transactions per second (default 1)
  -urls string
    	csv of urls (default "http://localhost:8545")

Examples:

chainload -id 9876 -urls http://node1:8545,http://node2:8545 -tps 100 -senders 50 -dur 5m
chainload version
> chainload version: 0.0.18

How it works

Accounts are managed locally under keystore/. Pre-existing accounts are reused and new ones are created as necessary. One seeder goroutine is started per url to seed funds to senders, and to continually re-claim funds from other accounts. Senders goroutines continually send txs to a set of receivers, while periodically cycling out the sender and receiver addresses. The gas and amount of each transaction varies randomly from the suggested approximate values.

Problems

At high volume, the error Too many open files may occur. This system limit can be inspected via ulimit -n, and temporarily raised via ulimit -n <new limit>. It can be permanently set in /etc/security/limits.conf by adding a line like:

root             soft    nofile          100000

Releases

CI releases are manually triggered. If no tag is set, then the commit hash will be used as the version and docker tag. To produce a versioned release, first tag the desired commit (e.g. v0.1.0), then approve the CI release step (or re-run, if a commit hash release has already been produced).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountStore

type AccountStore struct {
	// contains filtered or unexported fields
}

func NewAccountStore

func NewAccountStore(ks *keystore.KeyStore, chainID *big.Int, pass string) *AccountStore

func (*AccountStore) New

func (*AccountStore) Next

func (a *AccountStore) Next(ctx context.Context, node int) (acct *accounts.Account, nonce uint64, err error)

func (*AccountStore) NextRecv

func (a *AccountStore) NextRecv(send common.Address, n int) []common.Address

func (*AccountStore) NextSeed

func (a *AccountStore) NextSeed() (*accounts.Account, error)

NextSeed returns the next available account from the keystore.

func (*AccountStore) RandSeed

func (a *AccountStore) RandSeed() *common.Address

func (*AccountStore) Return

func (a *AccountStore) Return(acct *accounts.Account, node int, nonce uint64)

func (*AccountStore) SignTx

type Chainload

type Chainload struct {
	// contains filtered or unexported fields
}

func (*Chainload) Run

func (c *Chainload) Run() error

type Config

type Config struct {
	Id        uint64
	UrlsCSV   string
	TPS       int
	Senders   int
	Cycle     time.Duration
	Duration  time.Duration
	Password  string
	Gas       uint64
	Amount    uint64
	PprofAddr string
	Variable  time.Duration
}

func (*Config) MarshalLogObject added in v0.2.2

func (c *Config) MarshalLogObject(oe zapcore.ObjectEncoder) error

func (*Config) NewChainload added in v0.2.2

func (config *Config) NewChainload(lgr *zap.Logger) (*Chainload, error)

type Node

type Node struct {
	Number int

	*goclient.Client
	*AccountStore
	SeedCh chan SeedReq
	// contains filtered or unexported fields
}

type Report

type Report struct {
	// contains filtered or unexported fields
}

Report holds statistics for a stretch of time.

func (*Report) MarshalLogObject added in v0.2.2

func (r *Report) MarshalLogObject(oe zapcore.ObjectEncoder) error

func (*Report) TPS added in v0.2.2

func (r *Report) TPS() float64

type Reporter

type Reporter interface {
	// Report generates a report since the last (or start).
	Report() *Report
}

Reporter tracks statistics and emits reports for an execution.

func NewReporter

func NewReporter() Reporter

type Reports

type Reports struct {
	// contains filtered or unexported fields
}

Reports keeps a history of recent reports.

func (*Reports) Add

func (r *Reports) Add(rep *Report) *Status

Add adds the report to the set of reports.

type SeedReq

type SeedReq struct {
	Addr common.Address
	Resp chan<- error
}

type Seeder

type Seeder struct {
	*Node
	// contains filtered or unexported fields
}

Seeder issues funds to sender accounts and collects funds from inactive accounts.

func (*Seeder) Run

func (s *Seeder) Run(ctx context.Context, done func())

type Sender

type Sender struct {
	*Node

	Number    int
	RateLimit time.Duration
	// contains filtered or unexported fields
}

func (*Sender) Send

func (s *Sender) Send(ctx context.Context, txs <-chan struct{}, done func())

type Status

type Status struct {
	// contains filtered or unexported fields
}

func (*Status) MarshalLogObject added in v0.2.2

func (s *Status) MarshalLogObject(oe zapcore.ObjectEncoder) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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