This project is part of the neopt macro project, a C++ implementation of Neo Blockchain components, focused on portability.
-
finish BigInteger libraries: completed
-
port BigInteger libraries to NeoVM: ongoing
-
port json tests: todo
Currently, thirdparty/neo-vm-3
is locked at https://github.com/neo-project/neo-vm.git project, master branch:
- commit
defb2371d9a6a032bdea94e0c8b903a4729c9152
- date:Fri Dec 18 17:22:02 2020 +0800
Please use this as reference, and only advance when C++ project is ready to evolve (or is locked for so long time...)
Existing frameworks use high-level languages that may not be suitable for very lightweight architectures, such as microcontrollers with very limited computing capabilities.
C/C++ is interoperable with nearly all existing languages, so the idea is to provide modules that can be reused on other projects (on other languages too).
Note: this project is still being ported out of neopt, since other community projects have interest in using this special component in a very separate manner. In a few days, much more things should be here ;)
There are currently two implementations for NeoVM version 3: nvm3_native.cpp
or nvm3_mono.cpp
.
This implementation depends on csBigInteger C++ implementation.
On debian-based systems (or ubuntu), just type make vendor
(it will install libgmp-dev
package).
Mono implementation will generate a nvm3_dotnet.dll
and load it through nvm3_mono.so
(in the same manner currently done by csBigInteger library). It is much more complex process, but it guarantees that original NeoVM3 on C# is being used.
If you want to go this way, you will also need mono:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
sudo apt install apt-transport-https ca-certificates
echo "deb https://download.mono-project.com/repo/ubuntu stable-xenial main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update
sudo apt install mono-complete
It will also configure test library (as long as you cloned this project with --submodules
too).
To test, just run make test
.
Currently, C++11 is adopted, in order to keep the best compatibility between conversors and compilers. However, it is recommended to migrate to C++17 as soon as possible, if this does not break compatibility with any existing modules and tools.
Let's please follow the CppCoreGuidelines.
If using vscode IDE, it is recommended to install the following extensions:
- C/C++ (currently 0.23.0-insiders2)
- C++ Intellisense (currently 0.2.2)
- GoogleTest Adapter (currently 1.8.3)
The currently adopted style for C++ is Mozilla
, with indentation level set to 3.
Recommended configuration for vscode:
{
"[cpp]": {
"editor.tabSize" : 3,
"editor.detectIndentation": false
},
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle : Mozilla , ColumnLimit : 0, IndentWidth: 3, AccessModifierOffset: -3}"
}
The naming style for variables and methods is based on C#
language.
So, CamelCase is used and public
variables start with upper-case letters, while private
and local
variables start with lower-case.
The idea is to preseve maximum compatibility with reference project (which is on C#).
Anything that is beyond the scope of the reference project can use classic CamelCase C++
naming (for example, starting variables with lower-case).
Code follows MIT License
.
Implementation BigIntegerGMP.cpp
(class implementation of standard BigInteger.h
) is LGPLv3
. The reason is that this implementation depends on GNU MP Bignum Library (licensed LGPLv3 since version 6), what means that all modifications of BigIntegerGMP.cpp
, or usage of its code (even partially) on other projects should also adopt LGPLv3
(not MIT License).
Implementation BigIntegerMono.cpp
depends on Mono license, which is also MIT License.
The binaries generated by this project (nvm3_native.so
or nvm3_mono.so
) can be freely used on other projects, regardless of license.