-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Fixed GetString
method on VM Types
#3489
Conversation
@shargon @Jim8y @AnnaShaleva would this need to be a |
do we need it? |
It require a hardfork, and we have syscall for the conversion, we don't need it in my opinion |
But currently its returning invalid For example (Currently) var i = (Integer)BigInteger.One;
var str = i.GetString(); // Output is "\x01" not "1" |
GetString
method on VM Integer
typeGetString
method on VM Types
If it causes a hardfork, then we can live without this fix, to me it just doesn't worth the hardfork. |
What's the big deal with it being in the next hardfork? You want to keep invalid or bugged data on chain, than be my guess. So I guess i should stop fixing the vm, since I can't get anywhere? Give me one good reason, besides you don't want too? |
It can be fixed in the compiler |
What about a plugins? or core itself. Compiler can't help there. |
If GetString returns binary data with an Integer, compiler can fix it |
But doesn't the vm use Also if i do Example: using var engine = ApplicationEngine.Run(script, _dataCache, settings: neoSystem.Settings, gas: RestServerSettings.Current.MaxGasInvoke);
if (engine.State != VMState.HALT)
throw new NotSupportedException(nameof(scriptHash));
var boolstr = engine.ResultStack.Pop().GetString() ?? string.Empty; // This is a boolean or interger |
It's not invalid. It's not bugged. It's just that this behavior doesn't meet your expectations. But this behavior is known and it exists for 3+ years of N3, there is a lot of code that is written relying on this behavior. This change will just break it. For what purpose? Does this change solve any problem that can't be solved in another way? No, int/string conversion can be handled otherwise. Can we live without it? Yes, easily. So why making this change? |
Everyone wants to keep the behavior of not allowing data types to be converted to |
Description
The
Integer
,Boolean
type in the VM would use the default binary bytes of theBigInteger
to output the string. My guess is they forgot tooverride
the method inInteger.cs
andBoolean.cs
.Now outputs the value of the integer. For example if
Integer
is1
then it outputs1
as astring
.Change Log
GetString
method on VMInteger
andBoolean
typeType of change
How Has This Been Tested?
Checklist: