Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import (

// LoadConfig stores the configuration for load-related settings.
type LoadConfig struct {
ChainID int64 `json:"chainId,omitempty"`
ChainID int64 `json:"chainId,omitempty"`
// SeiChainID is the textual chain ID used for tagging metric collection.
SeiChainID string `json:"seiChainID,omitempty"`
Endpoints []string `json:"endpoints"`
Accounts *AccountConfig `json:"accounts,omitempty"`
Scenarios []Scenario `json:"scenarios,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func runLoadTest(ctx context.Context, cmd *cobra.Command, args []string) error {
// Create and start block collector if endpoints are available
var blockCollector *stats.BlockCollector
if len(cfg.Endpoints) > 0 && settings.TrackBlocks {
blockCollector = stats.NewBlockCollector()
blockCollector = stats.NewBlockCollector(cfg.SeiChainID)
collector.SetBlockCollector(blockCollector)
s.SpawnBgNamed("block collector", func() error {
return blockCollector.Run(ctx, cfg.Endpoints[0])
Expand Down
1 change: 1 addition & 0 deletions profiles/loadtest_default.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"chainId": 713714,
"seiChainId": "loadtest-default",
"endpoints": [
"http://127.0.0.1:8545"
],
Expand Down
1 change: 1 addition & 0 deletions profiles/local.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"chainId": 713714,
"seiChainId": "loadtest-local",
"endpoints": [
"http://127.0.0.1:8545"
],
Expand Down
6 changes: 3 additions & 3 deletions sender/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var (
observer.Observe(int64(worker.GetChannelLength()), metric.WithAttributes(
attribute.String("endpoint", worker.GetEndpoint()),
attribute.Int("worker_id", worker.id),
attribute.Int64("chain_id", worker.chainID),
attribute.String("chain_id", worker.seiChainID),
))
}
return nil
Expand All @@ -54,15 +54,15 @@ type chainWorkerObserver struct {
}
type chainWorkerID struct {
workerID int
chainID int64
chainID string
}

func meterWorkerQueueLength(worker *Worker) {
meteredChainWorkers.lock.Lock()
defer meteredChainWorkers.lock.Unlock()
id := chainWorkerID{
workerID: worker.id,
chainID: worker.chainID,
chainID: worker.seiChainID,
}
if _, exists := meteredChainWorkers.workers[id]; !exists {
meteredChainWorkers.workers[id] = worker
Expand Down
2 changes: 1 addition & 1 deletion sender/sharded_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewShardedSender(cfg *config.LoadConfig, bufferSize int, workers int, limit

workerList := make([]*Worker, len(cfg.Endpoints))
for i, endpoint := range cfg.Endpoints {
workerList[i] = NewWorker(i, cfg.ChainID, endpoint, bufferSize, workers, limiter)
workerList[i] = NewWorker(i, cfg.SeiChainID, endpoint, bufferSize, workers, limiter)
}

return &ShardedSender{
Expand Down
10 changes: 5 additions & 5 deletions sender/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
// Worker handles sending transactions to a specific endpoint
type Worker struct {
id int
chainID int64
seiChainID string
endpoint string
txChan chan *types.LoadTx
sentTxs chan *types.LoadTx
Expand Down Expand Up @@ -58,10 +58,10 @@ func newHttpClient() *http.Client {
}

// NewWorker creates a new worker for a specific endpoint
func NewWorker(id int, chainID int64, endpoint string, bufferSize int, workers int, limiter *rate.Limiter) *Worker {
func NewWorker(id int, seiChainID string, endpoint string, bufferSize int, workers int, limiter *rate.Limiter) *Worker {
w := &Worker{
id: id,
chainID: chainID,
seiChainID: seiChainID,
endpoint: endpoint,
txChan: make(chan *types.LoadTx, bufferSize),
sentTxs: make(chan *types.LoadTx, bufferSize),
Expand Down Expand Up @@ -140,7 +140,7 @@ func (w *Worker) waitForReceipt(ctx context.Context, eth *ethclient.Client, tx *
attribute.String("scenario", tx.Scenario.Name),
attribute.String("endpoint", w.endpoint),
attribute.Int("worker_id", w.id),
attribute.Int64("chain_id", w.chainID),
attribute.String("chain_id", w.seiChainID),
statusAttrFromError(_err)),
)
}(time.Now())
Expand Down Expand Up @@ -206,7 +206,7 @@ func (w *Worker) sendTransaction(ctx context.Context, client *http.Client, tx *t
attribute.String("scenario", tx.Scenario.Name),
attribute.String("endpoint", w.endpoint),
attribute.Int("worker_id", w.id),
attribute.Int64("chain_id", w.chainID),
attribute.String("chain_id", w.seiChainID),
statusAttrFromError(_err)),
)
}(time.Now())
Expand Down
14 changes: 9 additions & 5 deletions stats/block_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"github.com/ethereum/go-ethereum/ethclient"
"github.com/sei-protocol/sei-load/utils"
"github.com/sei-protocol/sei-load/utils/service"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
)

type blockCollectorStats struct {
Expand All @@ -29,12 +31,14 @@ type blockCollectorStats struct {

// BlockCollector subscribes to new blocks and tracks block metrics
type BlockCollector struct {
stats utils.Mutex[*blockCollectorStats]
seiChainID string
stats utils.Mutex[*blockCollectorStats]
}

// NewBlockCollector creates a new block data collector
func NewBlockCollector() *BlockCollector {
func NewBlockCollector(seiChainID string) *BlockCollector {
return &BlockCollector{
seiChainID: seiChainID,
stats: utils.NewMutex(&blockCollectorStats{
allBlockTimes: make([]time.Duration, 0),
allGasUsed: make([]uint64, 0),
Expand Down Expand Up @@ -86,10 +90,10 @@ func (bc *BlockCollector) processNewBlock(header *types.Header) {
now := time.Now()
blockNum := header.Number.Uint64()
gasUsed := header.GasUsed
metrics.gasUsed.Record(context.Background(), int64(gasUsed))
metrics.gasUsed.Record(context.Background(), int64(gasUsed), metric.WithAttributes(attribute.String("chain_id", bc.seiChainID)))
// Update max block number
if blockNum > stats.maxBlockNum {
metrics.blockNumber.Record(context.Background(), int64(blockNum))
metrics.blockNumber.Record(context.Background(), int64(blockNum), metric.WithAttributes(attribute.String("chain_id", bc.seiChainID)))
stats.maxBlockNum = blockNum
}

Expand All @@ -100,7 +104,7 @@ func (bc *BlockCollector) processNewBlock(header *types.Header) {
// Calculate time between blocks
if !stats.lastBlockTime.IsZero() {
timeBetween := now.Sub(stats.lastBlockTime)
metrics.blockTime.Record(context.Background(), timeBetween.Seconds())
metrics.blockTime.Record(context.Background(), timeBetween.Seconds(), metric.WithAttributes(attribute.String("chain_id", bc.seiChainID)))
stats.allBlockTimes = append(stats.allBlockTimes, timeBetween)
stats.windowBlockTimes = append(stats.windowBlockTimes, timeBetween)
}
Expand Down
Loading