-
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
bug: Fix default value when Stored #895
Changes from all commits
be7dfec
04e252e
32a14c8
a32baf5
f47eed2
8f722ad
26db4e6
63c1f13
b454f74
74e7b72
edcd9fa
e8f42a5
6e258f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -574,21 +574,42 @@ private void ConvertStorageBackedProperty(IPropertySymbol property, AttributeDat | |
Call(ApplicationEngine.System_Storage_Get); | ||
switch (property.Type.Name) | ||
{ | ||
case "SByte": | ||
case "Short": | ||
case "Int32": | ||
case "Int64": | ||
case "byte": | ||
case "sbyte": | ||
case "Byte": | ||
case "SByte": | ||
|
||
case "short": | ||
case "ushort": | ||
case "Int16": | ||
case "UInt16": | ||
|
||
case "int": | ||
case "uint": | ||
case "Int32": | ||
case "UInt32": | ||
|
||
case "long": | ||
case "ulong": | ||
case "Int64": | ||
case "UInt64": | ||
case "BigInteger": | ||
ChangeType(VM.Types.StackItemType.Integer); | ||
// Replace NULL with 0 | ||
AddInstruction(OpCode.DUP); | ||
AddInstruction(OpCode.ISNULL); | ||
JumpTarget ifFalse = new(); | ||
Jump(OpCode.JMPIFNOT_L, ifFalse); | ||
{ | ||
AddInstruction(OpCode.DROP); | ||
AddInstruction(OpCode.PUSH0); | ||
} | ||
ifFalse.Instruction = AddInstruction(OpCode.NOP); | ||
break; | ||
case "String": | ||
case "ByteString": | ||
case "UInt160": | ||
case "UInt256": | ||
case "ECPoint": | ||
break; | ||
default: | ||
Call(NativeContract.StdLib.Hash, "deserialize", 1, true); | ||
|
@@ -620,19 +641,31 @@ private void ConvertStorageBackedProperty(IPropertySymbol property, AttributeDat | |
AccessSlot(OpCode.LDARG, 1); | ||
switch (property.Type.Name) | ||
{ | ||
case "SByte": | ||
case "Short": | ||
case "Int32": | ||
case "Int64": | ||
case "byte": | ||
case "sbyte": | ||
case "Byte": | ||
case "SByte": | ||
|
||
case "short": | ||
case "ushort": | ||
case "Int16": | ||
case "UInt16": | ||
|
||
case "int": | ||
case "uint": | ||
case "Int32": | ||
case "UInt32": | ||
|
||
case "long": | ||
case "ulong": | ||
case "Int64": | ||
case "UInt64": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not an issue here, but should we check the length of UInt160, UInt256 and ECPoint? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the unique way to set a different value in a property is because an storage collision (same prefix) and manual write to the same storage |
||
case "BigInteger": | ||
case "String": | ||
case "ByteString": | ||
case "UInt160": | ||
case "UInt256": | ||
case "ECPoint": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change can break existing contracts on upgrade IIUC. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but it's wrong, I think that we don't have any release with Stored attribute There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The user should review the breaking changes #900 until a more stable version There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, yes, it was added in #841 and there were no releases since November, so it should be OK changing it now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Stored attribute is still not released. Won't cause any trouble. |
||
break; | ||
default: | ||
Call(NativeContract.StdLib.Hash, "serialize", 1, true); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the bug
https://github.com/neo-project/neo/blob/4a5a7f58567c1bf270d1c5515d90486c803b4e11/src/Neo.VM/Types/Null.cs#L30