replay

package
v0.0.0-...-035baff Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CodeRegistryMutex sync.Mutex
	CodeRegistry      map[common.Address][]byte
)

registry to keep track the bytecode of a smart contract

View Source
var (
	ChainIDFlag = cli.IntFlag{
		Name:  "chainid",
		Usage: "ChainID for replayer",
		Value: 250,
	}
	ProfileEVMCallFlag = cli.BoolFlag{
		Name:  "profiling-call",
		Usage: "enable profiling for EVM call",
	}
	MicroProfilingFlag = cli.BoolFlag{
		Name:  "micro-profiling",
		Usage: "enable micro-profiling of EVM",
	}
	BasicBlockProfilingFlag = cli.BoolFlag{
		Name:  "basic-block-profiling",
		Usage: "enable profiling of basic block",
	}
	OnlySuccessfulFlag = cli.BoolFlag{
		Name:  "only-successful",
		Usage: "only runs transactions that have been successful",
	}
	InterpreterImplFlag = cli.StringFlag{
		Name:  "interpreter",
		Usage: "select the interpreter version to be used",
	}
	CpuProfilingFlag = cli.StringFlag{
		Name:  "cpuprofile",
		Usage: "the file name where to write a CPU profile of the evaluation step to",
	}
	UseInMemoryStateDbFlag = cli.BoolFlag{
		Name:  "faststatedb",
		Usage: "enables a faster, yet still experimental StateDB implementation",
	}
	DatabaseNameFlag = cli.StringFlag{
		Name:  "db",
		Usage: "set a database name for storing micro-profiling results",
		Value: "./profiling.db",
	}
	ChannelBufferSizeFlag = cli.IntFlag{
		Name:  "buffer-size",
		Usage: "set a buffer size for profiling channel",
		Value: 100000,
	}
	// contract-db filename
	ContractDBFlag = cli.StringFlag{
		Name:  "contractdb",
		Usage: "Contract database name for smart contracts",
		Value: "./contracts.db",
	}
)

command line options

View Source
var (
	ErrReplayForkOutOfGas     = errors.New("out of gas in replay-fork")
	ErrReplayForkInvalidAlloc = errors.New("invalid alloc in replay-fork")
	ErrReplayForkMoreGas      = errors.New("more gas in replay-fork")
	ErrReplayForkLessGas      = errors.New("less gas in replay-fork")
	ErrReplayForkMisc         = errors.New("misc in replay-fork")
)
View Source
var ContractDB = ContractDBFlag.Value
View Source
var GetAddressStatsCommand = cli.Command{
	Action:    getAddressStatsAction,
	Name:      "address-stats",
	Usage:     "computes usage statistics of addresses",
	ArgsUsage: "<blockNumFirst> <blockNumLast>",
	Flags: []cli.Flag{
		&substate.WorkersFlag,
		&substate.SubstateDirFlag,
		&ChainIDFlag,
	},
	Description: `
The substate-cli address-stats command requires two arguments:
<blockNumFirst> <blockNumLast>

<blockNumFirst> and <blockNumLast> are the first and
last block of the inclusive range of blocks to be analysed.

Statistics on the usage of addresses are printed to the console.
`,
}

record-replay: substate-cli address-stats command

View Source
var GetCodeCommand = cli.Command{
	Action:    getCodeAction,
	Name:      "code",
	Usage:     "write all contracts into a database",
	ArgsUsage: "<blockNumFirst> <blockNumLast>",
	Flags: []cli.Flag{
		&substate.WorkersFlag,
		&substate.SubstateDirFlag,
		&ContractDBFlag,
		&ChainIDFlag,
	},
	Description: `
The substate-cli code command requires two arguments:
<blockNumFirst> <blockNumLast>

<blockNumFirst> and <blockNumLast> are the first and
last block of the inclusive range of blocks to replay transactions.

The contracts of the block range are written into a levelDB database.
`,
}

record-replay: substate-cli code command

View Source
var GetCodeSizeCommand = cli.Command{
	Action:    getCodeSizeAction,
	Name:      "code-size",
	Usage:     "reports code size and nonce of smart contracts in the specified block range",
	ArgsUsage: "<blockNumFirst> <blockNumLast>",
	Flags: []cli.Flag{
		&substate.WorkersFlag,
		&substate.SubstateDirFlag,
		&ChainIDFlag,
	},
	Description: `
The substate-cli code-size command requires two arguments:
<blockNumFirst> <blockNumLast>

<blockNumFirst> and <blockNumLast> are the first and
last block of the inclusive range of blocks to replay transactions.

Output log format: (block, timestamp, transaction, account, code size, nonce, transaction type)`,
}

substate-cli code-size command

View Source
var GetKeyStatsCommand = cli.Command{
	Action:    getKeyStatsAction,
	Name:      "key-stats",
	Usage:     "computes usage statistics of accessed storage locations",
	ArgsUsage: "<blockNumFirst> <blockNumLast>",
	Flags: []cli.Flag{
		&substate.WorkersFlag,
		&substate.SubstateDirFlag,
		&ChainIDFlag,
	},
	Description: `
The substate-cli key-stats command requires two arguments:
<blockNumFirst> <blockNumLast>

<blockNumFirst> and <blockNumLast> are the first and
last block of the inclusive range of blocks to be analysed.

Statistics on the usage of accessed storage locations are printed to the console.
`,
}

record-replay: substate-cli key-stats command

View Source
var GetLocationStatsCommand = cli.Command{
	Action:    getLocationStatsAction,
	Name:      "location-stats",
	Usage:     "computes usage statistics of accessed storage locations",
	ArgsUsage: "<blockNumFirst> <blockNumLast>",
	Flags: []cli.Flag{
		&substate.WorkersFlag,
		&substate.SubstateDirFlag,
		&ChainIDFlag,
	},
	Description: `
The substate-cli location-stats command requires two arguments:
<blockNumFirst> <blockNumLast>

<blockNumFirst> and <blockNumLast> are the first and
last block of the inclusive range of blocks to be analysed.

Statistics on the usage of accessed storage locations are printed to the console.
`,
}

record-replay: substate-cli location-stats command

View Source
var GetStorageUpdateSizeCommand = cli.Command{
	Action:    getStorageUpdateSizeAction,
	Name:      "storage-size",
	Usage:     "returns changes in storage size by transactions in the specified block range",
	ArgsUsage: "<blockNumFirst> <blockNumLast>",
	Flags: []cli.Flag{
		&substate.WorkersFlag,
		&substate.SubstateDirFlag,
		&ChainIDFlag,
	},
	Description: `
The substate-cli storage-size command requires two arguments:
<blockNumFirst> <blockNumLast>

<blockNumFirst> and <blockNumLast> are the first and
last block of the inclusive range of blocks to replay transactions.

Output log format: (block, timestamp, transaction, account, storage update size, storage size in input substate, storage size in output substate)`,
}

record-replay: substate-cli storage command

View Source
var HardForkFlag = cli.Int64Flag{
	Name: "hard-fork",
	Usage: func() string {
		s := ""
		s += "Hard-fork block number, won't change block number in Env for NUMBER instruction"

		hardForkNums := make([]int64, 0, len(HardForkName))
		for num64 := range HardForkName {
			hardForkNums = append(hardForkNums, num64)
		}
		sort.Slice(hardForkNums, func(i, j int) bool { return hardForkNums[i] < hardForkNums[j] })
		for _, num64 := range hardForkNums {
			s += fmt.Sprintf("\n\t  %v: %s", num64, HardForkName[num64])
		}
		return s
	}(),
	Value: hardForkFlagDefault(),
}
View Source
var HardForkName = map[int64]string{
	1:          "Frontier",
	1_150_000:  "Homestead",
	2_463_000:  "Tangerine Whistle",
	2_675_000:  "Spurious Dragon",
	4_370_000:  "Byzantium",
	7_280_000:  "Constantinople + Petersburg",
	9_069_000:  "Istanbul",
	12_244_000: "Berlin",
	12_965_000: "London",
}
View Source
var ReplayCommand = cli.Command{
	Action:    replayAction,
	Name:      "replay",
	Usage:     "executes full state transitions and check output consistency",
	ArgsUsage: "<blockNumFirst> <blockNumLast>",
	Flags: []cli.Flag{
		&substate.WorkersFlag,
		&substate.SkipTransferTxsFlag,
		&substate.SkipCallTxsFlag,
		&substate.SkipCreateTxsFlag,
		&substate.SubstateDirFlag,
		&ChainIDFlag,
		&ProfileEVMCallFlag,
		&MicroProfilingFlag,
		&BasicBlockProfilingFlag,
		&DatabaseNameFlag,
		&ChannelBufferSizeFlag,
		&InterpreterImplFlag,
		&OnlySuccessfulFlag,
		&CpuProfilingFlag,
		&UseInMemoryStateDbFlag,
	},
	Description: `
The substate-cli replay command requires two arguments:
<blockNumFirst> <blockNumLast>

<blockNumFirst> and <blockNumLast> are the first and
last block of the inclusive range of blocks to replay transactions.`,
}

record-replay: substate-cli replay command

View Source
var ReplayForkChainConfig *params.ChainConfig = &params.ChainConfig{}
View Source
var ReplayForkCommand = cli.Command{
	Action:    replayForkAction,
	Name:      "replay-fork",
	Usage:     "executes and check output consistency of all transactions in the range with the given hard-fork",
	ArgsUsage: "<blockNumFirst> <blockNumLast>",
	Flags: []cli.Flag{
		&substate.WorkersFlag,
		&substate.SkipTransferTxsFlag,
		&substate.SkipCallTxsFlag,
		&substate.SkipCreateTxsFlag,
		&HardForkFlag,
		&substate.SubstateDirFlag,
	},
	Description: `
The replay-fork command requires two arguments:
<blockNumFirst> <blockNumLast>

<blockNumFirst> and <blockNumLast> are the first and
last block of the inclusive range of blocks to replay transactions.

--hard-fork parameter is recommended for this command.`,
}

record-replay: replay-fork command

View Source
var ReplayForkStatChan chan *ReplayForkStat = make(chan *ReplayForkStat, 1_000_000)
View Source
var ReplayForkStatMap map[string]*ReplayForkStat = make(map[string]*ReplayForkStat)
View Source
var SubstateDumpCommand = cli.Command{
	Action:    substateDumpAction,
	Name:      "dump",
	Usage:     "returns content in substates in json format",
	ArgsUsage: "<blockNumFirst> <blockNumLast>",
	Flags: []cli.Flag{
		&substate.WorkersFlag,
		&substate.SubstateDirFlag,
	},
	Description: `
The substate-cli dump command requires two arguments:
<blockNumFirst> <blockNumLast>

<blockNumFirst> and <blockNumLast> are the first and
last block of the inclusive range of blocks to replay transactions.`,
}

substate-cli dump command

Functions

func GetTxType

func GetTxType(to *common.Address, alloc substate.SubstateAlloc) string

func PrintAllocationDiffSummary

func PrintAllocationDiffSummary(want, have *substate.SubstateAlloc)

func PrintResultDiffSummary

func PrintResultDiffSummary(want, have *substate.SubstateResult)

func SetBlockRange

func SetBlockRange(firstArg string, lastArg string) (uint64, uint64, error)

Types

type AccessStatistics

type AccessStatistics[T comparable] struct {
	// contains filtered or unexported fields
}

func (*AccessStatistics[T]) PrintSummary

func (a *AccessStatistics[T]) PrintSummary()

func (*AccessStatistics[T]) RegisterAccess

func (a *AccessStatistics[T]) RegisterAccess(reference *T)

type AccessStatisticsConsumer

type AccessStatisticsConsumer[T comparable] func(*AccessStatistics[T])

type BasicBlockProfilingCollectorContext

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

data collection execution context

func NewBasicBlockProfilingCollectorContext

func NewBasicBlockProfilingCollectorContext() *BasicBlockProfilingCollectorContext

create new execution context for a data collector

type Extractor

type Extractor[T any] func(*TransactionInfo) []T

type Index

type Index[T comparable] struct {
	// contains filtered or unexported fields
}

func (*Index[T]) Get

func (i *Index[T]) Get(value *T) int

type Location

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

type MicroProfilingCollectorContext

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

data collection execution context

func NewMicroProfilingCollectorContext

func NewMicroProfilingCollectorContext() *MicroProfilingCollectorContext

create new execution context for a data collector

type ReplayConfig

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

type ReplayForkStat

type ReplayForkStat struct {
	Count  int64
	ErrStr string
}

type TransactionInfo

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

Jump to

Keyboard shortcuts

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