TopperTrieBatchImpl caches clearPrefix call separately for performance. This makes honest TopperTrieBatchImpl::empty implementation more expensive, because it would need to check that if the underlying trie is not empty, then it could become empty after applying all clearPrefixes. It doesn't do this currently, as this seems to be a very rare scenario.
Steps to Reproduce
A topper trie batch that is empty, but has pending clear prefix calls. Its underlying trie is not empty, but will become empty if 'clear prefix'es are applied. In this case TopperTrieBatchImpl::empty should return true, but will return false.
Effects of the Bug
Incorrect behaviour of TopperTrieBatchImpl::empty in a very rare case.
Bug Summary
TopperTrieBatchImpl::empty ignores cached clearPrefix calls.
Bug Description
TopperTrieBatchImpl caches clearPrefix call separately for performance. This makes honest TopperTrieBatchImpl::empty implementation more expensive, because it would need to check that if the underlying trie is not empty, then it could become empty after applying all clearPrefixes. It doesn't do this currently, as this seems to be a very rare scenario.
Steps to Reproduce
A topper trie batch that is empty, but has pending clear prefix calls. Its underlying trie is not empty, but will become empty if 'clear prefix'es are applied. In this case TopperTrieBatchImpl::empty should return true, but will return false.
Effects of the Bug
Incorrect behaviour of TopperTrieBatchImpl::empty in a very rare case.
Expected Behavior
See 'Steps to Reproduce'.
System Information
Any system.
Additional Context
No response