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

api: fix Map key processing #283

Merged
merged 1 commit into from
Sep 29, 2023
Merged

api: fix Map key processing #283

merged 1 commit into from
Sep 29, 2023

Conversation

ixje
Copy link
Member

@ixje ixje commented Sep 28, 2023

The problems

  1. The NEO Virtual Machine has a Map type which translates to a dict on the Python side. The keys are restricted to what they call PrimitiveTypes being Boolean , Integer and ByteString stack item types (respectively bool, int and str in Python).

    However, it is also possible to push bytes using the PUSHDATA opcodes which will be converted to a ByteString stack item type. Therefore we can no longer assume that when the VM returns a ByteString stack item that it is always a str.

  2. int key types would incorrectly be converted to str.

The solution
This PR removes the "ByteString == str" assumption and also removes the int -> str conversion.

@ixje ixje requested a review from luc10921 September 28, 2023 09:33
@coveralls
Copy link

Coverage Status

coverage: 80.755% (+0.004%) from 80.751% when pulling e2d5ae9 on map-int-key into 4ac098c on master.

@ixje ixje merged commit 8060778 into master Sep 29, 2023
11 checks passed
@ixje ixje deleted the map-int-key branch September 29, 2023 13:51
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.

3 participants