Skip to content

cmd/workload: fixed filter test request error handling #31424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 11 additions & 9 deletions cmd/workload/filtertest.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ func (s *filterTestSuite) filterFullRange(t *utesting.T) {

func (s *filterTestSuite) queryAndCheck(t *utesting.T, query *filterQuery) {
query.run(s.cfg.client, s.cfg.historyPruneBlock)
if query.Err == errPrunedHistory {
return
}
if query.Err != nil {
t.Errorf("Filter query failed (fromBlock: %d toBlock: %d addresses: %v topics: %v error: %v)", query.FromBlock, query.ToBlock, query.Address, query.Topics, query.Err)
return
Expand All @@ -126,6 +129,9 @@ func (s *filterTestSuite) fullRangeQueryAndCheck(t *utesting.T, query *filterQue
Topics: query.Topics,
}
frQuery.run(s.cfg.client, s.cfg.historyPruneBlock)
if frQuery.Err == errPrunedHistory {
return
}
if frQuery.Err != nil {
t.Errorf("Full range filter query failed (addresses: %v topics: %v error: %v)", frQuery.Address, frQuery.Topics, frQuery.Err)
return
Expand Down Expand Up @@ -206,14 +212,10 @@ func (fq *filterQuery) run(client *client, historyPruneBlock *uint64) {
Addresses: fq.Address,
Topics: fq.Topics,
})
if err != nil {
if err = validateHistoryPruneErr(fq.Err, uint64(fq.FromBlock), historyPruneBlock); err == errPrunedHistory {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crap. big oversight on my part.. whoops

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was correct at some point. I must have inadvertently broken it before my original PR was merged.

return
} else if err != nil {
fmt.Printf("Filter query failed: fromBlock: %d toBlock: %d addresses: %v topics: %v error: %v\n",
fq.FromBlock, fq.ToBlock, fq.Address, fq.Topics, err)
}
fq.Err = err
}
fq.results = logs
fq.Err = validateHistoryPruneErr(err, uint64(fq.FromBlock), historyPruneBlock)
if fq.Err != nil && fq.Err != errPrunedHistory {
fmt.Printf("Filter query failed: fromBlock: %d toBlock: %d addresses: %v topics: %v error: %v\n",
fq.FromBlock, fq.ToBlock, fq.Address, fq.Topics, err)
}
}
6 changes: 6 additions & 0 deletions cmd/workload/filtertestgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ func filterGenCmd(ctx *cli.Context) error {
f.updateFinalizedBlock()
query := f.newQuery()
query.run(f.client, nil)
if query.Err == errPrunedHistory {
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should error here. It's not really possible to generate meaningful tests on a pruned node.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it so that the generator exits on errors instead of collecting them into a separate file. It also fails on history pruning errors. Now I think it doesn't make sense to collect errors into a file during generation as the test vectors should be generated in a correct environment. On the other hand it does make sense to collect errors during the performance test so I added it there (the --errors flag was there in filterperf anyways but it didn't do anything until now).

}
if query.Err != nil {
f.errors = append(f.errors, query)
continue
Expand All @@ -82,6 +85,9 @@ func filterGenCmd(ctx *cli.Context) error {
break
}
extQuery.run(f.client, nil)
if extQuery.Err == errPrunedHistory {
break
}
if extQuery.Err == nil && len(extQuery.results) < len(query.results) {
extQuery.Err = fmt.Errorf("invalid result length; old range %d %d; old length %d; new range %d %d; new length %d; address %v; Topics %v",
query.FromBlock, query.ToBlock, len(query.results),
Expand Down
13 changes: 9 additions & 4 deletions cmd/workload/filtertestperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var (
}
)

const passCount = 1
const passCount = 3

func filterPerfCmd(ctx *cli.Context) error {
cfg := testConfigFromCLI(ctx)
Expand All @@ -61,7 +61,7 @@ func filterPerfCmd(ctx *cli.Context) error {
}

// Run test queries.
var failed, mismatch int
var failed, pruned, mismatch int
for i := 1; i <= passCount; i++ {
fmt.Println("Performance test pass", i, "/", passCount)
for len(queries) > 0 {
Expand All @@ -71,6 +71,10 @@ func filterPerfCmd(ctx *cli.Context) error {
queries = queries[:len(queries)-1]
start := time.Now()
qt.query.run(cfg.client, cfg.historyPruneBlock)
if qt.query.Err == errPrunedHistory {
pruned++
continue
}
qt.runtime = append(qt.runtime, time.Since(start))
slices.Sort(qt.runtime)
qt.medianTime = qt.runtime[len(qt.runtime)/2]
Expand All @@ -80,18 +84,19 @@ func filterPerfCmd(ctx *cli.Context) error {
}
if rhash := qt.query.calculateHash(); *qt.query.ResultHash != rhash {
fmt.Printf("Filter query result mismatch: fromBlock: %d toBlock: %d addresses: %v topics: %v expected hash: %064x calculated hash: %064x\n", qt.query.FromBlock, qt.query.ToBlock, qt.query.Address, qt.query.Topics, *qt.query.ResultHash, rhash)
mismatch++
continue
}
processed = append(processed, qt)
if len(processed)%50 == 0 {
fmt.Println(" processed:", len(processed), "remaining", len(queries), "failed:", failed, "result mismatch:", mismatch)
fmt.Println(" processed:", len(processed), "remaining", len(queries), "failed:", failed, "pruned:", pruned, "result mismatch:", mismatch)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, we should replace Println calls with logging statements throughout this utility. But it's not really a blocker for this specific PR.

}
}
queries, processed = processed, nil
}

// Show results and stats.
fmt.Println("Performance test finished; processed:", len(queries), "failed:", failed, "result mismatch:", mismatch)
fmt.Println("Performance test finished; processed:", len(queries), "failed:", failed, "pruned:", pruned, "result mismatch:", mismatch)
stats := make([]bucketStats, len(f.queries))
var wildcardStats bucketStats
for _, qt := range queries {
Expand Down