Comments (17)
Hello, neo-project/neo#1891.
from neo-devpack-dotnet.
from neo-devpack-dotnet.
Wait, what? Aren't them all string?
from neo-devpack-dotnet.
No, BigInteger
is an Integer
and the ByteString
im guess is either a String
or ByteArray
biginteger::main[1] ...
False
biginteger::main['\x01'] ...
True
biginteger::debugfunction main
VMState.BREAK SourceCodeBreakpoint BigIntegerTest.cs line 21 instructionPointer 47: return i == stored;
stored: {'type': 'ByteString', 'value': 'AQ=='}
i: {'type': 'Integer', 'value': '1'}
from neo-devpack-dotnet.
I mean in your code:
public static bool Main(ByteString i)
{
ByteString stored = Storage.Get(Storage.CurrentContext, "i");
return i == stored;
}
ByteString i == ByteString stored
I dont see any problem here
from neo-devpack-dotnet.
Passing an Integer
in as a parameter will make it equal False
. For example in the test if you pass in 1
it will be False
and passing in \x01
will return True
from neo-devpack-dotnet.
I think the compiler is OK, because it is always just an INITSLOT for the start of a method.
from neo-devpack-dotnet.
How are you calling the method? In `RPC?
from neo-devpack-dotnet.
using System.ComponentModel;
using Neo.SmartContract.Framework;
using Neo.SmartContract.Framework.Attributes;
using Neo.SmartContract.Framework.Services;
namespace BigIntegerTest
{
[DisplayName("BigIntegerTest")]
[ManifestExtra("Author", "Hecate2")]
[ManifestExtra("Email", "[email protected]")]
[ManifestExtra("Description", "ByteString comparison")]
public class BigIntegerTest : SmartContract
{
public static void _deploy(object data, bool update)
{
Storage.Put(Storage.CurrentContext, "i", 1);
}
public static bool Main(ByteString i)
{
ByteString stored = Storage.Get(Storage.CurrentContext, "i");
return i == stored;
}
}
}
from neo_fairy_client import FairyClient, Hash160Str
user = Hash160Str('0xb1983fa2479a0c8e2beae032d2df564b5451b7a5')
c = FairyClient(fairy_session='biginteger', wallet_address_or_scripthash=user)
c.virutal_deploy_from_path('./bin/sc/BigIntegerTest.nef')
print(c.invokefunction('main', [1]))
print(c.invokefunction('main', ['\x01']))
c.delete_source_code_breakpoints()
c.set_source_code_breakpoint('BigIntegerTest.cs', 21)
print(c.debug_function_with_session('main', [1]))
print('stored:', c.get_variable_value_by_name('stored'))
print('i:', c.get_variable_value_by_name('i'))
biginteger::main[1] relay=True [{'account': '0xb1983fa2479a0c8e2beae032d2df564b5451b7a5', 'scopes': 'CalledByEntry', 'allowedcontracts': [], 'allowedgroups': [], 'rules': []}]
False
biginteger::main['\x01'] relay=True [{'account': '0xb1983fa2479a0c8e2beae032d2df564b5451b7a5', 'scopes': 'CalledByEntry', 'allowedcontracts': [], 'allowedgroups': [], 'rules': []}]
True
biginteger::debugfunction main[1]
VMState.BREAK SourceCodeBreakpoint BigIntegerTest.cs line 21 instructionPointer 47: return i == stored;
stored: {'type': 'ByteString', 'value': 'AQ=='}
i: {'type': 'Integer', 'value': '1'}
from neo-devpack-dotnet.
How are you calling the method? In `RPC?
Yes, in neo-fairy-client.
from neo-devpack-dotnet.
You using neon-js
or RpcClient
?
from neo-devpack-dotnet.
neo-fairy-client development by them is a very useful tool, @cschuchardt88 you can check it out.
from neo-devpack-dotnet.
@Jim8y either way. There is a problem with the ByteString
and BigInteger
comparer in NCCS
. Because ByteString == BigInteger
is not equal when BigInteger
. We need to add type checking validation or fix by CONVERT
parameter to type that is specified in the parameter of the method. NCCS
should fail it someone passes in a ByteArray
into a parameter that is BigInteger
unless you auto CONVERT
to Biginteger
. The types are to loose. You need to strict them to the types that they are. Because ApplicationEngine
does care.
from neo-devpack-dotnet.
you want extra parameter type check,,,, make sense,,,, and we can make it, ABI actually contains the parameter type.
from neo-devpack-dotnet.
@Jim8y looks like when you pass in type Integer
into ApplicationEngine
. It stores as Integer
in VM. Which is ok. But compiler should have type checking and strict parameters to their type for the reason in our case. so NCCS
should throw error for stored == i
forcing you to do stored == (ByteString)i
or stored == i.ToByteArray()
in the contract. So this way NCCS
generates an CONVERT
opcode for in VM
from neo-devpack-dotnet.
In our contract example, we never defined any BigInteger, and it should be quite OK to compare two ByteStrings. Maybe we can add a method in the RPC and neo-cli to invoke contracts with strict types.
from neo-devpack-dotnet.
@Hecate2 we wouldn't have the contract manifest
to compare too.
from neo-devpack-dotnet.
Related Issues (20)
- Make `Runtime.ScriptContainer` return a Transaction object HOT 8
- Map.toString() throwing Exception: An unhandled exception was thrown. Key not found in Map HOT 18
- Add support to Array.Empty HOT 1
- Move TestClasses into a separate project
- UTs are not working on macOS / VSCode
- Automatically include "Debug" event when building in debug mode
- How can we avoid problems with different .NET versions? What's the best way to distribute the compiler? HOT 9
- Create a TestEngine HOT 21
- StoredAttribute default value when integer is not working
- Release workflow doesn't work HOT 2
- Use github packages without user and password HOT 7
- Neo submodule issue HOT 6
- Release workflow may not work HOT 2
- Fix hardcoded version for packing
- Update neo submodule
- TestEngine: Coverage and test current smart contracts HOT 1
- Allow to compile a cs files without a project
- Avoid reuse the same namespace in devpack HOT 2
- property.SetMethod is null, compilation failed HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neo-devpack-dotnet.