Skip to content

Commit

Permalink
feat: erc20 transfer in stress
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkAfCod committed Nov 1, 2024
1 parent 7dcafd6 commit e58edcd
Show file tree
Hide file tree
Showing 6 changed files with 249 additions and 45 deletions.
2 changes: 2 additions & 0 deletions packages/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type ReplayorConfig struct {
Bucket string
StorageType string
DiskPath string
InjectERC20 bool
}

func (r ReplayorConfig) TestDescription() string {
Expand Down Expand Up @@ -98,5 +99,6 @@ func LoadReplayorConfig(cliCtx *cli.Context, l log.Logger) (ReplayorConfig, erro
Bucket: cliCtx.String(S3Bucket.Name),
StorageType: cliCtx.String(StorageType.Name),
DiskPath: cliCtx.String(DiskPath.Name),
InjectERC20: cliCtx.Bool(InjectErc20.Name),
}, nil
}
8 changes: 7 additions & 1 deletion packages/config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,17 @@ var (
Required: false,
EnvVars: opservice.PrefixEnvVar(EnvVarPrefix, "DISK_PATH"),
}
InjectErc20 = &cli.BoolFlag{
Name: "inject-erc20-txs",
Usage: "whether to inject erc20 txs",
Required: false,
EnvVars: opservice.PrefixEnvVar(EnvVarPrefix, "INJECT_ERC20_TXS"),
}
)

func init() {
Flags = append(Flags, oplog.CLIFlags(EnvVarPrefix)...)
Flags = append(Flags, EngineApiSecret, SourceNodeUrl, ChainId, EngineApiUrl, ExecutionUrl, Strategy, BlockCount, GasTarget, GasLimit, S3Bucket, StorageType, DiskPath, BenchmarkStartBlock, BenchmarkOpcodes, ComputeStorageDiffs, TestName, RollupConfigPath)
Flags = append(Flags, EngineApiSecret, SourceNodeUrl, ChainId, EngineApiUrl, ExecutionUrl, Strategy, BlockCount, GasTarget, GasLimit, S3Bucket, StorageType, DiskPath, BenchmarkStartBlock, BenchmarkOpcodes, ComputeStorageDiffs, TestName, RollupConfigPath, InjectErc20)
}

// Flags contains the list of configuration options available to the binary.
Expand Down
4 changes: 2 additions & 2 deletions packages/replayor/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (r *Service) Start(ctx context.Context) error {
}
r.log.Info("retrieved current block number", "blockNum", currentBlock.Number())

retry.Do(ctx, 720, retry.Fixed(10*time.Second), func() (bool, error) {
_, _ = retry.Do(ctx, 720, retry.Fixed(10*time.Second), func() (bool, error) {
result, err := r.clients.EngineApi.ForkchoiceUpdate(ctx, &eth.ForkchoiceState{
HeadBlockHash: currentBlock.Hash(),
SafeBlockHash: currentBlock.Hash(),
Expand Down Expand Up @@ -79,7 +79,7 @@ func (r *Service) Start(ctx context.Context) error {
false)

walkUpToBlock.Run(cCtx)
} else {
} else if currentBlock.NumberU64() > r.cfg.BenchmarkStartBlock {
panic("current block is greater than benchmark start block")
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/replayor/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ var storageTracerOptions = map[string]any{
}

func (r *Benchmark) computeTraceStats(ctx context.Context, s *stats.BlockCreationStats, receipts []*types.Receipt) {
r.log.Info("enriching block stats", "receipts", len(receipts), "gasUsed", s.GasUsed)
if r.benchmarkOpcodes {
s.OpCodes = make(map[string]stats.OpCodeStats)

for _, receipt := range receipts {
r.traceReceipt(ctx, receipt, s.OpCodes)
}
r.log.Info("traced block receipts", "receipts", len(receipts), "gasUsed", s.GasUsed)
}

if r.diffStorage {
Expand Down
Loading

0 comments on commit e58edcd

Please sign in to comment.