planetarium / libplanet

Blockchain in C#/.NET for on-chain, decentralized gaming
https://docs.libplanet.io/
GNU Lesser General Public License v2.1
506 stars 142 forks source link

System.Collections.Generic.KeyNotFoundException occurred while parsing GetRecentStates #531

Closed earlbread closed 4 years ago

earlbread commented 4 years ago
09/25/2019 08:56:48 +00:00: Something went wrong during message parsing: "System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
  at Libplanet.Store.BlockSet`1[T].get_Item (Libplanet.HashDigest`1[T] key) [0x00034] in <ded5f41b727f4d2a8edaa51acf068889>:0
  at Libplanet.Net.Swarm`1[T].TransferRecentStates (Libplanet.Net.Messages.GetRecentStates getRecentStates) [0x00140] in <ded5f41b727f4d2a8edaa51acf068889>:0
  at Libplanet.Net.Swarm`1+<ProcessMessageAsync>d__97[T].MoveNext () [0x0014a] in <ded5f41b727f4d2a8edaa51acf068889>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <1f0c1ef1ad524c38bbc5536809c46b48>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <1f0c1ef1ad524c38bbc5536809c46b48>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <1f0c1ef1ad524c38bbc5536809c46b48>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <1f0c1ef1ad524c38bbc5536809c46b48>:0
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <1f0c1ef1ad524c38bbc5536809c46b48>:0
  at Libplanet.Net.Swarm`1+<>c__DisplayClass111_0+<<ReceiveMessage>b__0>d[T].MoveNext () [0x0007b] in <ded5f41b727f4d2a8edaa51acf068889>:0 "
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
  at Libplanet.Store.BlockSet`1[T].get_Item (Libplanet.HashDigest`1[T] key) [0x00034] in <ded5f41b727f4d2a8edaa51acf068889>:0
  at Libplanet.Net.Swarm`1[T].TransferRecentStates (Libplanet.Net.Messages.GetRecentStates getRecentStates) [0x00140] in <ded5f41b727f4d2a8edaa51acf068889>:0
  at Libplanet.Net.Swarm`1+<ProcessMessageAsync>d__97[T].MoveNext () [0x0014a] in <ded5f41b727f4d2a8edaa51acf068889>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <1f0c1ef1ad524c38bbc5536809c46b48>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <1f0c1ef1ad524c38bbc5536809c46b48>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <1f0c1ef1ad524c38bbc5536809c46b48>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <1f0c1ef1ad524c38bbc5536809c46b48>:0
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <1f0c1ef1ad524c38bbc5536809c46b48>:0
  at Libplanet.Net.Swarm`1+<>c__DisplayClass111_0+<<ReceiveMessage>b__0>d[T].MoveNext () [0x0007b] in <ded5f41b727f4d2a8edaa51acf068889>:0
longfin commented 4 years ago

It seems to occur when two (or many) chains that don't share the genesis block sync each other. I'll handle it.

longfin commented 4 years ago

I was misunderstood about this problem. It doesn't relate with genesis sharing but relates with empty chain situation. I'll add test case and fix it.