1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

Merge branch 'ton-blockchain:testnet' into testnet

This commit is contained in:
Andrey Pfau 2023-12-02 17:04:02 +07:00 committed by GitHub
commit 52ad17406e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
153 changed files with 3777 additions and 4279 deletions

View file

@ -1,5 +1,5 @@
-xc++
-std=c++14
-std=c++17
-iquote .
-iquote tdtl/
-iquote tl/

View file

@ -3,8 +3,8 @@
# dependencies:
#sudo apt-get install -y build-essential git make cmake clang libgflags-dev zlib1g-dev libssl-dev libreadline-dev libmicrohttpd-dev pkg-config libgsl-dev python3 python3-dev python3-pip nodejs libevent-dev
export CC=$(which clang)
export CXX=$(which clang++)
export CC=$(which clang-16)
export CXX=$(which clang++-16)
export CCACHE_DISABLE=1
cd ../..
@ -13,7 +13,7 @@ echo `pwd`
git clone https://github.com/openssl/openssl.git
cd openssl
git checkout OpenSSL_1_1_1j
git checkout checkout openssl-3.1.4
./config
make -j16
OPENSSL_DIR=`pwd`
@ -37,7 +37,15 @@ cd ..
mkdir build
cd build
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DZLIB_LIBRARY=/usr/lib/x86_64-linux-gnu/libz.so -DZLIB_INCLUDE_DIR=$ZLIB_DIR -DOPENSSL_ROOT_DIR=$OPENSSL_DIR -DOPENSSL_INCLUDE_DIR=$OPENSSL_DIR/include -DOPENSSL_CRYPTO_LIBRARY=$OPENSSL_DIR/libcrypto.so -DOPENSSL_SSL_LIBRARY=$OPENSSL_DIR/libssl.so -DTON_USE_ABSEIL=OFF ..
cmake -GNinja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=17 \
-DZLIB_LIBRARY=/usr/lib/x86_64-linux-gnu/libz.so \
-DZLIB_INCLUDE_DIR=$ZLIB_DIR \
-DOPENSSL_ROOT_DIR=$OPENSSL_DIR \
-DOPENSSL_INCLUDE_DIR=$OPENSSL_DIR/include \
-DOPENSSL_CRYPTO_LIBRARY=$OPENSSL_DIR/libcrypto.so \
-DOPENSSL_SSL_LIBRARY=$OPENSSL_DIR/libssl.so \
-DTON_USE_ABSEIL=OFF ..
test $? -eq 0 || { echo "Can't configure TON build"; exit 1; }
@ -92,8 +100,23 @@ test $? -eq 0 || { echo "Can't compile libsodium with emmake "; exit 1; }
cd ../build
emcmake cmake -DUSE_EMSCRIPTEN=ON -DCMAKE_BUILD_TYPE=Release -DZLIB_LIBRARY=$ZLIB_DIR/libz.a -DZLIB_INCLUDE_DIR=$ZLIB_DIR -DOPENSSL_ROOT_DIR=$OPENSSL_DIR -DOPENSSL_INCLUDE_DIR=$OPENSSL_DIR/include -DOPENSSL_CRYPTO_LIBRARY=$OPENSSL_DIR/libcrypto.a -DOPENSSL_SSL_LIBRARY=$OPENSSL_DIR/libssl.a -DCMAKE_TOOLCHAIN_FILE=$EMSDK_DIR/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CXX_FLAGS="-sUSE_ZLIB=1" -DSECP256K1_INCLUDE_DIR=$SECP256K1_DIR/include -DSECP256K1_LIBRARY=$SECP256K1_DIR/.libs/libsecp256k1.a -DSODIUM_INCLUDE_DIR=$SODIUM_DIR/src/libsodium/include -DSODIUM_LIBRARY_RELEASE=$SODIUM_DIR/src/libsodium/.libs/libsodium.a -DSODIUM_LIBRARY_DEBUG=$SODIUM_DIR/src/libsodium/.libs/libsodium.a -DSODIUM_USE_STATIC_LIBS=ON ..
test $? -eq 0 || { echo "Can't configure TON with with emmake "; exit 1; }
emcmake cmake -DUSE_EMSCRIPTEN=ON -DCMAKE_BUILD_TYPE=Release \
-DZLIB_LIBRARY=$ZLIB_DIR/libz.a \
-DZLIB_INCLUDE_DIR=$ZLIB_DIR \
-DOPENSSL_ROOT_DIR=$OPENSSL_DIR \
-DOPENSSL_INCLUDE_DIR=$OPENSSL_DIR/include \
-DOPENSSL_CRYPTO_LIBRARY=$OPENSSL_DIR/libcrypto.a \
-DOPENSSL_SSL_LIBRARY=$OPENSSL_DIR/libssl.a \
-DCMAKE_TOOLCHAIN_FILE=$EMSDK_DIR/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
-DCMAKE_CXX_FLAGS="-sUSE_ZLIB=1" \
-DSECP256K1_INCLUDE_DIR=$SECP256K1_DIR/include \
-DSECP256K1_LIBRARY=$SECP256K1_DIR/.libs/libsecp256k1.a \
-DSODIUM_INCLUDE_DIR=$SODIUM_DIR/src/libsodium/include \
-DSODIUM_LIBRARY_RELEASE=$SODIUM_DIR/src/libsodium/.libs/libsodium.a \
-DSODIUM_LIBRARY_DEBUG=$SODIUM_DIR/src/libsodium/.libs/libsodium.a \
-DSODIUM_USE_STATIC_LIBS=ON ..
test $? -eq 0 || { echo "Can't configure TON with emmake "; exit 1; }
cp -R ../crypto/smartcont ../crypto/fift/lib crypto
emmake make -j16 funcfiftlib func fift tlbc emulator-emscripten

View file

@ -12,23 +12,58 @@ jobs:
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Compile OpenSSL
- name: Compile Secp256k1
run: |
git clone https://github.com/openssl/openssl openssl_1_1_1
cd openssl_1_1_1
git checkout OpenSSL_1_1_1-stable
./Configure --prefix=/usr/local/macos darwin64-x86_64-cc -static -mmacosx-version-min=11.7
make build_libs -j4
export NONINTERACTIVE=1
brew install ninja secp256k1 libsodium libmicrohttpd pkg-config automake libtool
git clone https://github.com/libbitcoin/secp256k1.git
cd secp256k1
./autogen.sh
./configure --enable-module-recovery
make
make install
- name: Build all
run: |
export NONINTERACTIVE=1
brew install ninja secp256k1 libsodium libmicrohttpd pkg-config
brew unlink openssl@1.1
brew install openssl@3
brew unlink openssl@3 && brew link --overwrite openssl@3
rootPath=`pwd`
mkdir build
cd build
cmake -GNinja -DOPENSSL_FOUND=1 -DOPENSSL_INCLUDE_DIR=$rootPath/openssl_1_1_1/include -DOPENSSL_CRYPTO_LIBRARY=$rootPath/openssl_1_1_1/libcrypto.a -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=11.7 -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_BUILD_TYPE=Release ..
ninja storage-daemon storage-daemon-cli blockchain-explorer fift func tonlib tonlibjson tonlib-cli validator-engine lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork tlbc emulator
cmake -GNinja -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=11.7 -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_BUILD_TYPE=Release ..
ninja storage-daemon storage-daemon-cli blockchain-explorer fift func tonlib tonlibjson tonlib-cli validator-engine \
lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server \
http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork tlbc emulator \
test-ed25519 test-ed25519-crypto test-bigint test-vm test-fift test-cells test-smartcont test-net test-tdactor \
test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain test-fec test-tddb test-db test-validator-session-state
- name: Strip binaries
run: |
strip build/storage/storage-daemon/storage-daemon
strip build/storage/storage-daemon/storage-daemon-cli
strip build/blockchain-explorer/blockchain-explorer
strip build/crypto/fift
strip build/crypto/func
strip build/crypto/create-state
strip build/crypto/tlbc
strip build/validator-engine-console/validator-engine-console
strip build/tonlib/tonlib-cli
strip build/http/http-proxy
strip build/rldp-http-proxy/rldp-http-proxy
strip build/dht-server/dht-server
strip build/lite-client/lite-client
strip build/validator-engine/validator-engine
strip build/utils/generate-random-id
strip build/utils/json2tlo
strip build/adnl/adnl-proxy
- name: Run tests
run: |
cd build
ctest --output-on-failure -E "test-catchain|test-actors"
- name: Find & copy binaries
run: |

View file

@ -12,18 +12,11 @@ jobs:
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Compile OpenSSL
run: |
export NONINTERACTIVE=1
brew install ninja libsodium automake
git clone https://github.com/openssl/openssl openssl_1_1_1
cd openssl_1_1_1
git checkout OpenSSL_1_1_1-stable
./Configure --prefix=/usr/local/macos darwin64-x86_64-cc -static -mmacosx-version-min=12.6
make build_libs -j4
- name: Compile Secp256k1
run: |
export NONINTERACTIVE=1
brew install ninja secp256k1 libsodium libmicrohttpd pkg-config automake libtool
git clone https://github.com/libbitcoin/secp256k1.git
cd secp256k1
./autogen.sh
@ -33,13 +26,44 @@ jobs:
- name: Build all
run: |
export NONINTERACTIVE=1
brew install ninja libmicrohttpd pkg-config
brew unlink openssl@1.1
brew install openssl@3
brew unlink openssl@3 && brew link --overwrite openssl@3
rootPath=`pwd`
mkdir build
cd build
cmake -GNinja -DOPENSSL_FOUND=1 -DOPENSSL_INCLUDE_DIR=$rootPath/openssl_1_1_1/include -DOPENSSL_CRYPTO_LIBRARY=$rootPath/openssl_1_1_1/libcrypto.a -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=12.6 -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_BUILD_TYPE=Release ..
ninja storage-daemon storage-daemon-cli blockchain-explorer fift func tonlib tonlibjson tonlib-cli validator-engine lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork tlbc emulator
cmake -GNinja -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=12.6 -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_BUILD_TYPE=Release ..
ninja storage-daemon storage-daemon-cli blockchain-explorer fift func tonlib tonlibjson tonlib-cli \
validator-engine lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server \
http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork tlbc emulator \
test-ed25519 test-ed25519-crypto test-bigint test-vm test-fift test-cells test-smartcont test-net test-tdactor \
test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain test-fec test-tddb test-db test-validator-session-state
- name: Strip binaries
run: |
strip build/storage/storage-daemon/storage-daemon
strip build/storage/storage-daemon/storage-daemon-cli
strip build/blockchain-explorer/blockchain-explorer
strip build/crypto/fift
strip build/crypto/func
strip build/crypto/create-state
strip build/crypto/tlbc
strip build/validator-engine-console/validator-engine-console
strip build/tonlib/tonlib-cli
strip build/http/http-proxy
strip build/rldp-http-proxy/rldp-http-proxy
strip build/dht-server/dht-server
strip build/lite-client/lite-client
strip build/validator-engine/validator-engine
strip build/utils/generate-random-id
strip build/utils/json2tlo
strip build/adnl/adnl-proxy
- name: Run tests
run: |
cd build
ctest --output-on-failure -E "test-catchain|test-actors"
- name: Find & copy binaries
run: |

View file

@ -15,7 +15,13 @@ jobs:
- name: Install libraries
run: |
sudo apt update
sudo apt install -y build-essential git make cmake ninja-build clang libgflags-dev zlib1g-dev libssl-dev libreadline-dev libmicrohttpd-dev pkg-config libgsl-dev python3 python3-dev python3-pip nodejs libsecp256k1-dev libsodium-dev
sudo apt install -y build-essential git make cmake ninja-build clang libgflags-dev zlib1g-dev libssl-dev libreadline-dev libmicrohttpd-dev pkg-config libgsl-dev python3 python3-dev python3-pip nodejs libsecp256k1-dev libsodium-dev automake libtool
- name: Setup compiler
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 16 all
- name: Configure & Build
run: |

View file

@ -15,7 +15,7 @@ jobs:
with:
submodules: 'recursive'
- uses: cachix/install-nix-action@v18
- uses: cachix/install-nix-action@v23
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}

View file

@ -11,7 +11,7 @@ jobs:
with:
submodules: 'recursive'
- uses: cachix/install-nix-action@v22
- uses: cachix/install-nix-action@v23
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}

View file

@ -20,8 +20,8 @@ jobs:
- name: Configure & Build
run: |
wget https://dl.google.com/android/repository/android-ndk-r25b-linux.zip
unzip android-ndk-r25b-linux.zip
wget -q https://dl.google.com/android/repository/android-ndk-r25b-linux.zip
unzip -q android-ndk-r25b-linux.zip
export JAVA_AWT_LIBRARY=NotNeeded
export JAVA_JVM_LIBRARY=NotNeeded
export JAVA_INCLUDE_PATH=${JAVA_HOME}/include

View file

@ -28,9 +28,9 @@ jobs:
export CXX=$(which clang++)
export CCACHE_DISABLE=1
git clone https://github.com/openssl/openssl openssl_1_1_1
cd openssl_1_1_1
git checkout OpenSSL_1_1_1-stable
git clone https://github.com/openssl/openssl openssl_3
cd openssl_3
git checkout openssl-3.1.4
./config
make build_libs -j4
@ -39,13 +39,27 @@ jobs:
mkdir build
cd build
cmake -GNinja -DOPENSSL_FOUND=1 -DOPENSSL_INCLUDE_DIR=$rootPath/openssl_1_1_1/include -DOPENSSL_CRYPTO_LIBRARY=$rootPath/openssl_1_1_1/libcrypto.a -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 -DTON_ARCH= -DCMAKE_CXX_FLAGS="-mavx2" ..
ninja storage-daemon storage-daemon-cli fift func tonlib tonlibjson tonlib-cli validator-engine lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy create-state emulator
cmake -GNinja -DOPENSSL_FOUND=1 -DOPENSSL_INCLUDE_DIR=$rootPath/openssl_3/include -DOPENSSL_CRYPTO_LIBRARY=$rootPath/openssl_3/libcrypto.a -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 -DTON_ARCH= ..
ninja storage-daemon storage-daemon-cli fift func tonlib tonlibjson tonlib-cli validator-engine lite-client \
pow-miner validator-engine-console generate-random-id json2tlo dht-server http-proxy rldp-http-proxy \
adnl-proxy create-state emulator \
test-ed25519 test-ed25519-crypto test-bigint test-vm test-fift test-cells test-smartcont test-net test-tdactor \
test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain test-fec test-tddb test-db test-validator-session-state
- name: Strip binaries
run: |
strip -g build/storage/storage-daemon/storage-daemon build/storage/storage-daemon/storage-daemon-cli build/crypto/fift build/crypto/tlbc build/crypto/func build/crypto/create-state build/validator-engine-console/validator-engine-console build/tonlib/tonlib-cli build/tonlib/libtonlibjson.so.0.5 build/http/http-proxy build/rldp-http-proxy/rldp-http-proxy build/dht-server/dht-server build/lite-client/lite-client build/validator-engine/validator-engine build/utils/generate-random-id build/utils/json2tlo build/adnl/adnl-proxy build/emulator/libemulator.*
- name: Run tests
run: |
cd build
ctest --output-on-failure -E "test-catchain|test-actors"
- name: Find & copy binaries
run: |
mkdir artifacts
cp build/storage/storage-daemon/storage-daemon build/storage/storage-daemon/storage-daemon-cli build/crypto/fift build/crypto/tlbc build/crypto/func build/crypto/create-state build/validator-engine-console/validator-engine-console build/tonlib/tonlib-cli build/tonlib/libtonlibjson.so.0.5 build/http/http-proxy build/rldp-http-proxy/rldp-http-proxy build/dht-server/dht-server build/lite-client/lite-client build/validator-engine/validator-engine build/utils/generate-random-id build/utils/json2tlo build/adnl/adnl-proxy build/emulator/libemulator.* artifacts
cp build/storage/storage-daemon/storage-daemon build/storage/storage-daemon/storage-daemon-cli build/crypto/fift build/crypto/tlbc build/crypto/func build/crypto/create-state build/validator-engine-console/validator-engine-console build/tonlib/tonlib-cli build/tonlib/libtonlibjson.so.0.5 build/http/http-proxy build/rldp-http-proxy/rldp-http-proxy build/dht-server/dht-server build/lite-client/lite-client build/validator-engine/validator-engine build/utils/generate-random-id build/utils/json2tlo build/adnl/adnl-proxy build/emulator/libemulator.* artifacts
chmod +x artifacts/*
cp -R crypto/smartcont artifacts/
cp -R crypto/fift/lib artifacts/

View file

@ -34,17 +34,30 @@ jobs:
mkdir build-${{ matrix.os }}
cd build-${{ matrix.os }}
git clone https://github.com/openssl/openssl openssl_1_1_1
cd openssl_1_1_1
git checkout OpenSSL_1_1_1-stable
git clone https://github.com/openssl/openssl openssl_3
cd openssl_3
git checkout openssl-3.1.4
./config
make build_libs -j4
cd ..
buildPath=`pwd`
rootPath=`pwd`
cmake -GNinja -DOPENSSL_FOUND=1 -DOPENSSL_INCLUDE_DIR=$buildPath/openssl_1_1_1/include -DOPENSSL_CRYPTO_LIBRARY=$buildPath/openssl_1_1_1/libcrypto.a -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 -DTON_ARCH= -DCMAKE_CXX_FLAGS="-mavx2" ..
ninja storage-daemon storage-daemon-cli fift func tonlib tonlibjson tonlib-cli validator-engine lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork emulator
cmake -GNinja -DOPENSSL_FOUND=1 -DOPENSSL_INCLUDE_DIR=$rootPath/openssl_3/include -DOPENSSL_CRYPTO_LIBRARY=$rootPath/openssl_3/libcrypto.a -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 -DTON_ARCH= ..
ninja storage-daemon storage-daemon-cli fift func tonlib tonlibjson tonlib-cli validator-engine lite-client \
pow-miner validator-engine-console generate-random-id json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy \
create-state create-hardfork emulator \
test-ed25519 test-ed25519-crypto test-bigint test-vm test-fift test-cells test-smartcont test-net test-tdactor \
test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain test-fec test-tddb test-db test-validator-session-state
- name: Strip binaries
run: |
strip -g build-${{ matrix.os }}/storage/storage-daemon/storage-daemon build-${{ matrix.os }}/storage/storage-daemon/storage-daemon-cli build-${{ matrix.os }}/crypto/fift build-${{ matrix.os }}/crypto/tlbc build-${{ matrix.os }}/crypto/func build-${{ matrix.os }}/crypto/create-state build-${{ matrix.os }}/validator-engine-console/validator-engine-console build-${{ matrix.os }}/tonlib/tonlib-cli build-${{ matrix.os }}/tonlib/libtonlibjson.so.0.5 build-${{ matrix.os }}/http/http-proxy build-${{ matrix.os }}/rldp-http-proxy/rldp-http-proxy build-${{ matrix.os }}/dht-server/dht-server build-${{ matrix.os }}/lite-client/lite-client build-${{ matrix.os }}/validator-engine/validator-engine build-${{ matrix.os }}/utils/generate-random-id build-${{ matrix.os }}/utils/json2tlo build-${{ matrix.os }}/adnl/adnl-proxy build-${{ matrix.os }}/emulator/libemulator.*
- name: Run tests
run: |
cd build-${{ matrix.os }}
ctest --output-on-failure -E "test-catchain|test-actors"
- name: Find & copy binaries
run: |

View file

@ -49,10 +49,10 @@ jobs:
curl -Lo libsodium-1.0.18-stable-msvc.zip https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable-msvc.zip
unzip libsodium-1.0.18-stable-msvc.zip
- name: Install pre-compiled OpenSSL Win64
- name: Install pre-compiled OpenSSL 3 Win64
run: |
curl -Lo openssl-1.1.1j.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/openssl-1.1.1j.zip
jar xf openssl-1.1.1j.zip
curl -Lo openssl-3.1.4.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/openssl-3.1.4.zip
unzip openssl-3.1.4.zip
- name: Install pre-compiled libmicrohttpd Win64
run: |
@ -72,8 +72,13 @@ jobs:
echo %SODIUM_DIR%
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DSODIUM_USE_STATIC_LIBS=1 -DSECP256K1_INCLUDE_DIR=%root%\secp256k1\include -DSECP256K1_LIBRARY=%root%\secp256k1\bin\x64\Release\v142\static\secp256k1.lib -DREADLINE_INCLUDE_DIR=%root%\readline-5.0-1-lib\include\readline -DREADLINE_LIBRARY=%root%\readline-5.0-1-lib\lib\readline.lib -DPORTABLE=1 -DZLIB_FOUND=1 -DMHD_FOUND=1 -DMHD_LIBRARY=%root%\libmicrohttpd-0.9.77-w32-bin\x86_64\VS2019\Release-static\libmicrohttpd.lib -DMHD_INCLUDE_DIR=%root%\libmicrohttpd-0.9.77-w32-bin\x86_64\VS2019\Release-static -DZLIB_INCLUDE_DIR=%root%\zlib -DZLIB_LIBRARY=%root%\zlib\contrib\vstudio\vc14\x64\ZlibStatReleaseWithoutAsm\zlibstat.lib -DOPENSSL_FOUND=1 -DOPENSSL_INCLUDE_DIR=%root%/openssl-1.1.1j/include -DOPENSSL_CRYPTO_LIBRARY=%root%/openssl-1.1.1j/lib/libcrypto_static.lib -DCMAKE_CXX_FLAGS="/DTD_WINDOWS=1 /EHsc /bigobj /W0" ..
cmake --build . --target storage-daemon storage-daemon-cli blockchain-explorer fift func tonlib tonlibjson tonlib-cli validator-engine lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork emulator --config Release
cmake -DSODIUM_USE_STATIC_LIBS=1 -DSECP256K1_INCLUDE_DIR=%root%\secp256k1\include -DSECP256K1_LIBRARY=%root%\secp256k1\bin\x64\Release\v142\static\secp256k1.lib -DREADLINE_INCLUDE_DIR=%root%\readline-5.0-1-lib\include\readline -DREADLINE_LIBRARY=%root%\readline-5.0-1-lib\lib\readline.lib -DPORTABLE=1 -DZLIB_FOUND=1 -DMHD_FOUND=1 -DMHD_LIBRARY=%root%\libmicrohttpd-0.9.77-w32-bin\x86_64\VS2019\Release-static\libmicrohttpd.lib -DMHD_INCLUDE_DIR=%root%\libmicrohttpd-0.9.77-w32-bin\x86_64\VS2019\Release-static -DZLIB_INCLUDE_DIR=%root%\zlib -DZLIB_LIBRARY=%root%\zlib\contrib\vstudio\vc14\x64\ZlibStatReleaseWithoutAsm\zlibstat.lib -DOPENSSL_FOUND=1 -DOPENSSL_INCLUDE_DIR=%root%/openssl-3.1.4/x64/include -DOPENSSL_CRYPTO_LIBRARY=%root%/openssl-3.1.4/x64/lib/libcrypto_static.lib -DCMAKE_CXX_FLAGS="/DTD_WINDOWS=1 /EHsc /bigobj /W0" ..
cmake --build . --config Release --target storage-daemon storage-daemon-cli blockchain-explorer fift func tonlib tonlibjson tonlib-cli validator-engine lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork emulator test-ed25519 test-ed25519-crypto test-bigint test-vm test-fift test-cells test-smartcont test-net test-tdactor test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain test-fec test-tddb test-db test-validator-session-state
- name: Run tests
run: |
cd build
ctest -C Release --output-on-failure -E "test-catchain|test-actors|test-validator-session-state"
- name: Show executables
run: |
@ -92,7 +97,7 @@ jobs:
mkdir artifacts\smartcont
mkdir artifacts\lib
for %%I in (build\storage\storage-daemon\Release\storage-daemon.exe build\storage\storage-daemon\Release\storage-daemon-cli.exe build\blockchain-explorer\blockchain-explorer.exe build\crypto\Release\fift.exe build\crypto\Release\tlbc.exe build\crypto\Release\func.exe build\crypto\Release\create-state.exe build\validator-engine-console\Release\validator-engine-console.exe build\tonlib\Release\tonlib-cli.exe build\tonlib\Release\tonlibjson.dll build\http\Release\http-proxy.exe build\rldp-http-proxy\Release\rldp-http-proxy.exe build\dht-server\Release\dht-server.exe build\lite-client\Release\lite-client.exe build\validator-engine\Release\validator-engine.exe build\utils\Release\generate-random-id.exe build\utils\Release\json2tlo.exe build\adnl\Release\adnl-proxy.exe build\emulator\Release\emulator.dll) do copy %%I artifacts\
for %%I in (build\storage\storage-daemon\Release\storage-daemon.exe build\storage\storage-daemon\Release\storage-daemon-cli.exe build\blockchain-explorer\blockchain-explorer.exe build\crypto\Release\fift.exe build\crypto\Release\tlbc.exe build\crypto\Release\func.exe build\crypto\Release\create-state.exe build\validator-engine-console\Release\validator-engine-console.exe build\tonlib\Release\tonlib-cli.exe build\tonlib\Release\tonlibjson.dll build\http\Release\http-proxy.exe build\rldp-http-proxy\Release\rldp-http-proxy.exe build\dht-server\Release\dht-server.exe build\lite-client\Release\lite-client.exe build\validator-engine\Release\validator-engine.exe build\utils\Release\generate-random-id.exe build\utils\Release\json2tlo.exe build\adnl\Release\adnl-proxy.exe build\emulator\Release\emulator.dll) do (strip -g %%I & copy %%I artifacts\)
xcopy /e /k /h /i crypto\smartcont artifacts\smartcont
xcopy /e /k /h /i crypto\fift\lib artifacts\lib

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(TON VERSION 0.5 LANGUAGES C CXX)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
@ -79,7 +79,7 @@ else()
set(HAVE_SSE42 FALSE)
endif()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS FALSE)
@ -255,6 +255,9 @@ if (MSVC)
add_definitions(-D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /W4 /wd4100 /wd4127 /wd4324 /wd4456 /wd4457 /wd4458 /wd4505 /wd4702")
elseif (CLANG OR GCC)
if (GCC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstrong-eval-order=some")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
if (APPLE)
#use "-Wl,-exported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/export_list" for exported symbols
@ -447,6 +450,10 @@ target_link_libraries(test-smartcont PRIVATE smc-envelope fift-lib ton_db)
add_executable(test-bigint ${BIGINT_TEST_SOURCE})
target_link_libraries(test-bigint PRIVATE ton_crypto)
if (WINGETOPT_FOUND)
target_link_libraries_system(test-bigint wingetopt)
endif()
add_executable(test-cells test/test-td-main.cpp ${CELLS_TEST_SOURCE})
target_link_libraries(test-cells PRIVATE ton_crypto)
@ -513,26 +520,12 @@ target_link_libraries(test-rldp2 adnl adnltest dht rldp2 tl_api)
add_executable(test-validator-session-state test/test-validator-session-state.cpp)
target_link_libraries(test-validator-session-state adnl dht rldp validatorsession tl_api)
#add_executable(test-node test/test-node.cpp)
#target_link_libraries(test-node overlay tdutils tdactor adnl tl_api dht
# catchain validatorsession)
add_executable(test-catchain test/test-catchain.cpp)
target_link_libraries(test-catchain overlay tdutils tdactor adnl adnltest rldp tl_api dht
catchain )
#add_executable(test-validator-session test/test-validator-session.cpp)
#target_link_libraries(test-validator-session overlay tdutils tdactor adnl tl_api dht
# catchain validatorsession)
add_executable(test-ton-collator test/test-ton-collator.cpp)
target_link_libraries(test-ton-collator overlay tdutils tdactor adnl tl_api dht
catchain validatorsession validator-disk ton_validator validator-disk )
#add_executable(test-validator test/test-validator.cpp)
#target_link_libraries(test-validator overlay tdutils tdactor adnl tl_api dht
# rldp catchain validatorsession ton-node validator ton_validator validator memprof ${JEMALLOC_LIBRARIES})
#add_executable(test-ext-server test/test-ext-server.cpp)
#target_link_libraries(test-ext-server tdutils tdactor adnl tl_api dht )
#add_executable(test-ext-client test/test-ext-client.cpp)
#target_link_libraries(test-ext-client tdutils tdactor adnl tl_api tl-lite-utils)
add_executable(test-http test/test-http.cpp)
target_link_libraries(test-http PRIVATE tonhttp)
@ -574,13 +567,53 @@ add_test(test-tdutils test-tdutils)
add_test(test-tonlib-offline test-tonlib-offline)
#END tonlib
# FunC tests
if (NOT NIX)
if (MSVC)
set(PYTHON_VER "python")
else()
set(PYTHON_VER "python3")
endif()
add_test(
NAME test-func
COMMAND ${PYTHON_VER} run_tests.py tests/
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/crypto/func/auto-tests)
if (WIN32)
set_property(TEST test-func PROPERTY ENVIRONMENT
"FUNC_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/crypto/Release/func.exe"
"FIFT_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/crypto/Release/fift.exe"
"FIFTPATH=${CMAKE_CURRENT_SOURCE_DIR}/crypto/fift/lib/")
else()
set_property(TEST test-func PROPERTY ENVIRONMENT
"FUNC_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/crypto/func"
"FIFT_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/crypto/fift"
"FIFTPATH=${CMAKE_CURRENT_SOURCE_DIR}/crypto/fift/lib/")
endif()
add_test(
NAME test-func-legacy
COMMAND ${PYTHON_VER} legacy_tester.py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/crypto/func/auto-tests)
if (WIN32)
set_property(TEST test-func-legacy PROPERTY ENVIRONMENT
"FUNC_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/crypto/Release/func.exe"
"FIFT_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/crypto/Release/fift.exe"
"FIFTPATH=${CMAKE_CURRENT_SOURCE_DIR}/crypto/fift/lib/")
else()
set_property(TEST test-func-legacy PROPERTY ENVIRONMENT
"FUNC_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/crypto/func"
"FIFT_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/crypto/fift"
"FIFTPATH=${CMAKE_CURRENT_SOURCE_DIR}/crypto/fift/lib/")
endif()
endif()
#BEGIN internal
if (NOT TON_ONLY_TONLIB)
add_test(test-adnl test-adnl)
add_test(test-dht test-dht)
add_test(test-rldp test-rldp)
add_test(test-rldp2 test-rldp2)
#add_test(test-validator-session-state test-validator-session-state)
add_test(test-validator-session-state test-validator-session-state)
add_test(test-catchain test-catchain)
add_test(test-fec test-fec)

View file

@ -1,3 +1,26 @@
##2023.11 Update
1. New TVM Functionality. (Disabled by default)
2. A series of emulator improvements: libraries support, higher max stack size, etc
3. A series of tonlib and tonlib-cli improvements: wallet-v4 support, getconfig, showtransactions, etc
4. Changes to public libraries: now contract can not publish more than 256 libraries (config parameter) and contracts can not be deployed with public libraries in initstate (instead contracts need explicitly publish all libraries)
5. Changes to storage due payment: now due payment is collected in Storage Phase, however for bouncable messages fee amount can not exceed balance of account prior to message.
Besides the work of the core team, this update is based on the efforts of @aleksej-paschenko (emulator improvements), @akifoq (security improvements), Trail of Bits auditor as well as all participants of [TEP-88 discussion](https://github.com/ton-blockchain/TEPs/pull/88).
## 2023.10 Update
1. A series of additional security checks in node: special cells in action list, init state in external messages, peers data prior to saving to disk.
2. Human-readable timestamps in explorer
Besides the work of the core team, this update is based on the efforts of @akifoq and @mr-tron.
## 2023.06 Update
1. (disabled by default) New deflation mechanisms: partial fee burning and blackhole address
2. Storage-contract improvement
Besides the work of the core team, this update is based on the efforts of @DearJohnDoe from Tonbyte (Storage-contract improvement).
## 2023.05 Update
1. Archive manager optimization
2. A series of catchain (basic consensus protocol) security improvements

View file

@ -37,7 +37,7 @@ Main TON monorepo, which includes the code of the node/validator, lite-client, t
## The Open Network
__The Open Network (TON)__ is a fast, secure, scalable blockchain focused on handling _millions of transactions per second_ (TPS) with the goal of reaching hundreds of millions of blockchain users.
- To learn more about different aspects of TON blockchain and its underlying ecosystem check [documentation](ton.org/docs)
- To learn more about different aspects of TON blockchain and its underlying ecosystem check [documentation](https://ton.org/docs)
- To run node, validator or lite-server check [Participate section](https://ton.org/docs/participate/nodes/run-node)
- To develop decentralised apps check [Tutorials](https://ton.org/docs/develop/smart-contracts/), [FunC docs](https://ton.org/docs/develop/func/overview) and [DApp tutorials](https://ton.org/docs/develop/dapps/)
- To work on TON check [wallets](https://ton.app/wallets), [explorers](https://ton.app/explorers), [DEXes](https://ton.app/dex) and [utilities](https://ton.app/utilities)
@ -66,3 +66,8 @@ If a CI workflow fails not because of your changes but workflow issues, try to f
* **C/C++ CI (ccpp-linux.yml)**: TBD
* **C/C++ CI Win64 Compile (ccpp-win64.yml)**: TBD
## Running tests
Tests are executed by running `ctest` in the build directory. See `doc/Tests.md` for more information.

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
#BEGIN internal
if (NOT TON_ONLY_TONLIB)

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
option(NIX "Use \"ON\" for a static build." OFF)

View file

@ -35,9 +35,38 @@
#include "vm/cells/MerkleProof.h"
#include "block/mc-config.h"
#include "ton/ton-shard.h"
#include "td/utils/date.h"
bool local_scripts{false};
static std::string time_to_human(unsigned ts) {
td::StringBuilder sb;
sb << date::format("%F %T",
std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds>{std::chrono::seconds(ts)})
<< ", ";
auto now = (unsigned)td::Clocks::system();
bool past = now >= ts;
unsigned x = past ? now - ts : ts - now;
if (!past) {
sb << "in ";
}
if (x < 60) {
sb << x << "s";
} else if (x < 3600) {
sb << x / 60 << "m " << x % 60 << "s";
} else if (x < 3600 * 24) {
x /= 60;
sb << x / 60 << "h " << x % 60 << "m";
} else {
x /= 3600;
sb << x / 24 << "d " << x % 24 << "h";
}
if (past) {
sb << " ago";
}
return sb.as_cslice().str();
}
HttpAnswer& HttpAnswer::operator<<(AddressCell addr_c) {
ton::WorkchainId wc;
ton::StdSmcAddress addr;
@ -84,7 +113,7 @@ HttpAnswer& HttpAnswer::operator<<(MessageCell msg) {
<< "<tr><th>source</th><td>" << AddressCell{info.src} << "</td></tr>\n"
<< "<tr><th>destination</th><td>NONE</td></tr>\n"
<< "<tr><th>lt</th><td>" << info.created_lt << "</td></tr>\n"
<< "<tr><th>time</th><td>" << info.created_at << "</td></tr>\n";
<< "<tr><th>time</th><td>" << info.created_at << " (" << time_to_human(info.created_at) << ")</td></tr>\n";
break;
}
case block::gen::CommonMsgInfo::int_msg_info: {
@ -103,7 +132,7 @@ HttpAnswer& HttpAnswer::operator<<(MessageCell msg) {
<< "<tr><th>source</th><td>" << AddressCell{info.src} << "</td></tr>\n"
<< "<tr><th>destination</th><td>" << AddressCell{info.dest} << "</td></tr>\n"
<< "<tr><th>lt</th><td>" << info.created_lt << "</td></tr>\n"
<< "<tr><th>time</th><td>" << info.created_at << "</td></tr>\n"
<< "<tr><th>time</th><td>" << info.created_at << " (" << time_to_human(info.created_at) << ")</td></tr>\n"
<< "<tr><th>value</th><td>" << value << "</td></tr>\n";
break;
}
@ -277,7 +306,7 @@ HttpAnswer& HttpAnswer::operator<<(TransactionCell trans_c) {
<< "<tr><th>account</th><td>" << trans_c.addr.rserialize(true) << "</td></tr>"
<< "<tr><th>hash</th><td>" << trans_c.root->get_hash().to_hex() << "</td></tr>\n"
<< "<tr><th>lt</th><td>" << trans.lt << "</td></tr>\n"
<< "<tr><th>time</th><td>" << trans.now << "</td></tr>\n"
<< "<tr><th>time</th><td>" << trans.now << " (" << time_to_human(trans.now) << ")</td></tr>\n"
<< "<tr><th>out messages</th><td>";
vm::Dictionary dict{trans.r1.out_msgs, 15};
for (td::int32 i = 0; i < trans.outmsg_cnt; i++) {
@ -456,7 +485,7 @@ HttpAnswer& HttpAnswer::operator<<(BlockHeaderCell head_c) {
<< "<tr><th>block</th><td>" << block_id.id.to_str() << "</td></tr>\n"
<< "<tr><th>roothash</th><td>" << block_id.root_hash.to_hex() << "</td></tr>\n"
<< "<tr><th>filehash</th><td>" << block_id.file_hash.to_hex() << "</td></tr>\n"
<< "<tr><th>time</th><td>" << info.gen_utime << "</td></tr>\n"
<< "<tr><th>time</th><td>" << info.gen_utime << " (" << time_to_human(info.gen_utime) << ")</td></tr>\n"
<< "<tr><th>lt</th><td>" << info.start_lt << " .. " << info.end_lt << "</td></tr>\n"
<< "<tr><th>global_id</th><td>" << blk.global_id << "</td></tr>\n"
<< "<tr><th>version</th><td>" << info.version << "</td></tr>\n"
@ -543,7 +572,8 @@ HttpAnswer& HttpAnswer::operator<<(BlockShardsCell shards_c) {
ton::ShardIdFull shard{id.workchain, id.shard};
if (ref.not_null()) {
*this << "<td>" << shard.to_str() << "</td><td><a href=\"" << HttpAnswer::BlockLink{ref->top_block_id()}
<< "\">" << ref->top_block_id().id.seqno << "</a></td><td>" << ref->created_at() << "</td>"
<< "\">" << ref->top_block_id().id.seqno << "</a></td><td><span title=\""
<< time_to_human(ref->created_at()) << "\">" << ref->created_at() << "</span></td>"
<< "<td>" << ref->want_split_ << "</td>"
<< "<td>" << ref->want_merge_ << "</td>"
<< "<td>" << ref->before_split_ << "</td>"

View file

@ -52,7 +52,7 @@
#include "vm/boc.h"
#include "vm/cellops.h"
#include "vm/cells/MerkleProof.h"
#include "vm/cp0.h"
#include "vm/vm.h"
#include "auto/tl/lite_api.h"
#include "ton/lite-tl.hpp"
@ -103,23 +103,24 @@ class HttpQueryRunner {
Self->finish(nullptr);
}
});
mutex_.lock();
scheduler_ptr->run_in_context_external([&]() { func(std::move(P)); });
}
void finish(MHD_Response* response) {
std::unique_lock<std::mutex> lock(mutex_);
response_ = response;
mutex_.unlock();
cond.notify_all();
}
MHD_Response* wait() {
mutex_.lock();
mutex_.unlock();
std::unique_lock<std::mutex> lock(mutex_);
cond.wait(lock, [&]() { return response_ != nullptr; });
return response_;
}
private:
std::function<void(td::Promise<MHD_Response*>)> func_;
MHD_Response* response_;
MHD_Response* response_ = nullptr;
std::mutex mutex_;
std::condition_variable cond;
};
class CoreActor : public CoreActorInterface {
@ -654,7 +655,7 @@ int main(int argc, char* argv[]) {
});
#endif
vm::init_op_cp0();
vm::init_vm().ensure();
td::actor::Scheduler scheduler({2});
scheduler_ptr = &scheduler;

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
if (NOT OPENSSL_FOUND)
find_package(OpenSSL REQUIRED)

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
set(COMMON_SOURCE
checksum.h

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
if (NOT OPENSSL_FOUND)
find_package(OpenSSL REQUIRED)

View file

@ -49,7 +49,7 @@
#include "validator/fabric.h"
#include "validator/impl/collator.h"
#include "crypto/vm/cp0.h"
#include "crypto/vm/vm.h"
#include "crypto/block/block-db.h"
#include "common/errorlog.h"
@ -307,7 +307,7 @@ int main(int argc, char *argv[]) {
SET_VERBOSITY_LEVEL(verbosity_INFO);
td::set_default_failure_signal_handler().ensure();
CHECK(vm::init_op_cp0());
vm::init_vm().ensure();
td::actor::ActorOwn<HardforkCreator> x;

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
if (NOT OPENSSL_FOUND)
find_package(OpenSSL REQUIRED)
@ -236,6 +236,7 @@ set(SMC_ENVELOPE_SOURCE
smc-envelope/SmartContractCode.cpp
smc-envelope/WalletInterface.cpp
smc-envelope/WalletV3.cpp
smc-envelope/WalletV4.cpp
smc-envelope/GenericAccount.h
smc-envelope/HighloadWallet.h
@ -246,6 +247,7 @@ set(SMC_ENVELOPE_SOURCE
smc-envelope/SmartContractCode.h
smc-envelope/WalletInterface.h
smc-envelope/WalletV3.h
smc-envelope/WalletV4.h
)
set(ED25519_TEST_SOURCE
@ -373,10 +375,10 @@ add_library(src_parser ${PARSER_SOURCE})
target_include_directories(src_parser PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_link_libraries(src_parser PUBLIC ton_crypto_core)
add_library(ton_block ${BLOCK_SOURCE})
add_library(ton_block STATIC ${BLOCK_SOURCE})
target_include_directories(ton_block PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/block> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
target_link_libraries(ton_block PUBLIC ton_crypto_core tdutils tdactor tl_api)
target_link_libraries(ton_block PUBLIC ton_crypto tdutils tdactor tl_api)
add_executable(func func/func-main.cpp ${FUNC_LIB_SOURCE})
target_include_directories(func PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)

View file

@ -715,7 +715,7 @@ td::uint64 BlockLimitStatus::estimate_block_size(const vm::NewCellStorageStat::S
sum += *extra;
}
return 2000 + (sum.bits >> 3) + sum.cells * 12 + sum.internal_refs * 3 + sum.external_refs * 40 + accounts * 200 +
transactions * 200 + (extra ? 200 : 0) + extra_out_msgs * 300;
transactions * 200 + (extra ? 200 : 0) + extra_out_msgs * 300 + extra_library_diff * 700;
}
int BlockLimitStatus::classify() const {

View file

@ -262,6 +262,7 @@ struct BlockLimitStatus {
td::uint64 gas_used{};
vm::NewCellStorageStat st_stat;
unsigned accounts{}, transactions{}, extra_out_msgs{};
unsigned extra_library_diff{}; // Number of public libraries in deleted/frozen accounts
BlockLimitStatus(const BlockLimits& limits_, ton::LogicalTime lt = 0)
: limits(limits_), cur_lt(std::max(limits_.start_lt, lt)) {
}
@ -271,6 +272,7 @@ struct BlockLimitStatus {
transactions = accounts = 0;
gas_used = 0;
extra_out_msgs = 0;
extra_library_diff = 0;
}
td::uint64 estimate_block_size(const vm::NewCellStorageStat::Stat* extra = nullptr) const;
int classify() const;

View file

@ -780,7 +780,8 @@ _ MisbehaviourPunishmentConfig = ConfigParam 40;
size_limits_config#01 max_msg_bits:uint32 max_msg_cells:uint32 max_library_cells:uint32 max_vm_data_depth:uint16
max_ext_msg_size:uint32 max_ext_msg_depth:uint16 = SizeLimitsConfig;
size_limits_config_v2#02 max_msg_bits:uint32 max_msg_cells:uint32 max_library_cells:uint32 max_vm_data_depth:uint16
max_ext_msg_size:uint32 max_ext_msg_depth:uint16 max_acc_state_cells:uint32 max_acc_state_bits:uint32 = SizeLimitsConfig;
max_ext_msg_size:uint32 max_ext_msg_depth:uint16 max_acc_state_cells:uint32 max_acc_state_bits:uint32
max_acc_public_libraries:uint32 = SizeLimitsConfig;
_ SizeLimitsConfig = ConfigParam 43;
// key is [ wc:int32 addr:uint256 ]

View file

@ -1934,6 +1934,7 @@ td::Result<SizeLimitsConfig> Config::get_size_limits_config() const {
unpack_v1(rec);
limits.max_acc_state_bits = rec.max_acc_state_bits;
limits.max_acc_state_cells = rec.max_acc_state_cells;
limits.max_acc_public_libraries = rec.max_acc_public_libraries;
};
gen::SizeLimitsConfig::Record_size_limits_config rec_v1;
gen::SizeLimitsConfig::Record_size_limits_config_v2 rec_v2;

View file

@ -389,6 +389,7 @@ struct SizeLimitsConfig {
ExtMsgLimits ext_msg_limits;
td::uint32 max_acc_state_cells = 1 << 16;
td::uint32 max_acc_state_bits = (1 << 16) * 1023;
td::uint32 max_acc_public_libraries = 256;
};
struct CatchainValidatorsConfig {

File diff suppressed because it is too large Load diff

View file

@ -116,6 +116,7 @@ struct ComputePhaseConfig {
int global_version = 0;
Ref<vm::Tuple> prev_blocks_info;
std::unique_ptr<vm::Dictionary> suspended_addresses;
SizeLimitsConfig size_limits;
int vm_log_verbosity = 0;
ComputePhaseConfig(td::uint64 _gas_price = 0, td::uint64 _gas_limit = 0, td::uint64 _gas_credit = 0)
@ -270,7 +271,7 @@ struct Account {
return balance;
}
bool set_address(ton::WorkchainId wc, td::ConstBitPtr new_addr);
bool unpack(Ref<vm::CellSlice> account, Ref<vm::CellSlice> extra, ton::UnixTime now, bool special = false);
bool unpack(Ref<vm::CellSlice> account, ton::UnixTime now, bool special);
bool init_new(ton::UnixTime now);
bool deactivate();
bool recompute_tmp_addr(Ref<vm::CellSlice>& tmp_addr, int split_depth, td::ConstBitPtr orig_addr_rewrite) const;
@ -372,7 +373,7 @@ struct Transaction {
std::vector<Ref<vm::Cell>> compute_vm_libraries(const ComputePhaseConfig& cfg);
bool prepare_compute_phase(const ComputePhaseConfig& cfg);
bool prepare_action_phase(const ActionPhaseConfig& cfg);
td::Status check_state_limits(const ActionPhaseConfig& cfg);
td::Status check_state_limits(const SizeLimitsConfig& size_limits, bool update_storage_stat = true);
bool prepare_bounce_phase(const ActionPhaseConfig& cfg);
bool compute_state();
bool serialize();
@ -382,8 +383,6 @@ struct Transaction {
td::Result<vm::NewCellStorageStat::Stat> estimate_block_storage_profile_incr(
const vm::NewCellStorageStat& store_stat, const vm::CellUsageTree* usage_tree) const;
bool update_block_storage_profile(vm::NewCellStorageStat& store_stat, const vm::CellUsageTree* usage_tree) const;
bool would_fit(unsigned cls, const block::BlockLimitStatus& blk_lim_st) const;
bool update_limits(block::BlockLimitStatus& blk_lim_st, bool with_size = true) const;
Ref<vm::Cell> commit(Account& _account); // _account should point to the same account
@ -406,7 +405,7 @@ struct Transaction {
bool serialize_compute_phase(vm::CellBuilder& cb);
bool serialize_action_phase(vm::CellBuilder& cb);
bool serialize_bounce_phase(vm::CellBuilder& cb);
bool unpack_msg_state(bool lib_only = false);
bool unpack_msg_state(const ComputePhaseConfig& cfg, bool lib_only = false, bool forbid_public_libs = false);
};
} // namespace transaction

View file

@ -130,7 +130,7 @@ void bits_memcpy(unsigned char* to, int to_offs, const unsigned char* from, int
from_offs &= 7;
to_offs &= 7;
//fprintf(stderr, "bits_memcpy: from=%p (%02x) to=%p (%02x) from_offs=%d to_offs=%d count=%lu\n", from, *from, to, *to, from_offs, to_offs, bit_count);
int sz = (int)bit_count;
int sz = static_cast<int>(bit_count);
bit_count += from_offs;
if (from_offs == to_offs) {
if (bit_count < 8) {
@ -206,7 +206,7 @@ void bits_memset(unsigned char* to, int to_offs, bool val, std::size_t bit_count
}
to += (to_offs >> 3);
to_offs &= 7;
int sz = (int)bit_count;
int sz = static_cast<int>(bit_count);
bit_count += to_offs;
int c = *to;
if (bit_count <= 8) {
@ -596,7 +596,7 @@ long parse_bitstring_hex_literal(unsigned char* buff, std::size_t buff_size, con
unsigned char* ptr = buff;
const char* rptr = str;
while (rptr < str_end) {
int c = *rptr++;
char c = *rptr++;
if (c == ' ' || c == '\t') {
continue;
}
@ -627,14 +627,14 @@ long parse_bitstring_hex_literal(unsigned char* buff, std::size_t buff_size, con
if (cmpl && bits) {
int t = (hex_digits_count & 1) ? (0x100 + *ptr) >> 4 : (0x100 + *--ptr);
while (bits > 0) {
if (t == 1) {
t = 0x100 + *--ptr;
}
--bits;
if (t & 1) {
break;
}
t >>= 1;
if (t == 1) {
t = 0x100 + *--ptr;
}
}
}
return bits;

View file

@ -461,19 +461,109 @@ x{B7A3} @Defop QNEGATE
x{B7A4} @Defop QINC
x{B7A5} @Defop QDEC
x{B7A8} @Defop QMUL
x{B7A904} @Defop QDIV
x{B7A905} @Defop QDIVR
x{B7A906} @Defop QDIVC
x{B7A908} @Defop QMOD
x{B7A909} @Defop QMODR
x{B7A90A} @Defop QMODC
x{B7A90C} @Defop QDIVMOD
x{B7A90D} @Defop QDIVMODR
x{B7A90E} @Defop QDIVMODC
x{B7A900} @Defop QADDDIVMOD
x{B7A901} @Defop QADDDIVMODR
x{B7A902} @Defop QADDDIVMODC
x{B7A925} @Defop QRSHIFTR
x{B7A926} @Defop QRSHIFTC
x{B7A928} @Defop QMODPOW2
x{B7A929} @Defop QMODPOW2R
x{B7A92A} @Defop QMODPOW2C
x{B7A92C} @Defop QRSHIFTMOD
x{B7A92D} @Defop QRSHIFTMODR
x{B7A92E} @Defop QRSHIFTMODC
x{B7A920} @Defop QADDRSHIFTMOD
x{B7A921} @Defop QADDRSHIFTMODR
x{B7A922} @Defop QADDRSHIFTMODC
x{B7A935} @Defop(8u+1) QRSHIFTR#
x{B7A936} @Defop(8u+1) QRSHIFTC#
x{B7A938} @Defop(8u+1) QMODPOW2#
x{B7A939} @Defop(8u+1) QMODPOW2R#
x{B7A93A} @Defop(8u+1) QMODPOW2C#
x{B7A93C} @Defop(8u+1) QRSHIFT#MOD
x{B7A93D} @Defop(8u+1) QRSHIFTR#MOD
x{B7A93E} @Defop(8u+1) QRSHIFTC#MOD
x{B7A930} @Defop(8u+1) QADDRSHIFT#MOD
x{B7A931} @Defop(8u+1) QADDRSHIFTR#MOD
x{B7A932} @Defop(8u+1) QADDRSHIFTC#MOD
x{B7A984} @Defop QMULDIV
x{B7A985} @Defop QMULDIVR
x{B7A986} @Defop QMULDIVC
x{B7A988} @Defop QMULMOD
x{B7A989} @Defop QMULMODR
x{B7A98A} @Defop QMULMODC
x{B7A98C} @Defop QMULDIVMOD
x{B7A980} @Defop QADDMULDIVMOD
x{B7A98D} @Defop QMULDIVMODR
x{B7A98E} @Defop QMULDIVMODC
x{B7A980} @Defop QMULADDDIVMOD
x{B7A981} @Defop QMULADDDIVMODR
x{B7A982} @Defop QMULADDDIVMODC
x{B7A9A4} @Defop QMULRSHIFT
x{B7A9A5} @Defop QMULRSHIFTR
x{B7A9A6} @Defop QMULRSHIFTC
x{B7A9A8} @Defop QMULMODPOW2
x{B7A9A9} @Defop QMULMODPOW2R
x{B7A9AA} @Defop QMULMODPOW2C
x{B7A9AC} @Defop QMULRSHIFTMOD
x{B7A9AD} @Defop QMULRSHIFTRMOD
x{B7A9AE} @Defop QMULRSHIFTCMOD
x{B7A9A0} @Defop QMULADDRSHIFTMOD
x{B7A9A1} @Defop QMULADDRSHIFTRMOD
x{B7A9A2} @Defop QMULADDRSHIFTCMOD
x{B7A9B4} @Defop(8u+1) QMULRSHIFT#
x{B7A9B5} @Defop(8u+1) QMULRSHIFTR#
x{B7A9B6} @Defop(8u+1) QMULRSHIFTC#
x{B7A9B8} @Defop(8u+1) QMULMODPOW2#
x{B7A9B9} @Defop(8u+1) QMULMODPOW2R#
x{B7A9BA} @Defop(8u+1) QMULMODPOW2C#
x{B7A9BC} @Defop(8u+1) QMULRSHIFT#MOD
x{B7A9BD} @Defop(8u+1) QMULRSHIFTR#MOD
x{B7A9BE} @Defop(8u+1) QMULRSHIFTC#MOD
x{B7A9B0} @Defop(8u+1) QMULADDRSHIFT#MOD
x{B7A9B1} @Defop(8u+1) QMULADDRSHIFTR#MOD
x{B7A9B2} @Defop(8u+1) QMULADDRSHIFTC#MOD
x{B7A9C4} @Defop QLSHIFTDIV
x{B7A9C5} @Defop QLSHIFTDIVR
x{B7A9C6} @Defop QLSHIFTDIVC
x{B7A9C8} @Defop QLSHIFTMOD
x{B7A9C9} @Defop QLSHIFTMODR
x{B7A9CA} @Defop QLSHIFTMODC
x{B7A9CC} @Defop QLSHIFTDIVMOD
x{B7A9CD} @Defop QLSHIFTDIVMODR
x{B7A9CE} @Defop QLSHIFTDIVMODC
x{B7A9C0} @Defop QLSHIFTADDDIVMOD
x{B7A9C1} @Defop QLSHIFTADDDIVMODR
x{B7A9C2} @Defop QLSHIFTADDDIVMODC
x{B7A9D4} @Defop(8u+1) QLSHIFT#DIV
x{B7A9D5} @Defop(8u+1) QLSHIFT#DIVR
x{B7A9D6} @Defop(8u+1) QLSHIFT#DIVC
x{B7A9D8} @Defop(8u+1) QLSHIFT#MOD
x{B7A9D9} @Defop(8u+1) QLSHIFT#MODR
x{B7A9DA} @Defop(8u+1) QLSHIFT#MODC
x{B7A9DC} @Defop(8u+1) QLSHIFT#DIVMOD
x{B7A9DD} @Defop(8u+1) QLSHIFT#DIVMODR
x{B7A9DE} @Defop(8u+1) QLSHIFT#DIVMODC
x{B7A9D0} @Defop(8u+1) QLSHIFT#ADDDIVMOD
x{B7A9D1} @Defop(8u+1) QLSHIFT#ADDDIVMODR
x{B7A9D2} @Defop(8u+1) QLSHIFT#ADDDIVMODC
x{B7AC} @Defop QLSHIFT
x{B7AD} @Defop QRSHIFT
x{B7AE} @Defop QPOW2
@ -1185,7 +1275,7 @@ x{F4BF} @Defop DICTUGETEXECZ
x{F800} @Defop ACCEPT
x{F801} @Defop SETGASLIMIT
x{F802} @Defop GASCONSUMED
x{F807} @Defop GASCONSUMED
x{F80F} @Defop COMMIT
x{F810} @Defop RANDU256

View file

@ -3512,7 +3512,7 @@ void init_words_ton(Dictionary& d) {
void init_words_vm(Dictionary& d, bool enable_debug) {
using namespace std::placeholders;
vm::init_op_cp0(enable_debug);
vm::init_vm(enable_debug).ensure();
// vm run
d.def_word("vmlibs ", LitCont::literal(vm_libraries));
// d.def_ctx_word("runvmcode ", std::bind(interpret_run_vm, _1, 0x40));

View file

@ -8,37 +8,37 @@ import shutil
add_pragmas = [] #["allow-post-modification", "compute-asm-ltr"];
tests = [
# note, that deployed version of elector,config and multisig differ since it is compilled with func-0.1.0.
# Newer compillators optimize arithmetic and logic expression that can be calculated at the compile time
["elector/elector-code.fc", 115226404411715505328583639896096915745686314074575650766750648324043316883483],
["config/config-code.fc", 10913070768607625342121305745084703121685937915388357634624451844356456145601],
["eth-bridge-multisig/multisig-code.fc", 101509909129354488841890823627011033360100627957439967918234053299675481277954],
# note, that deployed version of elector,config and multisig differ since it is compilled with func-0.1.0.
# Newer compillators optimize arithmetic and logic expression that can be calculated at the compile time
["elector/elector-code.fc", 115226404411715505328583639896096915745686314074575650766750648324043316883483],
["config/config-code.fc", 10913070768607625342121305745084703121685937915388357634624451844356456145601],
["eth-bridge-multisig/multisig-code.fc", 101509909129354488841890823627011033360100627957439967918234053299675481277954],
["bsc-bridge-collector/votes-collector.fc", 62190447221288642706570413295807615918589884489514159926097051017036969900417],
["uni-lock-wallet/uni-lockup-wallet.fc", 61959738324779104851267145467044677651344601417998258530238254441977103654381],
["nft-collection/nft-collection-editable.fc", 45561997735512210616567774035540357815786262097548276229169737015839077731274],
["dns-collection/nft-collection.fc", 107999822699841936063083742021519765435859194241091312445235370766165379261859],
["bsc-bridge-collector/votes-collector.fc", 62190447221288642706570413295807615918589884489514159926097051017036969900417],
["uni-lock-wallet/uni-lockup-wallet.fc", 61959738324779104851267145467044677651344601417998258530238254441977103654381],
["nft-collection/nft-collection-editable.fc", 45561997735512210616567774035540357815786262097548276229169737015839077731274],
["dns-collection/nft-collection.fc", 107999822699841936063083742021519765435859194241091312445235370766165379261859],
# note, that deployed version of tele-nft-item differs since it is compilled with func-0.3.0.
# After introducing of try/catch construction, c2 register is not always the default one.
# Thus it is necessary to save it upon jumps, differences of deployed and below compilled is that
# "c2 SAVE" is added to the beginning of recv_internal. It does not change behavior.
["tele-nft-item/nft-item.fc", 69777543125381987786450436977742010705076866061362104025338034583422166453344],
# note, that deployed version of tele-nft-item differs since it is compilled with func-0.3.0.
# After introducing of try/catch construction, c2 register is not always the default one.
# Thus it is necessary to save it upon jumps, differences of deployed and below compilled is that
# "c2 SAVE" is added to the beginning of recv_internal. It does not change behavior.
["tele-nft-item/nft-item.fc", 69777543125381987786450436977742010705076866061362104025338034583422166453344],
["storage/storage-contract.fc", 91377830060355733016937375216020277778264560226873154627574229667513068328151],
["storage/storage-provider.fc", 13618336676213331164384407184540461509022654507176709588621016553953760588122],
["nominator-pool/pool.fc", 69767057279163099864792356875696330339149706521019810113334238732928422055375],
["jetton-minter/jetton-minter.fc", 9028309926287301331466371999814928201427184114165428257502393474125007156494],
["gg-marketplace/nft-marketplace-v2.fc", 92199806964112524639740773542356508485601908152150843819273107618799016205930],
["jetton-wallet/jetton-wallet.fc", 86251125787443633057458168028617933212663498001665054651523310772884328206542],
["whales-nominators/nominators.fc", 8941364499854379927692172316865293429893094891593442801401542636695127885153],
["storage/storage-contract.fc", 91377830060355733016937375216020277778264560226873154627574229667513068328151],
["storage/storage-provider.fc", 13618336676213331164384407184540461509022654507176709588621016553953760588122],
["nominator-pool/pool.fc", 69767057279163099864792356875696330339149706521019810113334238732928422055375],
["jetton-minter/jetton-minter.fc", 9028309926287301331466371999814928201427184114165428257502393474125007156494],
["gg-marketplace/nft-marketplace-v2.fc", 92199806964112524639740773542356508485601908152150843819273107618799016205930],
["jetton-wallet/jetton-wallet.fc", 86251125787443633057458168028617933212663498001665054651523310772884328206542],
["whales-nominators/nominators.fc", 8941364499854379927692172316865293429893094891593442801401542636695127885153],
["tact-examples/treasure_Treasure.code.fc", 13962538639825790677138656603323869918938565499584297120566680287245364723897],
["tact-examples/jetton_SampleJetton.code.fc", 94076762218493729104783735200107713211245710256802265203823917715299139499110],
["tact-examples/jetton_JettonDefaultWallet.code.fc", 29421313492520031238091587108198906058157443241743283101866538036369069620563],
["tact-examples/maps_MapTestContract.code.fc", 22556550222249123835909180266811414538971143565993192846012583552876721649744],
["tact-examples/treasure_Treasure.code.fc", 13962538639825790677138656603323869918938565499584297120566680287245364723897],
["tact-examples/jetton_SampleJetton.code.fc", 94076762218493729104783735200107713211245710256802265203823917715299139499110],
["tact-examples/jetton_JettonDefaultWallet.code.fc", 29421313492520031238091587108198906058157443241743283101866538036369069620563],
["tact-examples/maps_MapTestContract.code.fc", 22556550222249123835909180266811414538971143565993192846012583552876721649744],
]
def getenv(name, default=None):
@ -51,7 +51,6 @@ def getenv(name, default=None):
FUNC_EXECUTABLE = getenv("FUNC_EXECUTABLE", "func")
FIFT_EXECUTABLE = getenv("FIFT_EXECUTABLE", "fift")
FIFT_LIBS = getenv("FIFTPATH")
TMP_DIR = tempfile.mkdtemp()
COMPILED_FIF = os.path.join(TMP_DIR, "compiled.fif")
@ -63,49 +62,49 @@ class ExecutionError(Exception):
pass
def pre_process_func(f):
shutil.copyfile(f, f+"_backup")
with open(f, "r") as src:
sources = src.read()
with open(f, "w") as src:
for pragma in add_pragmas:
src.write("#pragma %s;\n"%pragma)
src.write(sources)
shutil.copyfile(f, f+"_backup")
with open(f, "r") as src:
sources = src.read()
with open(f, "w") as src:
for pragma in add_pragmas:
src.write("#pragma %s;\n"%pragma)
src.write(sources)
def post_process_func(f):
shutil.move(f+"_backup", f)
shutil.move(f+"_backup", f)
def compile_func(f):
res = None
try:
pre_process_func(f)
if "storage-provider.fc" in f :
# This contract requires building of storage-contract to include it as ref
with open(f, "r") as src:
sources = src.read()
# This contract requires building of storage-contract to include it as ref
with open(f, "r") as src:
sources = src.read()
COMPILED_ST_BOC = os.path.join(TMP_DIR, "storage-contract-code.boc")
sources = sources.replace("storage-contract-code.boc", COMPILED_ST_BOC)
with open(f, "w") as src:
src.write(sources)
COMPILED_ST_FIF = os.path.join(TMP_DIR, "storage-contract.fif")
COMPILED_ST_BOC = os.path.join(TMP_DIR, "storage-contract-code.boc")
sources = sources.replace("storage-contract-code.boc", COMPILED_ST_BOC)
with open(f, "w") as src:
src.write(sources)
COMPILED_ST_FIF = os.path.join(TMP_DIR, "storage-contract.fif")
COMPILED_ST_BOC = os.path.join(TMP_DIR, "storage-contract-code.boc")
COMPILED_BUILD_BOC = os.path.join(TMP_DIR, "build-boc.fif")
res = subprocess.run([FUNC_EXECUTABLE, "-o", COMPILED_ST_FIF, "-SPA", f.replace("storage-provider.fc","storage-contract.fc")], capture_output=False, timeout=10)
with open(COMPILED_BUILD_BOC, "w") as scr:
scr.write("\"%s\" include boc>B \"%s\" B>file "%(COMPILED_ST_FIF, COMPILED_ST_BOC))
res = subprocess.run([FIFT_EXECUTABLE, COMPILED_BUILD_BOC ], capture_output=True, timeout=10)
COMPILED_BUILD_BOC = os.path.join(TMP_DIR, "build-boc.fif")
res = subprocess.run([FUNC_EXECUTABLE, "-o", COMPILED_ST_FIF, "-SPA", f.replace("storage-provider.fc","storage-contract.fc")], capture_output=False, timeout=10)
with open(COMPILED_BUILD_BOC, "w") as scr:
scr.write("\"%s\" include boc>B \"%s\" B>file "%(COMPILED_ST_FIF, COMPILED_ST_BOC))
res = subprocess.run([FIFT_EXECUTABLE, COMPILED_BUILD_BOC ], capture_output=True, timeout=10)
res = subprocess.run([FUNC_EXECUTABLE, "-o", COMPILED_FIF, "-SPA", f], capture_output=True, timeout=10)
except Exception as e:
post_process_func(f)
raise e
post_process_func(f)
raise e
else:
post_process_func(f)
post_process_func(f)
if res.returncode != 0:
raise ExecutionError(str(res.stderr, "utf-8"))
def run_runner():
res = subprocess.run([FIFT_EXECUTABLE, "-I", FIFT_LIBS, RUNNER_FIF], capture_output=True, timeout=10)
res = subprocess.run([FIFT_EXECUTABLE, RUNNER_FIF], capture_output=True, timeout=10)
if res.returncode != 0:
raise ExecutionError(str(res.stderr, "utf-8"))
s = str(res.stdout, "utf-8")
@ -138,16 +137,15 @@ for ti, t in enumerate(tests):
try:
func_out = run_runner()
if func_out != th:
raise ExecutionError("Error : expected '%d', found '%d'" % (th, func_out))
raise ExecutionError("Error : expected '%d', found '%d'" % (th, func_out))
success += 1
except ExecutionError as e:
print(e, file=sys.stderr)
#print("Compiled:", file=sys.stderr)
#with open(COMPILED_FIF, "r") as f:
# print(f.read(), file=sys.stderr)
#exit(2)
print("Compiled:", file=sys.stderr)
with open(COMPILED_FIF, "r") as f:
print(f.read(), file=sys.stderr)
exit(2)
print(" OK ", file=sys.stderr)
print(get_version())
print("Done: Success %d, Error: %d"%(success, len(tests)-success), file=sys.stderr)

View file

@ -4,6 +4,7 @@ import subprocess
import sys
import tempfile
def getenv(name, default=None):
if name in os.environ:
return os.environ[name]
@ -12,10 +13,9 @@ def getenv(name, default=None):
exit(1)
return default
FUNC_EXECUTABLE = getenv("FUNC_EXECUTABLE", "func")
FIFT_EXECUTABLE = getenv("FIFT_EXECUTABLE", "fift")
#FUNC_STDLIB = getenv("FUNC_STDLIB")
FIFT_LIBS = getenv("FIFT_LIBS")
TMP_DIR = tempfile.mkdtemp()
COMPILED_FIF = os.path.join(TMP_DIR, "compiled.fif")
RUNNER_FIF = os.path.join(TMP_DIR, "runner.fif")
@ -25,22 +25,26 @@ if len(sys.argv) != 2:
exit(1)
TESTS_DIR = sys.argv[1]
class ExecutionError(Exception):
pass
def compile_func(f):
res = subprocess.run([FUNC_EXECUTABLE, "-o", COMPILED_FIF, "-SPA", f], capture_output=True, timeout=10)
if res.returncode != 0:
raise ExecutionError(str(res.stderr, "utf-8"))
def run_runner():
res = subprocess.run([FIFT_EXECUTABLE, "-I", FIFT_LIBS, RUNNER_FIF], capture_output=True, timeout=10)
res = subprocess.run([FIFT_EXECUTABLE, RUNNER_FIF], capture_output=True, timeout=10)
if res.returncode != 0:
raise ExecutionError(str(res.stderr, "utf-8"))
s = str(res.stdout, "utf-8")
s = [x.strip() for x in s.split("\n")]
return [x for x in s if x != ""]
tests = [s for s in os.listdir(TESTS_DIR) if s.endswith(".fc")]
tests.sort()
print("Found", len(tests), "tests", file=sys.stderr)
@ -68,18 +72,18 @@ for ti, tf in enumerate(tests):
# preprocess arithmetics in input
for i in range(len(cases)):
inputs = cases[i][1].split(" ")
processed_inputs = ""
for in_arg in inputs:
if "x{" in in_arg:
processed_inputs += in_arg
continue
# filter and execute
# is it safe enough?
filtered_in = "".join(filter(lambda x: x in "0x123456789()+-*/<>", in_arg))
if(filtered_in):
processed_inputs += str(eval(filtered_in)) + " ";
cases[i][1] = processed_inputs.strip()
inputs = cases[i][1].split(" ")
processed_inputs = ""
for in_arg in inputs:
if "x{" in in_arg:
processed_inputs += in_arg
continue
# filter and execute
# is it safe enough?
filtered_in = "".join(filter(lambda x: x in "0x123456789()+-*/<>", in_arg))
if filtered_in:
processed_inputs += str(eval(filtered_in)) + " "
cases[i][1] = processed_inputs.strip()
with open(RUNNER_FIF, "w") as f:
print("\"%s\" include <s constant code" % COMPILED_FIF, file=f)

View file

@ -232,6 +232,7 @@ Bignum& Bignum::import_lsb(const unsigned char* buffer, std::size_t size) {
std::string Bignum::to_str() const {
char* ptr = BN_bn2dec(val);
CHECK(ptr);
std::string z(ptr);
OPENSSL_free(ptr);
return z;
@ -239,6 +240,7 @@ std::string Bignum::to_str() const {
std::string Bignum::to_hex() const {
char* ptr = BN_bn2hex(val);
CHECK(ptr);
std::string z(ptr);
OPENSSL_free(ptr);
return z;
@ -255,7 +257,13 @@ std::istream& operator>>(std::istream& is, Bignum& x) {
return is;
}
bool is_prime(const Bignum& p, int nchecks, bool trial_div) {
return BN_is_prime_fasttest_ex(p.bn_ptr(), BN_prime_checks, get_ctx(), trial_div, 0);
bool is_prime(const Bignum& p) {
#if OPENSSL_VERSION_MAJOR >= 3
int result = BN_check_prime(p.bn_ptr(), get_ctx(), nullptr);
LOG_IF(FATAL, result == -1);
return result;
#else
return BN_is_prime_fasttest_ex(p.bn_ptr(), BN_prime_checks, get_ctx(), true, 0);
#endif
}
} // namespace arith

View file

@ -335,7 +335,7 @@ const Bignum sqr(const Bignum& x);
std::ostream& operator<<(std::ostream& os, const Bignum& x);
std::istream& operator>>(std::istream& is, Bignum& x);
bool is_prime(const Bignum& p, int nchecks = 64, bool trial_div = true);
bool is_prime(const Bignum& p);
inline int cmp(const Bignum& x, const Bignum& y) {
return BN_cmp(x.bn_ptr(), y.bn_ptr());

View file

@ -250,7 +250,6 @@ const Lexem& Lexer::next() {
}
if (is_multiline_quote(src.get_ptr(), src.get_end_ptr())) {
src.advance(multiline_quote.size());
const char* begin = src.get_ptr();
const char* end = nullptr;
SrcLocation here = src.here();
std::string body;

View file

@ -155,7 +155,7 @@ td::Result<td::uint32> GenericAccount::get_wallet_id(const SmartContract& sc) {
return TRY_VM([&]() -> td::Result<td::uint32> {
auto answer = sc.run_get_method("wallet_id");
if (!answer.success) {
return td::Status::Error("seqno get method failed");
return td::Status::Error("wallet_id get method failed");
}
return static_cast<td::uint32>(answer.stack.write().pop_long_range(std::numeric_limits<td::uint32>::max()));
}());

View file

@ -305,7 +305,7 @@ class ManualDns : public ton::SmartContract, public DnsInterface {
if (!info.known_category.insert(action.category).second) {
continue;
}
if (action.category == 0) {
if (action.category.is_zero()) {
info.closed = true;
auto old_actions = std::move(info.actions);
bool is_empty = true;
@ -327,7 +327,7 @@ class ManualDns : public ton::SmartContract, public DnsInterface {
if (info.closed) {
CombinedActions<ActionT> ca;
ca.name = it.first;
ca.category = 0;
ca.category = td::Bits256::zero();
if (!info.actions.empty() || info.non_empty) {
ca.actions = std::move(info.actions);
}

View file

@ -181,7 +181,7 @@ SmartContract::Answer run_smartcont(SmartContract::State state, td::Ref<vm::Stac
int vm_log_verbosity, bool debug_enabled,
std::shared_ptr<const block::Config> config) {
auto gas_credit = gas.gas_credit;
vm::init_op_cp0(debug_enabled);
vm::init_vm(debug_enabled).ensure();
vm::DictionaryBase::get_empty_dictionary();
class Logger : public td::LogInterface {
@ -246,10 +246,10 @@ SmartContract::Answer run_smartcont(SmartContract::State state, td::Ref<vm::Stac
LOG(DEBUG) << "VM accepted: " << res.accepted;
LOG(DEBUG) << "VM success: " << res.success;
}
td::ConstBitPtr mlib = vm.get_missing_library();
if (!mlib.is_null()) {
LOG(DEBUG) << "Missing library: " << mlib.to_hex(256);
res.missing_library = mlib;
auto mlib = vm.get_missing_library();
if (mlib) {
LOG(DEBUG) << "Missing library: " << mlib.value().to_hex();
res.missing_library = mlib.value();
}
if (res.success) {
res.new_state.data = vm.get_c4();
@ -257,7 +257,7 @@ SmartContract::Answer run_smartcont(SmartContract::State state, td::Ref<vm::Stac
LOG(DEBUG) << "output actions:\n"
<< block::gen::OutList{res.output_actions_count(res.actions)}.as_string_ref(res.actions);
}
LOG_IF(ERROR, gas_credit != 0 && (res.accepted && !res.success) && mlib.is_null())
LOG_IF(ERROR, gas_credit != 0 && (res.accepted && !res.success) && !mlib)
<< "Accepted but failed with code " << res.code << "\n"
<< res.gas_used << "\n";
return res;

View file

@ -49,7 +49,7 @@ class SmartContract : public td::CntObject {
td::Ref<vm::Cell> actions;
td::int32 code;
td::int64 gas_used;
td::ConstBitPtr missing_library{0};
td::optional<td::Bits256> missing_library;
std::string vm_log;
static int output_actions_count(td::Ref<vm::Cell> list);
};

View file

@ -28,6 +28,7 @@ namespace {
// WALLET_REVISION = 2;
// WALLET2_REVISION = 2;
// WALLET3_REVISION = 2;
// WALLET4_REVISION = 2;
// HIGHLOAD_WALLET_REVISION = 2;
// HIGHLOAD_WALLET2_REVISION = 2;
// DNS_REVISION = 1;
@ -92,6 +93,20 @@ const auto& get_map() {
"AAXrc52omhpn5jrhf/AABesePaiaGmPmOuFj8ABDbbYHwR7Z5AOAQm1B1tnkA4BTu1E0IEBQNch0x/"
"0BNEC2zz4J28QAoAg9HtvpTGX+gAwoXC2CZEw4g8AOiGOETGA8/gzIG6SMHCU0NcLH+IB3yGSAaGSW3/iAAzTB9QC+wAAHssfFMsfEsv/yx/"
"0AMntVA==");
with_tvm_code(
"wallet-v4-r2",
"te6cckECFAEAAtQAART/APSkE/S88sgLAQIBIAIDAgFIBAUE+PKDCNcYINMf0x/THwL4I7vyZO1E0NMf0x/T//"
"QE0VFDuvKhUVG68qIF+QFUEGT5EPKj+AAkpMjLH1JAyx9SMMv/"
"UhD0AMntVPgPAdMHIcAAn2xRkyDXSpbTB9QC+wDoMOAhwAHjACHAAuMAAcADkTDjDQOkyMsfEssfy/"
"8QERITAubQAdDTAyFxsJJfBOAi10nBIJJfBOAC0x8hghBwbHVnvSKCEGRzdHK9sJJfBeAD+kAwIPpEAcjKB8v/"
"ydDtRNCBAUDXIfQEMFyBAQj0Cm+hMbOSXwfgBdM/"
"yCWCEHBsdWe6kjgw4w0DghBkc3RyupJfBuMNBgcCASAICQB4AfoA9AQw+CdvIjBQCqEhvvLgUIIQcGx1Z4MesXCAGFAEywUmzxZY+"
"gIZ9ADLaRfLH1Jgyz8gyYBA+wAGAIpQBIEBCPRZMO1E0IEBQNcgyAHPFvQAye1UAXKwjiOCEGRzdHKDHrFwgBhQBcsFUAPPFiP6AhPLassfyz/"
"JgED7AJJfA+ICASAKCwBZvSQrb2omhAgKBrkPoCGEcNQICEekk30pkQzmkD6f+YN4EoAbeBAUiYcVnzGEAgFYDA0AEbjJftRNDXCx+"
"AA9sp37UTQgQFA1yH0BDACyMoHy//J0AGBAQj0Cm+hMYAIBIA4PABmtznaiaEAga5Drhf/AABmvHfaiaEAQa5DrhY/AAG7SB/"
"oA1NQi+QAFyMoHFcv/ydB3dIAYyMsFywIizxZQBfoCFMtrEszMyXP7AMhAFIEBCPRR8qcCAHCBAQjXGPoA0z/"
"IVCBHgQEI9FHyp4IQbm90ZXB0gBjIywXLAlAGzxZQBPoCFMtqEssfyz/Jc/sAAgBsgQEI1xj6ANM/"
"MFIkgQEI9Fnyp4IQZHN0cnB0gBjIywXLAlAFzxZQA/oCE8tqyx8Syz/Jc/sAAAr0AMntVGliJeU=");
return map;
}();
return map;
@ -137,9 +152,12 @@ td::Span<int> SmartContractCode::get_revisions(Type type) {
static int res[] = {1};
return res;
}
case Type::WalletV4: {
static int res[] = {2};
return res;
}
}
UNREACHABLE();
return {};
}
td::Result<int> SmartContractCode::validate_revision(Type type, int revision) {
@ -179,9 +197,10 @@ td::Ref<vm::Cell> SmartContractCode::get_code(Type type, int ext_revision) {
return "payment-channel";
case Type::RestrictedWallet:
return "restricted-wallet3";
case Type::WalletV4:
return "wallet-v4";
}
UNREACHABLE();
return "";
}(type);
if (revision == -1) {
return load(basename).move_as_ok();

View file

@ -26,7 +26,16 @@ class SmartContractCode {
public:
static td::Result<td::Ref<vm::Cell>> load(td::Slice name);
enum Type { WalletV3 = 4, HighloadWalletV1, HighloadWalletV2, ManualDns, Multisig, PaymentChannel, RestrictedWallet };
enum Type {
WalletV3 = 4,
HighloadWalletV1,
HighloadWalletV2,
ManualDns,
Multisig,
PaymentChannel,
RestrictedWallet,
WalletV4
};
static td::Span<int> get_revisions(Type type);
static td::Result<int> validate_revision(Type type, int revision);
static td::Ref<vm::Cell> get_code(Type type, int revision = 0);

View file

@ -55,18 +55,21 @@ td::Ref<vm::Cell> WalletInterface::create_int_message(const Gift &gift) {
} else {
cbi.store_zeroes(1);
}
cbi.store_zeroes(1);
store_gift_message(cbi, gift);
return cbi.finalize();
}
void WalletInterface::store_gift_message(vm::CellBuilder &cb, const Gift &gift) {
if (gift.body.not_null()) {
auto body = vm::load_cell_slice(gift.body);
//TODO: handle error
CHECK(cb.append_cellslice_bool(body));
if (cb.can_extend_by(1 + body.size(), body.size_refs())) {
CHECK(cb.store_zeroes_bool(1) && cb.append_cellslice_bool(body));
} else {
CHECK(cb.store_ones_bool(1) && cb.store_ref_bool(gift.body));
}
return;
}
cb.store_zeroes(1);
if (gift.is_encrypted) {
cb.store_long(0x2167da4b, 32);
} else {

View file

@ -73,6 +73,8 @@ class WalletInterface : public SmartContract {
td::uint32 valid_until = std::numeric_limits<td::uint32>::max()) const;
static td::Ref<vm::Cell> create_int_message(const Gift &gift);
private:
static void store_gift_message(vm::CellBuilder &cb, const Gift &gift);
};

View file

@ -0,0 +1,71 @@
/*
This file is part of TON Blockchain Library.
TON Blockchain Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
TON Blockchain Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "WalletV4.h"
#include "GenericAccount.h"
#include "SmartContractCode.h"
#include "vm/boc.h"
#include "vm/cells/CellString.h"
#include "td/utils/base64.h"
#include <limits>
namespace ton {
td::Result<td::Ref<vm::Cell>> WalletV4::make_a_gift_message(const td::Ed25519::PrivateKey& private_key,
td::uint32 valid_until, td::Span<Gift> gifts) const {
CHECK(gifts.size() <= get_max_gifts_size());
TRY_RESULT(seqno, get_seqno());
TRY_RESULT(wallet_id, get_wallet_id());
vm::CellBuilder cb;
cb.store_long(wallet_id, 32).store_long(valid_until, 32).store_long(seqno, 32);
cb.store_long(0, 8); // The only difference with wallet-v3
for (auto& gift : gifts) {
td::int32 send_mode = 3;
if (gift.gramms == -1) {
send_mode += 128;
}
if (gift.send_mode > -1) {
send_mode = gift.send_mode;
}
cb.store_long(send_mode, 8).store_ref(create_int_message(gift));
}
auto message_outer = cb.finalize();
auto signature = private_key.sign(message_outer->get_hash().as_slice()).move_as_ok();
return vm::CellBuilder().store_bytes(signature).append_cellslice(vm::load_cell_slice(message_outer)).finalize();
}
td::Ref<vm::Cell> WalletV4::get_init_data(const InitData& init_data) noexcept {
return vm::CellBuilder()
.store_long(init_data.seqno, 32)
.store_long(init_data.wallet_id, 32)
.store_bytes(init_data.public_key)
.store_zeroes(1) // plugins dict
.finalize();
}
td::Result<td::uint32> WalletV4::get_wallet_id() const {
return TRY_VM([&]() -> td::Result<td::uint32> {
auto answer = run_get_method("get_subwallet_id");
if (!answer.success) {
return td::Status::Error("get_subwallet_id get method failed");
}
return static_cast<td::uint32>(answer.stack.write().pop_long_range(std::numeric_limits<td::uint32>::max()));
}());
}
} // namespace ton

View file

@ -0,0 +1,46 @@
/*
This file is part of TON Blockchain Library.
TON Blockchain Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
TON Blockchain Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "smc-envelope/SmartContract.h"
#include "smc-envelope/WalletInterface.h"
#include "vm/cells.h"
#include "Ed25519.h"
#include "block/block.h"
#include "vm/cells/CellString.h"
namespace ton {
struct WalletV4Traits {
using InitData = WalletInterface::DefaultInitData;
static constexpr unsigned max_message_size = vm::CellString::max_bytes;
static constexpr unsigned max_gifts_size = 4;
static constexpr auto code_type = SmartContractCode::WalletV4;
};
class WalletV4 : public WalletBase<WalletV4, WalletV4Traits> {
public:
explicit WalletV4(State state) : WalletBase(std::move(state)) {
}
td::Result<td::Ref<vm::Cell>> make_a_gift_message(const td::Ed25519::PrivateKey& private_key, td::uint32 valid_until,
td::Span<Gift> gifts) const override;
static td::Ref<vm::Cell> get_init_data(const InitData& init_data) noexcept;
td::Result<td::uint32> get_wallet_id() const override;
};
} // namespace ton

View file

@ -33,7 +33,7 @@ std::string load_test(std::string name) {
return td::read_file_str(current_dir() + "fift/" + name).move_as_ok();
}
td::Status run_fift(std::string name, bool expect_error = false, bool preload_fift = true) {
td::Status run_fift(std::string name, bool expect_error = false) {
auto res = fift::mem_run_fift(load_test(name));
if (expect_error) {
res.ensure_error();

View file

@ -9,6 +9,9 @@
[[ <{ RIST255_MULBASE DUP RIST255_VALIDATE }>s ]] 0 runvmx abort"Exitcode != 0"
@' n . dup (x.) type cr
@' ans <> abort"Invalid result"
@' n
[[ <{ 1 INT RIST255_MULBASE SWAP RIST255_MUL DUP RIST255_VALIDATE }>s ]] 0 runvmx abort"Exitcode != 0"
@' ans <> abort"Invalid result"
} : test-basepoint
0 0x0000000000000000000000000000000000000000000000000000000000000000 test-basepoint

View file

@ -180,7 +180,7 @@ struct MixedRadix {
template <int M>
const MixedRadix<M>& as_shorter() const {
static_assert(M <= N);
static_assert(M <= N,"error");
return *reinterpret_cast<const MixedRadix<M>*>(this);
}
@ -458,7 +458,7 @@ struct ModArray {
}
template <int M>
ModArray(const ModArray<M>& other) {
static_assert(M >= N);
static_assert(M >= N,"error");
std::copy(other.a, other.a + N, a);
}
ModArray(const int* p) : a(p) {
@ -819,7 +819,7 @@ struct ModArray {
template <int M>
const ModArray<M>& as_shorter() const {
static_assert(M <= N);
static_assert(M <= N,"error");
return *reinterpret_cast<const ModArray<M>*>(this);
}

View file

@ -16,12 +16,12 @@
*/
#include <assert.h>
#include <string.h>
#include <unistd.h>
#include <array>
#include <string>
#include <iostream>
#include <sstream>
#include <random>
#include <getopt.h>
#include "common/refcnt.hpp"
#include "common/bigint.hpp"
#include "common/refint.h"
@ -211,7 +211,7 @@ bool coin() {
// returns 0 with probability 1/2, 1 with prob. 1/4, ..., k with prob. 1/2^(k+1)
int randexp(int max = 63, int min = 0) {
return min + __builtin_clzll(Random() | (1ULL << (63 - max + min)));
return min + td::count_leading_zeroes64(Random() | (1ULL << (63 - max + min)));
}
void bin_add_small(unsigned char bin[64], long long val, int shift = 0) {
@ -363,7 +363,7 @@ void check_one_int_repr(td::RefInt256 x, int mode, int in_range, const BInt* val
if (is_small) {
// special check for small (64-bit) values
CHECK(x->to_long() == xval);
CHECK((long long)__builtin_bswap64(*(long long*)(bytes + 64 - 8)) == xval);
CHECK((long long)td::bswap64(*(long long*)(bytes + 64 - 8)) == xval);
CHECK(in_range);
// check sign
CHECK(x->sgn() == (xval > 0 ? 1 : (xval < 0 ? -1 : 0)));

View file

@ -127,12 +127,12 @@ class BenchSha256Low : public td::Benchmark {
void run(int n) override {
int res = 0;
SHA256_CTX ctx;
td::Sha256State ctx;
for (int i = 0; i < n; i++) {
SHA256_Init(&ctx);
SHA256_Update(&ctx, "abcd", 4);
ctx.init();
ctx.feed("abcd");
unsigned char buf[32];
SHA256_Final(buf, &ctx);
ctx.extract(td::MutableSlice{buf, 32});
res += buf[0];
}
td::do_not_optimize_away(res);

View file

@ -35,6 +35,7 @@
#include "smc-envelope/SmartContract.h"
#include "smc-envelope/SmartContractCode.h"
#include "smc-envelope/WalletV3.h"
#include "smc-envelope/WalletV4.h"
#include "smc-envelope/HighloadWallet.h"
#include "smc-envelope/HighloadWalletV2.h"
#include "smc-envelope/PaymentChannel.h"
@ -526,6 +527,7 @@ void do_test_wallet() {
TEST(Tonlib, Wallet) {
do_test_wallet<ton::WalletV3>();
do_test_wallet<ton::WalletV4>();
do_test_wallet<ton::HighloadWallet>();
do_test_wallet<ton::HighloadWalletV2>();
do_test_wallet<ton::RestrictedWallet>();
@ -956,7 +958,7 @@ class MapDns {
}
return;
}
if (!actions.category.is_zero()) {
if (actions.category.is_zero()) {
entries_.erase(actions.name);
LOG(ERROR) << "CLEAR " << actions.name;
if (!actions.actions) {
@ -1001,7 +1003,7 @@ class CheckedDns {
explicit CheckedDns(bool check_smc = true, bool check_combine = true) {
if (check_smc) {
key_ = td::Ed25519::generate_private_key().move_as_ok();
dns_ = ManualDns::create(ManualDns::create_init_data_fast(key_.value().get_public_key().move_as_ok(), 123));
dns_ = ManualDns::create(ManualDns::create_init_data_fast(key_.value().get_public_key().move_as_ok(), 123), -1);
}
if (check_combine) {
combined_map_dns_ = MapDns();
@ -1092,9 +1094,10 @@ class CheckedDns {
}
};
static td::Bits256 intToCat(int x) {
td::Bits256 cat = td::Bits256::zero();
cat.as_slice().copy_from(td::Slice((char*)&x, sizeof(x)));
static td::Bits256 intToCat(td::uint32 x) {
auto y = td::make_refint(x);
td::Bits256 cat;
y->export_bytes(cat.data(), 32, false);
return cat;
}
@ -1180,7 +1183,7 @@ TEST(Smartcont, DnsManual) {
auto key = td::Ed25519::generate_private_key().move_as_ok();
auto manual = ManualDns::create(ManualDns::create_init_data_fast(key.get_public_key().move_as_ok(), 123));
auto manual = ManualDns::create(ManualDns::create_init_data_fast(key.get_public_key().move_as_ok(), 123), -1);
CHECK(manual->get_wallet_id().move_as_ok() == 123);
auto init_query = manual->create_init_query(key).move_as_ok();
LOG(ERROR) << "A";

View file

@ -28,7 +28,7 @@
#include "td/utils/StringBuilder.h"
std::string run_vm(td::Ref<vm::Cell> cell) {
vm::init_op_cp0();
vm::init_vm().ensure();
vm::DictionaryBase::get_empty_dictionary();
class Logger : public td::LogInterface {

View file

@ -159,7 +159,6 @@ std::string CppIdentSet::compute_cpp_ident(std::string orig_ident, int count) {
}
if (!cnt) {
os << '_';
prev_skip = true;
}
if (count) {
os << count;

View file

@ -2252,11 +2252,9 @@ TypeExpr* parse_expr10(Lexer& lex, Constructor& cs, int mode) {
}
if (op == '>') {
std::swap(expr, expr2);
op = '<';
op_name = Less_name;
} else if (op == src::_Geq) {
std::swap(expr, expr2);
op = src::_Leq;
op_name = Leq_name;
}
auto sym_def = sym::lookup_symbol(op_name, 2);

View file

@ -285,8 +285,11 @@ int exec_divmod(VmState* st, unsigned args, int quiet) {
typename td::BigInt256::DoubleInt tmp{*x}, quot;
tmp += *w;
tmp.mod_div(*y, quot, round_mode);
stack.push_int_quiet(td::make_refint(quot), quiet);
stack.push_int_quiet(td::make_refint(tmp), quiet);
auto q = td::make_refint(quot), r = td::make_refint(tmp);
q.write().normalize();
r.write().normalize();
stack.push_int_quiet(std::move(q), quiet);
stack.push_int_quiet(std::move(r), quiet);
} else {
switch (d) {
case 1:
@ -399,6 +402,7 @@ std::string dump_shrmod(CellSlice&, unsigned args, int mode) {
if (mode & 1) {
os << 'Q';
}
std::string end;
switch (args & 12) {
case 4:
os << "RSHIFT";
@ -407,17 +411,22 @@ std::string dump_shrmod(CellSlice&, unsigned args, int mode) {
os << "MODPOW2";
break;
case 12:
os << "RSHIFTMOD";
os << "RSHIFT";
end = "MOD";
break;
case 0:
os << "ADDRSHIFTMOD";
os << "ADDRSHIFT";
end = "MOD";
break;
}
if (!(mode & 2)) {
os << end;
}
if (round_mode) {
os << "FRC"[round_mode];
}
if (mode & 2) {
os << ' ' << y;
os << "#" << end << ' ' << y;
}
return os.str();
}
@ -519,7 +528,7 @@ int exec_mulshrmod(VmState* st, unsigned args, int mode) {
if (add) {
tmp = *w;
}
tmp.add_mul(*x, *y);
tmp.add_mul(*x, *y).normalize();
switch (d) {
case 1:
tmp.rshift(z, round_mode).normalize();
@ -553,6 +562,7 @@ std::string dump_mulshrmod(CellSlice&, unsigned args, int mode) {
if (mode & 1) {
os << 'Q';
}
std::string end;
switch (args & 12) {
case 4:
os << "MULRSHIFT";
@ -561,15 +571,21 @@ std::string dump_mulshrmod(CellSlice&, unsigned args, int mode) {
os << "MULMODPOW2";
break;
case 12:
os << "MULRSHIFTMOD";
os << "MULRSHIFT";
end = "MOD";
break;
case 0:
os << "MULADDRSHIFTMOD";
os << "MULADDRSHIFT";
end = "MOD";
break;
}
if (round_mode) {
os << "FRC"[round_mode];
}
if (mode & 2) {
os << "#";
}
os << end;
if (mode & 2) {
os << ' ' << y;
}
@ -644,18 +660,22 @@ std::string dump_shldivmod(CellSlice&, unsigned args, int mode) {
if (mode & 1) {
os << "Q";
}
os << "LSHIFT";
if (mode & 2) {
os << "#";
}
switch (args & 12) {
case 4:
os << "LSHIFTDIV";
os << "DIV";
break;
case 8:
os << "LSHIFTMOD";
os << "MOD";
break;
case 12:
os << "LSHIFTDIVMOD";
os << "DIVMOD";
break;
case 0:
os << "LSHIFTADDDIVMOD";
os << "ADDDIVMOD";
break;
}
if (round_mode) {

View file

@ -142,28 +142,57 @@ td::Ref<vm::Cell> CellText::do_store(td::BitSlice slice) {
}
template <class F>
void CellText::for_each(F &&f, CellSlice cs) {
td::Status CellText::for_each(F &&f, CellSlice cs) {
if (!cs.have(8)) {
return td::Status::Error("Cell underflow");
}
auto depth = cs.fetch_ulong(8);
if (depth > max_chain_length) {
return td::Status::Error("Too deep string");
}
for (td::uint32 i = 0; i < depth; i++) {
auto size = cs.fetch_ulong(8);
f(cs.fetch_bits(td::narrow_cast<int>(size) * 8));
if (!cs.have(8)) {
return td::Status::Error("Cell underflow");
}
auto size = td::narrow_cast<int>(cs.fetch_ulong(8));
if (!cs.have(size * 8)) {
return td::Status::Error("Cell underflow");
}
TRY_STATUS(f(cs.fetch_bits(size * 8)));
if (i + 1 < depth) {
if (!cs.have_refs()) {
return td::Status::Error("Cell underflow");
}
cs = vm::load_cell_slice(cs.prefetch_ref());
}
}
return td::Status::OK();
}
td::Result<td::string> CellText::load(CellSlice &cs) {
unsigned int size = 0;
for_each([&](auto slice) { size += slice.size(); }, cs);
TRY_STATUS(for_each(
[&](auto slice) {
size += slice.size();
if (size > max_bytes * 8) {
return td::Status::Error("String is too long");
}
return td::Status::OK();
},
cs));
if (size % 8 != 0) {
return td::Status::Error("Size is not divisible by 8");
}
std::string res(size / 8, 0);
td::BitPtr to(td::MutableSlice(res).ubegin());
for_each([&](auto slice) { to.concat(slice); }, cs);
TRY_STATUS(for_each(
[&](auto slice) {
to.concat(slice);
return td::Status::OK();
},
cs));
CHECK(to.offs == (int)size);
return res;
}

View file

@ -52,7 +52,7 @@ class CellText {
private:
template <class F>
static void for_each(F &&f, CellSlice cs);
static td::Status for_each(F &&f, CellSlice cs);
static td::Ref<vm::Cell> do_store(td::BitSlice slice);
};

View file

@ -101,7 +101,7 @@ void register_basic_gas_ops(OpcodeTable& cp0) {
using namespace std::placeholders;
cp0.insert(OpcodeInstr::mksimple(0xf800, 16, "ACCEPT", exec_accept))
.insert(OpcodeInstr::mksimple(0xf801, 16, "SETGASLIMIT", exec_set_gas_limit))
.insert(OpcodeInstr::mksimple(0xf802, 16, "GASCONSUMED", exec_gas_consumed)->require_version(4))
.insert(OpcodeInstr::mksimple(0xf807, 16, "GASCONSUMED", exec_gas_consumed)->require_version(4))
.insert(OpcodeInstr::mksimple(0xf80f, 16, "COMMIT", exec_commit));
}
@ -620,7 +620,6 @@ int exec_ristretto255_from_hash(VmState* st) {
if (!x2->export_bytes(xb + 32, 32, false)) {
throw VmError{Excno::range_chk, "x2 must fit in an unsigned 256-bit integer"};
}
CHECK(sodium_init() >= 0);
crypto_core_ristretto255_from_hash(rb, xb);
td::RefInt256 r{true};
CHECK(r.write().import_bytes(rb, 32, false));
@ -633,8 +632,7 @@ int exec_ristretto255_validate(VmState* st, bool quiet) {
Stack& stack = st->get_stack();
auto x = stack.pop_int();
st->consume_gas(VmState::rist255_validate_gas_price);
unsigned char xb[64];
CHECK(sodium_init() >= 0);
unsigned char xb[32];
if (!x->export_bytes(xb, 32, false) || !crypto_core_ristretto255_is_valid_point(xb)) {
if (quiet) {
stack.push_bool(false);
@ -656,7 +654,6 @@ int exec_ristretto255_add(VmState* st, bool quiet) {
auto x = stack.pop_int();
st->consume_gas(VmState::rist255_add_gas_price);
unsigned char xb[32], yb[32], rb[32];
CHECK(sodium_init() >= 0);
if (!x->export_bytes(xb, 32, false) || !y->export_bytes(yb, 32, false) || crypto_core_ristretto255_add(rb, xb, yb)) {
if (quiet) {
stack.push_bool(false);
@ -681,7 +678,6 @@ int exec_ristretto255_sub(VmState* st, bool quiet) {
auto x = stack.pop_int();
st->consume_gas(VmState::rist255_add_gas_price);
unsigned char xb[32], yb[32], rb[32];
CHECK(sodium_init() >= 0);
if (!x->export_bytes(xb, 32, false) || !y->export_bytes(yb, 32, false) || crypto_core_ristretto255_sub(rb, xb, yb)) {
if (quiet) {
stack.push_bool(false);
@ -719,17 +715,20 @@ int exec_ristretto255_mul(VmState* st, bool quiet) {
auto n = stack.pop_int() % get_ristretto256_l();
auto x = stack.pop_int();
st->consume_gas(VmState::rist255_mul_gas_price);
unsigned char xb[32], nb[32], rb[32];
memset(rb, 255, sizeof(rb));
CHECK(sodium_init() >= 0);
if (!x->export_bytes(xb, 32, false) || !export_bytes_little(n, nb) || crypto_scalarmult_ristretto255(rb, nb, xb)) {
if (std::all_of(rb, rb + 32, [](unsigned char c) { return c == 255; })) {
if (quiet) {
stack.push_bool(false);
return 0;
}
throw VmError{Excno::range_chk, "invalid x or n"};
if (n->sgn() == 0) {
stack.push_smallint(0);
if (quiet) {
stack.push_bool(true);
}
return 0;
}
unsigned char xb[32], nb[32], rb[32];
if (!x->export_bytes(xb, 32, false) || !export_bytes_little(n, nb) || crypto_scalarmult_ristretto255(rb, nb, xb)) {
if (quiet) {
stack.push_bool(false);
return 0;
}
throw VmError{Excno::range_chk, "invalid x or n"};
}
td::RefInt256 r{true};
CHECK(r.write().import_bytes(rb, 32, false));
@ -747,7 +746,6 @@ int exec_ristretto255_mul_base(VmState* st, bool quiet) {
st->consume_gas(VmState::rist255_mulbase_gas_price);
unsigned char nb[32], rb[32];
memset(rb, 255, sizeof(rb));
CHECK(sodium_init() >= 0);
if (!export_bytes_little(n, nb) || crypto_scalarmult_ristretto255_base(rb, nb)) {
if (std::all_of(rb, rb + 32, [](unsigned char c) { return c == 255; })) {
if (quiet) {
@ -833,7 +831,7 @@ int exec_bls_verify(VmState* st) {
VM_LOG(st) << "execute BLS_VERIFY";
Stack& stack = st->get_stack();
stack.check_underflow(3);
st->consume_gas(st->bls_verify_gas_price);
st->consume_gas(VmState::bls_verify_gas_price);
bls::P2 sig = slice_to_bls_p2(*stack.pop_cellslice());
td::BufferSlice msg = slice_to_bls_msg(*stack.pop_cellslice());
bls::P1 pub = slice_to_bls_p1(*stack.pop_cellslice());
@ -845,8 +843,7 @@ int exec_bls_aggregate(VmState* st) {
VM_LOG(st) << "execute BLS_AGGREGATE";
Stack& stack = st->get_stack();
int n = stack.pop_smallint_range(stack.depth() - 1, 1);
st->consume_gas(
std::max(0LL, VmState::bls_aggregate_base_gas_price + (long long)n * VmState::bls_aggregate_element_gas_price));
st->consume_gas(VmState::bls_aggregate_base_gas_price + (long long)n * VmState::bls_aggregate_element_gas_price);
std::vector<bls::P2> sigs(n);
for (int i = n - 1; i >= 0; --i) {
sigs[i] = slice_to_bls_p2(*stack.pop_cellslice());

View file

@ -21,6 +21,8 @@
#include "vm/dict.h"
#include "vm/log.h"
#include "vm/vm.h"
#include "cp0.h"
#include <sodium.h>
namespace vm {
@ -633,7 +635,7 @@ Ref<Cell> VmState::load_library(td::ConstBitPtr hash) {
return lib;
}
}
missing_library = hash;
missing_library = td::Bits256{hash};
return {};
}
@ -770,4 +772,15 @@ void VmState::restore_parent_vm(int res) {
}
}
td::Status init_vm(bool enable_debug) {
if (!init_op_cp0(enable_debug)) {
return td::Status::Error("Failed to init TVM: failed to init cp0");
}
auto code = sodium_init();
if (code < 0) {
return td::Status::Error(PSTRING() << "Failed to init TVM: sodium_init, code=" << code);
}
return td::Status::OK();
}
} // namespace vm

View file

@ -25,6 +25,7 @@
#include "vm/log.h"
#include "vm/continuation.h"
#include "td/utils/HashSet.h"
#include "td/utils/optional.h"
namespace vm {
@ -97,7 +98,7 @@ class VmState final : public VmStateInterface {
td::HashSet<CellHash> loaded_cells;
int stack_trace{0}, debug_off{0};
bool chksig_always_succeed{false};
td::ConstBitPtr missing_library{0};
td::optional<td::Bits256> missing_library;
td::uint16 max_data_depth = 512; // Default value
int global_version{0};
size_t chksgn_counter = 0;
@ -383,7 +384,7 @@ class VmState final : public VmStateInterface {
Ref<OrdCont> ref_to_cont(Ref<Cell> cell) const {
return td::make_ref<OrdCont>(load_cell_slice_ref(std::move(cell)), get_cp());
}
td::ConstBitPtr get_missing_library() const {
td::optional<td::Bits256> get_missing_library() const {
return missing_library;
}
void set_max_data_depth(td::uint16 depth) {
@ -422,4 +423,6 @@ int run_vm_code(Ref<CellSlice> _code, Stack& _stack, int flags = 0, Ref<Cell>* d
Ref<vm::Cell> lookup_library_in(td::ConstBitPtr key, Ref<vm::Cell> lib_root);
td::Status init_vm(bool enable_debug = false);
} // namespace vm

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
if (NOT OPENSSL_FOUND)
find_package(OpenSSL REQUIRED)

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
if (NOT OPENSSL_FOUND)
find_package(OpenSSL REQUIRED)

24
doc/Tests.md Normal file
View file

@ -0,0 +1,24 @@
# Tests execution
TON contains multiple unit-tests, that facilitate detection of erroneous blockchain behaviour on each commit.
## Build tests
Go inside the build directory and, if you use ninja, build the tests using the following command:
```ninja test-ed25519 test-ed25519-crypto test-bigint test-vm test-fift test-cells test-smartcont test-net test-tdactor test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain test-fec test-tddb test-db test-validator-session-state```
For more details on how to build TON artifacts, please refer to any of Github actions.
For cmake use:
```cmake --build . --target test-ed25519 test-ed25519-crypto test-bigint test-vm test-fift test-cells test-smartcont test-net test-tdactor test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain test-fec test-tddb test-db test-validator-session-state```
## Run tests
Go inside the build directory and with ninja execute:
```ninja test```
with ctest:
```ctest```
## Integration of tests into CI
Most relevant GitHub actions include the step ```Run tests``` that executes the tests. If any of tests fails, the action will be interrupted and no artifacts will be provided.

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
option(BUILD_SHARED_LIBS "Use \"OFF\" for a static build." ON)

View file

@ -139,7 +139,7 @@ const char *transaction_emulator_emulate_transaction(void *transaction_emulator,
now = (unsigned)std::time(nullptr);
}
bool is_special = wc == ton::masterchainId && emulator->get_config().is_special_smartcontract(addr);
if (!account.unpack(vm::load_cell_slice_ref(shard_account_cell.move_as_ok()), td::Ref<vm::CellSlice>(), now, is_special)) {
if (!account.unpack(vm::load_cell_slice_ref(shard_account_cell.move_as_ok()), now, is_special)) {
ERROR_RESPONSE(PSTRING() << "Can't unpack shard account");
}
@ -217,7 +217,7 @@ const char *transaction_emulator_emulate_tick_tock_transaction(void *transaction
now = (unsigned)std::time(nullptr);
}
bool is_special = wc == ton::masterchainId && emulator->get_config().is_special_smartcontract(addr);
if (!account.unpack(vm::load_cell_slice_ref(shard_account_cell.move_as_ok()), td::Ref<vm::CellSlice>(), now, is_special)) {
if (!account.unpack(vm::load_cell_slice_ref(shard_account_cell.move_as_ok()), now, is_special)) {
ERROR_RESPONSE(PSTRING() << "Can't unpack shard account");
}
@ -503,7 +503,7 @@ const char *tvm_emulator_run_get_method(void *tvm_emulator, int method_id, const
auto emulator = static_cast<emulator::TvmEmulator *>(tvm_emulator);
auto result = emulator->run_get_method(method_id, stack);
vm::FakeVmStateLimits fstate(1000); // limit recursive (de)serialization calls
vm::FakeVmStateLimits fstate(3500); // limit recursive (de)serialization calls
vm::VmStateInterface::Guard guard(&fstate);
vm::CellBuilder stack_cb;
@ -522,10 +522,10 @@ const char *tvm_emulator_run_get_method(void *tvm_emulator, int method_id, const
json_obj("gas_used", std::to_string(result.gas_used));
json_obj("vm_exit_code", result.code);
json_obj("vm_log", result.vm_log);
if (result.missing_library.is_null()) {
if (!result.missing_library) {
json_obj("missing_library", td::JsonNull());
} else {
json_obj("missing_library", td::Bits256(result.missing_library).to_hex());
json_obj("missing_library", result.missing_library.value().to_hex());
}
json_obj.leave();
@ -548,10 +548,10 @@ const char *tvm_emulator_send_external_message(void *tvm_emulator, const char *m
json_obj("vm_exit_code", result.code);
json_obj("accepted", td::JsonBool(result.accepted));
json_obj("vm_log", result.vm_log);
if (result.missing_library.is_null()) {
if (!result.missing_library) {
json_obj("missing_library", td::JsonNull());
} else {
json_obj("missing_library", td::Bits256(result.missing_library).to_hex());
json_obj("missing_library", result.missing_library.value().to_hex());
}
if (result.actions.is_null()) {
json_obj("actions", td::JsonNull());
@ -581,10 +581,10 @@ const char *tvm_emulator_send_internal_message(void *tvm_emulator, const char *m
json_obj("vm_exit_code", result.code);
json_obj("accepted", td::JsonBool(result.accepted));
json_obj("vm_log", result.vm_log);
if (result.missing_library.is_null()) {
if (!result.missing_library) {
json_obj("missing_library", td::JsonNull());
} else {
json_obj("missing_library", td::Bits256(result.missing_library).to_hex());
json_obj("missing_library", result.missing_library.value().to_hex());
}
if (result.actions.is_null()) {
json_obj("actions", td::JsonNull());

View file

@ -1,7 +1,7 @@
#include <string>
#include "transaction-emulator.h"
#include "crypto/common/refcnt.hpp"
#include "vm/cp0.h"
#include "vm/vm.h"
#include "tdutils/td/utils/Time.h"
using td::Ref;
@ -34,7 +34,7 @@ td::Result<std::unique_ptr<TransactionEmulator::EmulationResult>> TransactionEmu
return fetch_res.move_as_error_prefix("cannot fetch config params ");
}
vm::init_op_cp0(debug_enabled_);
TRY_STATUS(vm::init_vm(debug_enabled_));
if (!lt) {
lt = lt_;

View file

@ -36,7 +36,7 @@ then
BLST_LIBRARY=$(pwd)/third_party/blst/armv8/libblst.a
fi
ORIG_ARCH=$ARCH
ARCH=$ABI
mkdir -p build-$ARCH
@ -46,7 +46,7 @@ cmake .. -GNinja -DPORTABLE=1 \
-DANDROID_ABI=x86 -DANDROID_PLATFORM=android-32 -DANDROID_NDK=${ANDROID_NDK_ROOT} \
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake \
-DCMAKE_BUILD_TYPE=Release -DANDROID_ABI=${ABI} \
-DOPENSSL_ROOT_DIR=${OPENSSL_DIR}/${ARCH} -DTON_ARCH="" \
-DOPENSSL_ROOT_DIR=${OPENSSL_DIR}/${ORIG_ARCH} -DTON_ARCH="" \
-DTON_ONLY_TONLIB=ON \
-DSECP256K1_INCLUDE_DIR=${SECP256K1_INCLUDE_DIR} -DSECP256K1_LIBRARY=${SECP256K1_LIBRARY} \
-DSODIUM_INCLUDE_DIR=${SODIUM_INCLUDE_DIR} -DSODIUM_LIBRARY_RELEASE=${SODIUM_LIBRARY_RELEASE} \

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
if (NOT OPENSSL_FOUND)
find_package(OpenSSL REQUIRED)

View file

@ -99,7 +99,7 @@ td::uint32 FecType::symbol_size() const {
}
td::Result<FecType> FecType::create(tl_object_ptr<ton_api::fec_Type> obj) {
td::int32 data_size_int, symbol_size_int, symbols_count_int;
td::int32 data_size_int = 0, symbol_size_int = 0, symbols_count_int = 0;
ton_api::downcast_call(*obj, td::overloaded([&](const auto &obj) {
data_size_int = obj.data_size_;
symbol_size_int = obj.symbol_size_;

6
flake.lock generated
View file

@ -36,8 +36,8 @@
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1682600000,
"narHash": "sha256-ha4BehR1dh8EnXSoE1m/wyyYVvHI9txjW4w5/oxsW5Y=",
"lastModified": 1698846319,
"narHash": "sha256-4jyW/dqFBVpWFnhl0nvP6EN4lP7/ZqPxYRjl6var0Oc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "50fc86b75d2744e1ab3837ef74b53f103a9b55a0",
@ -45,7 +45,7 @@
},
"original": {
"owner": "nixos",
"ref": "nixos-22.05",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}

View file

@ -1,6 +1,6 @@
{
inputs = {
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-22.05";
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-23.05";
nixpkgs-trunk.url = "github:nixos/nixpkgs";
flake-compat = {
url = "github:edolstra/flake-compat";
@ -28,14 +28,14 @@
# then we can skip these manual overrides
# and switch between pkgsStatic and pkgsStatic.pkgsMusl for static glibc and musl builds
if !staticExternalDeps then [
openssl_1_1
openssl
zlib
libmicrohttpd
libsodium
secp256k1
] else
[
(openssl_1_1.override { static = true; }).dev
(openssl.override { static = true; }).dev
(zlib.override { shared = false; }).dev
]
++ optionals (!stdenv.isDarwin) [ pkgsStatic.libmicrohttpd.dev pkgsStatic.libsodium.dev secp256k1 ]
@ -50,6 +50,8 @@
] ++ optionals (staticGlibc || staticMusl) [
"-DCMAKE_LINK_SEARCH_START_STATIC=ON"
"-DCMAKE_LINK_SEARCH_END_STATIC=ON"
] ++ optionals (stdenv.isDarwin) [
"-DCMAKE_CXX_FLAGS=-stdlib=libc++" "-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=11.7"
];
LDFLAGS = optional staticExternalDeps (concatStringsSep " " [

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
set(HTTP_SOURCE
http.h

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
set(KEYRING_SOURCE
keyring.h

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
set(KEYS_SOURCE
keys.cpp

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
add_library(lite-client-common lite-client-common.cpp lite-client-common.h)
target_link_libraries(lite-client-common PUBLIC tdutils tdactor adnllite tl_api tl_lite_api tl-lite-utils ton_crypto ton_block)

View file

@ -4307,7 +4307,7 @@ int main(int argc, char* argv[]) {
});
#endif
vm::init_op_cp0(true); // enable vm debug
vm::init_vm(true).ensure(); // enable vm debug
td::actor::Scheduler scheduler({2});

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
set(MEMPROF_SOURCE
memprof/memprof.cpp

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
if (NOT OPENSSL_FOUND)
find_package(OpenSSL REQUIRED)

View file

@ -291,7 +291,11 @@ void OverlayImpl::alarm() {
if (peers_.size() > 0) {
std::vector<OverlayNode> vec;
for (td::uint32 i = 0; i < 20; i++) {
vec.push_back(get_random_peer()->get());
auto P = get_random_peer();
if (!P) {
break;
}
vec.push_back(P->get());
}
td::actor::send_closure(manager_, &OverlayManager::save_to_db, local_id_, overlay_id_, std::move(vec));
}

View file

@ -1,8 +1,10 @@
## 2023.05 Update
1. Archive manager optimization
2. A series of catchain (basic consensus protocol) security improvements
3. Update for Fift libraries and FunC: better error-handling, fixes for `catch` stack recovery
4. A series of out message queue handling optimization (already deployed during emergency upgrades between releases)
5. Improvement of binaries portability
##2023.11 Update
Besides the work of the core team, this update is based on the efforts of @aleksej-paschenko (portability improvement), [Disintar team](https://github.com/disintar/) (archive manager optimization) and [sec3-service](https://github.com/sec3-service) security auditors (funC improvements).
1. New TVM Functionality. (Disabled by default)
2. A series of emulator improvements: libraries support, higher max stack size, etc
3. A series of tonlib and tonlib-cli improvements: wallet-v4 support, getconfig, showtransactions, etc
4. Changes to public libraries: now contract can not publish more than 256 libraries (config parameter) and contracts can not be deployed with public libraries in initstate (instead contracts need explicitly publish all libraries)
5. Changes to storage due payment: now due payment is collected in Storage Phase, however for bouncable messages fee amount can not exceed balance of account prior to message.
Besides the work of the core team, this update is based on the efforts of @aleksej-paschenko (emulator improvements), @akifoq (security improvements), Trail of Bits auditor as well as all participants of [TEP-88 discussion](https://github.com/ton-blockchain/TEPs/pull/88).

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
add_executable(rldp-http-proxy rldp-http-proxy.cpp DNSResolver.h DNSResolver.cpp)
target_include_directories(rldp-http-proxy PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
if (NOT OPENSSL_FOUND)
find_package(OpenSSL REQUIRED)

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
if (NOT OPENSSL_FOUND)
find_package(OpenSSL REQUIRED)

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
if (NOT OPENSSL_FOUND)
find_package(OpenSSL REQUIRED)

View file

@ -68,13 +68,23 @@ void TorrentHeader::parse(ParserT &parser) {
parser.set_error("Unknown fec type");
return;
}
name_index.resize(files_count);
for (auto &x : name_index) {
name_index.clear();
for (size_t i = 0; i < files_count; ++i) {
td::uint64 x;
parse(x, parser);
if (parser.get_error()) {
return;
}
name_index.push_back(x);
}
data_index.resize(files_count);
for (auto &x : data_index) {
data_index.clear();
for (size_t i = 0; i < files_count; ++i) {
td::uint64 x;
parse(x, parser);
if (parser.get_error()) {
return;
}
data_index.push_back(x);
}
names = parser.template fetch_string_raw<std::string>(tot_names_size);
}

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
add_executable(embed-provider-code smartcont/embed-provider-code.cpp)

View file

@ -400,7 +400,6 @@ class NetChannel : public td::actor::Actor {
break;
} else if (l > alive_end - eps) {
alive_begin += alive_step + sleep_step;
alive_end = alive_begin + alive_step;
} else {
double new_l = td::min(alive_end, r);
res += (new_l - l) * speed;
@ -516,9 +515,7 @@ class NetChannel : public td::actor::Actor {
queue_ = {};
}
bool ok = false;
while (!queue_.empty() && (double)queue_.front().size < got_) {
ok = true;
auto query = queue_.pop();
got_ -= (double)query.size;
total_size_ -= (double)query.size;

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
#SOURCE SETS
set(TDACTOR_SOURCE

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
set(BENCHMARK_SOURCE
benchmark.cpp

View file

@ -720,7 +720,7 @@ TEST(Actor2, actor_function_result) {
}
TEST(Actor2, actor_ping_pong) {
Scheduler scheduler{{3}, Scheduler::Paused};
Scheduler scheduler{{3}, false, Scheduler::Paused};
sb.clear();
scheduler.start();
@ -799,7 +799,7 @@ TEST(Actor2, Schedulers) {
for (auto run_count : {0, 1, 2}) {
for (auto stop_count : {0, 1, 2}) {
for (size_t threads : {0, 1}) {
Scheduler scheduler({threads}, mode);
Scheduler scheduler({threads}, false, mode);
for (int i = 0; i < start_count; i++) {
scheduler.start();
}

View file

@ -210,7 +210,7 @@ TEST(Actor, promise_future) {
TEST(Actor2, actor_lost_promise) {
using namespace td::actor;
using namespace td;
Scheduler scheduler({1}, Scheduler::Paused);
Scheduler scheduler({1}, false, Scheduler::Paused);
auto watcher = td::create_shared_destructor([] {
LOG(ERROR) << "STOP";

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
#SOURCE SETS
set(TDDB_UTILS_SOURCE

View file

@ -311,6 +311,7 @@ td::Result<BlobView> FileMemoryMappingBlobView::create(td::CSlice file_path, td:
class CyclicBlobViewImpl : public BlobViewImpl {
public:
CyclicBlobViewImpl(td::BufferSlice data, td::uint64 total_size) : data_(std::move(data)), total_size_(total_size) {
CHECK(!data_.empty());
}
td::Result<td::Slice> view_impl(td::MutableSlice slice, td::uint64 offset) override {
auto res = slice;

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
set(TDFEC_SOURCE
td/fec/raptorq/Rfc.cpp

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
add_executable(benchmark-fec benchmark.cpp )
target_include_directories(benchmark-fec PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)

View file

@ -61,7 +61,7 @@ class Rfc {
template <class F>
void encoding_row_for_each(EncodingRow t, F &&f) const {
f(t.b);
for (uint16 j = 1; j < t.d; ++j) {
for (uint32 j = 1; j < t.d; ++j) {
t.b = (t.b + t.a) % W;
f(t.b);
}

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
set(TDNET_SOURCE
td/net/FdListener.cpp

Some files were not shown because too many files have changed in this diff Show more