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

Merge branch 'testnet' into block-generation

This commit is contained in:
SpyCheese 2024-02-01 19:29:25 +03:00
commit f4fd3ff3be
246 changed files with 7895 additions and 5430 deletions

View file

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

8
.editorconfig Normal file
View file

@ -0,0 +1,8 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2

View file

@ -1,99 +0,0 @@
# The script builds funcfift compiler to WASM
# 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 CCACHE_DISABLE=1
cd ../..
rm -rf openssl zlib emsdk secp256k1 libsodium build
echo `pwd`
git clone https://github.com/openssl/openssl.git
cd openssl
git checkout OpenSSL_1_1_1j
./config
make -j16
OPENSSL_DIR=`pwd`
cd ..
git clone https://github.com/madler/zlib.git
cd zlib
ZLIB_DIR=`pwd`
cd ..
git clone https://github.com/bitcoin-core/secp256k1.git
cd secp256k1
./autogen.sh
SECP256K1_DIR=`pwd`
cd ..
git clone https://github.com/jedisct1/libsodium --branch stable
cd libsodium
SODIUM_DIR=`pwd`
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 ..
test $? -eq 0 || { echo "Can't configure TON build"; exit 1; }
ninja fift smc-envelope
test $? -eq 0 || { echo "Can't compile fift "; exit 1; }
rm -rf *
cd ..
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install 3.1.19
./emsdk activate 3.1.19
EMSDK_DIR=`pwd`
source $EMSDK_DIR/emsdk_env.sh
export CC=$(which emcc)
export CXX=$(which em++)
export CCACHE_DISABLE=1
cd ../openssl
make clean
emconfigure ./Configure linux-generic32 no-shared no-dso no-engine no-unit-test no-ui
sed -i 's/CROSS_COMPILE=.*/CROSS_COMPILE=/g' Makefile
sed -i 's/-ldl//g' Makefile
sed -i 's/-O3/-Os/g' Makefile
emmake make depend
emmake make -j16
test $? -eq 0 || { echo "Can't compile OpenSSL with emmake "; exit 1; }
cd ../zlib
emconfigure ./configure --static
emmake make -j16
test $? -eq 0 || { echo "Can't compile zlib with emmake "; exit 1; }
ZLIB_DIR=`pwd`
cd ../secp256k1
emconfigure ./configure --enable-module-recovery
emmake make -j16
test $? -eq 0 || { echo "Can't compile secp256k1 with emmake "; exit 1; }
cd ../libsodium
emconfigure ./configure --disable-ssp
emmake make -j16
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; }
cp -R ../crypto/smartcont ../crypto/fift/lib crypto
emmake make -j16 funcfiftlib func fift tlbc emulator-emscripten

View file

@ -0,0 +1,32 @@
name: Tonlib Android
on: [push,workflow_dispatch,workflow_call]
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Install system libraries
run: |
sudo apt-get update
sudo apt-get install -y build-essential git cmake ninja-build automake libtool texinfo autoconf libgflags-dev \
zlib1g-dev libssl-dev libreadline-dev libmicrohttpd-dev pkg-config libgsl-dev python3 python3-dev \
libtool autoconf libsodium-dev libsecp256k1-dev
- name: Build TON
run: |
cp assembly/android/build-android-tonlib.sh .
chmod +x build-android-tonlib.sh
./build-android-tonlib.sh -a
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: tonlib-android
path: artifacts

View file

@ -0,0 +1,40 @@
name: Ubuntu TON build (shared, x86-64)
on: [push,workflow_dispatch,workflow_call]
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Install system libraries
run: |
sudo apt-get update
sudo apt-get install -y build-essential git cmake ninja-build zlib1g-dev libsecp256k1-dev libmicrohttpd-dev libsodium-dev
- name: Install clang-16
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 16 all
- name: Build TON
run: |
cp assembly/native/build-ubuntu-shared.sh .
chmod +x build-ubuntu-shared.sh
./build-ubuntu-shared.sh -t -a
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: ton-binaries-${{ matrix.os }}
path: artifacts

View file

@ -0,0 +1,25 @@
name: MacOS TON build (shared, x86-64)
on: [push,workflow_dispatch,workflow_call]
jobs:
build:
runs-on: macos-12
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Build TON
run: |
cp assembly/native/build-macos-shared.sh .
chmod +x build-macos-shared.sh
./build-macos-shared.sh -t -a
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: ton-binaries-macos-12
path: artifacts

View file

@ -0,0 +1,30 @@
name: Emscripten TON build (wasm)
on: [push,workflow_dispatch,workflow_call]
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Install system libraries
run: |
sudo apt-get update
sudo apt-get install -y build-essential git openssl cmake ninja-build zlib1g-dev libssl-dev libsecp256k1-dev libmicrohttpd-dev libsodium-dev
- name: Build TON WASM artifacts
run: |
cd assembly/wasm
chmod +x fift-func-wasm-build-ubuntu.sh
./fift-func-wasm-build-ubuntu.sh -a
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: ton-wasm-binaries
path: artifacts

View file

@ -46,7 +46,7 @@ jobs:
- name: Download Windows artifacts - name: Download Windows artifacts
uses: dawidd6/action-download-artifact@v2 uses: dawidd6/action-download-artifact@v2
with: with:
workflow: win-2019-compile.yml workflow: ton-x86-64-windows.yml
path: artifacts path: artifacts
workflow_conclusion: success workflow_conclusion: success
skip_unpack: true skip_unpack: true
@ -54,7 +54,7 @@ jobs:
- name: Download and unzip Windows artifacts - name: Download and unzip Windows artifacts
uses: dawidd6/action-download-artifact@v2 uses: dawidd6/action-download-artifact@v2
with: with:
workflow: win-2019-compile.yml workflow: ton-x86-64-windows.yml
path: artifacts path: artifacts
workflow_conclusion: success workflow_conclusion: success
skip_unpack: false skip_unpack: false
@ -62,7 +62,7 @@ jobs:
- name: Download WASM artifacts - name: Download WASM artifacts
uses: dawidd6/action-download-artifact@v2 uses: dawidd6/action-download-artifact@v2
with: with:
workflow: ton-wasm-emscripten.yml workflow: build-ton-wasm-emscripten.yml
path: artifacts path: artifacts
workflow_conclusion: success workflow_conclusion: success
skip_unpack: true skip_unpack: true

View file

@ -1,4 +1,4 @@
name: Docker Ubuntu 20.04 image name: Docker Ubuntu 22.04 image
on: on:
workflow_dispatch: workflow_dispatch:
@ -12,10 +12,12 @@ env:
jobs: jobs:
build-and-push: build-and-push:
runs-on: ubuntu-20.04 runs-on: ubuntu-22.04
steps: steps:
- name: Checkout - name: Check out repository
uses: actions/checkout@v3 uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v1 uses: docker/setup-qemu-action@v1
@ -35,5 +37,5 @@ jobs:
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
push: true push: true
context: ./docker context: ./
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest

View file

@ -1,72 +0,0 @@
name: MacOS 11.7 Big Sur x86-64 Compile
on: [push,workflow_dispatch,workflow_call]
jobs:
build:
runs-on: macos-11
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Compile OpenSSL
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
- name: Build all
run: |
export NONINTERACTIVE=1
brew install ninja secp256k1 libsodium libmicrohttpd pkg-config
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 proxy-liteserver
- name: Find & copy binaries
run: |
mkdir artifacts
cp build/storage/storage-daemon/storage-daemon artifacts/
cp build/storage/storage-daemon/storage-daemon-cli artifacts/
cp build/blockchain-explorer/blockchain-explorer artifacts/
cp build/crypto/fift artifacts/
cp build/crypto/func artifacts/
cp build/crypto/create-state artifacts/
cp build/crypto/tlbc artifacts/
cp build/validator-engine-console/validator-engine-console artifacts/
cp build/tonlib/tonlib-cli artifacts/
cp build/tonlib/libtonlibjson.0.5.dylib artifacts/libtonlibjson.dylib
cp build/http/http-proxy artifacts/
cp build/rldp-http-proxy/rldp-http-proxy artifacts/
cp build/dht-server/dht-server artifacts/
cp build/lite-client/lite-client artifacts/
cp build/validator-engine/validator-engine artifacts/
cp build/utils/generate-random-id artifacts/
cp build/utils/json2tlo artifacts/
cp build/adnl/adnl-proxy artifacts/
cp build/emulator/*emulator.* artifacts/
cp build/utils/proxy-liteserver artifacts/
chmod +x artifacts/*
rsync -r crypto/smartcont artifacts/
rsync -r crypto/fift/lib artifacts/
ls -laRt artifacts
- name: Simple binaries test
run: |
artifacts/validator-engine -V
artifacts/lite-client -V
artifacts/fift -V
artifacts/func -V
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: ton-macos-11.7
path: artifacts

View file

@ -1,83 +0,0 @@
name: MacOS 12.6 Monterey x86-64 Compile
on: [push,workflow_dispatch,workflow_call]
jobs:
build:
runs-on: macos-12
steps:
- name: Check out repository
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: |
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 libmicrohttpd pkg-config
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 proxy-liteserver
- name: Find & copy binaries
run: |
mkdir artifacts
cp build/storage/storage-daemon/storage-daemon artifacts/
cp build/storage/storage-daemon/storage-daemon-cli artifacts/
cp build/blockchain-explorer/blockchain-explorer artifacts/
cp build/crypto/fift artifacts/
cp build/crypto/func artifacts/
cp build/crypto/create-state artifacts/
cp build/crypto/tlbc artifacts/
cp build/validator-engine-console/validator-engine-console artifacts/
cp build/tonlib/tonlib-cli artifacts/
cp build/tonlib/libtonlibjson.0.5.dylib artifacts/libtonlibjson.dylib
cp build/http/http-proxy artifacts/
cp build/rldp-http-proxy/rldp-http-proxy artifacts/
cp build/dht-server/dht-server artifacts/
cp build/lite-client/lite-client artifacts/
cp build/validator-engine/validator-engine artifacts/
cp build/utils/generate-random-id artifacts/
cp build/utils/json2tlo artifacts/
cp build/adnl/adnl-proxy artifacts/
cp build/emulator/*emulator.* artifacts/
cp build/utils/proxy-liteserver artifacts/
chmod +x artifacts/*
rsync -r crypto/smartcont artifacts/
rsync -r crypto/fift/lib artifacts/
ls -laRt artifacts
- name: Simple binaries test
run: |
artifacts/validator-engine -V
artifacts/lite-client -V
artifacts/fift -V
artifacts/func -V
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: ton-macos-12.6
path: artifacts

View file

@ -1,50 +0,0 @@
name: "TON aarch64 Linux binaries"
on: [workflow_dispatch,workflow_call]
jobs:
build:
runs-on: ubuntu-22.04
steps:
- run: |
sudo apt update
sudo apt install -y apt-utils
sudo apt install -q -y qemu-system-aarch64 qemu-efi binfmt-support qemu-user-static
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- uses: cachix/install-nix-action@v18
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Compile
run: nix build .?submodules=1#packages.aarch64-linux.ton-oldglibc_staticbinaries --print-build-logs --system aarch64-linux -o result-aarch64
- name: Copy binaries
run: |
ls -lart
mkdir artifacts
cp $PWD/result-aarch64-linux/bin/* artifacts/
chmod +x artifacts/*
cp $PWD/result-aarch64-linux/lib/libtonlibjson.so.0.5 artifacts/libtonlibjson.so
cp $PWD/result-aarch64-linux/lib/libemulator.so artifacts/
cp -R crypto/smartcont artifacts/
cp -R crypto/fift/lib artifacts/
- name: Simple binaries test
run: |
sudo mv /nix/store /nix/store2
artifacts/validator-engine -V
artifacts/lite-client -V
artifacts/fift -V
artifacts/func -V
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: ton-aarch64-linux-binaries
path: artifacts

View file

@ -1,47 +0,0 @@
name: "TON aarch64 macOS binaries"
on: [workflow_dispatch,workflow_call]
jobs:
build:
runs-on: macos-12
steps:
- run: brew install qemu
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- uses: cachix/install-nix-action@v18
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Compile
run: nix build .?submodules=1#packages.aarch64-darwin.ton-staticbin-dylib --print-build-logs -o result-aarch64-darwin
- name: Copy binaries
run: |
ls -lart
mkdir artifacts
cp $PWD/result-aarch64-darwin/bin/* artifacts/
chmod +x artifacts/*
cp $PWD/result-aarch64-darwin/lib/libtonlibjson* artifacts/
cp $PWD/result-aarch64-darwin/lib/libemulator* artifacts/
cp -R crypto/smartcont artifacts/
cp -R crypto/fift/lib artifacts/
- name: Simple binaries test
run: |
sudo mv /nix/store /nix/store2
artifacts/validator-engine -V
artifacts/lite-client -V
artifacts/fift -V
artifacts/func -V
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: ton-aarch64-macos-binaries
path: artifacts

View file

@ -1,10 +1,9 @@
name: TON Ccpcheck name: TON Static Code Analysis
on: [push,workflow_dispatch,workflow_call] on: [push,workflow_dispatch,workflow_call]
jobs: jobs:
build: build:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:

View file

@ -1,40 +0,0 @@
name: TON WASM Compile
on: [push,workflow_dispatch,workflow_call]
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- 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
- name: Configure & Build
run: |
cd .github/script
./fift-func-wasm-build-ubuntu.sh
- name: Find & copy binaries
run: |
mkdir artifacts
ls build/crypto
cp build/crypto/fift* artifacts
cp build/crypto/func* artifacts
cp build/crypto/tlbc* artifacts
cp build/emulator/emulator-emscripten* artifacts
cp -R crypto/smartcont artifacts
cp -R crypto/fift/lib artifacts
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: ton-wasm-binaries
path: artifacts

View file

@ -1,4 +1,4 @@
name: "TON x86_64 Linux binaries" name: Ubuntu TON build (portable, x86-64)
on: [push,workflow_dispatch,workflow_call] on: [push,workflow_dispatch,workflow_call]
@ -15,24 +15,16 @@ jobs:
with: with:
submodules: 'recursive' submodules: 'recursive'
- uses: cachix/install-nix-action@v18 - uses: cachix/install-nix-action@v23
with: with:
extra_nix_config: | extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Compile - name: Build TON
run: nix build .?submodules=1#packages.x86_64-linux.ton-oldglibc_staticbinaries --print-build-logs --system x86_64-linux -o result-x86_64
- name: Copy binaries
run: | run: |
ls -lart cp assembly/nix/build-linux-x86-64-nix.sh .
mkdir artifacts chmod +x build-linux-x86-64-nix.sh
cp $PWD/result-x86_64/bin/* artifacts/ ./build-linux-x86-64-nix.sh -t
chmod +x artifacts/*
cp $PWD/result-x86_64/lib/libtonlibjson.so.0.5 artifacts/libtonlibjson.so
cp $PWD/result-x86_64/lib/libemulator.so artifacts/
cp -R crypto/smartcont artifacts/
cp -R crypto/fift/lib artifacts/
- name: Simple binaries test - name: Simple binaries test
run: | run: |
@ -46,4 +38,4 @@ jobs:
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
name: ton-x86_64-linux-binaries name: ton-x86_64-linux-binaries
path: artifacts path: artifacts

View file

@ -1,4 +1,4 @@
name: "TON x86_64 macOS binaries" name: MacOS TON build (portable, x86-64)
on: [push,workflow_dispatch,workflow_call] on: [push,workflow_dispatch,workflow_call]
@ -11,24 +11,16 @@ jobs:
with: with:
submodules: 'recursive' submodules: 'recursive'
- uses: cachix/install-nix-action@v22 - uses: cachix/install-nix-action@v23
with: with:
extra_nix_config: | extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Compile - name: Build TON
run: nix build .?submodules=1#packages.x86_64-darwin.ton-staticbin-dylib --print-build-logs -o result-x86_64-darwin
- name: Copy binaries
run: | run: |
ls -lart cp assembly/nix/build-macos-nix.sh .
mkdir artifacts chmod +x build-macos-nix.sh
cp $PWD/result-x86_64-darwin/bin/* artifacts/ ./build-macos-nix.sh -t
chmod +x artifacts/*
cp $PWD/result-x86_64-darwin/lib/libtonlibjson.dylib artifacts/
cp $PWD/result-x86_64-darwin/lib/libemulator.dylib artifacts/
cp -R crypto/smartcont artifacts/
cp -R crypto/fift/lib artifacts/
- name: Simple binaries test - name: Simple binaries test
run: | run: |
@ -42,4 +34,4 @@ jobs:
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
name: ton-x86_64-macos-binaries name: ton-x86_64-macos-binaries
path: artifacts path: artifacts

View file

@ -0,0 +1,34 @@
name: Windows TON build (portable, x86-64)
on: [push,workflow_dispatch,workflow_call]
defaults:
run:
shell: cmd
jobs:
build:
runs-on: windows-2022
steps:
- name: Get Current OS version
run: |
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
- name: Check out current repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Build TON
run: |
copy assembly\native\build-windows-github.bat .
copy assembly\native\build-windows.bat .
build-windows-github.bat Enterprise
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: ton-win-binaries
path: artifacts

View file

@ -1,61 +0,0 @@
name: Tonlib Android JNI
on: [push,workflow_dispatch,workflow_call]
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Install libraries
run: |
sudo apt update
sudo apt 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 ninja-build
- name: Configure & Build
run: |
wget https://dl.google.com/android/repository/android-ndk-r25b-linux.zip
unzip android-ndk-r25b-linux.zip
export JAVA_AWT_LIBRARY=NotNeeded
export JAVA_JVM_LIBRARY=NotNeeded
export JAVA_INCLUDE_PATH=${JAVA_HOME}/include
export JAVA_AWT_INCLUDE_PATH=${JAVA_HOME}/include
export JAVA_INCLUDE_PATH2=${JAVA_HOME}/include/linux
export ANDROID_NDK_ROOT=$(pwd)/android-ndk-r25b
export NDK_PLATFORM="android-21"
export ANDROID_PLATFORM="android-21"
export OPENSSL_DIR=$(pwd)/example/android/third_party/crypto
rm -rf example/android/src/drinkless/org/ton/TonApi.java
cd example/android/
sudo apt install -y libtool autoconf libsodium-dev libsecp256k1-dev
cmake -GNinja -DTON_ONLY_TONLIB=ON .
ninja prepare_cross_compiling
sudo apt remove -y libsodium-dev libsecp256k1-dev
rm CMakeCache.txt
./build-all.sh
find . -name "*.debug" -type f -delete
- name: Find & copy binaries
run: |
mkdir -p artifacts/tonlib-android-jni
cp example/android/src/drinkless/org/ton/TonApi.java artifacts/tonlib-android-jni/
cp -R example/android/libs/* artifacts/tonlib-android-jni/
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: tonlib-android-jni
path: artifacts

View file

@ -1,64 +0,0 @@
name: Ubuntu 22.04 Compile
on: [push,workflow_dispatch,workflow_call]
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Install libraries
run: |
sudo apt update
sudo apt 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 ninja-build libsecp256k1-dev libsodium-dev
- name: Show CPU flags
run: |
cat /proc/cpuinfo
- name: Configure & Build
run: |
export CC=$(which clang)
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
./config
make build_libs -j4
cd ..
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_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 proxy-liteserver
- 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.* build/utils/proxy-liteserver artifacts
chmod +x artifacts/*
cp -R crypto/smartcont artifacts/
cp -R crypto/fift/lib artifacts/
- name: Simple binaries test
run: |
artifacts/validator-engine -V
artifacts/lite-client -V
artifacts/fift -V
artifacts/func -V
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: ton-ubuntu-binaries
path: artifacts

View file

@ -1,68 +0,0 @@
name: Ubuntu Compile x86-64
on: [push,workflow_dispatch,workflow_call]
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Install libraries
run: |
sudo apt update
sudo apt 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 ninja-build libsecp256k1-dev libsodium-dev
- name: Show CPU flags
run: |
cat /proc/cpuinfo
- name: Configure & Build
run: |
export CC=$(which clang)
export CXX=$(which clang++)
export CCACHE_DISABLE=1
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
./config
make build_libs -j4
cd ..
buildPath=`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 proxy-liteserver
- name: Find & copy binaries
run: |
mkdir artifacts-${{ matrix.os }}
cp 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.* build-${{ matrix.os }}/utils/proxy-liteserver artifacts-${{ matrix.os }}
chmod +x artifacts-${{ matrix.os }}/*
cp -R crypto/smartcont artifacts-${{ matrix.os }}
cp -R crypto/fift/lib artifacts-${{ matrix.os }}
- name: Simple binaries test
run: |
artifacts-${{ matrix.os }}/validator-engine -V
artifacts-${{ matrix.os }}/lite-client -V
artifacts-${{ matrix.os }}/fift -V
artifacts-${{ matrix.os }}/func -V
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: ton-binaries-${{ matrix.os }}
path: artifacts-${{ matrix.os }}

View file

@ -1,103 +0,0 @@
name: Windows Server 2019 x64 Compile
on: [push,workflow_dispatch,workflow_call]
defaults:
run:
shell: cmd
jobs:
build:
runs-on: windows-2019
steps:
- name: Get Current OS version
run: |
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
- name: Check out current repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Check out zlib repository
uses: actions/checkout@v3
with:
repository: desktop-app/zlib
path: zlib
- name: Setup msbuild.exe
uses: microsoft/setup-msbuild@v1.1
- name: Install Pkg-config Lite
run: choco install pkgconfiglite
- name: Compile zlib Win64
run: |
cd zlib\contrib\vstudio\vc14
msbuild zlibstat.vcxproj /p:Configuration=ReleaseWithoutAsm /p:platform=x64 -p:PlatformToolset=v142
- name: Compile secp256k1 Win64
run: |
git clone https://github.com/libbitcoin/secp256k1.git
cd secp256k1\builds\msvc\vs2017
msbuild /p:Configuration=StaticRelease -p:PlatformToolset=v142 -p:Platform=x64
- name: Install pre-compiled libsodium Win64
run: |
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
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
- name: Install pre-compiled libmicrohttpd Win64
run: |
curl -Lo libmicrohttpd-0.9.77-w32-bin.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/libmicrohttpd-0.9.77-w32-bin.zip
unzip libmicrohttpd-0.9.77-w32-bin.zip
- name: Install pre-compiled Readline Win64
run: |
curl -Lo readline-5.0-1-lib.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/readline-5.0-1-lib.zip
unzip readline-5.0-1-lib.zip
- name: Compile
run: |
set root=%cd%
set SODIUM_DIR=%root%\libsodium
echo %root%
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 proxy-liteserver --config Release
- name: Show executables
run: |
cd build
del Release\test-*
dir *.exe /a-D /S /B
dir *.dll /a-D /S /B
- name: Check if validator-engine.exe exists
run: |
copy %cd%\build\validator-engine\Release\validator-engine.exe test
- name: Find & copy binaries
run: |
mkdir artifacts
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 build\utils\proxy-liteserver.exe) do copy %%I artifacts\
xcopy /e /k /h /i crypto\smartcont artifacts\smartcont
xcopy /e /k /h /i crypto\fift\lib artifacts\lib
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: ton-win-binaries
path: artifacts

12
.gitignore vendored
View file

@ -12,4 +12,14 @@ test/regression-tests.cache/
*.swp *.swp
**/*build*/ **/*build*/
.idea .idea
.vscode .vscode
zlib/
libsodium/
libmicrohttpd-0.9.77-w32-bin/
readline-5.0-1-lib/
secp256k1/
openssl-3.1.4/
libsodium-1.0.18-stable-msvc.zip
libmicrohttpd-0.9.77-w32-bin.zip
openssl-3.1.4.zip
readline-5.0-1-lib.zip

View file

@ -2,23 +2,26 @@
# Once done this will define # Once done this will define
# #
# MHD_FOUND - system has MHD # MHD_FOUND - system has MHD
# MHD_INCLUDE_DIRS - the MHD include directory # MHD_INCLUDE_DIR - the MHD include directory
# MHD_LIBRARY - Link these to use MHD # MHD_LIBRARY - Link these to use MHD
find_path( if (NOT MHD_LIBRARY)
MHD_INCLUDE_DIR find_path(
NAMES microhttpd.h MHD_INCLUDE_DIR
DOC "microhttpd include dir" NAMES microhttpd.h
) DOC "microhttpd include dir"
)
find_library( find_library(
MHD_LIBRARY MHD_LIBRARY
NAMES microhttpd microhttpd-10 libmicrohttpd libmicrohttpd-dll NAMES microhttpd microhttpd-10 libmicrohttpd libmicrohttpd-dll
DOC "microhttpd library" DOC "microhttpd library"
) )
endif()
set(MHD_INCLUDE_DIRS ${MHD_INCLUDE_DIR}) if (MHD_LIBRARY)
set(MHD_LIBRARIES ${MHD_LIBRARY}) message(STATUS "Found MHD: ${MHD_LIBRARY}")
endif()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MHD DEFAULT_MSG MHD_INCLUDE_DIR MHD_LIBRARY) find_package_handle_standard_args(MHD DEFAULT_MSG MHD_INCLUDE_DIR MHD_LIBRARY)

View file

@ -2,28 +2,27 @@
# Once done this will define # Once done this will define
# #
# SECP256K1_FOUND - system has SECP256K1 # SECP256K1_FOUND - system has SECP256K1
# SECP256K1_INCLUDE_DIRS - the SECP256K1 include directory # SECP256K1_INCLUDE_DIR - the SECP256K1 include directory
# SECP256K1_LIBRARY - Link these to use SECP256K1 # SECP256K1_LIBRARY - Link these to use SECP256K1
find_path( if (NOT SECP256K1_LIBRARY)
SECP256K1_INCLUDE_DIR find_path(
NAMES secp256k1_recovery.h SECP256K1_INCLUDE_DIR
DOC "secp256k1_recovery.h include dir" NAMES secp256k1_recovery.h
) DOC "secp256k1_recovery.h include dir"
)
find_library( find_library(
SECP256K1_LIBRARY SECP256K1_LIBRARY
NAMES secp256k1 libsecp256k1 NAMES secp256k1 libsecp256k1
DOC "secp256k1 library" DOC "secp256k1 library"
) )
endif()
if (SECP256K1_LIBRARY) if (SECP256K1_LIBRARY)
message(STATUS "Found Secp256k1: ${SECP256K1_LIBRARY}") message(STATUS "Found Secp256k1: ${SECP256K1_LIBRARY}")
endif() endif()
set(SECP256K1_INCLUDE_DIRS ${SECP256K1_INCLUDE_DIR})
set(SECP256K1_LIBRARIES ${SECP256K1_LIBRARY})
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Secp256k1 DEFAULT_MSG SECP256K1_INCLUDE_DIR SECP256K1_LIBRARY) find_package_handle_standard_args(Secp256k1 DEFAULT_MSG SECP256K1_INCLUDE_DIR SECP256K1_LIBRARY)
mark_as_advanced(SECP256K1_INCLUDE_DIR SECP256K1_LIBRARY) mark_as_advanced(SECP256K1_INCLUDE_DIR SECP256K1_LIBRARY)

View file

@ -26,6 +26,7 @@
# Furthermore an imported "sodium" target is created. # Furthermore an imported "sodium" target is created.
# #
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" if (CMAKE_C_COMPILER_ID STREQUAL "GNU"
OR CMAKE_C_COMPILER_ID STREQUAL "Clang") OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(_GCC_COMPATIBLE 1) set(_GCC_COMPATIBLE 1)

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) project(TON VERSION 0.5 LANGUAGES C CXX)
set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON)
@ -79,7 +79,7 @@ else()
set(HAVE_SSE42 FALSE) set(HAVE_SSE42 FALSE)
endif() endif()
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS FALSE) set(CMAKE_CXX_EXTENSIONS FALSE)
@ -211,7 +211,13 @@ set(CMAKE_THREAD_PREFER_PTHREAD ON)
set(THREADS_PREFER_PTHREAD_FLAG ON) set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
find_package(ZLIB REQUIRED)
if (NOT ZLIB_FOUND)
find_package(ZLIB REQUIRED)
else()
message(STATUS "Using zlib ${ZLIB_LIBRARIES}")
endif()
if (TON_ARCH AND NOT MSVC) if (TON_ARCH AND NOT MSVC)
CHECK_CXX_COMPILER_FLAG( "-march=${TON_ARCH}" COMPILER_OPT_ARCH_SUPPORTED ) CHECK_CXX_COMPILER_FLAG( "-march=${TON_ARCH}" COMPILER_OPT_ARCH_SUPPORTED )
@ -255,6 +261,9 @@ if (MSVC)
add_definitions(-D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS) 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") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /W4 /wd4100 /wd4127 /wd4324 /wd4456 /wd4457 /wd4458 /wd4505 /wd4702")
elseif (CLANG OR GCC) 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") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
if (APPLE) if (APPLE)
#use "-Wl,-exported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/export_list" for exported symbols #use "-Wl,-exported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/export_list" for exported symbols
@ -368,6 +377,9 @@ if (LATEX_FOUND)
add_latex_document(doc/fiftbase.tex TARGET_NAME fift_basic_description) add_latex_document(doc/fiftbase.tex TARGET_NAME fift_basic_description)
add_latex_document(doc/catchain.tex TARGET_NAME catchain_consensus_description) add_latex_document(doc/catchain.tex TARGET_NAME catchain_consensus_description)
endif() endif()
if (NOT LATEX_FOUND)
message(STATUS "Could NOT find LATEX (this is NOT an error)")
endif()
#END internal #END internal
function(target_link_libraries_system target) function(target_link_libraries_system target)
@ -447,6 +459,10 @@ target_link_libraries(test-smartcont PRIVATE smc-envelope fift-lib ton_db)
add_executable(test-bigint ${BIGINT_TEST_SOURCE}) add_executable(test-bigint ${BIGINT_TEST_SOURCE})
target_link_libraries(test-bigint PRIVATE ton_crypto) 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}) add_executable(test-cells test/test-td-main.cpp ${CELLS_TEST_SOURCE})
target_link_libraries(test-cells PRIVATE ton_crypto) target_link_libraries(test-cells PRIVATE ton_crypto)
@ -513,26 +529,12 @@ target_link_libraries(test-rldp2 adnl adnltest dht rldp2 tl_api)
add_executable(test-validator-session-state test/test-validator-session-state.cpp) 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) 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) add_executable(test-catchain test/test-catchain.cpp)
target_link_libraries(test-catchain overlay tdutils tdactor adnl adnltest rldp tl_api dht target_link_libraries(test-catchain overlay tdutils tdactor adnl adnltest rldp tl_api dht
catchain ) 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) add_executable(test-ton-collator test/test-ton-collator.cpp)
target_link_libraries(test-ton-collator overlay tdutils tdactor adnl tl_api dht target_link_libraries(test-ton-collator overlay tdutils tdactor adnl tl_api dht
catchain validatorsession validator-disk ton_validator validator-disk ) 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) add_executable(test-http test/test-http.cpp)
target_link_libraries(test-http PRIVATE tonhttp) target_link_libraries(test-http PRIVATE tonhttp)
@ -574,13 +576,53 @@ add_test(test-tdutils test-tdutils)
add_test(test-tonlib-offline test-tonlib-offline) add_test(test-tonlib-offline test-tonlib-offline)
#END tonlib #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/func.exe"
"FIFT_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/crypto/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/func.exe"
"FIFT_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/crypto/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 #BEGIN internal
if (NOT TON_ONLY_TONLIB) if (NOT TON_ONLY_TONLIB)
add_test(test-adnl test-adnl) add_test(test-adnl test-adnl)
add_test(test-dht test-dht) add_test(test-dht test-dht)
add_test(test-rldp test-rldp) add_test(test-rldp test-rldp)
add_test(test-rldp2 test-rldp2) 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-catchain test-catchain)
add_test(test-fec test-fec) add_test(test-fec test-fec)

View file

@ -1,3 +1,55 @@
## 2024.01 Update
1. Fixes in how gas in transactions on special accounts is accounted in block limit. Previously, gas was counted as usual, so to conduct elections that costs >30m gas block limit in masterchain was set to 37m gas. To lower the limit for safety reasons it is proposed to caunt gas on special accounts separately. Besides `gas_max` is set to `special_gas_limit` for all types of transactions on special accounts. New behavior is activated through setting `version >= 5` in `ConfigParam 8;`.
* Besides update of config temporally increases gas limit on `EQD_v9j1rlsuHHw2FIhcsCFFSD367ldfDdCKcsNmNpIRzUlu` to `special_gas_limit`, see [details](https://t.me/tonstatus/88).
2. Improvements in LS behavior
* Improved detection of the state with all shards applied to decrease rate of `Block is not applied` error
* Better error logs: `block not in db` and `block is not applied` separation
* Fix error in proof generation for blocks after merge
* Fix most of `block is not applied` issues related to sending too recent block in Proofs
* LS now check external messages till `accept_message` (`set_gas`).
3. Improvements in DHT work and storage, CellDb, config.json ammendment, peer misbehavior detection, validator session stats collection, emulator.
4. Change in CTOS and XLOAD behavior activated through setting `version >= 5` in `ConfigParam 8;`:
* Loading "nested libraries" (i.e. a library cell that points to another library cell) throws an exception.
* Loading a library consumes gas for cell load only once (for the library cell), not twice (both for the library cell and the cell in the library).
* `XLOAD` now works differently. When it takes a library cell, it returns the cell that it points to. This allows loading "nested libraries", if needed.
Besides the work of the Core team, this update is based on the efforts of @XaBbl4 (peer misbehavior detection) and @akifoq (CTOS behavior and gas limit scheme for special accounts).
## 2023.12 Update
1. Optimized message queue handling, now queue cleaning speed doesn't depend on total queue size
* Cleaning delivered messages using lt augmentation instead of random search / consequtive walk
* Keeping root cell of queue message in memory until outdated (caching)
2. Changes to block collation/validation limits
3. Stop accepting new external message if message queue is overloaded
4. Introducing conditions for shard split/merge based on queue size
Read [more](https://blog.ton.org/technical-report-december-5-inscriptions-launch-on-ton) on that update.
## 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 ## 2023.05 Update
1. Archive manager optimization 1. Archive manager optimization
2. A series of catchain (basic consensus protocol) security improvements 2. A series of catchain (basic consensus protocol) security improvements

View file

@ -1,26 +1,29 @@
FROM ubuntu:20.04 as builder FROM ubuntu:22.04 as builder
RUN apt-get update && \ RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential cmake clang-6.0 openssl libssl-dev zlib1g-dev gperf wget git ninja-build libsecp256k1-dev libsodium-dev libmicrohttpd-dev pkg-config && \ DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential cmake clang openssl libssl-dev zlib1g-dev gperf wget git ninja-build libsecp256k1-dev libsodium-dev libmicrohttpd-dev pkg-config autoconf automake libtool && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
ENV CC clang-6.0 ENV CC clang
ENV CXX clang++-6.0 ENV CXX clang++
ENV CCACHE_DISABLE 1 ENV CCACHE_DISABLE 1
WORKDIR / WORKDIR /
RUN git clone --recursive https://github.com/ton-blockchain/ton RUN mkdir ton
WORKDIR /ton WORKDIR /ton
COPY ./ ./
RUN mkdir build && \ RUN mkdir build && \
cd build && \ cd build && \
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 -DTON_ARCH= -DCMAKE_CXX_FLAGS="-mavx2" .. && \ cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 -DTON_ARCH= .. && \
ninja storage-daemon storage-daemon-cli tonlibjson fift func validator-engine validator-engine-console generate-random-id dht-server lite-client ninja storage-daemon storage-daemon-cli tonlibjson fift func validator-engine validator-engine-console generate-random-id dht-server lite-client
FROM ubuntu:20.04 FROM ubuntu:22.04
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y openssl wget libatomic1 && \ apt-get install -y wget libatomic1 openssl libsecp256k1-dev libsodium-dev libmicrohttpd-dev && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
RUN mkdir -p /var/ton-work/db && \ RUN mkdir -p /var/ton-work/db && \
mkdir -p /var/ton-work/db/static mkdir -p /var/ton-work/db/static
COPY --from=builder /ton/build/storage/storage-daemon/storage-daemon /usr/local/bin/ COPY --from=builder /ton/build/storage/storage-daemon/storage-daemon /usr/local/bin/
COPY --from=builder /ton/build/storage/storage-daemon/storage-daemon-cli /usr/local/bin/ COPY --from=builder /ton/build/storage/storage-daemon/storage-daemon-cli /usr/local/bin/
@ -30,7 +33,7 @@ COPY --from=builder /ton/build/validator-engine-console/validator-engine-console
COPY --from=builder /ton/build/utils/generate-random-id /usr/local/bin/ COPY --from=builder /ton/build/utils/generate-random-id /usr/local/bin/
WORKDIR /var/ton-work/db WORKDIR /var/ton-work/db
COPY init.sh control.template ./ COPY ./docker/init.sh ./docker/control.template ./
RUN chmod +x init.sh RUN chmod +x init.sh
ENTRYPOINT ["/var/ton-work/db/init.sh"] ENTRYPOINT ["/var/ton-work/db/init.sh"]

View file

@ -37,13 +37,13 @@ Main TON monorepo, which includes the code of the node/validator, lite-client, t
## The Open Network ## 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. __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 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 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) - 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)
- To interact with TON check [APIs](https://ton.org/docs/develop/dapps/apis/) - To interact with TON check [APIs](https://ton.org/docs/develop/dapps/apis/)
## Updates flow: ## Updates flow
* **master branch** - mainnet is running on this stable branch. * **master branch** - mainnet is running on this stable branch.
@ -61,8 +61,91 @@ Usually, the response to your pull request will indicate which section it falls
* Thou shall not merge your own PRs, at least one person should review the PR and merge it (4-eyes rule) * Thou shall not merge your own PRs, at least one person should review the PR and merge it (4-eyes rule)
* Thou shall make sure that workflows are cleanly completed for your PR before considering merge * Thou shall make sure that workflows are cleanly completed for your PR before considering merge
## Workflows responsibility ## Build TON blockchain
If a CI workflow fails not because of your changes but workflow issues, try to fix it yourself or contact one of the persons listed below via Telegram messenger:
* **C/C++ CI (ccpp-linux.yml)**: TBD ### Ubuntu 20.4, 22.04 (x86-64, aarch64)
* **C/C++ CI Win64 Compile (ccpp-win64.yml)**: TBD Install additional system libraries
```bash
sudo apt-get update
sudo apt-get install -y build-essential git cmake ninja-build zlib1g-dev libsecp256k1-dev libmicrohttpd-dev libsodium-dev
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 16 all
```
Compile TON binaries
```bash
cp assembly/native/build-ubuntu-shared.sh .
chmod +x build-ubuntu-shared.sh
./build-ubuntu-shared.sh
```
### MacOS 11, 12 (x86-64, aarch64)
```bash
cp assembly/native/build-macos-shared.sh .
chmod +x build-macos-shared.sh
./build-macos-shared.sh
```
### Windows 10, 11, Server (x86-64)
You need to install `MS Visual Studio 2022` first.
Go to https://www.visualstudio.com/downloads/ and download `MS Visual Studio 2022 Community`.
Launch installer and select `Desktop development with C++`.
After installation, also make sure that `cmake` is globally available by adding
`C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin` to the system `PATH` (adjust the path per your needs).
Open an elevated (Run as Administrator) `x86-64 Native Tools Command Prompt for VS 2022`, go to the root folder and execute:
```bash
copy assembly\native\build-windows.bat .
build-windows.bat
```
### Building TON to WebAssembly
Install additional system libraries on Ubuntu
```bash
sudo apt-get update
sudo apt-get install -y build-essential git cmake ninja-build zlib1g-dev libsecp256k1-dev libmicrohttpd-dev libsodium-dev
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 16 all
```
Compile TON binaries with emscripten
```bash
cd assembly/wasm
chmod +x fift-func-wasm-build-ubuntu.sh
./fift-func-wasm-build-ubuntu.sh
```
### Building TON tonlib library for Android (arm64-v8a, armeabi-v7a, x86, x86-64)
Install additional system libraries on Ubuntu
```bash
sudo apt-get update
sudo apt-get install -y build-essential git cmake ninja-build automake libtool texinfo autoconf libgflags-dev \
zlib1g-dev libssl-dev libreadline-dev libmicrohttpd-dev pkg-config libgsl-dev python3 python3-dev \
libtool autoconf libsodium-dev libsecp256k1-dev
```
Compile TON tonlib library
```bash
cp assembly/android/build-android-tonlib.sh .
chmod +x build-android-tonlib.sh
./build-android-tonlib.sh
```
### Build TON portable binaries with Nix package manager
You need to install Nix first.
```bash
sh <(curl -L https://nixos.org/nix/install) --daemon
```
Then compile TON with Nix by executing below command from the root folder:
```bash
cp -r assembly/nix/* .
export NIX_PATH=nixpkgs=https://github.com/nixOS/nixpkgs/archive/23.05.tar.gz
nix-build linux-x86-64-static.nix
```
More examples for other platforms can be found under `assembly/nix`.
## 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 #BEGIN internal
if (NOT TON_ONLY_TONLIB) if (NOT TON_ONLY_TONLIB)

View file

@ -0,0 +1,55 @@
with_artifacts=false
while getopts 'a' flag; do
case "${flag}" in
a) with_artifacts=true ;;
*) break
;;
esac
done
if [ ! -d android-ndk-r25b ]; then
rm 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
test $? -eq 0 || { echo "Can't unzip android-ndk-r25b-linux.zip"; exit 1; }
echo Android NDK extracted
else
echo Using extracted Android NDK
fi
export JAVA_AWT_LIBRARY=NotNeeded
export JAVA_JVM_LIBRARY=NotNeeded
export JAVA_INCLUDE_PATH=${JAVA_HOME}/include
export JAVA_AWT_INCLUDE_PATH=${JAVA_HOME}/include
export JAVA_INCLUDE_PATH2=${JAVA_HOME}/include/linux
export ANDROID_NDK_ROOT=$(pwd)/android-ndk-r25b
export NDK_PLATFORM="android-21"
export ANDROID_PLATFORM="android-21"
export OPENSSL_DIR=$(pwd)/example/android/third_party/crypto
rm -rf example/android/src/drinkless/org/ton/TonApi.java
cd example/android/
rm CMakeCache.txt .ninja_*
cmake -GNinja -DTON_ONLY_TONLIB=ON .
test $? -eq 0 || { echo "Can't configure TON"; exit 1; }
ninja prepare_cross_compiling
test $? -eq 0 || { echo "Can't compile prepare_cross_compiling"; exit 1; }
rm CMakeCache.txt .ninja_*
. ./build-all.sh
find . -name "*.debug" -type f -delete
if [ "$with_artifacts" = true ]; then
cd ../..
mkdir -p artifacts/tonlib-android-jni
cp example/android/src/drinkless/org/ton/TonApi.java artifacts/tonlib-android-jni/
cp -R example/android/libs/* artifacts/tonlib-android-jni/
fi

View file

@ -0,0 +1,236 @@
pipeline {
agent none
stages {
stage('Run Builds') {
parallel {
stage('Ubuntu 20.04 x86-64 (shared)') {
agent {
label 'Ubuntu_x86-64'
}
steps {
timeout(time: 90, unit: 'MINUTES') {
sh '''
cp assembly/native/build-ubuntu-shared.sh .
chmod +x build-ubuntu-shared.sh
./build-ubuntu-shared.sh -t -a
'''
sh '''
cd artifacts
zip -9r ton-x86_64-linux-shared ./*
'''
archiveArtifacts artifacts: 'artifacts/ton-x86_64-linux-shared.zip'
}
}
}
stage('Ubuntu 20.04 x86-64 (portable)') {
agent {
label 'Ubuntu_x86-64'
}
steps {
timeout(time: 90, unit: 'MINUTES') {
sh '''
cp assembly/nix/build-linux-x86-64-nix.sh .
chmod +x build-linux-x86-64-nix.sh
./build-linux-x86-64-nix.sh -t
'''
sh '''
cd artifacts
zip -9r ton-x86-64-linux-portable ./*
'''
archiveArtifacts artifacts: 'artifacts/ton-x86-64-linux-portable.zip'
}
}
}
stage('Ubuntu 20.04 aarch64 (shared)') {
agent {
label 'Ubuntu_arm64'
}
steps {
timeout(time: 90, unit: 'MINUTES') {
sh '''
cp assembly/native/build-ubuntu-shared.sh .
chmod +x build-ubuntu-shared.sh
./build-ubuntu-shared.sh -t -a
'''
sh '''
cd artifacts
zip -9r ton-arm64-linux-shared ./*
'''
archiveArtifacts artifacts: 'artifacts/ton-arm64-linux-shared.zip'
}
}
}
stage('Ubuntu 20.04 aarch64 (portable)') {
agent {
label 'Ubuntu_arm64'
}
steps {
timeout(time: 90, unit: 'MINUTES') {
sh '''
cp assembly/nix/build-linux-arm64-nix.sh .
chmod +x build-linux-arm64-nix.sh
./build-linux-arm64-nix.sh -t
'''
sh '''
cd artifacts
zip -9r ton-arm64-linux-portable ./*
'''
archiveArtifacts artifacts: 'artifacts/ton-arm64-linux-portable.zip'
}
}
}
stage('macOS 12.7 x86-64 (shared)') {
agent {
label 'macOS_12.7_x86-64'
}
steps {
timeout(time: 90, unit: 'MINUTES') {
sh '''
cp assembly/native/build-macos-shared.sh .
chmod +x build-macos-shared.sh
./build-macos-shared.sh -t -a
'''
sh '''
cd artifacts
zip -9r ton-x86-64-macos-shared ./*
'''
archiveArtifacts artifacts: 'artifacts/ton-x86-64-macos-shared.zip'
}
}
}
stage('macOS 12.7 x86-64 (portable)') {
agent {
label 'macOS_12.7_x86-64'
}
steps {
timeout(time: 90, unit: 'MINUTES') {
sh '''
cp assembly/nix/build-macos-nix.sh .
chmod +x build-macos-nix.sh
./build-macos-nix.sh -t
'''
sh '''
cd artifacts
zip -9r ton-x86-64-macos-portable ./*
'''
archiveArtifacts artifacts: 'artifacts/ton-x86-64-macos-portable.zip'
}
}
}
stage('macOS 12.6 aarch64 (shared)') {
agent {
label 'macOS_12.6-arm64-m1'
}
steps {
timeout(time: 90, unit: 'MINUTES') {
sh '''
cp assembly/native/build-macos-shared.sh .
chmod +x build-macos-shared.sh
./build-macos-shared.sh -t -a
'''
sh '''
cd artifacts
zip -9r ton-arm64-macos-m1-shared ./*
'''
archiveArtifacts artifacts: 'artifacts/ton-arm64-macos-m1-shared.zip'
}
}
}
stage('macOS 12.6 aarch64 (portable)') {
agent {
label 'macOS_12.6-arm64-m1'
}
steps {
timeout(time: 90, unit: 'MINUTES') {
sh '''
cp assembly/nix/build-macos-nix.sh .
chmod +x build-macos-nix.sh
./build-macos-nix.sh -t
'''
sh '''
cd artifacts
zip -9r ton-arm64-macos-portable ./*
'''
archiveArtifacts artifacts: 'artifacts/ton-arm64-macos-portable.zip'
}
}
}
stage('macOS 13.2 aarch64 (shared)') {
agent {
label 'macOS_13.2-arm64-m2'
}
steps {
timeout(time: 90, unit: 'MINUTES') {
sh '''
cp assembly/native/build-macos-shared.sh .
chmod +x build-macos-shared.sh
./build-macos-shared.sh -t -a
'''
sh '''
cd artifacts
zip -9r ton-arm64-macos-m2-shared ./*
'''
archiveArtifacts artifacts: 'artifacts/ton-arm64-macos-m2-shared.zip'
}
}
}
stage('Windows Server 2022 x86-64') {
agent {
label 'Windows_x86-64'
}
steps {
timeout(time: 90, unit: 'MINUTES') {
bat '''
copy assembly\\native\\build-windows.bat .
build-windows.bat
'''
bat '''
cd artifacts
zip -9r ton-x86-64-windows ./*
'''
archiveArtifacts artifacts: 'artifacts/ton-x86-64-windows.zip'
}
}
}
stage('Android Tonlib') {
agent {
label 'Ubuntu_x86-64'
}
steps {
timeout(time: 90, unit: 'MINUTES') {
sh '''
cp assembly/android/build-android-tonlib.sh .
chmod +x build-android-tonlib.sh
./build-android-tonlib.sh -a
'''
sh '''
cd artifacts/tonlib-android-jni
zip -9r ton-android-tonlib ./*
'''
archiveArtifacts artifacts: 'artifacts/tonlib-android-jni/ton-android-tonlib.zip'
}
}
}
stage('WASM fift func emulator') {
agent {
label 'Ubuntu_x86-64'
}
steps {
timeout(time: 90, unit: 'MINUTES') {
sh '''
cd assembly/wasm
chmod +x fift-func-wasm-build-ubuntu.sh
./fift-func-wasm-build-ubuntu.sh -a
'''
sh '''
cd artifacts
zip -9r ton-wasm-binaries ./*
'''
archiveArtifacts artifacts: 'artifacts/ton-wasm-binaries.zip'
}
}
}
}
}
}
}

View file

@ -0,0 +1,207 @@
#/bin/bash
with_tests=false
with_artifacts=false
OSX_TARGET=10.15
while getopts 'tao:' flag; do
case "${flag}" in
t) with_tests=true ;;
a) with_artifacts=true ;;
o) OSX_TARGET=${OPTARG} ;;
*) break
;;
esac
done
if [ ! -d "build" ]; then
mkdir build
cd build
else
cd build
rm -rf .ninja* CMakeCache.txt
fi
export NONINTERACTIVE=1
brew install ninja pkg-config automake libtool autoconf
brew install llvm@16
if [ -f /opt/homebrew/opt/llvm@16/bin/clang ]; then
export CC=/opt/homebrew/opt/llvm@16/bin/clang
export CXX=/opt/homebrew/opt/llvm@16/bin/clang++
else
export CC=/usr/local/opt/llvm@16/bin/clang
export CXX=/usr/local/opt/llvm@16/bin/clang++
fi
export CCACHE_DISABLE=1
if [ ! -d "secp256k1" ]; then
git clone https://github.com/bitcoin-core/secp256k1.git
cd secp256k1
secp256k1Path=`pwd`
git checkout v0.3.2
./autogen.sh
./configure --enable-module-recovery --enable-static --disable-tests --disable-benchmark --with-pic
make -j12
test $? -eq 0 || { echo "Can't compile secp256k1"; exit 1; }
cd ..
else
secp256k1Path=$(pwd)/secp256k1
echo "Using compiled secp256k1"
fi
if [ ! -d "libsodium" ]; then
export LIBSODIUM_FULL_BUILD=1
git clone https://github.com/jedisct1/libsodium.git
cd libsodium
sodiumPath=`pwd`
git checkout 1.0.18
./autogen.sh
./configure --with-pic --enable-static
make -j12
test $? -eq 0 || { echo "Can't compile libsodium"; exit 1; }
cd ..
else
sodiumPath=$(pwd)/libsodium
echo "Using compiled libsodium"
fi
if [ ! -d "openssl_3" ]; then
git clone https://github.com/openssl/openssl openssl_3
cd openssl_3
opensslPath=`pwd`
git checkout openssl-3.1.4
./config -static
make build_libs -j12
test $? -eq 0 || { echo "Can't compile openssl_3"; exit 1; }
cd ..
else
opensslPath=$(pwd)/openssl_3
echo "Using compiled openssl_3"
fi
if [ ! -d "zlib" ]; then
git clone https://github.com/madler/zlib.git
cd zlib
zlibPath=`pwd`
./configure --static
make -j12
test $? -eq 0 || { echo "Can't compile zlib"; exit 1; }
cd ..
else
zlibPath=$(pwd)/zlib
echo "Using compiled zlib"
fi
if [ ! -d "libmicrohttpd" ]; then
git clone https://git.gnunet.org/libmicrohttpd.git
cd libmicrohttpd
libmicrohttpdPath=`pwd`
./autogen.sh
./configure --enable-static --disable-tests --disable-benchmark --disable-shared --disable-https --with-pic
make -j12
test $? -eq 0 || { echo "Can't compile libmicrohttpd"; exit 1; }
cd ..
else
libmicrohttpdPath=$(pwd)/libmicrohttpd
echo "Using compiled libmicrohttpd"
fi
cmake -GNinja .. \
-DPORTABLE=1 \
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=$OSX_TARGET \
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
-DCMAKE_BUILD_TYPE=Release \
-DOPENSSL_FOUND=1 \
-DOPENSSL_INCLUDE_DIR=$opensslPath/include \
-DOPENSSL_CRYPTO_LIBRARY=$opensslPath/libcrypto.a \
-DZLIB_FOUND=1 \
-DZLIB_INCLUDE_DIR=$zlibPath \
-DZLIB_LIBRARIES=$zlibPath/libz.a \
-DSECP256K1_FOUND=1 \
-DSECP256K1_INCLUDE_DIR=$secp256k1Path/include \
-DSECP256K1_LIBRARY=$secp256k1Path/.libs/libsecp256k1.a \
-DSODIUM_FOUND=1 \
-DSODIUM_INCLUDE_DIR=$sodiumPath/src/libsodium/include \
-DSODIUM_LIBRARY_RELEASE=$sodiumPath/src/libsodium/.libs/libsodium.a \
-DMHD_FOUND=1 \
-DMHD_INCLUDE_DIR=$libmicrohttpdPath/src/include \
-DMHD_LIBRARY=$libmicrohttpdPath/src/microhttpd/.libs/libmicrohttpd.a
test $? -eq 0 || { echo "Can't configure ton"; exit 1; }
if [ "$with_tests" = true ]; then
ninja storage-daemon storage-daemon-cli blockchain-explorer \
tonlib tonlibjson tonlib-cli validator-engine func fift \
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
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
else
ninja storage-daemon storage-daemon-cli blockchain-explorer \
tonlib tonlibjson tonlib-cli validator-engine func fift \
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 $? -eq 0 || { echo "Can't compile ton"; exit 1; }
fi
strip storage/storage-daemon/storage-daemon
strip storage/storage-daemon/storage-daemon-cli
strip blockchain-explorer/blockchain-explorer
strip crypto/fift
strip crypto/func
strip crypto/create-state
strip crypto/tlbc
strip validator-engine-console/validator-engine-console
strip tonlib/tonlib-cli
strip http/http-proxy
strip rldp-http-proxy/rldp-http-proxy
strip dht-server/dht-server
strip lite-client/lite-client
strip validator-engine/validator-engine
strip utils/generate-random-id
strip utils/json2tlo
strip adnl/adnl-proxy
cd ..
if [ "$with_artifacts" = true ]; then
echo Creating artifacts...
rm -rf artifacts
mkdir artifacts
cp crypto/fift/lib artifacts/
cp -R crypto/smartcont/ artifacts/
cp build/storage/storage-daemon/storage-daemon artifacts/
cp build/storage/storage-daemon/storage-daemon-cli artifacts/
cp build/blockchain-explorer/blockchain-explorer artifacts/
cp build/crypto/fift artifacts/
cp build/crypto/func artifacts/
cp build/crypto/create-state artifacts/
cp build/crypto/tlbc artifacts/
cp build/validator-engine-console/validator-engine-console artifacts/
cp build/tonlib/tonlib-cli artifacts/
cp build/tonlib/libtonlibjson.0.5.dylib artifacts/libtonlibjson.dylib
cp build/http/http-proxy artifacts/
cp build/rldp-http-proxy/rldp-http-proxy artifacts/
cp build/dht-server/dht-server artifacts/
cp build/lite-client/lite-client artifacts/
cp build/validator-engine/validator-engine artifacts/
cp build/utils/generate-random-id artifacts/
cp build/utils/json2tlo artifacts/
cp build/adnl/adnl-proxy artifacts/
cp build/emulator/libemulator.dylib artifacts/
chmod +x artifacts/*
rsync -r crypto/smartcont artifacts/
rsync -r crypto/fift/lib artifacts/
fi
if [ "$with_tests" = true ]; then
cd build
# ctest --output-on-failure -E "test-catchain|test-actors"
ctest --output-on-failure
fi

View file

@ -0,0 +1,136 @@
#/bin/bash
with_tests=false
with_artifacts=false
OSX_TARGET=10.15
while getopts 'tao:' flag; do
case "${flag}" in
t) with_tests=true ;;
a) with_artifacts=true ;;
o) OSX_TARGET=${OPTARG} ;;
*) break
;;
esac
done
if [ ! -d "build" ]; then
mkdir build
cd build
else
cd build
rm -rf .ninja* CMakeCache.txt
fi
export NONINTERACTIVE=1
brew install ninja libsodium libmicrohttpd pkg-config automake libtool autoconf gnutls
brew install llvm@16
if [ -f /opt/homebrew/opt/llvm@16/bin/clang ]; then
export CC=/opt/homebrew/opt/llvm@16/bin/clang
export CXX=/opt/homebrew/opt/llvm@16/bin/clang++
else
export CC=/usr/local/opt/llvm@16/bin/clang
export CXX=/usr/local/opt/llvm@16/bin/clang++
fi
export CCACHE_DISABLE=1
if [ ! -d "secp256k1" ]; then
git clone https://github.com/bitcoin-core/secp256k1.git
cd secp256k1
secp256k1Path=`pwd`
git checkout v0.3.2
./autogen.sh
./configure --enable-module-recovery --enable-static --disable-tests --disable-benchmark
make -j12
test $? -eq 0 || { echo "Can't compile secp256k1"; exit 1; }
cd ..
else
secp256k1Path=$(pwd)/secp256k1
echo "Using compiled secp256k1"
fi
brew unlink openssl@1.1
brew install openssl@3
brew unlink openssl@3 && brew link --overwrite openssl@3
cmake -GNinja -DCMAKE_BUILD_TYPE=Release .. \
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
-DSECP256K1_FOUND=1 \
-DSECP256K1_INCLUDE_DIR=$secp256k1Path/include \
-DSECP256K1_LIBRARY=$secp256k1Path/.libs/libsecp256k1.a
test $? -eq 0 || { echo "Can't configure ton"; exit 1; }
if [ "$with_tests" = true ]; then
ninja storage-daemon storage-daemon-cli blockchain-explorer \
tonlib tonlibjson tonlib-cli validator-engine func fift \
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
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
else
ninja storage-daemon storage-daemon-cli blockchain-explorer \
tonlib tonlibjson tonlib-cli validator-engine func fift \
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 $? -eq 0 || { echo "Can't compile ton"; exit 1; }
fi
strip storage/storage-daemon/storage-daemon
strip storage/storage-daemon/storage-daemon-cli
strip blockchain-explorer/blockchain-explorer
strip crypto/fift
strip crypto/func
strip crypto/create-state
strip crypto/tlbc
strip validator-engine-console/validator-engine-console
strip tonlib/tonlib-cli
strip http/http-proxy
strip rldp-http-proxy/rldp-http-proxy
strip dht-server/dht-server
strip lite-client/lite-client
strip validator-engine/validator-engine
strip utils/generate-random-id
strip utils/json2tlo
strip adnl/adnl-proxy
cd ..
if [ "$with_artifacts" = true ]; then
echo Creating artifacts...
rm -rf artifacts
mkdir artifacts
cp build/storage/storage-daemon/storage-daemon artifacts/
cp build/storage/storage-daemon/storage-daemon-cli artifacts/
cp build/blockchain-explorer/blockchain-explorer artifacts/
cp build/crypto/fift artifacts/
cp build/crypto/func artifacts/
cp build/crypto/create-state artifacts/
cp build/crypto/tlbc artifacts/
cp build/validator-engine-console/validator-engine-console artifacts/
cp build/tonlib/tonlib-cli artifacts/
cp build/tonlib/libtonlibjson.0.5.dylib artifacts/libtonlibjson.dylib
cp build/http/http-proxy artifacts/
cp build/rldp-http-proxy/rldp-http-proxy artifacts/
cp build/dht-server/dht-server artifacts/
cp build/lite-client/lite-client artifacts/
cp build/validator-engine/validator-engine artifacts/
cp build/utils/generate-random-id artifacts/
cp build/utils/json2tlo artifacts/
cp build/adnl/adnl-proxy artifacts/
cp build/emulator/libemulator.dylib artifacts/
chmod +x artifacts/*
rsync -r crypto/smartcont artifacts/
rsync -r crypto/fift/lib artifacts/
fi
if [ "$with_tests" = true ]; then
cd build
# ctest --output-on-failure -E "test-catchain|test-actors"
ctest --output-on-failure --timeout 1800
fi

View file

@ -0,0 +1,198 @@
#/bin/bash
#sudo apt-get update
#sudo apt-get install -y build-essential git cmake ninja-build automake libtool texinfo autoconf
with_tests=false
with_artifacts=false
while getopts 'ta' flag; do
case "${flag}" in
t) with_tests=true ;;
a) with_artifacts=true ;;
*) break
;;
esac
done
if [ ! -d "build" ]; then
mkdir build
cd build
else
cd build
rm -rf .ninja* CMakeCache.txt
fi
export CC=$(which clang-16)
export CXX=$(which clang++-16)
export CCACHE_DISABLE=1
if [ ! -d "secp256k1" ]; then
git clone https://github.com/bitcoin-core/secp256k1.git
cd secp256k1
secp256k1Path=`pwd`
git checkout v0.3.2
./autogen.sh
./configure --enable-module-recovery --enable-static --disable-tests --disable-benchmark --with-pic
make -j12
test $? -eq 0 || { echo "Can't compile secp256k1"; exit 1; }
cd ..
# ./.libs/libsecp256k1.a
# ./include
else
secp256k1Path=$(pwd)/secp256k1
echo "Using compiled secp256k1"
fi
if [ ! -d "libsodium" ]; then
export LIBSODIUM_FULL_BUILD=1
git clone https://github.com/jedisct1/libsodium.git
cd libsodium
sodiumPath=`pwd`
git checkout 1.0.18
./autogen.sh
./configure --with-pic --enable-static
make -j12
test $? -eq 0 || { echo "Can't compile libsodium"; exit 1; }
cd ..
else
sodiumPath=$(pwd)/libsodium
echo "Using compiled libsodium"
fi
if [ ! -d "openssl_3" ]; then
git clone https://github.com/openssl/openssl openssl_3
cd openssl_3
opensslPath=`pwd`
git checkout openssl-3.1.4
./config -static
make build_libs -j12
test $? -eq 0 || { echo "Can't compile openssl_3"; exit 1; }
cd ..
else
opensslPath=$(pwd)/openssl_3
echo "Using compiled openssl_3"
fi
if [ ! -d "zlib" ]; then
git clone https://github.com/madler/zlib.git
cd zlib
zlibPath=`pwd`
./configure --static
make -j12
test $? -eq 0 || { echo "Can't compile zlib"; exit 1; }
cd ..
else
zlibPath=$(pwd)/zlib
echo "Using compiled zlib"
fi
if [ ! -d "libmicrohttpd" ]; then
git clone https://git.gnunet.org/libmicrohttpd.git
cd libmicrohttpd
libmicrohttpdPath=`pwd`
./autogen.sh
./configure --enable-static --disable-tests --disable-benchmark --disable-shared --disable-https --with-pic
make -j12
test $? -eq 0 || { echo "Can't compile libmicrohttpd"; exit 1; }
cd ..
else
libmicrohttpdPath=$(pwd)/libmicrohttpd
echo "Using compiled libmicrohttpd"
fi
cmake -GNinja .. \
-DPORTABLE=1 \
-DCMAKE_BUILD_TYPE=Release \
-DOPENSSL_FOUND=1 \
-DOPENSSL_INCLUDE_DIR=$opensslPath/include \
-DOPENSSL_CRYPTO_LIBRARY=$opensslPath/libcrypto.a \
-DZLIB_FOUND=1 \
-DZLIB_INCLUDE_DIR=$zlibPath \
-DZLIB_LIBRARIES=$zlibPath/libz.a \
-DSECP256K1_FOUND=1 \
-DSECP256K1_INCLUDE_DIR=$secp256k1Path/include \
-DSECP256K1_LIBRARY=$secp256k1Path/.libs/libsecp256k1.a \
-DSODIUM_FOUND=1 \
-DSODIUM_INCLUDE_DIR=$sodiumPath/src/libsodium/include \
-DSODIUM_LIBRARY_RELEASE=$sodiumPath/src/libsodium/.libs/libsodium.a \
-DMHD_FOUND=1 \
-DMHD_INCLUDE_DIR=$libmicrohttpdPath/src/include \
-DMHD_LIBRARY=$libmicrohttpdPath/src/microhttpd/.libs/libmicrohttpd.a
test $? -eq 0 || { echo "Can't configure ton"; exit 1; }
if [ "$with_tests" = true ]; then
ninja storage-daemon storage-daemon-cli fift func tonlib tonlibjson tonlib-cli \
validator-engine lite-client pow-miner validator-engine-console blockchain-explorer \
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
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
else
ninja storage-daemon storage-daemon-cli fift func tonlib tonlibjson tonlib-cli \
validator-engine lite-client pow-miner validator-engine-console blockchain-explorer \
generate-random-id json2tlo dht-server http-proxy rldp-http-proxy \
adnl-proxy create-state emulator
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
fi
strip -g storage/storage-daemon/storage-daemon \
storage/storage-daemon/storage-daemon-cli \
blockchain-explorer/blockchain-explorer \
crypto/fift \
crypto/tlbc \
crypto/func \
crypto/create-state \
validator-engine-console/validator-engine-console \
tonlib/tonlib-cli \
tonlib/libtonlibjson.so.0.5 \
http/http-proxy \
rldp-http-proxy/rldp-http-proxy \
dht-server/dht-server \
lite-client/lite-client \
validator-engine/validator-engine \
utils/generate-random-id \
utils/json2tlo \
adnl/adnl-proxy \
emulator/libemulator.*
test $? -eq 0 || { echo "Can't strip final binaries"; exit 1; }
# simple binaries' test
./storage/storage-daemon/storage-daemon -V || exit 1
./validator-engine/validator-engine -V || exit 1
./lite-client/lite-client -V || exit 1
./crypto/fift -V || exit 1
cd ..
if [ "$with_artifacts" = true ]; then
rm -rf artifacts
mkdir artifacts
cp crypto/fift/lib artifacts/
cp -R crypto/smartcont/ artifacts/
mv build/tonlib/libtonlibjson.so.0.5 build/tonlib/libtonlibjson.so
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/blockchain-explorer/blockchain-explorer \
build/validator-engine-console/validator-engine-console build/tonlib/tonlib-cli \
build/tonlib/libtonlibjson.so 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.so \
artifacts
test $? -eq 0 || { echo "Can't copy final binaries"; exit 1; }
chmod +x artifacts/*
cp -R crypto/smartcont artifacts
cp -R crypto/fift/lib artifacts
fi
if [ "$with_tests" = true ]; then
cd build
# ctest --output-on-failure -E "test-catchain|test-actors|test-smartcont|test-adnl|test-validator-session-state|test-dht|test-rldp"
ctest --output-on-failure -E "test-adnl"
fi

View file

@ -0,0 +1,122 @@
#/bin/bash
#sudo apt-get update
#sudo apt-get install -y build-essential git cmake ninja-build zlib1g-dev libsecp256k1-dev libmicrohttpd-dev libsodium-dev
with_tests=false
with_artifacts=false
while getopts 'ta' flag; do
case "${flag}" in
t) with_tests=true ;;
a) with_artifacts=true ;;
*) break
;;
esac
done
if [ ! -d "build" ]; then
mkdir build
cd build
else
cd build
rm -rf .ninja* CMakeCache.txt
fi
export CC=$(which clang-16)
export CXX=$(which clang++-16)
export CCACHE_DISABLE=1
if [ ! -d "openssl_3" ]; then
git clone https://github.com/openssl/openssl openssl_3
cd openssl_3
opensslPath=`pwd`
git checkout openssl-3.1.4
./config
make build_libs -j12
test $? -eq 0 || { echo "Can't compile openssl_3"; exit 1; }
cd ..
else
opensslPath=$(pwd)/openssl_3
echo "Using compiled openssl_3"
fi
cmake -GNinja .. \
-DCMAKE_BUILD_TYPE=Release \
-DOPENSSL_ROOT_DIR=$opensslPath \
-DOPENSSL_INCLUDE_DIR=$opensslPath/include \
-DOPENSSL_CRYPTO_LIBRARY=$opensslPath/libcrypto.so
test $? -eq 0 || { echo "Can't configure ton"; exit 1; }
if [ "$with_tests" = true ]; then
ninja storage-daemon storage-daemon-cli fift func tonlib tonlibjson tonlib-cli \
validator-engine lite-client pow-miner validator-engine-console blockchain-explorer \
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
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
else
ninja storage-daemon storage-daemon-cli fift func tonlib tonlibjson tonlib-cli \
validator-engine lite-client pow-miner validator-engine-console blockchain-explorer \
generate-random-id json2tlo dht-server http-proxy rldp-http-proxy \
adnl-proxy create-state emulator
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
fi
strip -g storage/storage-daemon/storage-daemon \
storage/storage-daemon/storage-daemon-cli \
blockchain-explorer/blockchain-explorer \
crypto/fift \
crypto/tlbc \
crypto/func \
crypto/create-state \
validator-engine-console/validator-engine-console \
tonlib/tonlib-cli \
tonlib/libtonlibjson.so.0.5 \
http/http-proxy \
rldp-http-proxy/rldp-http-proxy \
dht-server/dht-server \
lite-client/lite-client \
validator-engine/validator-engine \
utils/generate-random-id \
utils/json2tlo \
adnl/adnl-proxy \
emulator/libemulator.*
test $? -eq 0 || { echo "Can't strip final binaries"; exit 1; }
# simple binaries' test
./storage/storage-daemon/storage-daemon -V || exit 1
./validator-engine/validator-engine -V || exit 1
./lite-client/lite-client -V || exit 1
./crypto/fift -V || exit 1
cd ..
if [ "$with_artifacts" = true ]; then
rm -rf artifacts
mkdir artifacts
mv build/tonlib/libtonlibjson.so.0.5 build/tonlib/libtonlibjson.so
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/blockchain-explorer/blockchain-explorer \
build/validator-engine-console/validator-engine-console build/tonlib/tonlib-cli \
build/tonlib/libtonlibjson.so 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.so \
artifacts
test $? -eq 0 || { echo "Can't copy final binaries"; exit 1; }
chmod +x artifacts/*
cp -R crypto/smartcont artifacts
cp -R crypto/fift/lib artifacts
fi
if [ "$with_tests" = true ]; then
cd build
# ctest --output-on-failure -E "test-catchain|test-actors|test-smartcont|test-adnl|test-validator-session-state|test-dht|test-rldp"
ctest --output-on-failure --timeout 1800
fi

View file

@ -0,0 +1,2 @@
call "C:\Program Files\Microsoft Visual Studio\2022\%1\VC\Auxiliary\Build\vcvars64.bat"
call build-windows.bat -t

View file

@ -0,0 +1,193 @@
REM execute this script inside elevated (Run as Administrator) console "x64 Native Tools Command Prompt for VS 2022"
echo off
echo Installing chocolatey windows package manager...
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
choco -?
IF %errorlevel% NEQ 0 (
echo Can't install chocolatey
exit /b %errorlevel%
)
choco feature enable -n allowEmptyChecksums
echo Installing pkgconfiglite...
choco install -y pkgconfiglite
IF errorlevel 1 (
echo Can't install pkgconfiglite
exit /b %errorlevel%
)
echo Installing ninja...
choco install -y ninja
IF errorlevel 1 (
echo Can't install ninja
exit /b %errorlevel%
)
if not exist "zlib" (
git clone https://github.com/madler/zlib.git
cd zlib\contrib\vstudio\vc14
msbuild zlibstat.vcxproj /p:Configuration=ReleaseWithoutAsm /p:platform=x64 -p:PlatformToolset=v143
IF errorlevel 1 (
echo Can't install zlib
exit /b %errorlevel%
)
cd ..\..\..\..
) else (
echo Using zlib...
)
if not exist "secp256k1" (
git clone https://github.com/libbitcoin/secp256k1.git
cd secp256k1\builds\msvc\vs2017
msbuild /p:Configuration=StaticRelease -p:PlatformToolset=v143 -p:Platform=x64
IF errorlevel 1 (
echo Can't install secp256k1
exit /b %errorlevel%
)
cd ..\..\..\..
) else (
echo Using secp256k1...
)
if not exist "libsodium" (
curl -Lo libsodium-1.0.18-stable-msvc.zip https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable-msvc.zip
IF errorlevel 1 (
echo Can't download libsodium
exit /b %errorlevel%
)
unzip libsodium-1.0.18-stable-msvc.zip
) else (
echo Using libsodium...
)
if not exist "openssl-3.1.4" (
curl -Lo openssl-3.1.4.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/openssl-3.1.4.zip
IF errorlevel 1 (
echo Can't download OpenSSL
exit /b %errorlevel%
)
unzip -q openssl-3.1.4.zip
) else (
echo Using openssl...
)
if not exist "libmicrohttpd-0.9.77-w32-bin" (
curl -Lo libmicrohttpd-0.9.77-w32-bin.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/libmicrohttpd-0.9.77-w32-bin.zip
IF errorlevel 1 (
echo Can't download libmicrohttpd
exit /b %errorlevel%
)
unzip -q libmicrohttpd-0.9.77-w32-bin.zip
) else (
echo Using libmicrohttpd...
)
if not exist "readline-5.0-1-lib" (
curl -Lo readline-5.0-1-lib.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/readline-5.0-1-lib.zip
IF errorlevel 1 (
echo Can't download readline
exit /b %errorlevel%
)
unzip -q -d readline-5.0-1-lib readline-5.0-1-lib.zip
) else (
echo Using readline...
)
set root=%cd%
echo %root%
set SODIUM_DIR=%root%\libsodium
mkdir build
cd build
cmake -GNinja -DCMAKE_BUILD_TYPE=Release ^
-DPORTABLE=1 ^
-DSODIUM_USE_STATIC_LIBS=1 ^
-DSECP256K1_FOUND=1 ^
-DSECP256K1_INCLUDE_DIR=%root%\secp256k1\include ^
-DSECP256K1_LIBRARY=%root%\secp256k1\bin\x64\Release\v143\static\secp256k1.lib ^
-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_FOUND=1 ^
-DZLIB_INCLUDE_DIR=%root%\zlib ^
-DZLIB_LIBRARIES=%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" ..
IF errorlevel 1 (
echo Can't configure TON
exit /b %errorlevel%
)
IF "%1"=="-t" (
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 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
IF errorlevel 1 (
echo Can't compile TON
exit /b %errorlevel%
)
) else (
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 emulator
IF errorlevel 1 (
echo Can't compile TON
exit /b %errorlevel%
)
)
copy validator-engine\validator-engine.exe test
IF errorlevel 1 (
echo validator-engine.exe does not exist
exit /b %errorlevel%
)
IF "%1"=="-t" (
echo Running tests...
REM ctest -C Release --output-on-failure -E "test-catchain|test-actors|test-validator-session-state"
ctest -C Release --output-on-failure --timeout 1800
IF errorlevel 1 (
echo Some tests failed
exit /b %errorlevel%
)
)
echo Creating artifacts...
cd ..
mkdir artifacts
mkdir artifacts\smartcont
mkdir artifacts\lib
for %%I in (build\storage\storage-daemon\storage-daemon.exe ^
build\storage\storage-daemon\storage-daemon-cli.exe ^
build\blockchain-explorer\blockchain-explorer.exe ^
build\crypto\fift.exe ^
build\crypto\tlbc.exe ^
build\crypto\func.exe ^
build\crypto\create-state.exe ^
build\validator-engine-console\validator-engine-console.exe ^
build\tonlib\tonlib-cli.exe ^
build\tonlib\tonlibjson.dll ^
build\http\http-proxy.exe ^
build\rldp-http-proxy\rldp-http-proxy.exe ^
build\dht-server\dht-server.exe ^
build\lite-client\lite-client.exe ^
build\validator-engine\validator-engine.exe ^
build\utils\generate-random-id.exe ^
build\utils\json2tlo.exe ^
build\adnl\adnl-proxy.exe ^
build\emulator\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

@ -0,0 +1,35 @@
#/bin/bash
nix-build --version
test $? -eq 0 || { echo "Nix is not installed!"; exit 1; }
with_tests=false
while getopts 't' flag; do
case "${flag}" in
t) with_tests=true ;;
*) break
;;
esac
done
cp assembly/nix/linux-arm64* .
cp assembly/nix/microhttpd.nix .
cp assembly/nix/openssl.nix .
export NIX_PATH=nixpkgs=https://github.com/nixOS/nixpkgs/archive/23.05.tar.gz
if [ "$with_tests" = true ]; then
nix-build linux-arm64-static.nix --arg testing true
else
nix-build linux-arm64-static.nix
fi
mkdir artifacts
cp ./result/bin/* artifacts/
chmod +x artifacts/*
rm -rf result
nix-build linux-arm64-tonlib.nix
cp ./result/lib/libtonlibjson.so.0.5 artifacts/libtonlibjson.so
cp ./result/lib/libemulator.so artifacts/
cp -r crypto/fift/lib artifacts/
cp -r crypto/smartcont artifacts/

View file

@ -0,0 +1,36 @@
#/bin/bash
nix-build --version
test $? -eq 0 || { echo "Nix is not installed!"; exit 1; }
with_tests=false
while getopts 't' flag; do
case "${flag}" in
t) with_tests=true ;;
*) break
;;
esac
done
cp assembly/nix/linux-x86-64* .
cp assembly/nix/microhttpd.nix .
cp assembly/nix/openssl.nix .
export NIX_PATH=nixpkgs=https://github.com/nixOS/nixpkgs/archive/23.05.tar.gz
if [ "$with_tests" = true ]; then
nix-build linux-x86-64-static.nix --arg testing true
else
nix-build linux-x86-64-static.nix
fi
mkdir artifacts
cp ./result/bin/* artifacts/
chmod +x artifacts/*
rm -rf result
nix-build linux-x86-64-tonlib.nix
cp ./result/lib/libtonlibjson.so.0.5 artifacts/libtonlibjson.so
cp ./result/lib/libemulator.so artifacts/
cp -r crypto/fift/lib artifacts/
cp -r crypto/smartcont artifacts/

View file

@ -0,0 +1,33 @@
#/bin/bash
nix-build --version
test $? -eq 0 || { echo "Nix is not installed!"; exit 1; }
with_tests=false
while getopts 't' flag; do
case "${flag}" in
t) with_tests=true ;;
*) break
;;
esac
done
cp assembly/nix/macos-* .
export NIX_PATH=nixpkgs=https://github.com/nixOS/nixpkgs/archive/23.05.tar.gz
if [ "$with_tests" = true ]; then
nix-build macos-static.nix --arg testing true
else
nix-build macos-static.nix
fi
mkdir artifacts
cp ./result-bin/bin/* artifacts/
chmod +x artifacts/*
rm -rf result-bin
nix-build macos-tonlib.nix
cp ./result/lib/libtonlibjson.dylib artifacts/
cp ./result/lib/libemulator.dylib artifacts/
cp -r crypto/fift/lib artifacts/
cp -r crypto/smartcont artifacts/

View file

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

View file

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

View file

@ -0,0 +1,46 @@
# export NIX_PATH=nixpkgs=https://github.com/nixOS/nixpkgs/archive/23.05.tar.gz
{ pkgs ? import <nixpkgs> { system = builtins.currentSystem; }
, lib ? pkgs.lib
, stdenv ? pkgs.stdenv
, testing ? false
}:
let
microhttpdmy = (import ./microhttpd.nix) {};
in
with import microhttpdmy;
stdenv.mkDerivation {
pname = "ton";
version = "dev-bin";
src = ./.;
nativeBuildInputs = with pkgs;
[
cmake ninja git pkg-config
];
buildInputs = with pkgs;
[
pkgsStatic.openssl microhttpdmy pkgsStatic.zlib pkgsStatic.libsodium.dev pkgsStatic.secp256k1 glibc.static
];
makeStatic = true;
doCheck = testing;
cmakeFlags = [
"-DTON_USE_ABSEIL=OFF"
"-DNIX=ON"
"-DBUILD_SHARED_LIBS=OFF"
"-DCMAKE_LINK_SEARCH_START_STATIC=ON"
"-DCMAKE_LINK_SEARCH_END_STATIC=ON"
"-DMHD_FOUND=1"
"-DMHD_INCLUDE_DIR=${microhttpdmy}/usr/local/include"
"-DMHD_LIBRARY=${microhttpdmy}/usr/local/lib/libmicrohttpd.a"
"-DCMAKE_CTEST_ARGUMENTS=--timeout;1800"
];
LDFLAGS = [
"-static-libgcc" "-static-libstdc++" "-static"
];
}

View file

@ -0,0 +1,44 @@
# export NIX_PATH=nixpkgs=https://github.com/nixOS/nixpkgs/archive/23.05.tar.gz
{
pkgs ? import <nixpkgs> { system = builtins.currentSystem; }
, lib ? pkgs.lib
, stdenv ? pkgs.stdenv
}:
let
microhttpdmy = (import ./microhttpd.nix) {};
in
with import microhttpdmy;
pkgs.llvmPackages_16.stdenv.mkDerivation {
pname = "ton";
version = "dev-lib";
src = ./.;
nativeBuildInputs = with pkgs;
[
cmake ninja git pkg-config
];
buildInputs = with pkgs;
[
pkgsStatic.openssl microhttpdmy pkgsStatic.zlib pkgsStatic.libsodium.dev pkgsStatic.secp256k1
];
dontAddStaticConfigureFlags = false;
cmakeFlags = [
"-DTON_USE_ABSEIL=OFF"
"-DNIX=ON"
"-DMHD_FOUND=1"
"-DMHD_INCLUDE_DIR=${microhttpdmy}/usr/local/include"
"-DMHD_LIBRARY=${microhttpdmy}/usr/local/lib/libmicrohttpd.a"
];
LDFLAGS = [
"-static-libgcc" "-static-libstdc++" "-fPIC" "-fcommon"
];
ninjaFlags = [
"tonlibjson" "emulator"
];
}

View file

@ -0,0 +1,46 @@
# export NIX_PATH=nixpkgs=https://github.com/nixOS/nixpkgs/archive/23.05.tar.gz
{ pkgs ? import <nixpkgs> { system = builtins.currentSystem; }
, lib ? pkgs.lib
, stdenv ? pkgs.stdenv
, testing ? false
}:
let
microhttpdmy = (import ./microhttpd.nix) {};
in
with import microhttpdmy;
stdenv.mkDerivation {
pname = "ton";
version = "dev-bin";
src = ./.;
nativeBuildInputs = with pkgs;
[
cmake ninja git pkg-config
];
buildInputs = with pkgs;
[
pkgsStatic.openssl microhttpdmy pkgsStatic.zlib pkgsStatic.libsodium.dev pkgsStatic.secp256k1 glibc.static
];
makeStatic = true;
doCheck = testing;
cmakeFlags = [
"-DTON_USE_ABSEIL=OFF"
"-DNIX=ON"
"-DBUILD_SHARED_LIBS=OFF"
"-DCMAKE_LINK_SEARCH_START_STATIC=ON"
"-DCMAKE_LINK_SEARCH_END_STATIC=ON"
"-DMHD_FOUND=1"
"-DMHD_INCLUDE_DIR=${microhttpdmy}/usr/local/include"
"-DMHD_LIBRARY=${microhttpdmy}/usr/local/lib/libmicrohttpd.a"
"-DCMAKE_CTEST_ARGUMENTS=--timeout;1800"
];
LDFLAGS = [
"-static-libgcc" "-static-libstdc++" "-static"
];
}

View file

@ -0,0 +1,54 @@
# export NIX_PATH=nixpkgs=https://github.com/nixOS/nixpkgs/archive/23.11.tar.gz
# copy linux-x86-64-tonlib.nix to git root directory and execute:
# nix-build linux-x86-64-tonlib.nix
{
pkgs ? import <nixpkgs> { system = builtins.currentSystem; }
, lib ? pkgs.lib
, stdenv ? pkgs.stdenv
}:
let
system = builtins.currentSystem;
nixos1909 = (import (builtins.fetchTarball {
url = "https://channels.nixos.org/nixos-19.09/nixexprs.tar.xz";
sha256 = "1vp1h2gkkrckp8dzkqnpcc6xx5lph5d2z46sg2cwzccpr8ay58zy";
}) { inherit system; });
glibc227 = nixos1909.glibc // { pname = "glibc"; };
stdenv227 = let
cc = pkgs.wrapCCWith {
cc = nixos1909.buildPackages.gcc-unwrapped;
libc = glibc227;
bintools = pkgs.binutils.override { libc = glibc227; };
};
in (pkgs.overrideCC pkgs.stdenv cc);
in
stdenv227.mkDerivation {
pname = "ton";
version = "dev-lib";
src = ./.;
nativeBuildInputs = with pkgs;
[ cmake ninja git pkg-config ];
buildInputs = with pkgs;
[
pkgsStatic.openssl pkgsStatic.zlib pkgsStatic.libmicrohttpd.dev pkgsStatic.libsodium.dev pkgsStatic.secp256k1
];
dontAddStaticConfigureFlags = false;
cmakeFlags = [
"-DTON_USE_ABSEIL=OFF"
"-DNIX=ON"
];
LDFLAGS = [
"-static-libgcc" "-static-libstdc++" "-fPIC"
];
ninjaFlags = [
"tonlibjson" "emulator"
];
}

View file

@ -0,0 +1,66 @@
# export NIX_PATH=nixpkgs=https://github.com/nixOS/nixpkgs/archive/23.05.tar.gz
{ pkgs ? import <nixpkgs> { system = builtins.currentSystem; }
, lib ? pkgs.lib
, stdenv ? pkgs.stdenv
, testing ? false
}:
pkgs.llvmPackages_14.stdenv.mkDerivation {
pname = "ton";
version = "dev-bin";
src = ./.;
nativeBuildInputs = with pkgs;
[ cmake ninja git pkg-config ];
buildInputs = with pkgs;
lib.forEach [
secp256k1 libsodium.dev libmicrohttpd.dev gmp.dev nettle.dev libtasn1.dev libidn2.dev libunistring.dev gettext (gnutls.override { withP11-kit = false; }).dev
]
(x: x.overrideAttrs(oldAttrs: rec { configureFlags = (oldAttrs.configureFlags or []) ++ [ "--enable-static" "--disable-shared" "--disable-tests" ]; dontDisableStatic = true; }))
++ [
darwin.apple_sdk.frameworks.CoreFoundation
(openssl.override { static = true; }).dev
(zlib.override { shared = false; }).dev
(libiconv.override { enableStatic = true; enableShared = false; })
];
dontAddStaticConfigureFlags = true;
makeStatic = true;
doCheck = testing;
configureFlags = [];
cmakeFlags = [
"-DTON_USE_ABSEIL=OFF"
"-DNIX=ON"
"-DCMAKE_CROSSCOMPILING=OFF"
"-DCMAKE_LINK_SEARCH_START_STATIC=ON"
"-DCMAKE_LINK_SEARCH_END_STATIC=ON"
"-DBUILD_SHARED_LIBS=OFF"
"-DCMAKE_CXX_FLAGS=-stdlib=libc++"
"-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=11.3"
"-DCMAKE_CTEST_ARGUMENTS=--timeout;1800"
];
LDFLAGS = [
"-static-libstdc++"
"-framework CoreFoundation"
];
postInstall = ''
moveToOutput bin "$bin"
'';
preFixup = ''
for fn in "$bin"/bin/* "$out"/lib/*.dylib; do
echo Fixing libc++ in "$fn"
install_name_tool -change "$(otool -L "$fn" | grep libc++.1 | cut -d' ' -f1 | xargs)" libc++.1.dylib "$fn"
install_name_tool -change "$(otool -L "$fn" | grep libc++abi.1 | cut -d' ' -f1 | xargs)" libc++abi.dylib "$fn"
done
'';
outputs = [ "bin" "out" ];
}

View file

@ -0,0 +1,55 @@
# export NIX_PATH=nixpkgs=https://github.com/nixOS/nixpkgs/archive/23.05.tar.gz
{ pkgs ? import <nixpkgs> { system = builtins.currentSystem; }
, lib ? pkgs.lib
, stdenv ? pkgs.stdenv
}:
pkgs.llvmPackages_14.stdenv.mkDerivation {
pname = "ton";
version = "dev-lib";
src = ./.;
nativeBuildInputs = with pkgs;
[ cmake ninja git pkg-config ];
buildInputs = with pkgs;
lib.forEach [
secp256k1 libsodium.dev libmicrohttpd.dev gmp.dev nettle.dev libtasn1.dev libidn2.dev libunistring.dev gettext (gnutls.override { withP11-kit = false; }).dev
] (x: x.overrideAttrs(oldAttrs: rec { configureFlags = (oldAttrs.configureFlags or []) ++ [ "--enable-static" "--disable-shared" "--disable-tests" ]; dontDisableStatic = true; }))
++ [
darwin.apple_sdk.frameworks.CoreFoundation
(openssl.override { static = true; }).dev
(zlib.override { shared = false; }).dev
(libiconv.override { enableStatic = true; enableShared = false; })
];
dontAddStaticConfigureFlags = true;
configureFlags = [];
cmakeFlags = [
"-DTON_USE_ABSEIL=OFF"
"-DNIX=ON"
"-DCMAKE_CXX_FLAGS=-stdlib=libc++"
"-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=11.3"
];
LDFLAGS = [
"-static-libstdc++"
"-framework CoreFoundation"
];
ninjaFlags = [
"tonlibjson" "emulator"
];
preFixup = ''
for fn in $out/bin/* $out/lib/*.dylib; do
echo Fixing libc++ in "$fn"
install_name_tool -change "$(otool -L "$fn" | grep libc++.1 | cut -d' ' -f1 | xargs)" libc++.1.dylib "$fn"
install_name_tool -change "$(otool -L "$fn" | grep libc++abi.1 | cut -d' ' -f1 | xargs)" libc++abi.dylib "$fn"
done
'';
}

View file

@ -0,0 +1,28 @@
{ pkgs ? import <nixpkgs> { system = builtins.currentSystem; }
, stdenv ? pkgs.stdenv
, fetchgit ? pkgs.fetchgit
}:
stdenv.mkDerivation rec {
name = "microhttpdmy";
src = fetchgit {
url = "https://git.gnunet.org/libmicrohttpd.git";
rev = "refs/tags/v0.9.77";
sha256 = "sha256-x+nfB07PbZwBlFc6kZZFYiRpk0a3QN/ByHB+hC8na/o=";
};
nativeBuildInputs = with pkgs; [ automake libtool autoconf texinfo ];
buildInputs = with pkgs; [ ];
configurePhase = ''
./autogen.sh
./configure --enable-static --disable-tests --disable-benchmark --disable-shared --disable-https --with-pic
'';
installPhase = ''
make install DESTDIR=$out
'';
}

30
assembly/nix/openssl.nix Normal file
View file

@ -0,0 +1,30 @@
{ pkgs ? import <nixpkgs> { system = builtins.currentSystem; }
, stdenv ? pkgs.stdenv
, fetchFromGitHub ? pkgs.fetchFromGitHub
}:
stdenv.mkDerivation rec {
name = "opensslmy";
src = fetchFromGitHub {
owner = "openssl";
repo = "openssl";
rev = "refs/tags/openssl-3.1.4";
sha256 = "sha256-Vvf1wiNb4ikg1lIS9U137aodZ2JzM711tSWMJFYWtWI=";
};
nativeBuildInputs = with pkgs; [ perl ];
buildInputs = with pkgs; [ ];
postPatch = ''
patchShebangs Configure
'';
configurePhase = ''
./Configure no-shared
'';
installPhase = ''
make install DESTDIR=$out
'';
}

View file

@ -0,0 +1,159 @@
# The script builds funcfift compiler to WASM
# Execute these prerequisites first
# 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 automake libtool
# wget https://apt.llvm.org/llvm.sh
# chmod +x llvm.sh
# sudo ./llvm.sh 16 all
with_artifacts=false
while getopts 'a' flag; do
case "${flag}" in
a) with_artifacts=true ;;
*) break
;;
esac
done
export CC=$(which clang-16)
export CXX=$(which clang++-16)
export CCACHE_DISABLE=1
cd ../..
rm -rf openssl zlib emsdk secp256k1 libsodium build
echo `pwd`
git clone https://github.com/openssl/openssl.git
cd openssl
git checkout checkout openssl-3.1.4
./config
make -j16
OPENSSL_DIR=`pwd`
cd ..
git clone https://github.com/madler/zlib.git
cd zlib
ZLIB_DIR=`pwd`
cd ..
git clone https://github.com/bitcoin-core/secp256k1.git
cd secp256k1
./autogen.sh
SECP256K1_DIR=`pwd`
cd ..
git clone https://github.com/jedisct1/libsodium --branch stable
cd libsodium
SODIUM_DIR=`pwd`
cd ..
mkdir build
cd build
cmake -GNinja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=17 \
-DOPENSSL_FOUND=1 \
-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; }
ninja fift smc-envelope
test $? -eq 0 || { echo "Can't compile fift "; exit 1; }
rm -rf *
cd ..
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install 3.1.19
./emsdk activate 3.1.19
EMSDK_DIR=`pwd`
ls $EMSDK_DIR
. $EMSDK_DIR/emsdk_env.sh
export CC=$(which emcc)
export CXX=$(which em++)
export CCACHE_DISABLE=1
cd ../openssl
make clean
emconfigure ./Configure linux-generic32 no-shared no-dso no-engine no-unit-test
sed -i 's/CROSS_COMPILE=.*/CROSS_COMPILE=/g' Makefile
sed -i 's/-ldl//g' Makefile
sed -i 's/-O3/-Os/g' Makefile
emmake make depend
emmake make -j16
test $? -eq 0 || { echo "Can't compile OpenSSL with emmake "; exit 1; }
cd ../zlib
emconfigure ./configure --static
emmake make -j16
test $? -eq 0 || { echo "Can't compile zlib with emmake "; exit 1; }
ZLIB_DIR=`pwd`
cd ../secp256k1
emconfigure ./configure --enable-module-recovery
emmake make -j16
test $? -eq 0 || { echo "Can't compile secp256k1 with emmake "; exit 1; }
cd ../libsodium
emconfigure ./configure --disable-ssp
emmake make -j16
test $? -eq 0 || { echo "Can't compile libsodium with emmake "; exit 1; }
cd ../build
emcmake cmake -DUSE_EMSCRIPTEN=ON -DCMAKE_BUILD_TYPE=Release \
-DZLIB_FOUND=1 \
-DZLIB_LIBRARIES=$ZLIB_DIR/libz.a \
-DZLIB_INCLUDE_DIR=$ZLIB_DIR \
-DOPENSSL_FOUND=1 \
-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_FOUND=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_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
test $? -eq 0 || { echo "Can't compile TON with emmake "; exit 1; }
if [ "$with_artifacts" = true ]; then
echo "Creating artifacts..."
cd ..
rm -rf artifacts
mkdir artifacts
ls build/crypto
cp build/crypto/fift* artifacts
cp build/crypto/func* artifacts
cp build/crypto/tlbc* artifacts
cp build/emulator/emulator-emscripten* artifacts
cp -R crypto/smartcont artifacts
cp -R crypto/fift/lib artifacts
fi

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) option(NIX "Use \"ON\" for a static build." OFF)
@ -14,15 +14,29 @@ set(BLOCHAIN_EXPLORER_SOURCE
add_executable(blockchain-explorer ${BLOCHAIN_EXPLORER_SOURCE}) add_executable(blockchain-explorer ${BLOCHAIN_EXPLORER_SOURCE})
if (NIX) if (NIX)
find_package(PkgConfig REQUIRED) if (MHD_FOUND)
pkg_check_modules(MHD libmicrohttpd) target_include_directories(blockchain-explorer PUBLIC ${MHD_INCLUDE_DIR})
target_include_directories(blockchain-explorer PUBLIC ${MHD_INCLUDE_DIRS} ${MHD_STATIC_INCLUDE_DIRS}) target_link_libraries(blockchain-explorer tdutils tdactor adnllite tl_lite_api tl-lite-utils ton_crypto ton_block ${MHD_LIBRARY})
target_link_libraries(blockchain-explorer tdutils tdactor adnllite tl_lite_api tl-lite-utils ton_crypto ton_block lite-client-common ${MHD_LIBRARIES} ${MHD_STATIC_LIBRARIES}) else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(MHD libmicrohttpd)
target_include_directories(blockchain-explorer PUBLIC ${MHD_INCLUDE_DIR} ${MHD_STATIC_INCLUDE_DIRS})
target_link_libraries(blockchain-explorer tdutils tdactor adnllite tl_lite_api tl-lite-utils ton_crypto ton_block ${MHD_LIBRARIES} ${MHD_STATIC_LIBRARIES})
endif()
else() else()
find_package(MHD) if (MHD_FOUND)
target_include_directories(blockchain-explorer PUBLIC ${MHD_INCLUDE_DIRS}) target_include_directories(blockchain-explorer PUBLIC ${MHD_INCLUDE_DIR})
target_link_libraries(blockchain-explorer tdutils tdactor adnllite tl_lite_api tl-lite-utils ton_crypto ton_block lite-client-common ${MHD_LIBRARIES}) target_link_libraries(blockchain-explorer tdutils tdactor adnllite tl_lite_api tl-lite-utils ton_crypto ton_block ${MHD_LIBRARY})
else()
find_package(MHD)
target_include_directories(blockchain-explorer PUBLIC ${MHD_INCLUDE_DIR})
target_link_libraries(blockchain-explorer tdutils tdactor adnllite tl_lite_api tl-lite-utils ton_crypto ton_block ${MHD_LIBRARY})
endif()
endif() endif()
target_include_directories(blockchain-explorer PUBLIC ${MHD_INCLUDE_DIR})
target_link_libraries(blockchain-explorer tdutils tdactor adnllite tl_lite_api tl-lite-utils ton_crypto ton_block ${MHD_LIBRARY})
target_link_libraries(blockchain-explorer lite-client-common)
install(TARGETS blockchain-explorer RUNTIME DESTINATION bin) install(TARGETS blockchain-explorer RUNTIME DESTINATION bin)

View file

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

View file

@ -287,7 +287,9 @@ void CatChainReceiverImpl::add_block_cont_3(tl_object_ptr<ton_api::catchain_bloc
run_scheduler(); run_scheduler();
if (!intentional_fork_) { if (!intentional_fork_) {
CHECK(last_sent_block_->delivered()); LOG_CHECK(last_sent_block_->delivered())
<< "source=" << last_sent_block_->get_source_id() << " ill=" << last_sent_block_->is_ill()
<< " height=" << last_sent_block_->get_height();
} }
active_send_ = false; active_send_ = false;

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 set(COMMON_SOURCE
checksum.h checksum.h

View file

@ -19,6 +19,6 @@
namespace ton { namespace ton {
// See doc/GlobalVersions.md // See doc/GlobalVersions.md
const int SUPPORTED_VERSION = 4; const int SUPPORTED_VERSION = 6;
} }

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) if (NOT OPENSSL_FOUND)
find_package(OpenSSL REQUIRED) find_package(OpenSSL REQUIRED)

View file

@ -49,7 +49,7 @@
#include "validator/fabric.h" #include "validator/fabric.h"
#include "validator/impl/collator.h" #include "validator/impl/collator.h"
#include "crypto/vm/cp0.h" #include "crypto/vm/vm.h"
#include "crypto/block/block-db.h" #include "crypto/block/block-db.h"
#include "common/errorlog.h" #include "common/errorlog.h"
@ -310,7 +310,7 @@ int main(int argc, char *argv[]) {
SET_VERBOSITY_LEVEL(verbosity_INFO); SET_VERBOSITY_LEVEL(verbosity_INFO);
td::set_default_failure_signal_handler().ensure(); td::set_default_failure_signal_handler().ensure();
CHECK(vm::init_op_cp0()); vm::init_vm().ensure();
td::actor::ActorOwn<HardforkCreator> x; 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) if (NOT OPENSSL_FOUND)
find_package(OpenSSL REQUIRED) find_package(OpenSSL REQUIRED)
@ -236,6 +236,7 @@ set(SMC_ENVELOPE_SOURCE
smc-envelope/SmartContractCode.cpp smc-envelope/SmartContractCode.cpp
smc-envelope/WalletInterface.cpp smc-envelope/WalletInterface.cpp
smc-envelope/WalletV3.cpp smc-envelope/WalletV3.cpp
smc-envelope/WalletV4.cpp
smc-envelope/GenericAccount.h smc-envelope/GenericAccount.h
smc-envelope/HighloadWallet.h smc-envelope/HighloadWallet.h
@ -246,6 +247,7 @@ set(SMC_ENVELOPE_SOURCE
smc-envelope/SmartContractCode.h smc-envelope/SmartContractCode.h
smc-envelope/WalletInterface.h smc-envelope/WalletInterface.h
smc-envelope/WalletV3.h smc-envelope/WalletV3.h
smc-envelope/WalletV4.h
) )
set(ED25519_TEST_SOURCE set(ED25519_TEST_SOURCE
@ -323,23 +325,20 @@ endif()
if (MSVC) if (MSVC)
find_package(Sodium REQUIRED) find_package(Sodium REQUIRED)
target_compile_definitions(ton_crypto PUBLIC SODIUM_STATIC) target_compile_definitions(ton_crypto PUBLIC SODIUM_STATIC)
target_include_directories(ton_crypto_core PUBLIC $<BUILD_INTERFACE:${SECP256K1_INCLUDE_DIRS}>) target_include_directories(ton_crypto_core PUBLIC $<BUILD_INTERFACE:${SECP256K1_INCLUDE_DIR}>)
target_link_libraries(ton_crypto PUBLIC ${SECP256K1_LIBRARIES}) target_link_libraries(ton_crypto PUBLIC ${SECP256K1_LIBRARY})
elseif (ANDROID) elseif (ANDROID OR EMSCRIPTEN)
target_include_directories(ton_crypto_core PUBLIC $<BUILD_INTERFACE:${SECP256K1_INCLUDE_DIR}>) target_include_directories(ton_crypto_core PUBLIC $<BUILD_INTERFACE:${SECP256K1_INCLUDE_DIR}>)
target_link_libraries(ton_crypto PUBLIC $<BUILD_INTERFACE:${SECP256K1_LIBRARY}>) target_link_libraries(ton_crypto PUBLIC $<BUILD_INTERFACE:${SECP256K1_LIBRARY}>)
else() else()
if (NOT USE_EMSCRIPTEN) if (NOT SODIUM_FOUND)
find_package(Sodium REQUIRED) find_package(Sodium REQUIRED)
target_include_directories(ton_crypto_core PUBLIC $<BUILD_INTERFACE:${SECP256K1_INCLUDE_DIRS}>)
target_link_libraries(ton_crypto PUBLIC ${SECP256K1_LIBRARIES})
else() else()
target_include_directories(ton_crypto_core PUBLIC $<BUILD_INTERFACE:${SECP256K1_INCLUDE_DIR}>) message(STATUS "Using Sodium ${SODIUM_LIBRARY_RELEASE}")
target_link_libraries(ton_crypto PUBLIC ${SECP256K1_LIBRARY})
endif()
if (NOT APPLE AND NOT USE_EMSCRIPTEN)
target_link_libraries(ton_crypto_core PUBLIC secp256k1)
endif() endif()
target_compile_definitions(ton_crypto PUBLIC SODIUM_STATIC)
target_include_directories(ton_crypto_core PUBLIC $<BUILD_INTERFACE:${SECP256K1_INCLUDE_DIR}>)
target_link_libraries(ton_crypto PUBLIC ${SECP256K1_LIBRARY})
endif() endif()
target_include_directories(ton_crypto_core PUBLIC $<BUILD_INTERFACE:${SODIUM_INCLUDE_DIR}>) target_include_directories(ton_crypto_core PUBLIC $<BUILD_INTERFACE:${SODIUM_INCLUDE_DIR}>)
@ -354,7 +353,7 @@ add_executable(test-ed25519-crypto test/test-ed25519-crypto.cpp)
target_include_directories(test-ed25519-crypto PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>) target_include_directories(test-ed25519-crypto PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_link_libraries(test-ed25519-crypto PUBLIC ton_crypto) target_link_libraries(test-ed25519-crypto PUBLIC ton_crypto)
add_library(fift-lib ${FIFT_SOURCE}) add_library(fift-lib STATIC ${FIFT_SOURCE})
target_include_directories(fift-lib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>) target_include_directories(fift-lib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_link_libraries(fift-lib PUBLIC ton_crypto ton_db tdutils ton_block) target_link_libraries(fift-lib PUBLIC ton_crypto ton_db tdutils ton_block)
if (USE_EMSCRIPTEN) if (USE_EMSCRIPTEN)
@ -398,6 +397,7 @@ if (USE_EMSCRIPTEN)
target_link_options(funcfiftlib PRIVATE -sIGNORE_MISSING_MAIN=1) target_link_options(funcfiftlib PRIVATE -sIGNORE_MISSING_MAIN=1)
target_link_options(funcfiftlib PRIVATE -sAUTO_NATIVE_LIBRARIES=0) target_link_options(funcfiftlib PRIVATE -sAUTO_NATIVE_LIBRARIES=0)
target_link_options(funcfiftlib PRIVATE -sMODULARIZE=1) target_link_options(funcfiftlib PRIVATE -sMODULARIZE=1)
target_link_options(funcfiftlib PRIVATE -sTOTAL_MEMORY=33554432)
target_link_options(funcfiftlib PRIVATE -sALLOW_MEMORY_GROWTH=1) target_link_options(funcfiftlib PRIVATE -sALLOW_MEMORY_GROWTH=1)
target_link_options(funcfiftlib PRIVATE -sALLOW_TABLE_GROWTH=1) target_link_options(funcfiftlib PRIVATE -sALLOW_TABLE_GROWTH=1)
target_link_options(funcfiftlib PRIVATE --embed-file ${CMAKE_CURRENT_SOURCE_DIR}/fift/lib@/fiftlib) target_link_options(funcfiftlib PRIVATE --embed-file ${CMAKE_CURRENT_SOURCE_DIR}/fift/lib@/fiftlib)
@ -504,7 +504,7 @@ if (NOT CMAKE_CROSSCOMPILING OR USE_EMSCRIPTEN)
GenFif(DEST smartcont/auto/simple-wallet-ext-code SOURCE smartcont/simple-wallet-ext-code.fc NAME simple-wallet-ext) GenFif(DEST smartcont/auto/simple-wallet-ext-code SOURCE smartcont/simple-wallet-ext-code.fc NAME simple-wallet-ext)
endif() endif()
add_library(smc-envelope ${SMC_ENVELOPE_SOURCE}) add_library(smc-envelope STATIC ${SMC_ENVELOPE_SOURCE})
target_include_directories(smc-envelope PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>) target_include_directories(smc-envelope PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_link_libraries(smc-envelope PUBLIC ton_crypto PRIVATE tdutils ton_block) target_link_libraries(smc-envelope PUBLIC ton_crypto PRIVATE tdutils ton_block)
if (NOT CMAKE_CROSSCOMPILING) if (NOT CMAKE_CROSSCOMPILING)

View file

@ -734,7 +734,7 @@ td::uint64 BlockLimitStatus::estimate_block_size(const vm::NewCellStorageStat::S
sum += *extra; sum += *extra;
} }
return 2000 + (sum.bits >> 3) + sum.cells * 12 + sum.internal_refs * 3 + sum.external_refs * 40 + accounts * 200 + 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 + public_library_diff * 700;
} }
int BlockLimitStatus::classify() const { int BlockLimitStatus::classify() const {
@ -1030,8 +1030,8 @@ td::Status ShardState::merge_with(ShardState& sib) {
return td::Status::OK(); return td::Status::OK();
} }
td::Result<std::unique_ptr<vm::AugmentedDictionary>> ShardState::compute_split_out_msg_queue( td::Result<std::unique_ptr<vm::AugmentedDictionary>> ShardState::compute_split_out_msg_queue(ton::ShardIdFull subshard,
ton::ShardIdFull subshard) { td::uint32* queue_size) {
auto shard = id_.shard_full(); auto shard = id_.shard_full();
if (!ton::shard_is_parent(shard, subshard)) { if (!ton::shard_is_parent(shard, subshard)) {
return td::Status::Error(-666, "cannot split subshard "s + subshard.to_str() + " from state of " + id_.to_str() + return td::Status::Error(-666, "cannot split subshard "s + subshard.to_str() + " from state of " + id_.to_str() +
@ -1039,7 +1039,7 @@ td::Result<std::unique_ptr<vm::AugmentedDictionary>> ShardState::compute_split_o
} }
CHECK(out_msg_queue_); CHECK(out_msg_queue_);
auto subqueue = std::make_unique<vm::AugmentedDictionary>(*out_msg_queue_); auto subqueue = std::make_unique<vm::AugmentedDictionary>(*out_msg_queue_);
int res = block::filter_out_msg_queue(*subqueue, shard, subshard); int res = block::filter_out_msg_queue(*subqueue, shard, subshard, queue_size);
if (res < 0) { if (res < 0) {
return td::Status::Error(-666, "error splitting OutMsgQueue of "s + id_.to_str()); return td::Status::Error(-666, "error splitting OutMsgQueue of "s + id_.to_str());
} }
@ -1061,7 +1061,7 @@ td::Result<std::shared_ptr<block::MsgProcessedUptoCollection>> ShardState::compu
return std::move(sub_processed_upto); return std::move(sub_processed_upto);
} }
td::Status ShardState::split(ton::ShardIdFull subshard) { td::Status ShardState::split(ton::ShardIdFull subshard, td::uint32* queue_size) {
if (!ton::shard_is_parent(id_.shard_full(), subshard)) { if (!ton::shard_is_parent(id_.shard_full(), subshard)) {
return td::Status::Error(-666, "cannot split subshard "s + subshard.to_str() + " from state of " + id_.to_str() + return td::Status::Error(-666, "cannot split subshard "s + subshard.to_str() + " from state of " + id_.to_str() +
" because it is not a parent"); " because it is not a parent");
@ -1079,7 +1079,7 @@ td::Status ShardState::split(ton::ShardIdFull subshard) {
auto shard1 = id_.shard_full(); auto shard1 = id_.shard_full();
CHECK(ton::shard_is_parent(shard1, subshard)); CHECK(ton::shard_is_parent(shard1, subshard));
CHECK(out_msg_queue_); CHECK(out_msg_queue_);
int res1 = block::filter_out_msg_queue(*out_msg_queue_, shard1, subshard); int res1 = block::filter_out_msg_queue(*out_msg_queue_, shard1, subshard, queue_size);
if (res1 < 0) { if (res1 < 0) {
return td::Status::Error(-666, "error splitting OutMsgQueue of "s + id_.to_str()); return td::Status::Error(-666, "error splitting OutMsgQueue of "s + id_.to_str());
} }
@ -1119,8 +1119,12 @@ td::Status ShardState::split(ton::ShardIdFull subshard) {
return td::Status::OK(); return td::Status::OK();
} }
int filter_out_msg_queue(vm::AugmentedDictionary& out_queue, ton::ShardIdFull old_shard, ton::ShardIdFull subshard) { int filter_out_msg_queue(vm::AugmentedDictionary& out_queue, ton::ShardIdFull old_shard, ton::ShardIdFull subshard,
return out_queue.filter([subshard, old_shard](vm::CellSlice& cs, td::ConstBitPtr key, int key_len) -> int { td::uint32* queue_size) {
if (queue_size) {
*queue_size = 0;
}
return out_queue.filter([=](vm::CellSlice& cs, td::ConstBitPtr key, int key_len) -> int {
CHECK(key_len == 352); CHECK(key_len == 352);
LOG(DEBUG) << "scanning OutMsgQueue entry with key " << key.to_hex(key_len); LOG(DEBUG) << "scanning OutMsgQueue entry with key " << key.to_hex(key_len);
block::tlb::MsgEnvelope::Record_std env; block::tlb::MsgEnvelope::Record_std env;
@ -1143,7 +1147,11 @@ int filter_out_msg_queue(vm::AugmentedDictionary& out_queue, ton::ShardIdFull ol
<< " does not contain current address belonging to shard " << old_shard.to_str(); << " does not contain current address belonging to shard " << old_shard.to_str();
return -1; return -1;
} }
return ton::shard_contains(subshard, cur_prefix); bool res = ton::shard_contains(subshard, cur_prefix);
if (res && queue_size) {
++*queue_size;
}
return res;
}); });
} }

View file

@ -275,6 +275,7 @@ struct BlockLimitStatus {
vm::NewCellStorageStat st_stat; vm::NewCellStorageStat st_stat;
unsigned accounts{}, transactions{}, extra_out_msgs{}; unsigned accounts{}, transactions{}, extra_out_msgs{};
vm::ProofStorageStat collated_data_stat; vm::ProofStorageStat collated_data_stat;
unsigned public_library_diff{};
BlockLimitStatus(const BlockLimits& limits_, ton::LogicalTime lt = 0) BlockLimitStatus(const BlockLimits& limits_, ton::LogicalTime lt = 0)
: limits(limits_), cur_lt(std::max(limits_.start_lt, lt)) { : limits(limits_), cur_lt(std::max(limits_.start_lt, lt)) {
} }
@ -284,6 +285,7 @@ struct BlockLimitStatus {
transactions = accounts = 0; transactions = accounts = 0;
gas_used = 0; gas_used = 0;
extra_out_msgs = 0; extra_out_msgs = 0;
public_library_diff = 0;
collated_data_stat = {}; collated_data_stat = {};
} }
td::uint64 estimate_block_size(const vm::NewCellStorageStat::Stat* extra = nullptr) const; td::uint64 estimate_block_size(const vm::NewCellStorageStat::Stat* extra = nullptr) const;
@ -445,10 +447,11 @@ struct ShardState {
ton::BlockSeqno prev_mc_block_seqno, bool after_split, bool clear_history, ton::BlockSeqno prev_mc_block_seqno, bool after_split, bool clear_history,
std::function<bool(ton::BlockSeqno)> for_each_mcseqno); std::function<bool(ton::BlockSeqno)> for_each_mcseqno);
td::Status merge_with(ShardState& sib); td::Status merge_with(ShardState& sib);
td::Result<std::unique_ptr<vm::AugmentedDictionary>> compute_split_out_msg_queue(ton::ShardIdFull subshard); td::Result<std::unique_ptr<vm::AugmentedDictionary>> compute_split_out_msg_queue(ton::ShardIdFull subshard,
td::uint32* queue_size = nullptr);
td::Result<std::shared_ptr<block::MsgProcessedUptoCollection>> compute_split_processed_upto( td::Result<std::shared_ptr<block::MsgProcessedUptoCollection>> compute_split_processed_upto(
ton::ShardIdFull subshard); ton::ShardIdFull subshard);
td::Status split(ton::ShardIdFull subshard); td::Status split(ton::ShardIdFull subshard, td::uint32* queue_size = nullptr);
td::Status unpack_out_msg_queue_info(Ref<vm::Cell> out_msg_queue_info); td::Status unpack_out_msg_queue_info(Ref<vm::Cell> out_msg_queue_info);
bool clear_load_history() { bool clear_load_history() {
overload_history_ = underload_history_ = 0; overload_history_ = underload_history_ = 0;
@ -668,7 +671,8 @@ class MtCarloComputeShare {
void gen_vset(); void gen_vset();
}; };
int filter_out_msg_queue(vm::AugmentedDictionary& out_queue, ton::ShardIdFull old_shard, ton::ShardIdFull subshard); int filter_out_msg_queue(vm::AugmentedDictionary& out_queue, ton::ShardIdFull old_shard, ton::ShardIdFull subshard,
td::uint32* queue_size = nullptr);
std::ostream& operator<<(std::ostream& os, const ShardId& shard_id); std::ostream& operator<<(std::ostream& os, const ShardId& shard_id);

View file

@ -789,7 +789,8 @@ _ CollatorConfig = ConfigParam 41;
size_limits_config#01 max_msg_bits:uint32 max_msg_cells:uint32 max_library_cells:uint32 max_vm_data_depth:uint16 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; 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 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; _ SizeLimitsConfig = ConfigParam 43;
// key is [ wc:int32 addr:uint256 ] // key is [ wc:int32 addr:uint256 ]

View file

@ -621,12 +621,14 @@ td::Result<std::vector<StoragePrices>> Config::get_storage_prices() const {
} }
vm::Dictionary dict{std::move(cell), 32}; vm::Dictionary dict{std::move(cell), 32};
if (!dict.check_for_each([&res](Ref<vm::CellSlice> cs_ref, td::ConstBitPtr key, int n) -> bool { if (!dict.check_for_each([&res](Ref<vm::CellSlice> cs_ref, td::ConstBitPtr key, int n) -> bool {
block::gen::StoragePrices::Record data; auto r_prices = do_get_one_storage_prices(*cs_ref);
if (!tlb::csr_unpack(std::move(cs_ref), data) || data.utime_since != key.get_uint(n)) { if (r_prices.is_error()) {
return false;
}
res.push_back(r_prices.move_as_ok());
if (res.back().valid_since != key.get_uint(n)) {
return false; return false;
} }
res.emplace_back(data.utime_since, data.bit_price_ps, data.cell_price_ps, data.mc_bit_price_ps,
data.mc_cell_price_ps);
return true; return true;
})) { })) {
return td::Status::Error("invalid storage prices dictionary in configuration parameter 18"); return td::Status::Error("invalid storage prices dictionary in configuration parameter 18");
@ -634,16 +636,25 @@ td::Result<std::vector<StoragePrices>> Config::get_storage_prices() const {
return std::move(res); return std::move(res);
} }
td::Result<GasLimitsPrices> Config::do_get_gas_limits_prices(td::Ref<vm::Cell> cell, int id) { td::Result<StoragePrices> Config::do_get_one_storage_prices(vm::CellSlice cs) {
block::gen::StoragePrices::Record data;
if (!tlb::unpack(cs, data)) {
return td::Status::Error("invalid storage prices dictionary in configuration parameter 18");
}
return StoragePrices{data.utime_since, data.bit_price_ps, data.cell_price_ps, data.mc_bit_price_ps,
data.mc_cell_price_ps};
}
td::Result<GasLimitsPrices> Config::do_get_gas_limits_prices(vm::CellSlice cs, int id) {
GasLimitsPrices res; GasLimitsPrices res;
auto cs = vm::load_cell_slice(cell); vm::CellSlice cs0 = cs;
block::gen::GasLimitsPrices::Record_gas_flat_pfx flat; block::gen::GasLimitsPrices::Record_gas_flat_pfx flat;
if (tlb::unpack(cs, flat)) { if (tlb::unpack(cs, flat)) {
cs = *flat.other; cs = *flat.other;
res.flat_gas_limit = flat.flat_gas_limit; res.flat_gas_limit = flat.flat_gas_limit;
res.flat_gas_price = flat.flat_gas_price; res.flat_gas_price = flat.flat_gas_price;
} else { } else {
cs = vm::load_cell_slice(cell); cs = cs0;
} }
auto f = [&](const auto& r, td::uint64 spec_limit) { auto f = [&](const auto& r, td::uint64 spec_limit) {
res.gas_limit = r.gas_limit; res.gas_limit = r.gas_limit;
@ -658,7 +669,7 @@ td::Result<GasLimitsPrices> Config::do_get_gas_limits_prices(td::Ref<vm::Cell> c
f(rec, rec.special_gas_limit); f(rec, rec.special_gas_limit);
} else { } else {
block::gen::GasLimitsPrices::Record_gas_prices rec0; block::gen::GasLimitsPrices::Record_gas_prices rec0;
if (tlb::unpack(cs, rec0)) { if (tlb::unpack(cs = cs0, rec0)) {
f(rec0, rec0.gas_limit); f(rec0, rec0.gas_limit);
} else { } else {
return td::Status::Error(PSLICE() << "configuration parameter " << id return td::Status::Error(PSLICE() << "configuration parameter " << id
@ -688,7 +699,7 @@ td::Result<GasLimitsPrices> Config::get_gas_limits_prices(bool is_masterchain) c
if (cell.is_null()) { if (cell.is_null()) {
return td::Status::Error(PSLICE() << "configuration parameter " << id << " with gas prices is absent"); return td::Status::Error(PSLICE() << "configuration parameter " << id << " with gas prices is absent");
} }
return do_get_gas_limits_prices(std::move(cell), id); return do_get_gas_limits_prices(vm::load_cell_slice(cell), id);
} }
td::Result<MsgPrices> Config::get_msg_prices(bool is_masterchain) const { td::Result<MsgPrices> Config::get_msg_prices(bool is_masterchain) const {
@ -697,7 +708,10 @@ td::Result<MsgPrices> Config::get_msg_prices(bool is_masterchain) const {
if (cell.is_null()) { if (cell.is_null()) {
return td::Status::Error(PSLICE() << "configuration parameter " << id << " with msg prices is absent"); return td::Status::Error(PSLICE() << "configuration parameter " << id << " with msg prices is absent");
} }
auto cs = vm::load_cell_slice(std::move(cell)); return do_get_msg_prices(vm::load_cell_slice(cell), id);
}
td::Result<MsgPrices> Config::do_get_msg_prices(vm::CellSlice cs, int id) {
block::gen::MsgForwardPrices::Record rec; block::gen::MsgForwardPrices::Record rec;
if (!tlb::unpack(cs, rec)) { if (!tlb::unpack(cs, rec)) {
return td::Status::Error(PSLICE() << "configuration parameter " << id return td::Status::Error(PSLICE() << "configuration parameter " << id
@ -1916,10 +1930,17 @@ std::vector<ton::ValidatorDescr> Config::compute_total_validator_set(int next) c
} }
td::Result<SizeLimitsConfig> Config::get_size_limits_config() const { td::Result<SizeLimitsConfig> Config::get_size_limits_config() const {
SizeLimitsConfig limits;
td::Ref<vm::Cell> param = get_config_param(43); td::Ref<vm::Cell> param = get_config_param(43);
if (param.is_null()) { if (param.is_null()) {
return limits; return do_get_size_limits_config({});
}
return do_get_size_limits_config(vm::load_cell_slice_ref(param));
}
td::Result<SizeLimitsConfig> Config::do_get_size_limits_config(td::Ref<vm::CellSlice> cs) {
SizeLimitsConfig limits;
if (cs.is_null()) {
return limits; // default values
} }
auto unpack_v1 = [&](auto& rec) { auto unpack_v1 = [&](auto& rec) {
limits.max_msg_bits = rec.max_msg_bits; limits.max_msg_bits = rec.max_msg_bits;
@ -1934,12 +1955,13 @@ td::Result<SizeLimitsConfig> Config::get_size_limits_config() const {
unpack_v1(rec); unpack_v1(rec);
limits.max_acc_state_bits = rec.max_acc_state_bits; limits.max_acc_state_bits = rec.max_acc_state_bits;
limits.max_acc_state_cells = rec.max_acc_state_cells; 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 rec_v1;
gen::SizeLimitsConfig::Record_size_limits_config_v2 rec_v2; gen::SizeLimitsConfig::Record_size_limits_config_v2 rec_v2;
if (tlb::unpack_cell(param, rec_v1)) { if (tlb::csr_unpack(cs, rec_v1)) {
unpack_v1(rec_v1); unpack_v1(rec_v1);
} else if (tlb::unpack_cell(param, rec_v2)) { } else if (tlb::csr_unpack(cs, rec_v2)) {
unpack_v2(rec_v2); unpack_v2(rec_v2);
} else { } else {
return td::Status::Error("configuration parameter 43 is invalid"); return td::Status::Error("configuration parameter 43 is invalid");
@ -1974,6 +1996,42 @@ BurningConfig Config::get_burning_config() const {
return c; return c;
} }
td::Ref<vm::Tuple> Config::get_unpacked_config_tuple(ton::UnixTime now) const {
auto get_param = [&](td::int32 idx) -> vm::StackEntry {
auto cell = get_config_param(idx);
if (cell.is_null()) {
return {};
}
return vm::load_cell_slice_ref(cell);
};
auto get_current_storage_prices = [&]() -> vm::StackEntry {
auto cell = get_config_param(18);
if (cell.is_null()) {
return {};
}
vm::StackEntry res;
vm::Dictionary dict{std::move(cell), 32};
dict.check_for_each([&](Ref<vm::CellSlice> cs_ref, td::ConstBitPtr key, int n) -> bool {
auto utime_since = key.get_uint(n);
if (now >= utime_since) {
res = std::move(cs_ref);
return true;
}
return false;
});
return res;
};
std::vector<vm::StackEntry> tuple;
tuple.push_back(get_current_storage_prices()); // storage_prices
tuple.push_back(get_param(19)); // global_id
tuple.push_back(get_param(20)); // config_mc_gas_prices
tuple.push_back(get_param(21)); // config_gas_prices
tuple.push_back(get_param(24)); // config_mc_fwd_prices
tuple.push_back(get_param(25)); // config_fwd_prices
tuple.push_back(get_param(43)); // size_limits_config
return td::make_cnt_ref<std::vector<vm::StackEntry>>(std::move(tuple));
}
td::Result<std::pair<ton::UnixTime, ton::UnixTime>> Config::unpack_validator_set_start_stop(Ref<vm::Cell> vset_root) { td::Result<std::pair<ton::UnixTime, ton::UnixTime>> Config::unpack_validator_set_start_stop(Ref<vm::Cell> vset_root) {
if (vset_root.is_null()) { if (vset_root.is_null()) {
return td::Status::Error("validator set absent"); return td::Status::Error("validator set absent");

View file

@ -350,7 +350,11 @@ struct GasLimitsPrices {
td::uint64 freeze_due_limit{0}; td::uint64 freeze_due_limit{0};
td::uint64 delete_due_limit{0}; td::uint64 delete_due_limit{0};
td::RefInt256 compute_gas_price(td::uint64 gas_used) const; td::RefInt256 compute_gas_price(td::uint64 gas_used) const {
return gas_used <= flat_gas_limit
? td::make_refint(flat_gas_price)
: td::rshift(td::make_refint(gas_price) * (gas_used - flat_gas_limit), 16, 1) + flat_gas_price;
}
}; };
// msg_fwd_fees = (lump_price + ceil((bit_price * msg.bits + cell_price * msg.cells)/2^16)) nanograms // msg_fwd_fees = (lump_price + ceil((bit_price * msg.bits + cell_price * msg.cells)/2^16)) nanograms
@ -365,6 +369,7 @@ struct MsgPrices {
td::uint32 first_frac; td::uint32 first_frac;
td::uint32 next_frac; td::uint32 next_frac;
td::uint64 compute_fwd_fees(td::uint64 cells, td::uint64 bits) const; td::uint64 compute_fwd_fees(td::uint64 cells, td::uint64 bits) const;
td::RefInt256 compute_fwd_fees256(td::uint64 cells, td::uint64 bits) const;
std::pair<td::uint64, td::uint64> compute_fwd_ihr_fees(td::uint64 cells, td::uint64 bits, std::pair<td::uint64, td::uint64> compute_fwd_ihr_fees(td::uint64 cells, td::uint64 bits,
bool ihr_disabled = false) const; bool ihr_disabled = false) const;
MsgPrices() = default; MsgPrices() = default;
@ -389,6 +394,7 @@ struct SizeLimitsConfig {
ExtMsgLimits ext_msg_limits; ExtMsgLimits ext_msg_limits;
td::uint32 max_acc_state_cells = 1 << 16; td::uint32 max_acc_state_cells = 1 << 16;
td::uint32 max_acc_state_bits = (1 << 16) * 1023; td::uint32 max_acc_state_bits = (1 << 16) * 1023;
td::uint32 max_acc_public_libraries = 256;
}; };
struct CatchainValidatorsConfig { struct CatchainValidatorsConfig {
@ -614,9 +620,11 @@ class Config {
bool is_special_smartcontract(const ton::StdSmcAddress& addr) const; bool is_special_smartcontract(const ton::StdSmcAddress& addr) const;
static td::Result<std::unique_ptr<ValidatorSet>> unpack_validator_set(Ref<vm::Cell> valset_root); static td::Result<std::unique_ptr<ValidatorSet>> unpack_validator_set(Ref<vm::Cell> valset_root);
td::Result<std::vector<StoragePrices>> get_storage_prices() const; td::Result<std::vector<StoragePrices>> get_storage_prices() const;
static td::Result<StoragePrices> do_get_one_storage_prices(vm::CellSlice cs);
td::Result<GasLimitsPrices> get_gas_limits_prices(bool is_masterchain = false) const; td::Result<GasLimitsPrices> get_gas_limits_prices(bool is_masterchain = false) const;
static td::Result<GasLimitsPrices> do_get_gas_limits_prices(td::Ref<vm::Cell> cell, int id); static td::Result<GasLimitsPrices> do_get_gas_limits_prices(vm::CellSlice cs, int id);
td::Result<MsgPrices> get_msg_prices(bool is_masterchain = false) const; td::Result<MsgPrices> get_msg_prices(bool is_masterchain = false) const;
static td::Result<MsgPrices> do_get_msg_prices(vm::CellSlice cs, int id);
static CatchainValidatorsConfig unpack_catchain_validators_config(Ref<vm::Cell> cell); static CatchainValidatorsConfig unpack_catchain_validators_config(Ref<vm::Cell> cell);
CatchainValidatorsConfig get_catchain_validators_config() const; CatchainValidatorsConfig get_catchain_validators_config() const;
td::Status visit_validator_params() const; td::Status visit_validator_params() const;
@ -644,8 +652,10 @@ class Config {
std::vector<ton::ValidatorDescr> compute_total_validator_set(int next) const; std::vector<ton::ValidatorDescr> compute_total_validator_set(int next) const;
CollatorConfig get_collator_config(bool need_collator_nodes) const; CollatorConfig get_collator_config(bool need_collator_nodes) const;
td::Result<SizeLimitsConfig> get_size_limits_config() const; td::Result<SizeLimitsConfig> get_size_limits_config() const;
static td::Result<SizeLimitsConfig> do_get_size_limits_config(td::Ref<vm::CellSlice> cs);
std::unique_ptr<vm::Dictionary> get_suspended_addresses(ton::UnixTime now) const; std::unique_ptr<vm::Dictionary> get_suspended_addresses(ton::UnixTime now) const;
BurningConfig get_burning_config() const; BurningConfig get_burning_config() const;
td::Ref<vm::Tuple> get_unpacked_config_tuple(ton::UnixTime now) const;
static std::vector<ton::ValidatorDescr> do_compute_validator_set(const block::CatchainValidatorsConfig& ccv_conf, static std::vector<ton::ValidatorDescr> do_compute_validator_set(const block::CatchainValidatorsConfig& ccv_conf,
ton::ShardIdFull shard, ton::ShardIdFull shard,
const block::ValidatorSet& vset, ton::UnixTime time, const block::ValidatorSet& vset, ton::UnixTime time,

File diff suppressed because it is too large Load diff

View file

@ -104,6 +104,8 @@ struct ComputePhaseConfig {
td::uint64 gas_credit; td::uint64 gas_credit;
td::uint64 flat_gas_limit = 0; td::uint64 flat_gas_limit = 0;
td::uint64 flat_gas_price = 0; td::uint64 flat_gas_price = 0;
bool special_gas_full = false;
block::GasLimitsPrices mc_gas_prices;
static constexpr td::uint64 gas_infty = (1ULL << 63) - 1; static constexpr td::uint64 gas_infty = (1ULL << 63) - 1;
td::RefInt256 gas_price256; td::RefInt256 gas_price256;
td::RefInt256 max_gas_threshold; td::RefInt256 max_gas_threshold;
@ -115,15 +117,13 @@ struct ComputePhaseConfig {
td::uint16 max_vm_data_depth = 512; td::uint16 max_vm_data_depth = 512;
int global_version = 0; int global_version = 0;
Ref<vm::Tuple> prev_blocks_info; Ref<vm::Tuple> prev_blocks_info;
Ref<vm::Tuple> unpacked_config_tuple;
std::unique_ptr<vm::Dictionary> suspended_addresses; std::unique_ptr<vm::Dictionary> suspended_addresses;
SizeLimitsConfig size_limits;
int vm_log_verbosity = 0; int vm_log_verbosity = 0;
bool stop_on_accept_message = false;
ComputePhaseConfig(td::uint64 _gas_price = 0, td::uint64 _gas_limit = 0, td::uint64 _gas_credit = 0) ComputePhaseConfig() : gas_price(0), gas_limit(0), special_gas_limit(0), gas_credit(0) {
: gas_price(_gas_price), gas_limit(_gas_limit), special_gas_limit(_gas_limit), gas_credit(_gas_credit) {
compute_threshold();
}
ComputePhaseConfig(td::uint64 _gas_price, td::uint64 _gas_limit, td::uint64 _spec_gas_limit, td::uint64 _gas_credit)
: gas_price(_gas_price), gas_limit(_gas_limit), special_gas_limit(_spec_gas_limit), gas_credit(_gas_credit) {
compute_threshold(); compute_threshold();
} }
void compute_threshold(); void compute_threshold();
@ -270,7 +270,7 @@ struct Account {
return balance; return balance;
} }
bool set_address(ton::WorkchainId wc, td::ConstBitPtr new_addr); 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 init_new(ton::UnixTime now);
bool deactivate(); bool deactivate();
bool recompute_tmp_addr(Ref<vm::CellSlice>& tmp_addr, int split_depth, td::ConstBitPtr orig_addr_rewrite) const; bool recompute_tmp_addr(Ref<vm::CellSlice>& tmp_addr, int split_depth, td::ConstBitPtr orig_addr_rewrite) const;
@ -361,18 +361,20 @@ struct Transaction {
std::unique_ptr<ActionPhase> action_phase; std::unique_ptr<ActionPhase> action_phase;
std::unique_ptr<BouncePhase> bounce_phase; std::unique_ptr<BouncePhase> bounce_phase;
vm::CellStorageStat new_storage_stat; vm::CellStorageStat new_storage_stat;
bool gas_limit_overridden{false};
Transaction(const Account& _account, int ttype, ton::LogicalTime req_start_lt, ton::UnixTime _now, Transaction(const Account& _account, int ttype, ton::LogicalTime req_start_lt, ton::UnixTime _now,
Ref<vm::Cell> _inmsg = {}); Ref<vm::Cell> _inmsg = {});
bool unpack_input_msg(bool ihr_delivered, const ActionPhaseConfig* cfg); bool unpack_input_msg(bool ihr_delivered, const ActionPhaseConfig* cfg);
bool check_in_msg_state_hash(); bool check_in_msg_state_hash();
bool prepare_storage_phase(const StoragePhaseConfig& cfg, bool force_collect = true, bool adjust_msg_value = false); bool prepare_storage_phase(const StoragePhaseConfig& cfg, bool force_collect = true, bool adjust_msg_value = false);
bool prepare_credit_phase(); bool prepare_credit_phase();
td::uint64 gas_bought_for(const ComputePhaseConfig& cfg, td::RefInt256 nanograms);
bool compute_gas_limits(ComputePhase& cp, const ComputePhaseConfig& cfg); bool compute_gas_limits(ComputePhase& cp, const ComputePhaseConfig& cfg);
Ref<vm::Stack> prepare_vm_stack(ComputePhase& cp); Ref<vm::Stack> prepare_vm_stack(ComputePhase& cp);
std::vector<Ref<vm::Cell>> compute_vm_libraries(const ComputePhaseConfig& cfg); std::vector<Ref<vm::Cell>> compute_vm_libraries(const ComputePhaseConfig& cfg);
bool prepare_compute_phase(const ComputePhaseConfig& cfg); bool prepare_compute_phase(const ComputePhaseConfig& cfg);
bool prepare_action_phase(const ActionPhaseConfig& 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 prepare_bounce_phase(const ActionPhaseConfig& cfg);
bool compute_state(); bool compute_state();
bool serialize(); bool serialize();
@ -382,9 +384,7 @@ struct Transaction {
td::Result<vm::NewCellStorageStat::Stat> estimate_block_storage_profile_incr( td::Result<vm::NewCellStorageStat::Stat> estimate_block_storage_profile_incr(
const vm::NewCellStorageStat& store_stat, const vm::CellUsageTree* usage_tree) const; 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 update_limits(block::BlockLimitStatus& blk_lim_st, bool with_gas = true, bool with_size = true) 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 Ref<vm::Cell> commit(Account& _account); // _account should point to the same account
LtCellRef extract_out_msg(unsigned i); LtCellRef extract_out_msg(unsigned i);
@ -406,7 +406,7 @@ struct Transaction {
bool serialize_compute_phase(vm::CellBuilder& cb); bool serialize_compute_phase(vm::CellBuilder& cb);
bool serialize_action_phase(vm::CellBuilder& cb); bool serialize_action_phase(vm::CellBuilder& cb);
bool serialize_bounce_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 } // 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; from_offs &= 7;
to_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); //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; bit_count += from_offs;
if (from_offs == to_offs) { if (from_offs == to_offs) {
if (bit_count < 8) { 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 += (to_offs >> 3);
to_offs &= 7; to_offs &= 7;
int sz = (int)bit_count; int sz = static_cast<int>(bit_count);
bit_count += to_offs; bit_count += to_offs;
int c = *to; int c = *to;
if (bit_count <= 8) { if (bit_count <= 8) {

View file

@ -2,7 +2,7 @@ library TVM_Asm
// simple TVM Assembler // simple TVM Assembler
namespace Asm namespace Asm
Asm definitions Asm definitions
"0.4.4" constant asm-fif-version "0.4.5" constant asm-fif-version
variable @atend variable @atend
variable @was-split variable @was-split
@ -461,19 +461,109 @@ x{B7A3} @Defop QNEGATE
x{B7A4} @Defop QINC x{B7A4} @Defop QINC
x{B7A5} @Defop QDEC x{B7A5} @Defop QDEC
x{B7A8} @Defop QMUL x{B7A8} @Defop QMUL
x{B7A904} @Defop QDIV x{B7A904} @Defop QDIV
x{B7A905} @Defop QDIVR x{B7A905} @Defop QDIVR
x{B7A906} @Defop QDIVC x{B7A906} @Defop QDIVC
x{B7A908} @Defop QMOD x{B7A908} @Defop QMOD
x{B7A909} @Defop QMODR
x{B7A90A} @Defop QMODC
x{B7A90C} @Defop QDIVMOD x{B7A90C} @Defop QDIVMOD
x{B7A90D} @Defop QDIVMODR x{B7A90D} @Defop QDIVMODR
x{B7A90E} @Defop QDIVMODC x{B7A90E} @Defop QDIVMODC
x{B7A900} @Defop QADDDIVMOD x{B7A900} @Defop QADDDIVMOD
x{B7A901} @Defop QADDDIVMODR x{B7A901} @Defop QADDDIVMODR
x{B7A902} @Defop QADDDIVMODC 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{B7A985} @Defop QMULDIVR
x{B7A986} @Defop QMULDIVC
x{B7A988} @Defop QMULMOD
x{B7A989} @Defop QMULMODR
x{B7A98A} @Defop QMULMODC
x{B7A98C} @Defop QMULDIVMOD 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{B7AC} @Defop QLSHIFT
x{B7AD} @Defop QRSHIFT x{B7AD} @Defop QRSHIFT
x{B7AE} @Defop QPOW2 x{B7AE} @Defop QPOW2
@ -723,6 +813,12 @@ x{D761} @Defop LDONES
x{D762} @Defop LDSAME x{D762} @Defop LDSAME
x{D764} @Defop SDEPTH x{D764} @Defop SDEPTH
x{D765} @Defop CDEPTH x{D765} @Defop CDEPTH
x{D766} @Defop CLEVEL
x{D767} @Defop CLEVELMASK
{ <b x{D76A_} s, swap 2 u, @addopb } : CHASHI
{ <b x{D76E_} s, swap 2 u, @addopb } : CDEPTHI
x{D770} @Defop CHASHIX
x{D771} @Defop CDEPTHIX
// //
// continuation / flow control primitives // continuation / flow control primitives
x{D8} dup @Defop EXECUTE @Defop CALLX x{D8} dup @Defop EXECUTE @Defop CALLX
@ -1185,7 +1281,7 @@ x{F4BF} @Defop DICTUGETEXECZ
x{F800} @Defop ACCEPT x{F800} @Defop ACCEPT
x{F801} @Defop SETGASLIMIT x{F801} @Defop SETGASLIMIT
x{F802} @Defop GASCONSUMED x{F807} @Defop GASCONSUMED
x{F80F} @Defop COMMIT x{F80F} @Defop COMMIT
x{F810} @Defop RANDU256 x{F810} @Defop RANDU256
@ -1205,12 +1301,21 @@ x{F82A} @Defop MYCODE
x{F82B} @Defop INCOMINGVALUE x{F82B} @Defop INCOMINGVALUE
x{F82C} @Defop STORAGEFEES x{F82C} @Defop STORAGEFEES
x{F82D} @Defop PREVBLOCKSINFOTUPLE x{F82D} @Defop PREVBLOCKSINFOTUPLE
x{F82E} @Defop UNPACKEDCONFIGTUPLE
x{F82F} @Defop DUEPAYMENT
x{F830} @Defop CONFIGDICT x{F830} @Defop CONFIGDICT
x{F832} @Defop CONFIGPARAM x{F832} @Defop CONFIGPARAM
x{F833} @Defop CONFIGOPTPARAM x{F833} @Defop CONFIGOPTPARAM
x{F83400} @Defop PREVMCBLOCKS x{F83400} @Defop PREVMCBLOCKS
x{F83401} @Defop PREVKEYBLOCK x{F83401} @Defop PREVKEYBLOCK
x{F835} @Defop GLOBALID x{F835} @Defop GLOBALID
x{F836} @Defop GETGASFEE
x{F837} @Defop GETSTORAGEFEE
x{F838} @Defop GETFORWARDFEE
x{F839} @Defop GETPRECOMPILEDGAS
x{F83A} @Defop GETORIGINALFWDFEE
x{F83B} @Defop GETGASFEESIMPLE
x{F83C} @Defop GETFORWARDFEESIMPLE
x{F840} @Defop GETGLOBVAR x{F840} @Defop GETGLOBVAR
{ dup 1 31 @rangechk <b x{F85_} s, swap 5 u, @addopb } : GETGLOB { dup 1 31 @rangechk <b x{F85_} s, swap 5 u, @addopb } : GETGLOB

View file

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

View file

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

View file

@ -232,6 +232,7 @@ Bignum& Bignum::import_lsb(const unsigned char* buffer, std::size_t size) {
std::string Bignum::to_str() const { std::string Bignum::to_str() const {
char* ptr = BN_bn2dec(val); char* ptr = BN_bn2dec(val);
CHECK(ptr);
std::string z(ptr); std::string z(ptr);
OPENSSL_free(ptr); OPENSSL_free(ptr);
return z; return z;
@ -239,6 +240,7 @@ std::string Bignum::to_str() const {
std::string Bignum::to_hex() const { std::string Bignum::to_hex() const {
char* ptr = BN_bn2hex(val); char* ptr = BN_bn2hex(val);
CHECK(ptr);
std::string z(ptr); std::string z(ptr);
OPENSSL_free(ptr); OPENSSL_free(ptr);
return z; return z;
@ -255,7 +257,13 @@ std::istream& operator>>(std::istream& is, Bignum& x) {
return is; return is;
} }
bool is_prime(const Bignum& p, int nchecks, bool trial_div) { bool is_prime(const Bignum& p) {
return BN_is_prime_fasttest_ex(p.bn_ptr(), BN_prime_checks, get_ctx(), trial_div, 0); #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 } // namespace arith

View file

@ -335,7 +335,7 @@ const Bignum sqr(const Bignum& x);
std::ostream& operator<<(std::ostream& os, const Bignum& x); std::ostream& operator<<(std::ostream& os, const Bignum& x);
std::istream& operator>>(std::istream& is, 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) { inline int cmp(const Bignum& x, const Bignum& y) {
return BN_cmp(x.bn_ptr(), y.bn_ptr()); 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())) { if (is_multiline_quote(src.get_ptr(), src.get_end_ptr())) {
src.advance(multiline_quote.size()); src.advance(multiline_quote.size());
const char* begin = src.get_ptr();
const char* end = nullptr; const char* end = nullptr;
SrcLocation here = src.here(); SrcLocation here = src.here();
std::string body; std::string body;

View file

@ -3,6 +3,22 @@
;; this version does not use seqno for replay protection; instead, it remembers all recent query_ids ;; this version does not use seqno for replay protection; instead, it remembers all recent query_ids
;; in this way several external messages with different query_id can be sent in parallel ;; in this way several external messages with different query_id can be sent in parallel
;; Note, when dealing with highload-wallet the following limits need to be checked and taken into account:
;; 1) Storage size limit. Currently, size of contract storage should be less than 65535 cells. If size of
;; old_queries will grow above this limit, exception in ActionPhase will be thrown and transaction will fail.
;; Failed transaction may be replayed.
;; 2) Gas limit. Currently, gas limit is 1'000'000 gas units, that means that there is a limit of how much
;; old queries may be cleaned in one tx. If number of expired queries will be higher, contract will stuck.
;; That means that it is not recommended to set too high expiration date:
;; number of queries during expiration timespan should not exceed 1000.
;; Also, number of expired queries cleaned in one transaction should be below 100.
;; Such precautions are not easy to follow, so it is recommended to use highload contract
;; only when strictly necessary and the developer understands the above details.
() recv_internal(slice in_msg) impure { () recv_internal(slice in_msg) impure {
;; do nothing for internal messages ;; do nothing for internal messages
} }

View file

@ -155,7 +155,7 @@ td::Result<td::uint32> GenericAccount::get_wallet_id(const SmartContract& sc) {
return TRY_VM([&]() -> td::Result<td::uint32> { return TRY_VM([&]() -> td::Result<td::uint32> {
auto answer = sc.run_get_method("wallet_id"); auto answer = sc.run_get_method("wallet_id");
if (!answer.success) { 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())); 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) { if (!info.known_category.insert(action.category).second) {
continue; continue;
} }
if (action.category == 0) { if (action.category.is_zero()) {
info.closed = true; info.closed = true;
auto old_actions = std::move(info.actions); auto old_actions = std::move(info.actions);
bool is_empty = true; bool is_empty = true;
@ -327,7 +327,7 @@ class ManualDns : public ton::SmartContract, public DnsInterface {
if (info.closed) { if (info.closed) {
CombinedActions<ActionT> ca; CombinedActions<ActionT> ca;
ca.name = it.first; ca.name = it.first;
ca.category = 0; ca.category = td::Bits256::zero();
if (!info.actions.empty() || info.non_empty) { if (!info.actions.empty() || info.non_empty) {
ca.actions = std::move(info.actions); ca.actions = std::move(info.actions);
} }

View file

@ -171,6 +171,10 @@ td::Ref<vm::Tuple> prepare_vm_c7(SmartContract::Args args, td::Ref<vm::Cell> cod
// prev_key_block:BlockId ] : PrevBlocksInfo // prev_key_block:BlockId ] : PrevBlocksInfo
tuple.push_back(args.prev_blocks_info ? args.prev_blocks_info.value() : vm::StackEntry{}); // prev_block_info tuple.push_back(args.prev_blocks_info ? args.prev_blocks_info.value() : vm::StackEntry{}); // prev_block_info
} }
if (args.config && args.config.value()->get_global_version() >= 6) {
tuple.push_back(args.config.value()->get_unpacked_config_tuple(now)); // unpacked_config_tuple
tuple.push_back(td::zero_refint()); // due_payment
}
auto tuple_ref = td::make_cnt_ref<std::vector<vm::StackEntry>>(std::move(tuple)); auto tuple_ref = td::make_cnt_ref<std::vector<vm::StackEntry>>(std::move(tuple));
//LOG(DEBUG) << "SmartContractInfo initialized with " << vm::StackEntry(tuple).to_string(); //LOG(DEBUG) << "SmartContractInfo initialized with " << vm::StackEntry(tuple).to_string();
return vm::make_tuple_ref(std::move(tuple_ref)); return vm::make_tuple_ref(std::move(tuple_ref));
@ -181,7 +185,7 @@ SmartContract::Answer run_smartcont(SmartContract::State state, td::Ref<vm::Stac
int vm_log_verbosity, bool debug_enabled, int vm_log_verbosity, bool debug_enabled,
std::shared_ptr<const block::Config> config) { std::shared_ptr<const block::Config> config) {
auto gas_credit = gas.gas_credit; auto gas_credit = gas.gas_credit;
vm::init_op_cp0(debug_enabled); vm::init_vm(debug_enabled).ensure();
vm::DictionaryBase::get_empty_dictionary(); vm::DictionaryBase::get_empty_dictionary();
class Logger : public td::LogInterface { class Logger : public td::LogInterface {

View file

@ -28,6 +28,7 @@ namespace {
// WALLET_REVISION = 2; // WALLET_REVISION = 2;
// WALLET2_REVISION = 2; // WALLET2_REVISION = 2;
// WALLET3_REVISION = 2; // WALLET3_REVISION = 2;
// WALLET4_REVISION = 2;
// HIGHLOAD_WALLET_REVISION = 2; // HIGHLOAD_WALLET_REVISION = 2;
// HIGHLOAD_WALLET2_REVISION = 2; // HIGHLOAD_WALLET2_REVISION = 2;
// DNS_REVISION = 1; // DNS_REVISION = 1;
@ -92,6 +93,20 @@ const auto& get_map() {
"AAXrc52omhpn5jrhf/AABesePaiaGmPmOuFj8ABDbbYHwR7Z5AOAQm1B1tnkA4BTu1E0IEBQNch0x/" "AAXrc52omhpn5jrhf/AABesePaiaGmPmOuFj8ABDbbYHwR7Z5AOAQm1B1tnkA4BTu1E0IEBQNch0x/"
"0BNEC2zz4J28QAoAg9HtvpTGX+gAwoXC2CZEw4g8AOiGOETGA8/gzIG6SMHCU0NcLH+IB3yGSAaGSW3/iAAzTB9QC+wAAHssfFMsfEsv/yx/" "0BNEC2zz4J28QAoAg9HtvpTGX+gAwoXC2CZEw4g8AOiGOETGA8/gzIG6SMHCU0NcLH+IB3yGSAaGSW3/iAAzTB9QC+wAAHssfFMsfEsv/yx/"
"0AMntVA=="); "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;
}(); }();
return map; return map;
@ -137,9 +152,12 @@ td::Span<int> SmartContractCode::get_revisions(Type type) {
static int res[] = {1}; static int res[] = {1};
return res; return res;
} }
case Type::WalletV4: {
static int res[] = {2};
return res;
}
} }
UNREACHABLE(); UNREACHABLE();
return {};
} }
td::Result<int> SmartContractCode::validate_revision(Type type, int revision) { 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"; return "payment-channel";
case Type::RestrictedWallet: case Type::RestrictedWallet:
return "restricted-wallet3"; return "restricted-wallet3";
case Type::WalletV4:
return "wallet-v4";
} }
UNREACHABLE(); UNREACHABLE();
return "";
}(type); }(type);
if (revision == -1) { if (revision == -1) {
return load(basename).move_as_ok(); return load(basename).move_as_ok();

View file

@ -26,7 +26,16 @@ class SmartContractCode {
public: public:
static td::Result<td::Ref<vm::Cell>> load(td::Slice name); 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::Span<int> get_revisions(Type type);
static td::Result<int> validate_revision(Type type, int revision); static td::Result<int> validate_revision(Type type, int revision);
static td::Ref<vm::Cell> get_code(Type type, int revision = 0); static td::Ref<vm::Cell> get_code(Type type, int revision = 0);

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(); 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)); auto res = fift::mem_run_fift(load_test(name));
if (expect_error) { if (expect_error) {
res.ensure_error(); res.ensure_error();
@ -163,3 +163,7 @@ TEST(Fift, test_bls) {
TEST(Fift, test_bls_ops) { TEST(Fift, test_bls_ops) {
run_fift("bls_ops.fif"); run_fift("bls_ops.fif");
} }
TEST(Fift, test_levels) {
run_fift("levels.fif");
}

View file

@ -0,0 +1,75 @@
"Asm.fif" include
"FiftExt.fif" include
{
dup
."Cell " .dump cr
dup [[ <{ CLEVEL }>s ]] 0 runvmx abort"exitcode != 0" ."Level = " . cr
dup [[ <{ CLEVELMASK }>s ]] 0 runvmx abort"exitcode != 0" ."Level mask = 0b" b. cr
dup dup [[ <{ 0 CHASHI DUP ROT 0 INT CHASHIX EQUAL 55 THROWIFNOT }>s ]] 0 runvmx abort"exitcode != 0" ."Hash_0 = " X. cr
dup dup [[ <{ 1 CHASHI DUP ROT 1 INT CHASHIX EQUAL 55 THROWIFNOT }>s ]] 0 runvmx abort"exitcode != 0" ."Hash_1 = " X. cr
dup dup [[ <{ 2 CHASHI DUP ROT 2 INT CHASHIX EQUAL 55 THROWIFNOT }>s ]] 0 runvmx abort"exitcode != 0" ."Hash_2 = " X. cr
dup dup [[ <{ 3 CHASHI DUP ROT 3 INT CHASHIX EQUAL 55 THROWIFNOT }>s ]] 0 runvmx abort"exitcode != 0" ."Hash_3 = " X. cr
dup dup [[ <{ 0 CDEPTHI DUP ROT 0 INT CDEPTHIX EQUAL 55 THROWIFNOT }>s ]] 0 runvmx abort"exitcode != 0" ."Depth_0 = " . cr
dup dup [[ <{ 1 CDEPTHI DUP ROT 1 INT CDEPTHIX EQUAL 55 THROWIFNOT }>s ]] 0 runvmx abort"exitcode != 0" ."Depth_1 = " . cr
dup dup [[ <{ 2 CDEPTHI DUP ROT 2 INT CDEPTHIX EQUAL 55 THROWIFNOT }>s ]] 0 runvmx abort"exitcode != 0" ."Depth_2 = " . cr
dup dup [[ <{ 3 CDEPTHI DUP ROT 3 INT CDEPTHIX EQUAL 55 THROWIFNOT }>s ]] 0 runvmx abort"exitcode != 0" ."Depth_3 = " . cr
drop
cr
} : print-all
// Ordinary cell of level 0
<b
123 32 u,
<b <b 22 32 u, b> ref, b> ref,
<b b> ref,
b>
print-all
// Prunned branch of level 1
<b
1 8 u,
1 8 u,
0xabcd1111abcd1111abcd1111abcd1111abcd1111abcd1111abcd1111abcd1111 256 u,
14 16 u,
b>spec
print-all
// Prunned branch of level 3
<b
1 8 u,
7 8 u,
0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 256 u,
0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 256 u,
0xcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 256 u,
55 16 u,
44 16 u,
33 16 u,
b>spec
print-all
// Prunned branch of level 3, mask 0b101
<b
1 8 u,
5 8 u,
0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 256 u,
0xcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 256 u,
55 16 u,
33 16 u,
b>spec
print-all
// Tree with the previous cell inside
<b
<b
<b
1 8 u,
5 8 u,
0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 256 u,
0xcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 256 u,
55 16 u,
33 16 u,
b>spec ref,
b> ref,
b>
print-all

View file

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

View file

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

View file

@ -16,12 +16,12 @@
*/ */
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <array> #include <array>
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <random> #include <random>
#include <getopt.h>
#include "common/refcnt.hpp" #include "common/refcnt.hpp"
#include "common/bigint.hpp" #include "common/bigint.hpp"
#include "common/refint.h" #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) // 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) { 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) { 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) { if (is_small) {
// special check for small (64-bit) values // special check for small (64-bit) values
CHECK(x->to_long() == xval); 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(in_range);
// check sign // check sign
CHECK(x->sgn() == (xval > 0 ? 1 : (xval < 0 ? -1 : 0))); 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 { void run(int n) override {
int res = 0; int res = 0;
SHA256_CTX ctx; td::Sha256State ctx;
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
SHA256_Init(&ctx); ctx.init();
SHA256_Update(&ctx, "abcd", 4); ctx.feed("abcd");
unsigned char buf[32]; unsigned char buf[32];
SHA256_Final(buf, &ctx); ctx.extract(td::MutableSlice{buf, 32});
res += buf[0]; res += buf[0];
} }
td::do_not_optimize_away(res); td::do_not_optimize_away(res);

View file

@ -35,6 +35,7 @@
#include "smc-envelope/SmartContract.h" #include "smc-envelope/SmartContract.h"
#include "smc-envelope/SmartContractCode.h" #include "smc-envelope/SmartContractCode.h"
#include "smc-envelope/WalletV3.h" #include "smc-envelope/WalletV3.h"
#include "smc-envelope/WalletV4.h"
#include "smc-envelope/HighloadWallet.h" #include "smc-envelope/HighloadWallet.h"
#include "smc-envelope/HighloadWalletV2.h" #include "smc-envelope/HighloadWalletV2.h"
#include "smc-envelope/PaymentChannel.h" #include "smc-envelope/PaymentChannel.h"
@ -488,7 +489,7 @@ void do_test_wallet(int revision) {
auto address = std::move(res.address); auto address = std::move(res.address);
auto iwallet = std::move(res.wallet); auto iwallet = std::move(res.wallet);
auto public_key = priv_key.get_public_key().move_as_ok().as_octet_string(); auto public_key = priv_key.get_public_key().move_as_ok().as_octet_string();
;
check_wallet_state(iwallet, 1, 123, public_key); check_wallet_state(iwallet, 1, 123, public_key);
// lets send a lot of messages // lets send a lot of messages
@ -526,6 +527,7 @@ void do_test_wallet() {
TEST(Tonlib, Wallet) { TEST(Tonlib, Wallet) {
do_test_wallet<ton::WalletV3>(); do_test_wallet<ton::WalletV3>();
do_test_wallet<ton::WalletV4>();
do_test_wallet<ton::HighloadWallet>(); do_test_wallet<ton::HighloadWallet>();
do_test_wallet<ton::HighloadWalletV2>(); do_test_wallet<ton::HighloadWalletV2>();
do_test_wallet<ton::RestrictedWallet>(); do_test_wallet<ton::RestrictedWallet>();
@ -956,7 +958,7 @@ class MapDns {
} }
return; return;
} }
if (!actions.category.is_zero()) { if (actions.category.is_zero()) {
entries_.erase(actions.name); entries_.erase(actions.name);
LOG(ERROR) << "CLEAR " << actions.name; LOG(ERROR) << "CLEAR " << actions.name;
if (!actions.actions) { if (!actions.actions) {
@ -1001,7 +1003,7 @@ class CheckedDns {
explicit CheckedDns(bool check_smc = true, bool check_combine = true) { explicit CheckedDns(bool check_smc = true, bool check_combine = true) {
if (check_smc) { if (check_smc) {
key_ = td::Ed25519::generate_private_key().move_as_ok(); 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) { if (check_combine) {
combined_map_dns_ = MapDns(); combined_map_dns_ = MapDns();
@ -1024,7 +1026,7 @@ class CheckedDns {
} }
return action; return action;
}); });
auto query = dns_->create_update_query(key_.value(), smc_actions).move_as_ok(); auto query = dns_->create_update_query(key_.value(), smc_actions, query_id_++).move_as_ok();
CHECK(dns_.write().send_external_message(std::move(query)).code == 0); CHECK(dns_.write().send_external_message(std::move(query)).code == 0);
} }
map_dns_.update(entries); map_dns_.update(entries);
@ -1079,6 +1081,7 @@ class CheckedDns {
using ManualDns = ton::ManualDns; using ManualDns = ton::ManualDns;
td::optional<td::Ed25519::PrivateKey> key_; td::optional<td::Ed25519::PrivateKey> key_;
td::Ref<ManualDns> dns_; td::Ref<ManualDns> dns_;
td::uint32 query_id_ = 1; // Query id serve as "valid until", but in tests now() == 0
MapDns map_dns_; MapDns map_dns_;
td::optional<MapDns> combined_map_dns_; td::optional<MapDns> combined_map_dns_;
@ -1092,9 +1095,10 @@ class CheckedDns {
} }
}; };
static td::Bits256 intToCat(int x) { static td::Bits256 intToCat(td::uint32 x) {
td::Bits256 cat = td::Bits256::zero(); auto y = td::make_refint(x);
cat.as_slice().copy_from(td::Slice((char*)&x, sizeof(x))); td::Bits256 cat;
y->export_bytes(cat.data(), 32, false);
return cat; return cat;
} }
@ -1180,7 +1184,7 @@ TEST(Smartcont, DnsManual) {
auto key = td::Ed25519::generate_private_key().move_as_ok(); 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); CHECK(manual->get_wallet_id().move_as_ok() == 123);
auto init_query = manual->create_init_query(key).move_as_ok(); auto init_query = manual->create_init_query(key).move_as_ok();
LOG(ERROR) << "A"; LOG(ERROR) << "A";

View file

@ -28,7 +28,7 @@
#include "td/utils/StringBuilder.h" #include "td/utils/StringBuilder.h"
std::string run_vm(td::Ref<vm::Cell> cell) { std::string run_vm(td::Ref<vm::Cell> cell) {
vm::init_op_cp0(); vm::init_vm().ensure();
vm::DictionaryBase::get_empty_dictionary(); vm::DictionaryBase::get_empty_dictionary();
class Logger : public td::LogInterface { 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) { if (!cnt) {
os << '_'; os << '_';
prev_skip = true;
} }
if (count) { if (count) {
os << count; os << count;

View file

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

View file

@ -930,7 +930,7 @@ unsigned long long BagOfCells::get_idx_entry_raw(int index) {
* *
*/ */
td::Result<Ref<Cell>> std_boc_deserialize(td::Slice data, bool can_be_empty) { td::Result<Ref<Cell>> std_boc_deserialize(td::Slice data, bool can_be_empty, bool allow_nonzero_level) {
if (data.empty() && can_be_empty) { if (data.empty() && can_be_empty) {
return Ref<Cell>(); return Ref<Cell>();
} }
@ -946,7 +946,7 @@ td::Result<Ref<Cell>> std_boc_deserialize(td::Slice data, bool can_be_empty) {
if (root.is_null()) { if (root.is_null()) {
return td::Status::Error("bag of cells has null root cell (?)"); return td::Status::Error("bag of cells has null root cell (?)");
} }
if (root->get_level() != 0) { if (!allow_nonzero_level && root->get_level() != 0) {
return td::Status::Error("bag of cells has a root with non-zero level"); return td::Status::Error("bag of cells has a root with non-zero level");
} }
return std::move(root); return std::move(root);

View file

@ -53,6 +53,7 @@ class NewCellStorageStat {
bool operator==(const Stat& other) const { bool operator==(const Stat& other) const {
return key() == other.key(); return key() == other.key();
} }
Stat(const Stat& other) = default;
Stat& operator=(const Stat& other) = default; Stat& operator=(const Stat& other) = default;
Stat& operator+=(const Stat& other) { Stat& operator+=(const Stat& other) {
cells += other.cells; cells += other.cells;
@ -336,7 +337,7 @@ class BagOfCells {
std::vector<td::uint8>* cell_should_cache); std::vector<td::uint8>* cell_should_cache);
}; };
td::Result<Ref<Cell>> std_boc_deserialize(td::Slice data, bool can_be_empty = false); td::Result<Ref<Cell>> std_boc_deserialize(td::Slice data, bool can_be_empty = false, bool allow_nonzero_level = false);
td::Result<td::BufferSlice> std_boc_serialize(Ref<Cell> root, int mode = 0); td::Result<td::BufferSlice> std_boc_serialize(Ref<Cell> root, int mode = 0);
td::Result<std::vector<Ref<Cell>>> std_boc_deserialize_multi(td::Slice data, td::Result<std::vector<Ref<Cell>>> std_boc_deserialize_multi(td::Slice data,

View file

@ -892,6 +892,40 @@ int exec_load_special_cell(VmState* st, bool quiet) {
Stack& stack = st->get_stack(); Stack& stack = st->get_stack();
VM_LOG(st) << "execute XLOAD" << (quiet ? "Q" : ""); VM_LOG(st) << "execute XLOAD" << (quiet ? "Q" : "");
auto cell = stack.pop_cell(); auto cell = stack.pop_cell();
if (st->get_global_version() >= 5) {
st->register_cell_load(cell->get_hash());
auto r_loaded_cell = cell->load_cell();
if (r_loaded_cell.is_error()) {
if (quiet) {
stack.push_bool(false);
return 0;
} else {
throw VmError{Excno::cell_und, "failed to load cell"};
}
}
auto loaded_cell = r_loaded_cell.move_as_ok();
if (loaded_cell.data_cell->is_special()) {
if (loaded_cell.data_cell->special_type() != CellTraits::SpecialType::Library) {
if (quiet) {
stack.push_bool(false);
return 0;
} else {
throw VmError{Excno::cell_und, "unexpected special cell"};
}
}
CellSlice cs(std::move(loaded_cell));
DCHECK(cs.size() == Cell::hash_bits + 8);
cell = st->load_library(cs.data_bits() + 8);
if (cell.is_null()) {
if (quiet) {
stack.push_bool(false);
return 0;
} else {
throw VmError{Excno::cell_und, "failed to load library cell"};
}
}
}
}
stack.push_cell(cell); stack.push_cell(cell);
if (quiet) { if (quiet) {
stack.push_bool(true); stack.push_bool(true);
@ -1357,6 +1391,55 @@ int exec_slice_depth(VmState* st) {
return 0; return 0;
} }
int exec_cell_level(VmState* st) {
Stack& stack = st->get_stack();
VM_LOG(st) << "execute CLEVEL";
auto cell = stack.pop_cell();
stack.push_smallint(cell->get_level());
return 0;
}
int exec_cell_level_mask(VmState* st) {
Stack& stack = st->get_stack();
VM_LOG(st) << "execute CLEVELMASK";
auto cell = stack.pop_cell();
stack.push_smallint(cell->get_level_mask().get_mask());
return 0;
}
int exec_cell_hash_i(VmState* st, unsigned args, bool var) {
unsigned i;
Stack& stack = st->get_stack();
if (var) {
VM_LOG(st) << "execute CHASHIX";
i = stack.pop_smallint_range(3);
} else {
i = args & 3;
VM_LOG(st) << "execute CHASHI " << i;
}
auto cell = stack.pop_cell();
std::array<unsigned char, 32> hash = cell->get_hash(i).as_array();
td::RefInt256 res{true};
CHECK(res.write().import_bytes(hash.data(), hash.size(), false));
stack.push_int(std::move(res));
return 0;
}
int exec_cell_depth_i(VmState* st, unsigned args, bool var) {
unsigned i;
Stack& stack = st->get_stack();
if (var) {
VM_LOG(st) << "execute CDEPTHIX";
i = stack.pop_smallint_range(3);
} else {
i = args & 3;
VM_LOG(st) << "execute CDEPTHI " << i;
}
auto cell = stack.pop_cell();
stack.push_smallint(cell->get_depth(i));
return 0;
}
void register_cell_deserialize_ops(OpcodeTable& cp0) { void register_cell_deserialize_ops(OpcodeTable& cp0) {
using namespace std::placeholders; using namespace std::placeholders;
cp0.insert(OpcodeInstr::mksimple(0xd0, 8, "CTOS", exec_cell_to_slice)) cp0.insert(OpcodeInstr::mksimple(0xd0, 8, "CTOS", exec_cell_to_slice))
@ -1445,7 +1528,13 @@ void register_cell_deserialize_ops(OpcodeTable& cp0) {
.insert(OpcodeInstr::mksimple(0xd761, 16, "LDONES", std::bind(exec_load_same, _1, "LDONES", 1))) .insert(OpcodeInstr::mksimple(0xd761, 16, "LDONES", std::bind(exec_load_same, _1, "LDONES", 1)))
.insert(OpcodeInstr::mksimple(0xd762, 16, "LDSAME", std::bind(exec_load_same, _1, "LDSAME", -1))) .insert(OpcodeInstr::mksimple(0xd762, 16, "LDSAME", std::bind(exec_load_same, _1, "LDSAME", -1)))
.insert(OpcodeInstr::mksimple(0xd764, 16, "SDEPTH", exec_slice_depth)) .insert(OpcodeInstr::mksimple(0xd764, 16, "SDEPTH", exec_slice_depth))
.insert(OpcodeInstr::mksimple(0xd765, 16, "CDEPTH", exec_cell_depth)); .insert(OpcodeInstr::mksimple(0xd765, 16, "CDEPTH", exec_cell_depth))
.insert(OpcodeInstr::mksimple(0xd766, 16, "CLEVEL", exec_cell_level)->require_version(6))
.insert(OpcodeInstr::mksimple(0xd767, 16, "CLEVELMASK", exec_cell_level_mask)->require_version(6))
.insert(OpcodeInstr::mkfixed(0xd768 >> 2, 14, 2, instr::dump_1c_and(3, "CHASHI "), std::bind(exec_cell_hash_i, _1, _2, false))->require_version(6))
.insert(OpcodeInstr::mkfixed(0xd76c >> 2, 14, 2, instr::dump_1c_and(3, "CDEPTHI "), std::bind(exec_cell_depth_i, _1, _2, false))->require_version(6))
.insert(OpcodeInstr::mksimple(0xd770, 16, "CHASHIX ", std::bind(exec_cell_hash_i, _1, 0, true))->require_version(6))
.insert(OpcodeInstr::mksimple(0xd771, 16, "CDEPTHIX ", std::bind(exec_cell_depth_i, _1, 0, true))->require_version(6));
} }
void register_cell_ops(OpcodeTable& cp0) { void register_cell_ops(OpcodeTable& cp0) {

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