Akagi201 / blockstm-go

General Block-STM execution engine for EVM in Go
Apache License 2.0
4 stars 1 forks source link

无法通过测试用例 #2

Closed SipengXie closed 2 weeks ago

SipengXie commented 2 months ago

我尝试运行executor_test.go,在很多测试用例中会出现超量弹出队列元素的操作

=== RUN   TestLessConflicts
=== PAUSE TestLessConflicts
=== CONT  TestLessConflicts
panic: Core Priority Queue Error: No items found in the queue

=== RUN   TestLessConflictsWithMetadata
=== PAUSE TestLessConflictsWithMetadata
=== CONT  TestLessConflictsWithMetadata
panic: Core Priority Queue Error: No items found in the queue

这发生在Pe.Prepare()中,代码尝试并行地执行SpeculativeTask:

if procNum < pe.numSpeculativeProcs {
    for range pe.scheduler.chSpeculativeTasks {
        doWork(pe.specTaskQueue.Pop())
    }
} else {
    for task := range pe.scheduler.chTasks {
        doWork(task)
    }
}
dev-ape-ai[bot] commented 2 months ago

👋 @SipengXie 😊

It looks like there's an issue with the queue operations in your implementation. From the error messages you provided, the issue pertains to attempts to pop from an empty queue, which results in a panic. This usually happens when the code tries to access queue elements without ensuring that the queue actually contains items.

Related Code

Unfortunately, I was unable to find snippets directly related to your codebase, specifically concerning the Pe.Prepare, scheduler, or queue interactions within the files mentioned. This might suggest an area where added debug logging or more defensive coding could be adopted to ensure no attempts are made to pop from an empty queue.

Related Search Results

Here are some resources that could be helpful in addressing your issue:

  1. Understanding panic in Go and error handling best practices
  2. GoLang Queue Package Documentation
  3. Error Handling in Go: Best Practices and Patterns
  4. Advanced Panic Handling in Go

Consider using checks like len(queue) > 0 before any pop operation or using more sophisticated queuing strategies. Additionally, adding more comprehensive error handling can prevent such a system from entering an inconsistent state. If you need more help with a specific part of the codebase, please provide those sections or further context so I can provide more targeted assistance!

SipengXie commented 2 months ago

我把Queue换成原来的非gpq实现的Queue就成功了