Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

packmap operation keeps duplicate entries #3613

Open
Slava0135 opened this issue Oct 14, 2024 · 2 comments
Open

packmap operation keeps duplicate entries #3613

Slava0135 opened this issue Oct 14, 2024 · 2 comments
Labels
bug Something isn't working I4 No visible changes S4 Routine U1 Critically important to resolve quickly vm VM tasks/bugs/issues
Milestone

Comments

@Slava0135
Copy link
Contributor

Slava0135 commented Oct 14, 2024

Current Behavior

packmap keeps duplicate keys (and entries)
behavior might be considered undefined, though its probably better to copy C# implementation

image

[
  {
    "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

  1. ./bin/neo-go vm
  2. loadbase64 ERERERK+
  3. run

Your Environment

  • Version of the product used: master (a924253)
@Slava0135 Slava0135 added bug Something isn't working U2 Seriously planned labels Oct 14, 2024
@AnnaShaleva AnnaShaleva added vm VM tasks/bugs/issues U1 Critically important to resolve quickly S4 Routine I4 No visible changes and removed U2 Seriously planned labels Oct 14, 2024
@AnnaShaleva AnnaShaleva added this to the v0.106.4 milestone Oct 14, 2024
@AnnaShaleva
Copy link
Member

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

@roman-khimov
Copy link
Member

And it's a map, it can't have duplicate keys, one key --- one value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working I4 No visible changes S4 Routine U1 Critically important to resolve quickly vm VM tasks/bugs/issues
Projects
None yet
Development

No branches or pull requests

3 participants