block-core / blockcore

Open source .NET Core Bitcoin based blockchain node in C#
https://www.blockcore.net
219 stars 90 forks source link

mempool bug found on bitcoin network #323

Open dangershony opened 3 years ago

dangershony commented 3 years ago
There was a problem initializing the node. Details: 'System.AggregateException: One or more errors occurred. (One or more errors occurred. (Unable to sort because the IComparer.Compare() method returns inconsistent results. Either a value does not compare equal to itself, or one value repeatedly compared to another value yields different results. IComparer: 'System.Collections.Generic.ComparisonComparer`1[System.Int32]'.))
 ---> System.AggregateException: One or more errors occurred. (Unable to sort because the IComparer.Compare() method returns inconsistent results. Either a value does not compare equal to itself, or one value repeatedly compared to another value yields different results. IComparer: 'System.Collections.Generic.ComparisonComparer`1[System.Int32]'.)
 ---> System.ArgumentException: Unable to sort because the IComparer.Compare() method returns inconsistent results. Either a value does not compare equal to itself, or one value repeatedly compared to another value yields different results. IComparer: 'System.Collections.Generic.ComparisonComparer`1[System.Int32]'.
   at System.Collections.Generic.IntrospectiveSortUtilities.ThrowOrIgnoreBadComparer(Object comparer)
   at System.Collections.Generic.GenericArraySortHelper`1.Sort(T[] keys, Int32 index, Int32 length, IComparer`1 comparer)
   at System.Array.Sort[T](T[] array, Int32 index, Int32 length, IComparer`1 comparer)
   at System.Linq.EnumerableSorter`1.Sort(TElement[] elements, Int32 count)
   at System.Linq.OrderedEnumerable`1.GetEnumerator()+MoveNext()
   at System.Linq.Enumerable.SelectIPartitionIterator`2.ToList()
   at Blockcore.Features.MemoryPool.MempoolManager.InfoAll() in C:\Users\Dan\Documents\GitHub\blockcore\src\Features\Blockcore.Features.MemoryPool\MempoolManager.cs:line 109
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location where exception was thrown ---
   at Blockcore.Features.MemoryPool.MempoolBehavior.SendMempoolPayloadAsync(INetworkPeer peer, MempoolPayload message) in C:\Users\Dan\Documents\GitHub\blockcore\src\Features\Blockcore.Features.MemoryPool\MempoolBehavior.cs:line 251
   at Blockcore.Features.MemoryPool.MempoolBehavior.ProcessMessageAsync(INetworkPeer peer, IncomingMessage message) in C:\Users\Dan\Documents\GitHub\blockcore\src\Features\Blockcore.Features.MemoryPool\MempoolBehavior.cs:line 219
   at Blockcore.Features.MemoryPool.MempoolBehavior.OnMessageReceivedAsync(INetworkPeer peer, IncomingMessage message) in C:\Users\Dan\Documents\GitHub\blockcore\src\Features\Blockcore.Features.MemoryPool\MempoolBehavior.cs:line 183
   at Blockcore.Utilities.AsyncExecutionEvent`2.ExecuteCallbacksAsync(TSender sender, TArg arg) in C:\Users\Dan\Documents\GitHub\blockcore\src\Blockcore\Utilities\AsyncExecutionEvent.cs:line 156
   at Blockcore.P2P.Peer.NetworkPeer.ProcessMessageAsync(IncomingMessage message, CancellationToken cancellation) in C:\Users\Dan\Documents\GitHub\blockcore\src\Blockcore\P2P\Peer\NetworkPeer.cs:line 553
   at Blockcore.AsyncWork.AsyncQueue`1.ConsumerAsync() in C:\Users\Dan\Documents\GitHub\blockcore\src\Blockcore\AsyncWork\AsyncQueue.cs:line 151
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Blockcore.AsyncWork.AsyncQueue`1.DisposeInternal(Boolean calledFromConsumerTask) in C:\Users\Dan\Documents\GitHub\blockcore\src\Blockcore\AsyncWork\AsyncQueue.cs:line 266
   at Blockcore.P2P.Peer.NetworkPeerConnection.Dispose() in C:\Users\Dan\Documents\GitHub\blockcore\src\Blockcore\P2P\Peer\NetworkPeerConnection.cs:line 473
   at Blockcore.P2P.Peer.NetworkPeer.Dispose() in C:\Users\Dan\Documents\GitHub\blockcore\src\Blockcore\P2P\Peer\NetworkPeer.cs:line 935
   at Blockcore.P2P.Peer.NetworkPeerDisposer.OnEnqueueAsync(INetworkPeer peer, CancellationToken cancellationToken) in C:\Users\Dan\Documents\GitHub\blockcore\src\Blockcore\P2P\Peer\NetworkPeerDisposer.cs:line 83
   at Blockcore.AsyncWork.AsyncQueue`1.ConsumerAsync() in C:\Users\Dan\Documents\GitHub\blockcore\src\Blockcore\AsyncWork\AsyncQueue.cs:line 151
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Blockcore.AsyncWork.AsyncQueue`1.DisposeInternal(Boolean calledFromConsumerTask) in C:\Users\Dan\Documents\GitHub\blockcore\src\Blockcore\AsyncWork\AsyncQueue.cs:line 266
   at Blockcore.P2P.Peer.NetworkPeerDisposer.Dispose() in C:\Users\Dan\Documents\GitHub\blockcore\src\Blockcore\P2P\Peer\NetworkPeerDisposer.cs:line 109
   at Blockcore.P2P.Peer.NetworkPeerServer.Dispose() in C:\Users\Dan\Documents\GitHub\blockcore\src\Blockcore\P2P\Peer\NetworkPeerServer.cs:line 195
   at Blockcore.Connection.ConnectionManager.Dispose() in C:\Users\Dan\Documents\GitHub\blockcore\src\Blockcore\Connection\ConnectionManager.cs:line 366
   at Blockcore.FullNode.Dispose() in C:\Users\Dan\Documents\GitHub\blockcore\src\Blockcore\FullNode.cs:line 287
   at Blockcore.Utilities.FullNodeExtensions.RunAsync(IFullNode node, CancellationToken cancellationToken) in C:\Users\Dan\Documents\GitHub\blockcore\src\Blockcore\Utilities\FullNodeExtensions.cs:line 100
   at Blockcore.Utilities.FullNodeExtensions.RunAsync(IFullNode node) in C:\Users\Dan\Documents\GitHub\blockcore\src\Blockcore\Utilities\FullNodeExtensions.cs:line 54
   at Blockcore.Node.Program.Main(String[] args) in C:\Users\Dan\Documents\GitHub\blockcore\src\Node\Blockcore.Node\Program.cs:line 34'
dangershony commented 3 years ago

Looking at the code I assume its because the mempool call to the collection is not locked.