-
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
AllowOverflow option to avoid checking int range #1205
base: master
Are you sure you want to change the base?
Conversation
Changed the methodology. Skip range checks and throws with compilation option |
Need a way to compile neo-devpack-dotnet\tests\Neo.Compiler.CSharp.TestContracts\Contract_BigInteger.cs with SimulateOverflow=true |
Allowed CompilationOptions to be used in tests. |
…to unchecked # Conflicts: # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Array.cs # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_BigInteger.cs # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Delegate.cs # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Foreach.cs # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Inline.cs # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Lambda.cs # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Linq.cs # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_NullableType.cs # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Out.cs # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Params.cs # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_PostfixUnary.cs # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Record.cs # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Returns.cs # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_StaticVar.cs # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Switch.cs # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_TryCatch.cs # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_shift.cs # tests/Neo.Compiler.CSharp.UnitTests/UnitTest_NullableType.cs # tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_List.cs # tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_Map.cs # tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_Regex.cs # tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_Runtime.cs
This name is so scary.... |
this can save tons of gas, yes,,,,,, but,,,,,,, |
rather than allow overflow, i think biginteger only is better |
We should not save gas if the security is involved |
Sorry miss click |
No security problem is involved. This is just handling all int, long, short as BigInteger. |
Sometimes it's impossible to write BigInteger everywhere literally in codes. For example, shifting operations (>> and <<) in C# supports only int as the shifted count of bits. Also indexes of arrays have to be int. Then we have to write an explicit coversion (int) which wastes a range check. |
And our current default settings (with or without my PR) are --checked=false (--allow-overflow=false). This allows silent overflows (from int.MaxValue to int.MinValue, without or without my PR). I think this is even more dangerous. Maybe it's better to have default as --checked=false --allow-overflow=true, or --checked=true --allow-overflow=false |
we should detect |
We are actually detecting it (with or without this PR). But by default everything is unchecked. |
excatly, just use what is allowed in biginteger. |
…to unchecked # Conflicts: # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Out.cs
…to unchecked # Conflicts: # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Polymorphism.cs
…to unchecked # Conflicts: # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_GoTo.cs # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Initializer.cs # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_TryCatch.cs # tests/Neo.Compiler.CSharp.UnitTests/UnitTest_GoTo.cs
unchecked((int)bigInteger))
Will conflict. Draft for now.