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

[3.0] fix inconsistency in ABI generated for map #38

Merged
merged 1 commit into from
Sep 23, 2022

Conversation

linh2931
Copy link
Member

Change Description

Resolve #34.

Please see #34 for detailed problem description and solution discussion.

Previously, map ABI was a pair of key and value. If a pair's component types were the same as a map, depending on the order of map and pair definition, different ABIs for pair were generated.

For example, before the fix, pair_int32_int64 were different depending on my_map was defined before or after my_pair:

std::map<int32_t, int64_t> my_map; 
std::pair<int32_t, int64_t> my_pair;

generates

        {
            "name": "pair_int32_int64",
            "base": "",
            "fields": [
                {
                    "name": "key",
                    "type": "int32"
                },
                {
                    "name": "value",
                    "type": "int64"
                }
            ]
        },
...
        [
                {
                    "name": "my_map",
                    "type": "pair_int32_int64[]"
                },
                {
                    "name": "my_pair",
                    "type": "pair_int32_int64"
                }
        ]
std::pair<int32_t, int64_t> my_pair;
std::map<int32_t, int64_t> my_map;

generates

        {
            "name": "pair_int32_int64",
            "base": "",
            "fields": [
                {
                    "name": "first",
                    "type": "int32"
                },
                {
                    "name": "first",
                    "type": "int64"
                }
            ]
        },
...
       [
                {
                    "name": "my_pair",
                    "type": "pair_int32_int64"
                },
                {
                    "name": "my_map",
                    "type": "pair_int32_int64[]"
                }
       ]

After the fix, both produce the same ABI for pair_int32_int64

    {
         "name": "pair_int32_int64",
         "base": "",
         "fields": [
             {
                 "name": "first",
                 "type": "int32"
             },
             {
                 "name": "second",
                 "type": "int64"
             }
         ]
     },
...
     [
           {
                 "name": "my_map",
                  "type": "pair_int32_int64[]"
           },
           {
                 "name": "my_pair",
                 "type": "pair_int32_int64"
           }
    ]

In addition, Reference Contracts https://github.com/AntelopeIO/reference-contracts were tested against the new CDT and CDT 3.0.0, ABIs generated by both CDTs were the same.

API Changes

  • API Changes

Documentation Additions

  • Documentation Additions

@linh2931 linh2931 requested review from larryk85 and arhag September 23, 2022 16:44
@linh2931 linh2931 merged commit c22f4c7 into release/3.0 Sep 23, 2022
@linh2931 linh2931 deleted the fix_map_abi_generation branch September 23, 2022 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants