mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 07:06:42 +00:00
cmd/workload: fixed filter workload test request error handling
This commit is contained in:
parent
c4f0450710
commit
7960b3ffce
3 changed files with 26 additions and 13 deletions
|
|
@ -109,6 +109,9 @@ func (s *filterTestSuite) filterFullRange(t *utesting.T) {
|
||||||
|
|
||||||
func (s *filterTestSuite) queryAndCheck(t *utesting.T, query *filterQuery) {
|
func (s *filterTestSuite) queryAndCheck(t *utesting.T, query *filterQuery) {
|
||||||
query.run(s.cfg.client, s.cfg.historyPruneBlock)
|
query.run(s.cfg.client, s.cfg.historyPruneBlock)
|
||||||
|
if query.Err == errPrunedHistory {
|
||||||
|
return
|
||||||
|
}
|
||||||
if query.Err != nil {
|
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)
|
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
|
return
|
||||||
|
|
@ -126,6 +129,9 @@ func (s *filterTestSuite) fullRangeQueryAndCheck(t *utesting.T, query *filterQue
|
||||||
Topics: query.Topics,
|
Topics: query.Topics,
|
||||||
}
|
}
|
||||||
frQuery.run(s.cfg.client, s.cfg.historyPruneBlock)
|
frQuery.run(s.cfg.client, s.cfg.historyPruneBlock)
|
||||||
|
if frQuery.Err == errPrunedHistory {
|
||||||
|
return
|
||||||
|
}
|
||||||
if frQuery.Err != nil {
|
if frQuery.Err != nil {
|
||||||
t.Errorf("Full range filter query failed (addresses: %v topics: %v error: %v)", frQuery.Address, frQuery.Topics, frQuery.Err)
|
t.Errorf("Full range filter query failed (addresses: %v topics: %v error: %v)", frQuery.Address, frQuery.Topics, frQuery.Err)
|
||||||
return
|
return
|
||||||
|
|
@ -206,14 +212,10 @@ func (fq *filterQuery) run(client *client, historyPruneBlock *uint64) {
|
||||||
Addresses: fq.Address,
|
Addresses: fq.Address,
|
||||||
Topics: fq.Topics,
|
Topics: fq.Topics,
|
||||||
})
|
})
|
||||||
if err != nil {
|
|
||||||
if err = validateHistoryPruneErr(fq.Err, uint64(fq.FromBlock), historyPruneBlock); err == errPrunedHistory {
|
|
||||||
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.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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,9 @@ func filterGenCmd(ctx *cli.Context) error {
|
||||||
f.updateFinalizedBlock()
|
f.updateFinalizedBlock()
|
||||||
query := f.newQuery()
|
query := f.newQuery()
|
||||||
query.run(f.client, nil)
|
query.run(f.client, nil)
|
||||||
|
if query.Err == errPrunedHistory {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if query.Err != nil {
|
if query.Err != nil {
|
||||||
f.errors = append(f.errors, query)
|
f.errors = append(f.errors, query)
|
||||||
continue
|
continue
|
||||||
|
|
@ -82,6 +85,9 @@ func filterGenCmd(ctx *cli.Context) error {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
extQuery.run(f.client, nil)
|
extQuery.run(f.client, nil)
|
||||||
|
if extQuery.Err == errPrunedHistory {
|
||||||
|
break
|
||||||
|
}
|
||||||
if extQuery.Err == nil && len(extQuery.results) < len(query.results) {
|
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",
|
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),
|
query.FromBlock, query.ToBlock, len(query.results),
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ var (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const passCount = 1
|
const passCount = 3
|
||||||
|
|
||||||
func filterPerfCmd(ctx *cli.Context) error {
|
func filterPerfCmd(ctx *cli.Context) error {
|
||||||
cfg := testConfigFromCLI(ctx)
|
cfg := testConfigFromCLI(ctx)
|
||||||
|
|
@ -61,7 +61,7 @@ func filterPerfCmd(ctx *cli.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run test queries.
|
// Run test queries.
|
||||||
var failed, mismatch int
|
var failed, pruned, mismatch int
|
||||||
for i := 1; i <= passCount; i++ {
|
for i := 1; i <= passCount; i++ {
|
||||||
fmt.Println("Performance test pass", i, "/", passCount)
|
fmt.Println("Performance test pass", i, "/", passCount)
|
||||||
for len(queries) > 0 {
|
for len(queries) > 0 {
|
||||||
|
|
@ -71,6 +71,10 @@ func filterPerfCmd(ctx *cli.Context) error {
|
||||||
queries = queries[:len(queries)-1]
|
queries = queries[:len(queries)-1]
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
qt.query.run(cfg.client, cfg.historyPruneBlock)
|
qt.query.run(cfg.client, cfg.historyPruneBlock)
|
||||||
|
if qt.query.Err == errPrunedHistory {
|
||||||
|
pruned++
|
||||||
|
continue
|
||||||
|
}
|
||||||
qt.runtime = append(qt.runtime, time.Since(start))
|
qt.runtime = append(qt.runtime, time.Since(start))
|
||||||
slices.Sort(qt.runtime)
|
slices.Sort(qt.runtime)
|
||||||
qt.medianTime = qt.runtime[len(qt.runtime)/2]
|
qt.medianTime = qt.runtime[len(qt.runtime)/2]
|
||||||
|
|
@ -80,18 +84,19 @@ func filterPerfCmd(ctx *cli.Context) error {
|
||||||
}
|
}
|
||||||
if rhash := qt.query.calculateHash(); *qt.query.ResultHash != rhash {
|
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)
|
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
|
continue
|
||||||
}
|
}
|
||||||
processed = append(processed, qt)
|
processed = append(processed, qt)
|
||||||
if len(processed)%50 == 0 {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
queries, processed = processed, nil
|
queries, processed = processed, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show results and stats.
|
// 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))
|
stats := make([]bucketStats, len(f.queries))
|
||||||
var wildcardStats bucketStats
|
var wildcardStats bucketStats
|
||||||
for _, qt := range queries {
|
for _, qt := range queries {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue