Skip to content
Open
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
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ import "github.com/skip-mev/catalyst/loadtest"
// Create a load test specification
spec := types.LoadTestSpec{
ChainID: "my-chain-1",
NumOfBlocks: 100,
NumOfTxs: 100,
NumBatches: 50, // Send 50 batches
SendInterval: 5 * time.Second, // Send a batch every 5 seconds
NodesAddresses: []types.NodeAddress{...},
BaseMnemonic: "word1 word2 word3", // BIP39 mnemonic
NumWallets: 1500 // number of wallets to derive from the base mnemonic.
NumWallets: 1500, // number of wallets to derive from the base mnemonic.
GasDenom: "stake",
Bech32Prefix: "cosmos",
Msgs: []types.LoadTestMsg{
{NumTxs: 70, Type: "MsgSend"}, // 70 transactions per batch
{NumTxs: 30, Type: "MsgMultiSend"}, // 30 transactions per batch
},
}

// Create and run the load test
Expand Down
21 changes: 7 additions & 14 deletions chains/cosmos/metrics/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,7 @@ func (m *Collector) processNodeStats(result *loadtesttypes.LoadTestResult) {
}

// processBlockStats processes statistics for each block
func (m *Collector) processBlockStats(result *loadtesttypes.LoadTestResult, gasLimit int64,
numberOfBlocksRequested int,
) {
func (m *Collector) processBlockStats(result *loadtesttypes.LoadTestResult, gasLimit int64) {
var results []loadtesttypes.BlockStat
result.ByBlock = results

Expand All @@ -247,14 +245,6 @@ func (m *Collector) processBlockStats(result *loadtesttypes.LoadTestResult, gasL
sort.Slice(blockHeights, func(i, j int) bool {
return blockHeights[i] < blockHeights[j]
})
// ignore any extra blocks where txs landed in block
if len(blockHeights) > numberOfBlocksRequested {
m.logger.Info("found extra blocks, excluding from gas utilization stats",
zap.Int("number_of_blocks_requested", numberOfBlocksRequested),
zap.Int("number_of_blocks_found", len(blockHeights)),
zap.Int("number_of_blocks_excluded", len(blockHeights)-numberOfBlocksRequested))
blockHeights = blockHeights[:numberOfBlocksRequested]
}

for _, height := range blockHeights {
txs := m.txsByBlock[height]
Expand All @@ -280,7 +270,10 @@ func (m *Collector) processBlockStats(result *loadtesttypes.LoadTestResult, gasL
msgStats[tx.MsgType] = stats
}

gasUtilization := float64(blockGasUsed) / float64(gasLimit)
var gasUtilization float64
if gasLimit > 0 {
gasUtilization = float64(blockGasUsed) / float64(gasLimit)
}

blockStats := loadtesttypes.BlockStat{
BlockHeight: height,
Expand Down Expand Up @@ -310,7 +303,7 @@ func (m *Collector) processBlockStats(result *loadtesttypes.LoadTestResult, gasL
}

// ProcessResults returns the final load test results
func (m *Collector) ProcessResults(gasLimit int64, numOfBlocksRequested int) loadtesttypes.LoadTestResult {
func (m *Collector) ProcessResults(gasLimit int64) loadtesttypes.LoadTestResult {
result := loadtesttypes.LoadTestResult{
Overall: loadtesttypes.OverallStats{
StartTime: m.startTime,
Expand Down Expand Up @@ -347,7 +340,7 @@ func (m *Collector) ProcessResults(gasLimit int64, numOfBlocksRequested int) loa

go func() {
defer wg.Done()
m.processBlockStats(&result, gasLimit, numOfBlocksRequested)
m.processBlockStats(&result, gasLimit)
}()

wg.Wait()
Expand Down
Loading