-
Notifications
You must be signed in to change notification settings - Fork 102
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
Map does not respect K,V types #769
Comments
I think this could have also been prevented by neo-project/neo#1891 (which is closed for what seems like no apparent reason) |
This issue actually hits a similar problem where it cannot trust that what is returned from storage is converted back to the type one wishes |
This convert to Integer from obj |
I don't understand your reply. The above code is a snippet from a contract that is deployed by GhostMarket. That means it compiled without errors and therefore giving the programmer the false idea that the casting works (because the analysis in my post shows it actually doesn't do anything). |
Let's move this forward, @ixje. @superboyiii, |
Perhaps it has been closed by #835 (comment) |
Close as completed |
I don't believe this is fixed by #835. #835 is a work around but everything said in #769 (comment) is still valid. Unless some warning is printed when using code like in the snippet in the comment people will continue to face this problem. |
I will double check, you can use getinteger now. |
Background
I'm helping the GhostMarket team debug why a
transfer
event is emitted with aByteString
foramount
instead of anInteger
(as should be per NEP-17 spec) to prevent problems once the Notify ABI validation PR gets merged.We have 3 transactions on T5 that can be summarized as
transfer
on Python Nep-17 contract, emits amount asByteString
transfer
on non-native C# Nep-17 contract, emits amount asByteString
transfer
on native Nep-17 contract, emits amount asint
ContractA
is a C# contract where theClaimTradingFees
function is calledIssue
I found that the cast to BigInteger has no effect once translated to nvm code.
In other words; it it retrieved from the
iterator.value
as aByteString
and it is stored as aByteString
in the map. When executed it looks like thisNo where in the execution do we see a
CONVERT
toIntegerStackItem
to respect theBigInteger
value type of the map.The same holds for reading the value from the map here
Which looks just like this
and no
CONVERT
happens after it anywhere.The reason transaction
3.
(to a native contract) emitsamount
as integer is because it does parameter conversion here prior to callingtransfer()
solution
One option is for contracts to perform parameter type checking. However, I still think that the
Map
K,V
types could and should be respected otherwise it becomes really hard to reason about the code you're writing.The text was updated successfully, but these errors were encountered: