neo-go
neo-go copied to clipboard
packmap operation keeps duplicate entries
Current Behavior
packmap keeps duplicate keys (and entries) behavior might be considered undefined, though its probably better to copy C# implementation
[
{
"type": "Map",
"value": [
{
"key": {
"type": "Integer",
"value": "1"
},
"value": {
"type": "Integer",
"value": "1"
}
},
{
"key": {
"type": "Integer",
"value": "1"
},
"value": {
"type": "Integer",
"value": "1"
}
}
]
}
]
Expected Behavior
C# results:
[
{
"type": "Map",
"value": [
{
"key": {
"type": "Integer",
"value": "1"
},
"value": {
"type": "Integer",
"value": "1"
}
}
]
}
]
Possible Solution
Steps to Reproduce
-
./bin/neo-go vm -
loadbase64 ERERERK+ -
run
Your Environment
- Version of the product used: master (a9242535db757faba860e21c194033f30c679f48)
Wow, a really unexpected bug! Sure, it should be aligned with C# implementation. They use an ordered dictionary for the internal Map item implementation, so the bug is legit. https://github.com/neo-project/neo/blob/3f2f78c1fcf71ea51f2c40c3a0e67062ac390aed/src/Neo.VM/JumpTable/JumpTable.Compound.cs#L45 https://github.com/neo-project/neo/blob/3f2f78c1fcf71ea51f2c40c3a0e67062ac390aed/src/Neo.VM/Types/Map.cs#L63
And it's a map, it can't have duplicate keys, one key --- one value.