diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..78c6ddee
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,8 @@
+root = true
+
+[*]
+end_of_line = lf
+insert_final_newline = true
+charset = utf-8
+indent_style = space
+indent_size = 2
diff --git a/.github/script/amd64-20.04.Dockerfile b/.github/script/amd64-20.04.Dockerfile
deleted file mode 100644
index 40d980e5..00000000
--- a/.github/script/amd64-20.04.Dockerfile
+++ /dev/null
@@ -1,20 +0,0 @@
-FROM ubuntu:20.04
-
-RUN apt update
-RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
-RUN apt install -y build-essential cmake clang openssl libssl-dev zlib1g-dev gperf wget git curl libreadline-dev ccache libmicrohttpd-dev ninja-build libsecp256k1-dev libsodium-dev pkg-config
-
-WORKDIR /
-
-ARG BRANCH
-ARG REPO
-RUN git clone --recurse-submodules https://github.com/$REPO ton && cd ton && git checkout $BRANCH && git submodule update
-
-WORKDIR /ton
-RUN mkdir /ton/build
-WORKDIR /ton/build
-ENV CC clang
-ENV CXX clang++
-ENV CCACHE_DISABLE 1
-RUN cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 -DTON_ARCH= -DCMAKE_CXX_FLAGS="-mavx2" ..
-RUN ninja storage-daemon storage-daemon-cli tonlibjson blockchain-explorer fift func validator-engine validator-engine-console create-state generate-random-id create-hardfork dht-server lite-client
\ No newline at end of file
diff --git a/.github/script/amd64-22.04.Dockerfile b/.github/script/amd64-22.04.Dockerfile
deleted file mode 100644
index 44c9c40b..00000000
--- a/.github/script/amd64-22.04.Dockerfile
+++ /dev/null
@@ -1,20 +0,0 @@
-FROM ubuntu:22.04
-
-RUN apt update
-RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
-RUN apt install -y build-essential cmake clang openssl libssl-dev zlib1g-dev gperf wget git curl libreadline-dev ccache libmicrohttpd-dev ninja-build libsecp256k1-dev libsodium-dev pkg-config
-
-WORKDIR /
-
-ARG BRANCH
-ARG REPO
-RUN git clone --recurse-submodules https://github.com/$REPO ton && cd ton && git checkout $BRANCH && git submodule update
-
-WORKDIR /ton
-RUN mkdir /ton/build
-WORKDIR /ton/build
-ENV CC clang
-ENV CXX clang++
-ENV CCACHE_DISABLE 1
-RUN cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 -DTON_ARCH= -DCMAKE_CXX_FLAGS="-mavx2" ..
-RUN ninja storage-daemon storage-daemon-cli tonlibjson blockchain-explorer fift func validator-engine validator-engine-console create-state generate-random-id create-hardfork dht-server lite-client
\ No newline at end of file
diff --git a/.github/script/arm64-20.04.Dockerfile b/.github/script/arm64-20.04.Dockerfile
deleted file mode 100644
index 1f57dc40..00000000
--- a/.github/script/arm64-20.04.Dockerfile
+++ /dev/null
@@ -1,20 +0,0 @@
-FROM ubuntu:20.04
-
-RUN apt update
-RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
-RUN apt install -y build-essential cmake clang openssl libssl-dev zlib1g-dev gperf wget git curl libreadline-dev ccache libmicrohttpd-dev ninja-build libsecp256k1-dev libsodium-dev pkg-config
-
-WORKDIR /
-
-ARG BRANCH
-ARG REPO
-RUN git clone --recurse-submodules https://github.com/$REPO ton && cd ton && git checkout $BRANCH && git submodule update
-
-WORKDIR /ton
-RUN mkdir /ton/build
-WORKDIR /ton/build
-ENV CC clang
-ENV CXX clang++
-ENV CCACHE_DISABLE 1
-RUN cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 -DTON_ARCH= ..
-RUN ninja storage-daemon storage-daemon-cli tonlibjson blockchain-explorer fift func validator-engine validator-engine-console create-state generate-random-id dht-server lite-client
\ No newline at end of file
diff --git a/.github/script/arm64-22.04.Dockerfile b/.github/script/arm64-22.04.Dockerfile
deleted file mode 100644
index 2b595839..00000000
--- a/.github/script/arm64-22.04.Dockerfile
+++ /dev/null
@@ -1,20 +0,0 @@
-FROM ubuntu:22.04
-
-RUN apt update
-RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
-RUN apt install -y build-essential cmake clang openssl libssl-dev zlib1g-dev gperf wget git curl libreadline-dev ccache libmicrohttpd-dev ninja-build libsecp256k1-dev libsodium-dev pkg-config
-
-WORKDIR /
-
-ARG BRANCH
-ARG REPO
-RUN git clone --recurse-submodules https://github.com/$REPO ton && cd ton && git checkout $BRANCH && git submodule update
-
-WORKDIR /ton
-RUN mkdir /ton/build
-WORKDIR /ton/build
-ENV CC clang
-ENV CXX clang++
-ENV CCACHE_DISABLE 1
-RUN cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 -DTON_ARCH= ..
-RUN ninja storage-daemon storage-daemon-cli tonlibjson blockchain-explorer fift func validator-engine validator-engine-console create-state generate-random-id dht-server lite-client
\ No newline at end of file
diff --git a/.github/script/fift-func-wasm-build-ubuntu.sh b/.github/script/fift-func-wasm-build-ubuntu.sh
deleted file mode 100755
index feac19e3..00000000
--- a/.github/script/fift-func-wasm-build-ubuntu.sh
+++ /dev/null
@@ -1,122 +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-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 \
--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 emmake "; exit 1; }
-cp -R ../crypto/smartcont ../crypto/fift/lib crypto
-
-emmake make -j16 funcfiftlib func fift tlbc emulator-emscripten
diff --git a/.github/workflows/build-ton-linux-android-tonlib.yml b/.github/workflows/build-ton-linux-android-tonlib.yml
new file mode 100644
index 00000000..b1ef5281
--- /dev/null
+++ b/.github/workflows/build-ton-linux-android-tonlib.yml
@@ -0,0 +1,34 @@
+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 liblz4-dev
+
+ - name: Build TON
+ run: |
+ git submodule sync --recursive
+ git submodule update
+ 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: ton-android-tonlib
+ path: artifacts
diff --git a/.github/workflows/build-ton-linux-arm64-appimage.yml b/.github/workflows/build-ton-linux-arm64-appimage.yml
new file mode 100644
index 00000000..d464d8a2
--- /dev/null
+++ b/.github/workflows/build-ton-linux-arm64-appimage.yml
@@ -0,0 +1,57 @@
+name: Ubuntu TON build (AppImages, arm64)
+
+on: [push,workflow_dispatch,workflow_call]
+
+jobs:
+ build:
+ runs-on: ubuntu-22.04-arm
+
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v3
+ with:
+ submodules: 'recursive'
+
+ - name: Install system libraries
+ run: |
+ sudo apt update
+ sudo apt install -y build-essential git cmake ninja-build zlib1g-dev libsecp256k1-dev libmicrohttpd-dev libsodium-dev liblz4-dev
+ sudo apt remove libgsl-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: |
+ git submodule sync --recursive
+ git submodule update
+ cp assembly/native/build-ubuntu-appimages.sh .
+ chmod +x build-ubuntu-appimages.sh
+ ./build-ubuntu-appimages.sh -a
+
+ - name: Make AppImages
+ run: |
+ cp assembly/appimage/create-appimages.sh .
+ cp assembly/appimage/AppRun .
+ cp assembly/appimage/ton.png .
+ chmod +x create-appimages.sh
+ ./create-appimages.sh aarch64
+ rm -rf artifacts
+
+
+ - name: Build TON libs
+ run: |
+ cp assembly/native/build-ubuntu-portable-libs.sh .
+ chmod +x build-ubuntu-portable-libs.sh
+ ./build-ubuntu-portable-libs.sh -a
+ cp ./artifacts/libtonlibjson.so appimages/artifacts/
+ cp ./artifacts/libemulator.so appimages/artifacts/
+
+ - name: Upload artifacts
+ uses: actions/upload-artifact@master
+ with:
+ name: ton-arm64-linux
+ path: appimages/artifacts
diff --git a/.github/workflows/build-ton-linux-arm64-shared.yml b/.github/workflows/build-ton-linux-arm64-shared.yml
new file mode 100644
index 00000000..6433df0b
--- /dev/null
+++ b/.github/workflows/build-ton-linux-arm64-shared.yml
@@ -0,0 +1,43 @@
+name: Ubuntu TON build (shared, arm64)
+
+on: [push,workflow_dispatch,workflow_call]
+
+jobs:
+ build:
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [ubuntu-22.04-arm, ubuntu-24.04-arm]
+ 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 liblz4-dev libjemalloc-dev
+
+ - if: matrix.os != 'ubuntu-24.04-arm'
+ name: Install llvm-16
+ run: |
+ wget https://apt.llvm.org/llvm.sh
+ chmod +x llvm.sh
+ sudo ./llvm.sh 16 all
+
+ - name: Build TON
+ run: |
+ git submodule sync --recursive
+ git submodule update
+ 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
diff --git a/.github/workflows/build-ton-linux-x86-64-appimage.yml b/.github/workflows/build-ton-linux-x86-64-appimage.yml
new file mode 100644
index 00000000..4f78ece9
--- /dev/null
+++ b/.github/workflows/build-ton-linux-x86-64-appimage.yml
@@ -0,0 +1,63 @@
+name: Ubuntu TON build (AppImages, x86-64)
+
+on: [push,workflow_dispatch,workflow_call]
+
+jobs:
+ build:
+ runs-on: ubuntu-20.04
+
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v3
+ with:
+ submodules: 'recursive'
+
+ - name: Install system libraries
+ run: |
+ sudo apt update
+ sudo apt install -y build-essential git cmake ninja-build zlib1g-dev libsecp256k1-dev libmicrohttpd-dev libsodium-dev liblz4-dev
+ sudo apt remove libgsl-dev
+
+ - name: Install gcc-11 g++-11
+ run: |
+ sudo apt install -y manpages-dev software-properties-common
+ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
+ sudo apt update && sudo apt install gcc-11 g++-11
+
+ - 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: |
+ git submodule sync --recursive
+ git submodule update
+ cp assembly/native/build-ubuntu-appimages.sh .
+ chmod +x build-ubuntu-appimages.sh
+ ./build-ubuntu-appimages.sh -a
+
+ - name: Make AppImages
+ run: |
+ cp assembly/appimage/create-appimages.sh .
+ cp assembly/appimage/AppRun .
+ cp assembly/appimage/ton.png .
+ chmod +x create-appimages.sh
+ ./create-appimages.sh x86_64
+ rm -rf artifacts
+
+
+ - name: Build TON libs
+ run: |
+ cp assembly/native/build-ubuntu-portable-libs.sh .
+ chmod +x build-ubuntu-portable-libs.sh
+ ./build-ubuntu-portable-libs.sh -a
+ cp ./artifacts/libtonlibjson.so appimages/artifacts/
+ cp ./artifacts/libemulator.so appimages/artifacts/
+
+ - name: Upload artifacts
+ uses: actions/upload-artifact@master
+ with:
+ name: ton-x86_64-linux
+ path: appimages/artifacts
diff --git a/.github/workflows/build-ton-linux-x86-64-shared.yml b/.github/workflows/build-ton-linux-x86-64-shared.yml
new file mode 100644
index 00000000..bf78f7df
--- /dev/null
+++ b/.github/workflows/build-ton-linux-x86-64-shared.yml
@@ -0,0 +1,48 @@
+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, ubuntu-24.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 liblz4-dev libjemalloc-dev
+
+ - if: matrix.os == 'ubuntu-20.04'
+ run: |
+ sudo apt install -y manpages-dev software-properties-common
+ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
+ sudo apt update && sudo apt install gcc-11 g++-11
+
+ - if: matrix.os != 'ubuntu-24.04'
+ run: |
+ wget https://apt.llvm.org/llvm.sh
+ chmod +x llvm.sh
+ sudo ./llvm.sh 16 all
+
+ - name: Build TON
+ run: |
+ git submodule sync --recursive
+ git submodule update
+ 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
diff --git a/.github/workflows/build-ton-macos-13-x86-64-portable.yml b/.github/workflows/build-ton-macos-13-x86-64-portable.yml
new file mode 100644
index 00000000..5e50a468
--- /dev/null
+++ b/.github/workflows/build-ton-macos-13-x86-64-portable.yml
@@ -0,0 +1,27 @@
+name: MacOS-13 TON build (portable, x86-64)
+
+on: [push,workflow_dispatch,workflow_call]
+
+jobs:
+ build:
+ runs-on: macos-13
+
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v3
+ with:
+ submodules: 'recursive'
+
+ - name: Build TON
+ run: |
+ git submodule sync --recursive
+ git submodule update
+ cp assembly/native/build-macos-portable.sh .
+ chmod +x build-macos-portable.sh
+ ./build-macos-portable.sh -t -a
+
+ - name: Upload artifacts
+ uses: actions/upload-artifact@master
+ with:
+ name: ton-x86_64-macos
+ path: artifacts
diff --git a/.github/workflows/build-ton-macos-14-arm64-portable.yml b/.github/workflows/build-ton-macos-14-arm64-portable.yml
new file mode 100644
index 00000000..8eb3af70
--- /dev/null
+++ b/.github/workflows/build-ton-macos-14-arm64-portable.yml
@@ -0,0 +1,27 @@
+name: MacOS-14 TON build (portable, arm64)
+
+on: [push,workflow_dispatch,workflow_call]
+
+jobs:
+ build:
+ runs-on: macos-14
+
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v3
+ with:
+ submodules: 'recursive'
+
+ - name: Build TON
+ run: |
+ git submodule sync --recursive
+ git submodule update
+ cp assembly/native/build-macos-portable.sh .
+ chmod +x build-macos-portable.sh
+ ./build-macos-portable.sh -t -a
+
+ - name: Upload artifacts
+ uses: actions/upload-artifact@master
+ with:
+ name: ton-arm64-macos
+ path: artifacts
diff --git a/.github/workflows/build-ton-macos-15-arm64-shared.yml b/.github/workflows/build-ton-macos-15-arm64-shared.yml
new file mode 100644
index 00000000..00d8f639
--- /dev/null
+++ b/.github/workflows/build-ton-macos-15-arm64-shared.yml
@@ -0,0 +1,27 @@
+name: MacOS-15 TON build (shared, arm64)
+
+on: [push,workflow_dispatch,workflow_call]
+
+jobs:
+ build:
+ runs-on: macos-15
+
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v3
+ with:
+ submodules: 'recursive'
+
+ - name: Build TON
+ run: |
+ git submodule sync --recursive
+ git submodule update
+ 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-15
+ path: artifacts
diff --git a/.github/workflows/build-ton-macos-arm64-shared.yml b/.github/workflows/build-ton-macos-arm64-shared.yml
new file mode 100644
index 00000000..7481f9ff
--- /dev/null
+++ b/.github/workflows/build-ton-macos-arm64-shared.yml
@@ -0,0 +1,27 @@
+name: MacOS-14 TON build (shared, arm64)
+
+on: [push,workflow_dispatch,workflow_call]
+
+jobs:
+ build:
+ runs-on: macos-14
+
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v3
+ with:
+ submodules: 'recursive'
+
+ - name: Build TON
+ run: |
+ git submodule sync --recursive
+ git submodule update
+ 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-14
+ path: artifacts
diff --git a/.github/workflows/build-ton-macos-x86-64-shared.yml b/.github/workflows/build-ton-macos-x86-64-shared.yml
new file mode 100644
index 00000000..6a69b2e3
--- /dev/null
+++ b/.github/workflows/build-ton-macos-x86-64-shared.yml
@@ -0,0 +1,27 @@
+name: MacOS TON build (shared, x86-64)
+
+on: [push,workflow_dispatch,workflow_call]
+
+jobs:
+ build:
+ runs-on: macos-13
+
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v3
+ with:
+ submodules: 'recursive'
+
+ - name: Build TON
+ run: |
+ git submodule sync --recursive
+ git submodule update
+ 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-13
+ path: artifacts
diff --git a/.github/workflows/build-ton-wasm-emscripten.yml b/.github/workflows/build-ton-wasm-emscripten.yml
new file mode 100644
index 00000000..bac0cf98
--- /dev/null
+++ b/.github/workflows/build-ton-wasm-emscripten.yml
@@ -0,0 +1,51 @@
+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 liblz4-dev libjemalloc-dev
+
+ - name: Build TON WASM artifacts
+ run: |
+ git submodule sync --recursive
+ git submodule update
+ cp assembly/wasm/fift-func-wasm-build-ubuntu.sh .
+ chmod +x fift-func-wasm-build-ubuntu.sh
+ ./fift-func-wasm-build-ubuntu.sh -a
+
+ - name: Prepare test
+ run: |
+ cp assembly/wasm/*.fc .
+ git clone https://github.com/ton-community/func-js.git
+ cd func-js
+ npm install
+ npm run build
+ npm link
+
+ - name: Test TON WASM artifacts
+ run: |
+ base64 -w 0 artifacts/funcfiftlib.wasm > artifacts/funcfiftlib.wasm.js
+ printf "module.exports = { FuncFiftLibWasm: '" | cat - artifacts/funcfiftlib.wasm.js > temp.txt && mv temp.txt artifacts/funcfiftlib.wasm.js
+ echo "'}" >> artifacts/funcfiftlib.wasm.js
+ cp artifacts/funcfiftlib.wasm.js func-js/node_modules/@ton-community/func-js-bin/dist/funcfiftlib.wasm.js
+ cp artifacts/funcfiftlib.js func-js/node_modules/@ton-community/func-js-bin/dist/funcfiftlib.js
+ npx func-js stdlib.fc intrinsics.fc --fift ./output.f
+
+
+ - name: Upload artifacts
+ uses: actions/upload-artifact@master
+ with:
+ name: ton-wasm
+ path: artifacts
diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml
index 10c20ac0..05a3db26 100644
--- a/.github/workflows/create-release.yml
+++ b/.github/workflows/create-release.yml
@@ -4,6 +4,9 @@ on: [workflow_dispatch]
permissions: write-all
+env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
jobs:
create-release:
runs-on: ubuntu-22.04
@@ -11,60 +14,112 @@ jobs:
steps:
- uses: actions/checkout@v3
- - name: Download Linux x86-64 artifacts
- uses: dawidd6/action-download-artifact@v2
+ - name: Download Linux arm64 artifacts
+ uses: dawidd6/action-download-artifact@v6
with:
- workflow: ton-x86-64-linux.yml
+ workflow: build-ton-linux-arm64-appimage.yml
path: artifacts
workflow_conclusion: success
+ branch: master
+ skip_unpack: true
+
+ - name: Download and unzip Linux arm64 artifacts
+ uses: dawidd6/action-download-artifact@v6
+ with:
+ workflow: build-ton-linux-arm64-appimage.yml
+ path: artifacts
+ workflow_conclusion: success
+ branch: master
+ skip_unpack: false
+
+ - name: Download Linux x86-64 artifacts
+ uses: dawidd6/action-download-artifact@v6
+ with:
+ workflow: build-ton-linux-x86-64-appimage.yml
+ path: artifacts
+ workflow_conclusion: success
+ branch: master
skip_unpack: true
- name: Download and unzip Linux x86-64 artifacts
- uses: dawidd6/action-download-artifact@v2
+ uses: dawidd6/action-download-artifact@v6
with:
- workflow: ton-x86-64-linux.yml
+ workflow: build-ton-linux-x86-64-appimage.yml
path: artifacts
workflow_conclusion: success
+ branch: master
skip_unpack: false
- name: Download Mac x86-64 artifacts
- uses: dawidd6/action-download-artifact@v2
+ uses: dawidd6/action-download-artifact@v6
with:
- workflow: ton-x86-64-macos.yml
+ workflow: build-ton-macos-13-x86-64-portable.yml
path: artifacts
workflow_conclusion: success
+ branch: master
+ skip_unpack: true
+
+ - name: Download Mac arm64 artifacts
+ uses: dawidd6/action-download-artifact@v6
+ with:
+ workflow: build-ton-macos-14-arm64-portable.yml
+ path: artifacts
+ workflow_conclusion: success
+ branch: master
skip_unpack: true
- name: Download and unzip Mac x86-64 artifacts
- uses: dawidd6/action-download-artifact@v2
+ uses: dawidd6/action-download-artifact@v6
with:
- workflow: ton-x86-64-macos.yml
+ workflow: build-ton-macos-13-x86-64-portable.yml
path: artifacts
workflow_conclusion: success
+ branch: master
+ skip_unpack: false
+
+ - name: Download and unzip arm64 artifacts
+ uses: dawidd6/action-download-artifact@v6
+ with:
+ workflow: build-ton-macos-14-arm64-portable.yml
+ path: artifacts
+ workflow_conclusion: success
+ branch: master
skip_unpack: false
- name: Download Windows artifacts
- uses: dawidd6/action-download-artifact@v2
+ uses: dawidd6/action-download-artifact@v6
with:
- workflow: win-2019-compile.yml
+ workflow: ton-x86-64-windows.yml
path: artifacts
workflow_conclusion: success
+ branch: master
skip_unpack: true
- name: Download and unzip Windows artifacts
- uses: dawidd6/action-download-artifact@v2
+ uses: dawidd6/action-download-artifact@v6
with:
- workflow: win-2019-compile.yml
+ workflow: ton-x86-64-windows.yml
path: artifacts
workflow_conclusion: success
+ branch: master
skip_unpack: false
- name: Download WASM artifacts
- uses: dawidd6/action-download-artifact@v2
+ uses: dawidd6/action-download-artifact@v6
with:
- workflow: ton-wasm-emscripten.yml
+ workflow: build-ton-wasm-emscripten.yml
path: artifacts
workflow_conclusion: success
+ branch: master
+ skip_unpack: true
+
+ - name: Download Android Tonlib artifacts
+ uses: dawidd6/action-download-artifact@v6
+ with:
+ workflow: build-ton-linux-android-tonlib.yml
+ path: artifacts
+ workflow_conclusion: success
+ branch: master
skip_unpack: true
- name: Show all artifacts
@@ -123,7 +178,7 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-win-binaries.zip
+ file: artifacts/ton-x86-64-windows.zip
asset_name: ton-win-x86-64.zip
tag: ${{ steps.tag.outputs.TAG }}
@@ -131,7 +186,7 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-win-binaries/fift.exe
+ file: artifacts/ton-x86-64-windows/fift.exe
asset_name: fift.exe
tag: ${{ steps.tag.outputs.TAG }}
@@ -139,23 +194,39 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-win-binaries/func.exe
+ file: artifacts/ton-x86-64-windows/func.exe
asset_name: func.exe
tag: ${{ steps.tag.outputs.TAG }}
+ - name: Upload Windows 2019 single artifact - tolk
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-x86-64-windows/tolk.exe
+ asset_name: tolk.exe
+ tag: ${{ steps.tag.outputs.TAG }}
+
- name: Upload Windows 2019 single artifact - lite-client
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-win-binaries/lite-client.exe
+ file: artifacts/ton-x86-64-windows/lite-client.exe
asset_name: lite-client.exe
tag: ${{ steps.tag.outputs.TAG }}
+ - name: Upload Windows 2019 single artifact - proxy-liteserver
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-x86-64-windows/proxy-liteserver.exe
+ asset_name: proxy-liteserver.exe
+ tag: ${{ steps.tag.outputs.TAG }}
+
- name: Upload Windows 2019 single artifact - rldp-http-proxy
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-win-binaries/rldp-http-proxy.exe
+ file: artifacts/ton-x86-64-windows/rldp-http-proxy.exe
asset_name: rldp-http-proxy.exe
tag: ${{ steps.tag.outputs.TAG }}
@@ -163,7 +234,7 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-win-binaries/http-proxy.exe
+ file: artifacts/ton-x86-64-windows/http-proxy.exe
asset_name: http-proxy.exe
tag: ${{ steps.tag.outputs.TAG }}
@@ -171,7 +242,7 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-win-binaries/storage-daemon-cli.exe
+ file: artifacts/ton-x86-64-windows/storage-daemon-cli.exe
asset_name: storage-daemon-cli.exe
tag: ${{ steps.tag.outputs.TAG }}
@@ -179,7 +250,7 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-win-binaries/storage-daemon.exe
+ file: artifacts/ton-x86-64-windows/storage-daemon.exe
asset_name: storage-daemon.exe
tag: ${{ steps.tag.outputs.TAG }}
@@ -187,15 +258,23 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-win-binaries/tonlibjson.dll
+ file: artifacts/ton-x86-64-windows/tonlibjson.dll
asset_name: tonlibjson.dll
tag: ${{ steps.tag.outputs.TAG }}
+ - name: Upload Windows 2019 single artifact - libemulator
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-x86-64-windows/emulator.dll
+ asset_name: libemulator.dll
+ tag: ${{ steps.tag.outputs.TAG }}
+
- name: Upload Windows 2019 single artifact - tonlib-cli
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-win-binaries/tonlib-cli.exe
+ file: artifacts/ton-x86-64-windows/tonlib-cli.exe
asset_name: tonlib-cli.exe
tag: ${{ steps.tag.outputs.TAG }}
@@ -205,7 +284,7 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-x86_64-macos-binaries.zip
+ file: artifacts/ton-x86_64-macos.zip
asset_name: ton-mac-x86-64.zip
tag: ${{ steps.tag.outputs.TAG }}
@@ -213,7 +292,7 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-x86_64-macos-binaries/fift
+ file: artifacts/ton-x86_64-macos/fift
asset_name: fift-mac-x86-64
tag: ${{ steps.tag.outputs.TAG }}
@@ -221,23 +300,39 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-x86_64-macos-binaries/func
+ file: artifacts/ton-x86_64-macos/func
asset_name: func-mac-x86-64
tag: ${{ steps.tag.outputs.TAG }}
+ - name: Upload Mac x86-64 single artifact - tolk
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-x86_64-macos/tolk
+ asset_name: tolk-mac-x86-64
+ tag: ${{ steps.tag.outputs.TAG }}
+
- name: Upload Mac x86-64 single artifact - lite-client
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-x86_64-macos-binaries/lite-client
+ file: artifacts/ton-x86_64-macos/lite-client
asset_name: lite-client-mac-x86-64
tag: ${{ steps.tag.outputs.TAG }}
+ - name: Upload Mac x86-64 single artifact - proxy-liteserver
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-x86_64-macos/proxy-liteserver
+ asset_name: proxy-liteserver-mac-x86-64
+ tag: ${{ steps.tag.outputs.TAG }}
+
- name: Upload Mac x86-64 single artifact - rldp-http-proxy
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-x86_64-macos-binaries/rldp-http-proxy
+ file: artifacts/ton-x86_64-macos/rldp-http-proxy
asset_name: rldp-http-proxy-mac-x86-64
tag: ${{ steps.tag.outputs.TAG }}
@@ -245,7 +340,7 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-x86_64-macos-binaries/http-proxy
+ file: artifacts/ton-x86_64-macos/http-proxy
asset_name: http-proxy-mac-x86-64
tag: ${{ steps.tag.outputs.TAG }}
@@ -253,7 +348,7 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-x86_64-macos-binaries/storage-daemon-cli
+ file: artifacts/ton-x86_64-macos/storage-daemon-cli
asset_name: storage-daemon-cli-mac-x86-64
tag: ${{ steps.tag.outputs.TAG }}
@@ -261,7 +356,7 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-x86_64-macos-binaries/storage-daemon
+ file: artifacts/ton-x86_64-macos/storage-daemon
asset_name: storage-daemon-mac-x86-64
tag: ${{ steps.tag.outputs.TAG }}
@@ -269,33 +364,156 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-x86_64-macos-binaries/libtonlibjson.dylib
+ file: artifacts/ton-x86_64-macos/libtonlibjson.dylib
asset_name: tonlibjson-mac-x86-64.dylib
tag: ${{ steps.tag.outputs.TAG }}
+ - name: Upload Mac x86-64 single artifact - libemulator
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-x86_64-macos/libemulator.dylib
+ asset_name: libemulator-mac-x86-64.dylib
+ tag: ${{ steps.tag.outputs.TAG }}
+
- name: Upload Mac x86-64 single artifact - tonlib-cli
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-x86_64-macos-binaries/tonlib-cli
+ file: artifacts/ton-x86_64-macos/tonlib-cli
asset_name: tonlib-cli-mac-x86-64
tag: ${{ steps.tag.outputs.TAG }}
+
+ # mac arm64
+
+ - name: Upload Mac arm64 artifacts
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-macos.zip
+ asset_name: ton-mac-arm64.zip
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Mac arm64 single artifact - fift
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-macos/fift
+ asset_name: fift-mac-arm64
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Mac arm64 single artifact - func
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-macos/func
+ asset_name: func-mac-arm64
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Mac arm64 single artifact - tolk
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-macos/tolk
+ asset_name: tolk-mac-arm64
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Mac arm64 single artifact - lite-client
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-macos/lite-client
+ asset_name: lite-client-mac-arm64
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Mac arm64 single artifact - proxy-liteserver
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-macos/proxy-liteserver
+ asset_name: proxy-liteserver-mac-arm64
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Mac arm64 single artifact - rldp-http-proxy
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-macos/rldp-http-proxy
+ asset_name: rldp-http-proxy-mac-arm64
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Mac arm64 single artifact - http-proxy
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-macos/http-proxy
+ asset_name: http-proxy-mac-arm64
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Mac arm64 single artifact - storage-daemon-cli
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-macos/storage-daemon-cli
+ asset_name: storage-daemon-cli-mac-arm64
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Mac arm64 single artifact - storage-daemon
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-macos/storage-daemon
+ asset_name: storage-daemon-mac-arm64
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Mac arm64 single artifact - tonlibjson
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-macos/libtonlibjson.dylib
+ asset_name: tonlibjson-mac-arm64.dylib
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Mac arm64 single artifact - libemulator
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-macos/libemulator.dylib
+ asset_name: libemulator-mac-arm64.dylib
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Mac arm64 single artifact - tonlib-cli
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-macos/tonlib-cli
+ asset_name: tonlib-cli-mac-arm64
+ tag: ${{ steps.tag.outputs.TAG }}
+
# linux x86-64
- name: Upload Linux x86-64 artifacts
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-x86_64-linux-binaries.zip
+ file: artifacts/ton-x86_64-linux.zip
asset_name: ton-linux-x86_64.zip
tag: ${{ steps.tag.outputs.TAG }}
+ - name: Upload generic smartcont+lib artifact
+ run: |
+ mkdir smartcont_lib
+ cd smartcont_lib
+ cp -r ../artifacts/ton-x86_64-linux/{smartcont,lib} .
+ zip -r smartcont_lib.zip .
+ gh release upload ${{ steps.tag.outputs.TAG }} smartcont_lib.zip
+
- name: Upload Linux x86-64 single artifact - fift
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-x86_64-linux-binaries/fift
+ file: artifacts/ton-x86_64-linux/fift
asset_name: fift-linux-x86_64
tag: ${{ steps.tag.outputs.TAG }}
@@ -303,23 +521,39 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-x86_64-linux-binaries/func
+ file: artifacts/ton-x86_64-linux/func
asset_name: func-linux-x86_64
tag: ${{ steps.tag.outputs.TAG }}
+ - name: Upload Linux x86-64 single artifact - tolk
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-x86_64-linux/tolk
+ asset_name: tolk-linux-x86_64
+ tag: ${{ steps.tag.outputs.TAG }}
+
- name: Upload Linux x86-64 single artifact - lite-client
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-x86_64-linux-binaries/lite-client
+ file: artifacts/ton-x86_64-linux/lite-client
asset_name: lite-client-linux-x86_64
tag: ${{ steps.tag.outputs.TAG }}
+ - name: Upload Linux x86-64 single artifact - proxy-liteserver
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-x86_64-linux/proxy-liteserver
+ asset_name: proxy-liteserver-linux-x86_64
+ tag: ${{ steps.tag.outputs.TAG }}
+
- name: Upload Linux x86-64 single artifact - rldp-http-proxy
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-x86_64-linux-binaries/rldp-http-proxy
+ file: artifacts/ton-x86_64-linux/rldp-http-proxy
asset_name: rldp-http-proxy-linux-x86_64
tag: ${{ steps.tag.outputs.TAG }}
@@ -327,7 +561,7 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-x86_64-linux-binaries/http-proxy
+ file: artifacts/ton-x86_64-linux/http-proxy
asset_name: http-proxy-linux-x86_64
tag: ${{ steps.tag.outputs.TAG }}
@@ -335,7 +569,7 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-x86_64-linux-binaries/storage-daemon-cli
+ file: artifacts/ton-x86_64-linux/storage-daemon-cli
asset_name: storage-daemon-cli-linux-x86_64
tag: ${{ steps.tag.outputs.TAG }}
@@ -343,7 +577,7 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-x86_64-linux-binaries/storage-daemon
+ file: artifacts/ton-x86_64-linux/storage-daemon
asset_name: storage-daemon-linux-x86_64
tag: ${{ steps.tag.outputs.TAG }}
@@ -351,22 +585,146 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-x86_64-linux-binaries/libtonlibjson.so
+ file: artifacts/ton-x86_64-linux/libtonlibjson.so
asset_name: tonlibjson-linux-x86_64.so
tag: ${{ steps.tag.outputs.TAG }}
+ - name: Upload Linux x86-64 single artifact - libemulator
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-x86_64-linux/libemulator.so
+ asset_name: libemulator-linux-x86_64.so
+ tag: ${{ steps.tag.outputs.TAG }}
+
- name: Upload Linux x86-64 single artifact - tonlib-cli
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-x86_64-linux-binaries/tonlib-cli
+ file: artifacts/ton-x86_64-linux/tonlib-cli
asset_name: tonlib-cli-linux-x86_64
tag: ${{ steps.tag.outputs.TAG }}
+
+ # linux arm64
+
+ - name: Upload Linux arm64 artifacts
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-linux.zip
+ asset_name: ton-linux-arm64.zip
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Linux arm64 single artifact - fift
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-linux/fift
+ asset_name: fift-linux-arm64
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Linux arm64 single artifact - func
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-linux/func
+ asset_name: func-linux-arm64
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Linux arm64 single artifact - tolk
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-linux/tolk
+ asset_name: tolk-linux-arm64
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Linux arm64 single artifact - lite-client
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-linux/lite-client
+ asset_name: lite-client-linux-arm64
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Linux arm64 single artifact - proxy-liteserver
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-linux/proxy-liteserver
+ asset_name: proxy-liteserver-linux-arm64
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Linux arm64 single artifact - rldp-http-proxy
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-linux/rldp-http-proxy
+ asset_name: rldp-http-proxy-linux-arm64
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Linux arm64 single artifact - http-proxy
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-linux/http-proxy
+ asset_name: http-proxy-linux-arm64
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Linux arm64 single artifact - storage-daemon-cli
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-linux/storage-daemon-cli
+ asset_name: storage-daemon-cli-linux-arm64
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Linux arm64 single artifact - storage-daemon
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-linux/storage-daemon
+ asset_name: storage-daemon-linux-arm64
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Linux arm64 single artifact - tonlibjson
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-linux/libtonlibjson.so
+ asset_name: tonlibjson-linux-arm64.so
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Linux arm64 single artifact - libemulator
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-linux/libemulator.so
+ asset_name: libemulator-linux-arm64.so
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Linux arm64 single artifact - tonlib-cli
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-linux/tonlib-cli
+ asset_name: tonlib-cli-linux-arm64
+ tag: ${{ steps.tag.outputs.TAG }}
+
+
- name: Upload WASM artifacts
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: artifacts/ton-wasm-binaries.zip
- asset_name: ton-wasm-binaries.zip
+ file: artifacts/ton-wasm.zip
+ asset_name: ton-wasm.zip
+ tag: ${{ steps.tag.outputs.TAG }}
+
+ - name: Upload Android Tonlib artifacts
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-android-tonlib.zip
+ asset_name: ton-android-tonlib.zip
tag: ${{ steps.tag.outputs.TAG }}
diff --git a/.github/workflows/create-tolk-release.yml b/.github/workflows/create-tolk-release.yml
new file mode 100644
index 00000000..fb8438a1
--- /dev/null
+++ b/.github/workflows/create-tolk-release.yml
@@ -0,0 +1,154 @@
+name: Create tolk release
+
+on:
+ workflow_dispatch:
+ inputs:
+ tag:
+ description: 'tolk release and tag name'
+ required: true
+
+permissions: write-all
+
+jobs:
+ create-release:
+ runs-on: ubuntu-22.04
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Download and unzip Linux arm64 artifacts
+ uses: dawidd6/action-download-artifact@v6
+ with:
+ workflow: build-ton-linux-arm64-appimage.yml
+ path: artifacts
+ workflow_conclusion: success
+ branch: master
+ skip_unpack: false
+
+ - name: Download and unzip Linux x86-64 artifacts
+ uses: dawidd6/action-download-artifact@v6
+ with:
+ workflow: build-ton-linux-x86-64-appimage.yml
+ path: artifacts
+ workflow_conclusion: success
+ branch: master
+ skip_unpack: false
+
+ - name: Download and unzip Mac x86-64 artifacts
+ uses: dawidd6/action-download-artifact@v6
+ with:
+ workflow: build-ton-macos-13-x86-64-portable.yml
+ path: artifacts
+ workflow_conclusion: success
+ branch: master
+ skip_unpack: false
+
+ - name: Download and unzip arm64 artifacts
+ uses: dawidd6/action-download-artifact@v6
+ with:
+ workflow: build-ton-macos-14-arm64-portable.yml
+ path: artifacts
+ workflow_conclusion: success
+ branch: master
+ skip_unpack: false
+
+ - name: Download and unzip Windows artifacts
+ uses: dawidd6/action-download-artifact@v6
+ with:
+ workflow: ton-x86-64-windows.yml
+ path: artifacts
+ workflow_conclusion: success
+ branch: master
+ skip_unpack: false
+
+ - name: Download WASM artifacts
+ uses: dawidd6/action-download-artifact@v6
+ with:
+ workflow: build-ton-wasm-emscripten.yml
+ path: artifacts
+ workflow_conclusion: success
+ branch: master
+ skip_unpack: true
+
+ - name: Show all artifacts
+ run: |
+ tree artifacts
+
+
+ # create release
+ - name: Get registration token
+ id: getRegToken
+ run: |
+ curl -X POST -H \"Accept: application/vnd.github+json\" -H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' https://api.github.com/repos/ton-blockchain/ton/actions/runners/registration-token
+
+ - name: Create release
+ id: create_release
+ uses: actions/create-release@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ tag_name: ${{ inputs.tag }}
+ release_name: ${{ inputs.tag }}
+ draft: false
+ prerelease: false
+
+ # upload
+
+ # win
+
+ - name: Upload Windows 2019 single artifact - tolk
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-x86-64-windows/tolk.exe
+ asset_name: tolk.exe
+ tag: ${{ inputs.tag }}
+
+ # mac x86-64
+
+ - name: Upload Mac x86-64 single artifact - tolk
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-x86_64-macos/tolk
+ asset_name: tolk-mac-x86-64
+ tag: ${{ inputs.tag }}
+
+ # mac arm64
+
+ - name: Upload Mac arm64 single artifact - tolk
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-macos/tolk
+ asset_name: tolk-mac-arm64
+ tag: ${{ inputs.tag }}
+
+ # linux x86-64
+
+ - name: Upload Linux x86-64 single artifact - tolk
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-x86_64-linux/tolk
+ asset_name: tolk-linux-x86_64
+ tag: ${{ inputs.tag }}
+
+ # linux arm64
+
+ - name: Upload Linux arm64 single artifact - tolk
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-arm64-linux/tolk
+ asset_name: tolk-linux-arm64
+ tag: ${{ inputs.tag }}
+
+ - name: Upload WASM artifacts
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: artifacts/ton-wasm.zip
+ asset_name: ton-wasm.zip
+ tag: ${{ inputs.tag }}
+
diff --git a/.github/workflows/docker-ubuntu-branch-image.yml b/.github/workflows/docker-ubuntu-branch-image.yml
new file mode 100644
index 00000000..00aa5015
--- /dev/null
+++ b/.github/workflows/docker-ubuntu-branch-image.yml
@@ -0,0 +1,61 @@
+name: Docker Ubuntu 22.04 branch image
+
+on:
+ workflow_dispatch:
+ push:
+ branches-ignore:
+ - master
+
+env:
+ REGISTRY: ghcr.io
+ IMAGE_NAME: ${{ github.repository }}
+
+jobs:
+ build-and-push:
+ runs-on: ubuntu-22.04
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v3
+ with:
+ submodules: 'recursive'
+
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v3.5.0
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3.10.0
+ with:
+ driver-opts: image=moby/buildkit:v0.11.0
+
+ - name: Login to GitHub Container Registry
+ uses: docker/login-action@v3
+ with:
+ registry: ${{ env.REGISTRY }}
+ username: ${{ github.repository_owner }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Build and export to Docker
+ uses: docker/build-push-action@v6
+ with:
+ load: true
+ context: ./
+ tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test
+
+ - name: Test
+ run: |
+ docker run --rm -e "TEST=1" ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test
+
+ - name: Get tag as branch name
+ id: tag
+ run: |
+ echo "TAG=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
+
+ - name: Build and push
+ id: docker_build
+ uses: docker/build-push-action@v6
+ with:
+ platforms: linux/amd64,linux/arm64
+ push: true
+ context: ./
+ tags: |
+ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.TAG }}
diff --git a/.github/workflows/docker-ubuntu-image.yml b/.github/workflows/docker-ubuntu-image.yml
index ca754078..aa4eaeef 100644
--- a/.github/workflows/docker-ubuntu-image.yml
+++ b/.github/workflows/docker-ubuntu-image.yml
@@ -1,4 +1,4 @@
-name: Docker Ubuntu 20.04 image
+name: Docker Ubuntu 22.04 image
on:
workflow_dispatch:
@@ -12,28 +12,57 @@ env:
jobs:
build-and-push:
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-22.04
steps:
- - name: Checkout
+ - name: Check out repository
uses: actions/checkout@v3
+ with:
+ submodules: 'recursive'
- name: Set up QEMU
- uses: docker/setup-qemu-action@v1
-
+ uses: docker/setup-qemu-action@v3.5.0
+
- name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v1
+ uses: docker/setup-buildx-action@v3.10.0
- name: Login to GitHub Container Registry
- uses: docker/login-action@v1
+ uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
+ - name: Build and export to Docker
+ uses: docker/build-push-action@v6
+ with:
+ load: true
+ context: ./
+ tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test
+
+ - name: Test
+ run: |
+ docker run --rm -e "TEST=1" ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test
+
+ - name: Get next tag
+ id: tag
+ run: |
+ git fetch --all --tags
+ git tag -l
+ NEW_TAG=v$(date +'%Y.%m')
+ FOUND=$(git tag -l | grep $NEW_TAG | wc -l)
+ if [ $FOUND -eq 0 ]; then
+ echo "TAG=$NEW_TAG" >> $GITHUB_OUTPUT
+ else
+ echo "TAG=$NEW_TAG-$FOUND" >> $GITHUB_OUTPUT
+ fi
+
- name: Build and push
id: docker_build
- uses: docker/build-push-action@v2
+ uses: docker/build-push-action@v6
with:
+ platforms: linux/amd64,linux/arm64
push: true
- context: ./docker
- tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
+ context: ./
+ tags: |
+ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
+ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.TAG }}
diff --git a/.github/workflows/macos-11.7-compile.yml b/.github/workflows/macos-11.7-compile.yml
deleted file mode 100644
index eb12db1b..00000000
--- a/.github/workflows/macos-11.7-compile.yml
+++ /dev/null
@@ -1,106 +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 Secp256k1
- run: |
- export NONINTERACTIVE=1
- brew install ninja secp256k1 libsodium libmicrohttpd pkg-config automake libtool
- git clone https://github.com/libbitcoin/secp256k1.git
- cd secp256k1
- ./autogen.sh
- ./configure --enable-module-recovery
- make
- make install
-
- - name: Build all
- run: |
- brew unlink openssl@1.1
- brew install openssl@3
- brew unlink openssl@3 && brew link --overwrite openssl@3
- rootPath=`pwd`
- mkdir build
- cd build
- cmake -GNinja -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=11.7 -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_BUILD_TYPE=Release ..
-
- ninja storage-daemon storage-daemon-cli blockchain-explorer fift func tonlib tonlibjson tonlib-cli validator-engine \
- lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server \
- http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork tlbc emulator \
- test-ed25519 test-ed25519-crypto test-bigint test-vm test-fift test-cells test-smartcont test-net test-tdactor \
- test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain test-fec test-tddb test-db test-validator-session-state
-
- - name: Strip binaries
- run: |
- strip build/storage/storage-daemon/storage-daemon
- strip build/storage/storage-daemon/storage-daemon-cli
- strip build/blockchain-explorer/blockchain-explorer
- strip build/crypto/fift
- strip build/crypto/func
- strip build/crypto/create-state
- strip build/crypto/tlbc
- strip build/validator-engine-console/validator-engine-console
- strip build/tonlib/tonlib-cli
- strip build/http/http-proxy
- strip build/rldp-http-proxy/rldp-http-proxy
- strip build/dht-server/dht-server
- strip build/lite-client/lite-client
- strip build/validator-engine/validator-engine
- strip build/utils/generate-random-id
- strip build/utils/json2tlo
- strip build/adnl/adnl-proxy
-
- - name: Run tests
- run: |
- cd build
- ctest --output-on-failure -E "test-catchain|test-actors"
-
- - name: Find & copy binaries
- run: |
- 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/
- 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
diff --git a/.github/workflows/macos-12.6-compile.yml b/.github/workflows/macos-12.6-compile.yml
deleted file mode 100644
index f41efc66..00000000
--- a/.github/workflows/macos-12.6-compile.yml
+++ /dev/null
@@ -1,106 +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 Secp256k1
- run: |
- export NONINTERACTIVE=1
- brew install ninja secp256k1 libsodium libmicrohttpd pkg-config automake libtool
- git clone https://github.com/libbitcoin/secp256k1.git
- cd secp256k1
- ./autogen.sh
- ./configure --enable-module-recovery
- make
- make install
-
- - name: Build all
- run: |
- brew unlink openssl@1.1
- brew install openssl@3
- brew unlink openssl@3 && brew link --overwrite openssl@3
- rootPath=`pwd`
- mkdir build
- cd build
- cmake -GNinja -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=12.6 -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_BUILD_TYPE=Release ..
-
- ninja storage-daemon storage-daemon-cli blockchain-explorer fift func tonlib tonlibjson tonlib-cli \
- validator-engine lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server \
- http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork tlbc emulator \
- test-ed25519 test-ed25519-crypto test-bigint test-vm test-fift test-cells test-smartcont test-net test-tdactor \
- test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain test-fec test-tddb test-db test-validator-session-state
-
- - name: Strip binaries
- run: |
- strip build/storage/storage-daemon/storage-daemon
- strip build/storage/storage-daemon/storage-daemon-cli
- strip build/blockchain-explorer/blockchain-explorer
- strip build/crypto/fift
- strip build/crypto/func
- strip build/crypto/create-state
- strip build/crypto/tlbc
- strip build/validator-engine-console/validator-engine-console
- strip build/tonlib/tonlib-cli
- strip build/http/http-proxy
- strip build/rldp-http-proxy/rldp-http-proxy
- strip build/dht-server/dht-server
- strip build/lite-client/lite-client
- strip build/validator-engine/validator-engine
- strip build/utils/generate-random-id
- strip build/utils/json2tlo
- strip build/adnl/adnl-proxy
-
- - name: Run tests
- run: |
- cd build
- ctest --output-on-failure -E "test-catchain|test-actors"
-
- - name: Find & copy binaries
- run: |
- 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/
- 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
diff --git a/.github/workflows/ton-aarch64-linux.yml b/.github/workflows/ton-aarch64-linux.yml
deleted file mode 100644
index 3c600bee..00000000
--- a/.github/workflows/ton-aarch64-linux.yml
+++ /dev/null
@@ -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
\ No newline at end of file
diff --git a/.github/workflows/ton-aarch64-macos.yml b/.github/workflows/ton-aarch64-macos.yml
deleted file mode 100644
index 75fcec78..00000000
--- a/.github/workflows/ton-aarch64-macos.yml
+++ /dev/null
@@ -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
diff --git a/.github/workflows/ton-ccpcheck.yml b/.github/workflows/ton-ccpcheck.yml
index 8e9d6ad2..95bef5f3 100644
--- a/.github/workflows/ton-ccpcheck.yml
+++ b/.github/workflows/ton-ccpcheck.yml
@@ -1,10 +1,9 @@
-name: TON Ccpcheck
+name: TON Static Code Analysis
on: [push,workflow_dispatch,workflow_call]
jobs:
build:
-
runs-on: ubuntu-22.04
steps:
@@ -21,7 +20,7 @@ jobs:
generate report: true
- name: Upload report
- uses: actions/upload-artifact@v1
+ uses: actions/upload-artifact@master
with:
name: ton-ccpcheck-report
path: output
diff --git a/.github/workflows/ton-wasm-emscripten.yml b/.github/workflows/ton-wasm-emscripten.yml
deleted file mode 100644
index a3167800..00000000
--- a/.github/workflows/ton-wasm-emscripten.yml
+++ /dev/null
@@ -1,46 +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 automake libtool
-
- - name: Setup compiler
- run: |
- wget https://apt.llvm.org/llvm.sh
- chmod +x llvm.sh
- sudo ./llvm.sh 16 all
-
- - name: Configure & Build
- run: |
- 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
\ No newline at end of file
diff --git a/.github/workflows/ton-x86-64-linux.yml b/.github/workflows/ton-x86-64-linux.yml
deleted file mode 100644
index a4760dc4..00000000
--- a/.github/workflows/ton-x86-64-linux.yml
+++ /dev/null
@@ -1,49 +0,0 @@
-name: "TON x86_64 Linux binaries"
-
-on: [push,workflow_dispatch,workflow_call]
-
-jobs:
- build:
- runs-on: ubuntu-22.04
-
- steps:
- - run: |
- sudo apt update
- sudo apt install -y apt-utils
-
- - uses: actions/checkout@v3
- with:
- submodules: 'recursive'
-
- - uses: cachix/install-nix-action@v23
- with:
- extra_nix_config: |
- access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
-
- - name: Compile
- 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: |
- ls -lart
- mkdir artifacts
- cp $PWD/result-x86_64/bin/* artifacts/
- 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
- 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-x86_64-linux-binaries
- path: artifacts
\ No newline at end of file
diff --git a/.github/workflows/ton-x86-64-macos.yml b/.github/workflows/ton-x86-64-macos.yml
deleted file mode 100644
index cea2937a..00000000
--- a/.github/workflows/ton-x86-64-macos.yml
+++ /dev/null
@@ -1,45 +0,0 @@
-name: "TON x86_64 macOS binaries"
-
-on: [push,workflow_dispatch,workflow_call]
-
-jobs:
- build:
- runs-on: macos-12
-
- steps:
- - uses: actions/checkout@v3
- with:
- submodules: 'recursive'
-
- - uses: cachix/install-nix-action@v23
- with:
- extra_nix_config: |
- access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
-
- - name: Compile
- run: nix build .?submodules=1#packages.x86_64-darwin.ton-staticbin-dylib --print-build-logs -o result-x86_64-darwin
-
- - name: Copy binaries
- run: |
- ls -lart
- mkdir artifacts
- cp $PWD/result-x86_64-darwin/bin/* artifacts/
- 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
- 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-x86_64-macos-binaries
- path: artifacts
\ No newline at end of file
diff --git a/.github/workflows/ton-x86-64-windows.yml b/.github/workflows/ton-x86-64-windows.yml
new file mode 100644
index 00000000..baaad778
--- /dev/null
+++ b/.github/workflows/ton-x86-64-windows.yml
@@ -0,0 +1,36 @@
+name: Windows TON build (portable, x86-64)
+
+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: Build TON
+ run: |
+ git submodule sync --recursive
+ git submodule update
+ copy assembly\native\build-windows-github-2019.bat .
+ copy assembly\native\build-windows-2019.bat .
+ build-windows-github-2019.bat Enterprise
+
+ - name: Upload artifacts
+ uses: actions/upload-artifact@master
+ with:
+ name: ton-x86-64-windows
+ path: artifacts
diff --git a/.github/workflows/tonlib-android-jni.yml b/.github/workflows/tonlib-android-jni.yml
deleted file mode 100644
index 6e04f8b7..00000000
--- a/.github/workflows/tonlib-android-jni.yml
+++ /dev/null
@@ -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 -q https://dl.google.com/android/repository/android-ndk-r25b-linux.zip
- unzip -q android-ndk-r25b-linux.zip
- export JAVA_AWT_LIBRARY=NotNeeded
- export JAVA_JVM_LIBRARY=NotNeeded
- export JAVA_INCLUDE_PATH=${JAVA_HOME}/include
- 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
\ No newline at end of file
diff --git a/.github/workflows/ubuntu-22.04-compile.yml b/.github/workflows/ubuntu-22.04-compile.yml
deleted file mode 100644
index af8943a1..00000000
--- a/.github/workflows/ubuntu-22.04-compile.yml
+++ /dev/null
@@ -1,78 +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_3
- cd openssl_3
- git checkout openssl-3.1.4
- ./config
- make build_libs -j4
-
- cd ..
- rootPath=`pwd`
- mkdir build
- cd build
-
- cmake -GNinja -DOPENSSL_FOUND=1 -DOPENSSL_INCLUDE_DIR=$rootPath/openssl_3/include -DOPENSSL_CRYPTO_LIBRARY=$rootPath/openssl_3/libcrypto.a -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 -DTON_ARCH= ..
-
- ninja storage-daemon storage-daemon-cli fift func tonlib tonlibjson tonlib-cli validator-engine lite-client \
- pow-miner validator-engine-console generate-random-id json2tlo dht-server http-proxy rldp-http-proxy \
- adnl-proxy create-state emulator \
- test-ed25519 test-ed25519-crypto test-bigint test-vm test-fift test-cells test-smartcont test-net test-tdactor \
- test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain test-fec test-tddb test-db test-validator-session-state
-
- - name: Strip binaries
- run: |
- strip -g build/storage/storage-daemon/storage-daemon build/storage/storage-daemon/storage-daemon-cli build/crypto/fift build/crypto/tlbc build/crypto/func build/crypto/create-state build/validator-engine-console/validator-engine-console build/tonlib/tonlib-cli build/tonlib/libtonlibjson.so.0.5 build/http/http-proxy build/rldp-http-proxy/rldp-http-proxy build/dht-server/dht-server build/lite-client/lite-client build/validator-engine/validator-engine build/utils/generate-random-id build/utils/json2tlo build/adnl/adnl-proxy build/emulator/libemulator.*
-
- - name: Run tests
- run: |
- cd build
- ctest --output-on-failure -E "test-catchain|test-actors"
-
- - name: Find & copy binaries
- run: |
- mkdir artifacts
- cp build/storage/storage-daemon/storage-daemon build/storage/storage-daemon/storage-daemon-cli build/crypto/fift build/crypto/tlbc build/crypto/func build/crypto/create-state build/validator-engine-console/validator-engine-console build/tonlib/tonlib-cli build/tonlib/libtonlibjson.so.0.5 build/http/http-proxy build/rldp-http-proxy/rldp-http-proxy build/dht-server/dht-server build/lite-client/lite-client build/validator-engine/validator-engine build/utils/generate-random-id build/utils/json2tlo build/adnl/adnl-proxy build/emulator/libemulator.* artifacts
- 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
diff --git a/.github/workflows/ubuntu-compile.yml b/.github/workflows/ubuntu-compile.yml
deleted file mode 100644
index 3c1e7bad..00000000
--- a/.github/workflows/ubuntu-compile.yml
+++ /dev/null
@@ -1,81 +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_3
- cd openssl_3
- git checkout openssl-3.1.4
- ./config
- make build_libs -j4
-
- cd ..
- rootPath=`pwd`
-
- cmake -GNinja -DOPENSSL_FOUND=1 -DOPENSSL_INCLUDE_DIR=$rootPath/openssl_3/include -DOPENSSL_CRYPTO_LIBRARY=$rootPath/openssl_3/libcrypto.a -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 -DTON_ARCH= ..
- ninja storage-daemon storage-daemon-cli fift func tonlib tonlibjson tonlib-cli validator-engine lite-client \
- pow-miner validator-engine-console generate-random-id json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy \
- create-state create-hardfork emulator \
- test-ed25519 test-ed25519-crypto test-bigint test-vm test-fift test-cells test-smartcont test-net test-tdactor \
- test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain test-fec test-tddb test-db test-validator-session-state
-
- - name: Strip binaries
- run: |
- strip -g build-${{ matrix.os }}/storage/storage-daemon/storage-daemon build-${{ matrix.os }}/storage/storage-daemon/storage-daemon-cli build-${{ matrix.os }}/crypto/fift build-${{ matrix.os }}/crypto/tlbc build-${{ matrix.os }}/crypto/func build-${{ matrix.os }}/crypto/create-state build-${{ matrix.os }}/validator-engine-console/validator-engine-console build-${{ matrix.os }}/tonlib/tonlib-cli build-${{ matrix.os }}/tonlib/libtonlibjson.so.0.5 build-${{ matrix.os }}/http/http-proxy build-${{ matrix.os }}/rldp-http-proxy/rldp-http-proxy build-${{ matrix.os }}/dht-server/dht-server build-${{ matrix.os }}/lite-client/lite-client build-${{ matrix.os }}/validator-engine/validator-engine build-${{ matrix.os }}/utils/generate-random-id build-${{ matrix.os }}/utils/json2tlo build-${{ matrix.os }}/adnl/adnl-proxy build-${{ matrix.os }}/emulator/libemulator.*
-
- - name: Run tests
- run: |
- cd build-${{ matrix.os }}
- ctest --output-on-failure -E "test-catchain|test-actors"
-
- - name: Find & copy binaries
- run: |
- 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.* 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 }}
diff --git a/.github/workflows/win-2019-compile.yml b/.github/workflows/win-2019-compile.yml
deleted file mode 100644
index e94655f7..00000000
--- a/.github/workflows/win-2019-compile.yml
+++ /dev/null
@@ -1,108 +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 3 Win64
- run: |
- curl -Lo openssl-3.1.4.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/openssl-3.1.4.zip
- unzip openssl-3.1.4.zip
-
- - name: Install pre-compiled libmicrohttpd Win64
- run: |
- 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 -DSODIUM_USE_STATIC_LIBS=1 -DSECP256K1_INCLUDE_DIR=%root%\secp256k1\include -DSECP256K1_LIBRARY=%root%\secp256k1\bin\x64\Release\v142\static\secp256k1.lib -DREADLINE_INCLUDE_DIR=%root%\readline-5.0-1-lib\include\readline -DREADLINE_LIBRARY=%root%\readline-5.0-1-lib\lib\readline.lib -DPORTABLE=1 -DZLIB_FOUND=1 -DMHD_FOUND=1 -DMHD_LIBRARY=%root%\libmicrohttpd-0.9.77-w32-bin\x86_64\VS2019\Release-static\libmicrohttpd.lib -DMHD_INCLUDE_DIR=%root%\libmicrohttpd-0.9.77-w32-bin\x86_64\VS2019\Release-static -DZLIB_INCLUDE_DIR=%root%\zlib -DZLIB_LIBRARY=%root%\zlib\contrib\vstudio\vc14\x64\ZlibStatReleaseWithoutAsm\zlibstat.lib -DOPENSSL_FOUND=1 -DOPENSSL_INCLUDE_DIR=%root%/openssl-3.1.4/x64/include -DOPENSSL_CRYPTO_LIBRARY=%root%/openssl-3.1.4/x64/lib/libcrypto_static.lib -DCMAKE_CXX_FLAGS="/DTD_WINDOWS=1 /EHsc /bigobj /W0" ..
- cmake --build . --config Release --target storage-daemon storage-daemon-cli blockchain-explorer fift func tonlib tonlibjson tonlib-cli validator-engine lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork emulator test-ed25519 test-ed25519-crypto test-bigint test-vm test-fift test-cells test-smartcont test-net test-tdactor test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain test-fec test-tddb test-db test-validator-session-state
-
- - name: Run tests
- run: |
- cd build
- ctest -C Release --output-on-failure -E "test-catchain|test-actors|test-validator-session-state"
-
- - name: Show executables
- run: |
- 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) 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
-
- - name: Upload artifacts
- uses: actions/upload-artifact@master
- with:
- name: ton-win-binaries
- path: artifacts
diff --git a/.gitignore b/.gitignore
index 54d9ffc7..e5bb366c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,4 +12,15 @@ test/regression-tests.cache/
*.swp
**/*build*/
.idea
-.vscode
\ No newline at end of file
+.vscode
+.DS_Store
+dev/
+zlib/
+libsodium/
+libmicrohttpd-0.9.77-w32-bin/
+readline-5.0-1-lib/
+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
diff --git a/.gitmodules b/.gitmodules
index f201ed73..325e3f4e 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -13,3 +13,7 @@
[submodule "third-party/blst"]
path = third-party/blst
url = https://github.com/supranational/blst.git
+[submodule "third-party/secp256k1"]
+ path = third-party/secp256k1
+ url = https://github.com/bitcoin-core/secp256k1
+ branch = v0.3.2
diff --git a/CMake/BuildSECP256K1.cmake b/CMake/BuildSECP256K1.cmake
new file mode 100644
index 00000000..f8b3c8ca
--- /dev/null
+++ b/CMake/BuildSECP256K1.cmake
@@ -0,0 +1,55 @@
+if (NOT SECP256K1_LIBRARY)
+
+ set(SECP256K1_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third-party/secp256k1)
+ set(SECP256K1_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/third-party/secp256k1)
+ set(SECP256K1_INCLUDE_DIR ${SECP256K1_BINARY_DIR}/include)
+
+ file(MAKE_DIRECTORY ${SECP256K1_BINARY_DIR})
+ file(MAKE_DIRECTORY "${SECP256K1_BINARY_DIR}/include")
+
+ if (MSVC)
+ set(SECP256K1_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third-party/secp256k1)
+ set(SECP256K1_LIBRARY ${SECP256K1_SOURCE_DIR}/build/src/Release/libsecp256k1.lib)
+ set(SECP256K1_INCLUDE_DIR ${SECP256K1_BINARY_DIR}/include)
+ add_custom_command(
+ WORKING_DIRECTORY ${SECP256K1_SOURCE_DIR}
+ COMMAND cmake -E env CFLAGS="/WX" cmake -A x64 -B build -DSECP256K1_ENABLE_MODULE_RECOVERY=ON -DSECP256K1_ENABLE_MODULE_EXTRAKEYS=ON -DSECP256K1_BUILD_EXAMPLES=OFF -DBUILD_SHARED_LIBS=OFF
+ COMMAND cmake --build build --config Release
+ COMMENT "Build Secp256k1"
+ DEPENDS ${SECP256K1_SOURCE_DIR}
+ OUTPUT ${SECP256K1_LIBRARY}
+ )
+ elseif (EMSCRIPTEN)
+ set(SECP256K1_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third-party/secp256k1)
+ set(SECP256K1_LIBRARY ${SECP256K1_BINARY_DIR}/.libs/libsecp256k1.a)
+ set(SECP256K1_INCLUDE_DIR ${SECP256K1_SOURCE_DIR}/include)
+ add_custom_command(
+ WORKING_DIRECTORY ${SECP256K1_SOURCE_DIR}
+ COMMAND ./autogen.sh
+ COMMAND emconfigure ./configure --enable-module-recovery --enable-module-extrakeys --disable-tests --disable-benchmark
+ COMMAND emmake make clean
+ COMMAND emmake make
+ COMMENT "Build Secp256k1 with emscripten"
+ DEPENDS ${SECP256K1_SOURCE_DIR}
+ OUTPUT ${SECP256K1_LIBRARY}
+ )
+ else()
+ if (NOT NIX)
+ set(SECP256K1_LIBRARY ${SECP256K1_BINARY_DIR}/lib/libsecp256k1.a)
+ add_custom_command(
+ WORKING_DIRECTORY ${SECP256K1_SOURCE_DIR}
+ COMMAND ./autogen.sh
+ COMMAND ./configure -q --disable-option-checking --enable-module-recovery --enable-module-extrakeys --prefix ${SECP256K1_BINARY_DIR} --with-pic --disable-shared --enable-static --disable-tests --disable-benchmark
+ COMMAND make -j16
+ COMMAND make install
+ COMMENT "Build secp256k1"
+ DEPENDS ${SECP256K1_SOURCE_DIR}
+ OUTPUT ${SECP256K1_LIBRARY}
+ )
+ endif()
+ endif()
+else()
+ message(STATUS "Use Secp256k1: ${SECP256K1_LIBRARY}")
+endif()
+
+add_custom_target(secp256k1 DEPENDS ${SECP256K1_LIBRARY})
diff --git a/CMake/FindMHD.cmake b/CMake/FindMHD.cmake
index c4b94c0e..7d6dd5fd 100644
--- a/CMake/FindMHD.cmake
+++ b/CMake/FindMHD.cmake
@@ -2,23 +2,26 @@
# Once done this will define
#
# 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
-find_path(
- MHD_INCLUDE_DIR
- NAMES microhttpd.h
- DOC "microhttpd include dir"
-)
+if (NOT MHD_LIBRARY)
+ find_path(
+ MHD_INCLUDE_DIR
+ NAMES microhttpd.h
+ DOC "microhttpd include dir"
+ )
-find_library(
- MHD_LIBRARY
- NAMES microhttpd microhttpd-10 libmicrohttpd libmicrohttpd-dll
- DOC "microhttpd library"
-)
+ find_library(
+ MHD_LIBRARY
+ NAMES microhttpd microhttpd-10 libmicrohttpd libmicrohttpd-dll
+ DOC "microhttpd library"
+ )
+endif()
-set(MHD_INCLUDE_DIRS ${MHD_INCLUDE_DIR})
-set(MHD_LIBRARIES ${MHD_LIBRARY})
+if (MHD_LIBRARY)
+ message(STATUS "Found MHD: ${MHD_LIBRARY}")
+endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MHD DEFAULT_MSG MHD_INCLUDE_DIR MHD_LIBRARY)
diff --git a/CMake/FindSecp256k1.cmake b/CMake/FindSecp256k1.cmake
index 11603f15..1f776796 100644
--- a/CMake/FindSecp256k1.cmake
+++ b/CMake/FindSecp256k1.cmake
@@ -1,29 +1,27 @@
-# - Try to find SECP256K1
+# - Try to find Secp256k1
# Once done this will define
#
-# SECP256K1_FOUND - system has SECP256K1
-# SECP256K1_INCLUDE_DIRS - the SECP256K1 include directory
-# SECP256K1_LIBRARY - Link these to use SECP256K1
+# SECP256K1_INCLUDE_DIR - the Secp256k1 include directory
+# SECP256K1_LIBRARY - Link these to use Secp256k1
-find_path(
- SECP256K1_INCLUDE_DIR
- NAMES secp256k1_recovery.h
- DOC "secp256k1_recovery.h include dir"
-)
+if (NOT SECP256K1_LIBRARY)
+ find_path(
+ SECP256K1_INCLUDE_DIR
+ NAMES secp256k1_recovery.h
+ DOC "secp256k1_recovery.h include dir"
+ )
-find_library(
- SECP256K1_LIBRARY
- NAMES secp256k1 libsecp256k1
- DOC "secp256k1 library"
-)
+ find_library(
+ SECP256K1_LIBRARY
+ NAMES secp256k1 libsecp256k1
+ DOC "secp256k1 library"
+ )
+endif()
if (SECP256K1_LIBRARY)
message(STATUS "Found Secp256k1: ${SECP256K1_LIBRARY}")
endif()
-set(SECP256K1_INCLUDE_DIRS ${SECP256K1_INCLUDE_DIR})
-set(SECP256K1_LIBRARIES ${SECP256K1_LIBRARY})
-
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Secp256k1 DEFAULT_MSG SECP256K1_INCLUDE_DIR SECP256K1_LIBRARY)
mark_as_advanced(SECP256K1_INCLUDE_DIR SECP256K1_LIBRARY)
diff --git a/CMake/FindSodium.cmake b/CMake/FindSodium.cmake
index 0053ac54..3818ef89 100644
--- a/CMake/FindSodium.cmake
+++ b/CMake/FindSodium.cmake
@@ -26,6 +26,7 @@
# Furthermore an imported "sodium" target is created.
#
+
if (CMAKE_C_COMPILER_ID STREQUAL "GNU"
OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(_GCC_COMPATIBLE 1)
@@ -36,12 +37,14 @@ if (NOT DEFINED SODIUM_USE_STATIC_LIBS)
option(SODIUM_USE_STATIC_LIBS "enable to statically link against sodium" OFF)
endif()
if(NOT (SODIUM_USE_STATIC_LIBS EQUAL SODIUM_USE_STATIC_LIBS_LAST))
- unset(sodium_LIBRARY CACHE)
- unset(SODIUM_LIBRARY_DEBUG CACHE)
- unset(SODIUM_LIBRARY_RELEASE CACHE)
- unset(sodium_DLL_DEBUG CACHE)
- unset(sodium_DLL_RELEASE CACHE)
- set(SODIUM_USE_STATIC_LIBS_LAST ${SODIUM_USE_STATIC_LIBS} CACHE INTERNAL "internal change tracking variable")
+ if (NOT SODIUM_LIBRARY_RELEASE)
+ unset(sodium_LIBRARY CACHE)
+ unset(SODIUM_LIBRARY_DEBUG CACHE)
+ unset(SODIUM_LIBRARY_RELEASE CACHE)
+ unset(sodium_DLL_DEBUG CACHE)
+ unset(sodium_DLL_RELEASE CACHE)
+ set(SODIUM_USE_STATIC_LIBS_LAST ${SODIUM_USE_STATIC_LIBS} CACHE INTERNAL "internal change tracking variable")
+ endif()
endif()
@@ -124,10 +127,16 @@ elseif (WIN32)
endif()
string(APPEND _PLATFORM_PATH "/$$CONFIG$$")
+ message(STATUS "MSVC_VERSION ${MSVC_VERSION}")
if (MSVC_VERSION LESS 1900)
math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 60")
else()
- math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 50")
+ if (MSVC_VERSION EQUAL 1941)
+ math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 51")
+ else()
+ math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 50")
+ endif()
+
endif()
string(APPEND _PLATFORM_PATH "/v${_VS_VERSION}")
@@ -294,4 +303,4 @@ else()
)
endif()
endif()
-endif()
\ No newline at end of file
+endif()
diff --git a/CMake/FindJeMalloc.cmake b/CMake/Findjemalloc.cmake
similarity index 100%
rename from CMake/FindJeMalloc.cmake
rename to CMake/Findjemalloc.cmake
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c6d7ed87..cea3fc7e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -79,11 +79,12 @@ else()
set(HAVE_SSE42 FALSE)
endif()
-set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS FALSE)
#BEGIN internal
+option(BUILD_SHARED_LIBS "Use \"ON\" to build shared libraries instead of static where it's not specified (not recommended)" OFF)
option(USE_EMSCRIPTEN "Use \"ON\" for config building wasm." OFF)
option(TON_ONLY_TONLIB "Use \"ON\" to build only tonlib." OFF)
if (USE_EMSCRIPTEN)
@@ -183,6 +184,7 @@ message("Add ton")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
include(BuildBLST)
+include(BuildSECP256K1)
# Configure CCache if available
find_program(CCACHE_FOUND ccache)
@@ -211,7 +213,13 @@ set(CMAKE_THREAD_PREFER_PTHREAD ON)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads 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)
CHECK_CXX_COMPILER_FLAG( "-march=${TON_ARCH}" COMPILER_OPT_ARCH_SUPPORTED )
@@ -228,9 +236,14 @@ if (THREADS_HAVE_PTHREAD_ARG)
endif()
if (TON_USE_JEMALLOC)
- find_package(JeMalloc REQUIRED)
+ find_package(jemalloc REQUIRED)
endif()
+if (NIX)
+ find_package(Secp256k1 REQUIRED)
+endif()
+
+
set(MEMPROF "" CACHE STRING "Use one of \"ON\", \"FAST\" or \"SAFE\" to enable memory profiling. \
Works under macOS and Linux when compiled using glibc. \
In FAST mode stack is unwinded only using frame pointers, which may fail. \
@@ -327,6 +340,10 @@ add_cxx_compiler_flag("-Wno-sign-conversion")
add_cxx_compiler_flag("-Qunused-arguments")
add_cxx_compiler_flag("-Wno-unused-private-field")
add_cxx_compiler_flag("-Wno-redundant-move")
+
+#add_cxx_compiler_flag("-Wno-unused-function")
+#add_cxx_compiler_flag("-Wno-unused-variable")
+#add_cxx_compiler_flag("-Wno-shorten-64-to-32")
#add_cxx_compiler_flag("-Werror")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem /usr/include/c++/v1")
@@ -371,6 +388,9 @@ if (LATEX_FOUND)
add_latex_document(doc/fiftbase.tex TARGET_NAME fift_basic_description)
add_latex_document(doc/catchain.tex TARGET_NAME catchain_consensus_description)
endif()
+if (NOT LATEX_FOUND)
+ message(STATUS "Could NOT find LATEX (this is NOT an error)")
+endif()
#END internal
function(target_link_libraries_system target)
@@ -400,6 +420,7 @@ add_subdirectory(adnl)
add_subdirectory(crypto)
add_subdirectory(lite-client)
add_subdirectory(emulator)
+add_subdirectory(tolk)
#BEGIN tonlib
add_subdirectory(tonlib)
@@ -475,10 +496,10 @@ target_link_libraries(test-net PRIVATE tdnet tdutils ${CMAKE_THREAD_LIBS_INIT})
#BEGIN tonlib
add_executable(test-tonlib ${TONLIB_ONLINE_TEST_SOURCE})
-target_link_libraries(test-tonlib tdutils tdactor adnllite tl_api ton_crypto ton_block tl_tonlib_api tonlib)
+target_link_libraries(test-tonlib tdactor adnllite tl_api ton_crypto tl_tonlib_api tonlib)
add_executable(test-tonlib-offline test/test-td-main.cpp ${TONLIB_OFFLINE_TEST_SOURCE})
-target_link_libraries(test-tonlib-offline tdutils tdactor adnllite tl_api ton_crypto ton_block fift-lib tl_tonlib_api tonlib)
+target_link_libraries(test-tonlib-offline tdactor adnllite tl_api ton_crypto fift-lib tl_tonlib_api tonlib)
if (NOT CMAKE_CROSSCOMPILING)
add_dependencies(test-tonlib-offline gen_fif)
@@ -520,6 +541,8 @@ target_link_libraries(test-rldp2 adnl adnltest dht rldp2 tl_api)
add_executable(test-validator-session-state test/test-validator-session-state.cpp)
target_link_libraries(test-validator-session-state adnl dht rldp validatorsession tl_api)
+add_executable(test-overlay test/test-overlay.cpp)
+target_link_libraries(test-overlay overlay tdutils tdactor adnl adnltest tl_api dht )
add_executable(test-catchain test/test-catchain.cpp)
target_link_libraries(test-catchain overlay tdutils tdactor adnl adnltest rldp tl_api dht
catchain )
@@ -530,6 +553,9 @@ target_link_libraries(test-ton-collator overlay tdutils tdactor adnl tl_api dht
add_executable(test-http test/test-http.cpp)
target_link_libraries(test-http PRIVATE tonhttp)
+add_executable(test-emulator test/test-td-main.cpp emulator/test/emulator-tests.cpp)
+target_link_libraries(test-emulator PRIVATE emulator)
+
get_directory_property(HAS_PARENT PARENT_DIRECTORY)
if (HAS_PARENT)
set(ALL_TEST_SOURCE
@@ -561,6 +587,7 @@ add_test(test-cells test-cells ${TEST_OPTIONS})
add_test(test-smartcont test-smartcont)
add_test(test-net test-net)
add_test(test-actors test-tdactor)
+add_test(test-emulator test-emulator)
#BEGIN tonlib
add_test(test-tdutils test-tdutils)
@@ -580,8 +607,8 @@ if (NOT NIX)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/crypto/func/auto-tests)
if (WIN32)
set_property(TEST test-func PROPERTY ENVIRONMENT
- "FUNC_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/crypto/Release/func.exe"
- "FIFT_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/crypto/Release/fift.exe"
+ "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
@@ -596,8 +623,8 @@ if (NOT NIX)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/crypto/func/auto-tests)
if (WIN32)
set_property(TEST test-func-legacy PROPERTY ENVIRONMENT
- "FUNC_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/crypto/Release/func.exe"
- "FIFT_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/crypto/Release/fift.exe"
+ "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
@@ -607,6 +634,30 @@ if (NOT NIX)
endif()
endif()
+# Tolk tests
+if (NOT NIX)
+ if (MSVC)
+ set(PYTHON_VER "python")
+ else()
+ set(PYTHON_VER "python3")
+ endif()
+ add_test(
+ NAME test-tolk
+ COMMAND ${PYTHON_VER} tolk-tester.py tests/
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tolk-tester)
+ if (WIN32)
+ set_property(TEST test-tolk PROPERTY ENVIRONMENT
+ "TOLK_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/tolk/tolk.exe"
+ "FIFT_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/crypto/fift.exe"
+ "FIFTPATH=${CMAKE_CURRENT_SOURCE_DIR}/crypto/fift/lib/")
+ else()
+ set_property(TEST test-tolk PROPERTY ENVIRONMENT
+ "TOLK_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/tolk/tolk"
+ "FIFT_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/crypto/fift"
+ "FIFTPATH=${CMAKE_CURRENT_SOURCE_DIR}/crypto/fift/lib/")
+ endif()
+endif()
+
#BEGIN internal
if (NOT TON_ONLY_TONLIB)
add_test(test-adnl test-adnl)
diff --git a/Changelog.md b/Changelog.md
index 440866c2..4dce39fc 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,4 +1,155 @@
-##2023.11 Update
+## 2025.03 Update
+1. New extracurrency behavior introduced, check [GlobalVersions.md](./doc/GlobalVersions.md#version-10)
+2. Optmization of validation process, in particular CellStorageStat.
+3. Flag for speeding up broadcasts in various overlays.
+4. Fixes for static builds for emulator and tonlibjson
+5. Improving getstats output: adds
+ * Liteserver queries count
+ * Collated/validated blocks count, number of active sessions
+ * Persistent state sizes
+ * Initial sync progress
+6. Fixes in logging, TON Storage, external message checking, persistent state downloading, UB in tonlib
+
+Besides the work of the core team, this update is based on the efforts of @Sild from StonFi(UB in tonlib).
+
+## 2025.02 Update
+1. Series of improvement/fixes for `Config8.version >= 9`, check [GlobalVersions.md](./doc/GlobalVersions.md)
+2. Fix for better discovery of updated nodes' (validators') IPs: retry dht queries
+3. Series of improvements for extra currency adoption: fixed c7 in rungetmethod, reserve modes
+4. TVM: Fix processing continuation control data on deep jump
+5. A few fixes of tl-b schemes: crc computation, incorrect tag for merkle proofs, advance_ext, NatWidth print
+6. Emulator improvements: fix setting libraries, extracurrency support
+7. Increase of gas limit for unlocking highload-v2 wallets locked in the beginning of 2024
+8. Validator console improvement: dashed names, better shard formats
+
+
+Besides the work of the core team, this update is based on the efforts of @dbaranovstonfi from StonFi(libraries in emulator), @Rexagon (ret on deep jumps), @tvorogme from DTon (`advance_ext`), Nan from Zellic (`stk_und` and JNI)
+
+## 2024.12 Update
+
+1. FunC 0.4.6: Fix in try/catch handling, fixing pure flag for functions stored in variables
+2. Merging parts of Accelerator: support of specific shard monitoring, archive/liteserver slice format, support for partial liteservers, proxy liteserver, on-demand neighbour queue loading
+3. Fix of asynchronous cell loading
+4. Various improvements: caching certificates checks, better block overloading detection, `_malloc` in emulator
+5. Introduction of telemetry in overlays
+6. Use non-null local-id for tonlib-LS interaction - mitigates MitM attack.
+7. Adding `SECP256K1_XONLY_PUBKEY_TWEAK_ADD`, `SETCONTCTRMANY` instructions to TVM (activated by `Config8.version >= 9`)
+8. Private keys export via validator-engine-console - required for better backups
+9. Fix proof checking in tonlib, `hash` in `raw.Message` in tonlib_api
+
+Besides the work of the core team, this update is based on the efforts of OtterSec and LayerZero (FunC), tg:@throwunless (FunC), Aviv Frenkel and Dima Kogan from Fordefi (LS MitM), @hacker-volodya (Tonlib), OKX team (async cell loading), @krigga (emulator)
+
+## 2024.10 Update
+
+1. Parallel write to celldb: substantial improvement of sync and GC speed, especially with slow disks.
+2. Decreased network traffic: only first block candidate is sent optimistically.
+3. Improved channel creation and dht lookups, introduction of semi-private overlays
+4. New LS dispatch queue related methods and improvement security
+5. Fixing recursion in TVM continuations
+6. Improved stats for actors, validator sessions, perf counters, overlays, adnl, rocksdb
+7. Migration to C++20
+8. Improved block size estimates: account for depth in various structures
+9. Fix bug with `<<` optimization in FunC
+10. Minor changes of TVM which will be activated by `Config8.version >= 9`
+11. Multiple minor improvements
+
+Besides the work of the core team, this update is based on the efforts of @krigga (emulator), Arayz @ TonBit (LS security, TVM recursion), @ret2happy (UB in BLST).
+
+## 2024.08 Update
+
+1. Introduction of dispatch queues, message envelopes with transaction chain metadata, and explicitly stored msg_queue size, which will be activated by `Config8.version >= 8` and new `Config8.capabilities` bits: `capStoreOutMsgQueueSize`, `capMsgMetadata`, `capDeferMessages`.
+2. A number of changes to transaction executor which will activated for `Config8.version >= 8`:
+ - Check mode on invalid `action_send_msg`. Ignore action if `IGNORE_ERROR` (+2) bit is set, bounce if `BOUNCE_ON_FAIL` (+16) bit is set.
+ - Slightly change random seed generation to fix mix of `addr_rewrite` and `addr`.
+ - Fill in `skipped_actions` for both invalid and valid messages with `IGNORE_ERROR` mode that can't be sent.
+ - Allow unfreeze through external messages.
+ - Don't use user-provided `fwd_fee` and `ihr_fee` for internal messages.
+3. A few issues with broadcasts were fixed: stop on receiving last piece, response to AdnlMessageCreateChannel
+4. A number of fixes and improvements for emulator and tonlib: correct work with config_addr, not accepted externals, bounces, debug ops gas consumption, added version and c5 dump, fixed tonlib crashes
+5. Added new flags and commands to the node, in particular `--fast-state-serializer`, `getcollatoroptionsjson`, `setcollatoroptionsjson`
+
+Besides the work of the core team, this update is based on the efforts of @krigga (emulator), stonfi team, in particular @dbaranovstonfi and @hey-researcher (emulator), and @loeul, @xiaoxianBoy, @simlecode (typos in comments and docs).
+
+
+
+## 2024.06 Update
+
+1. Make Jemalloc default allocator
+2. Add candidate broadcasting and caching
+3. Limit per address speed for external messages broadcast by reasonably large number
+4. Overlay improvements: fix dropping peers in small custom overlays, fix wrong certificate on missed keyblocks
+5. Extended statistics and logs for celldb usage, session stats, persistent state serialization
+6. Tonlib and explorer fixes
+7. Flags for precize control of Celldb: `--celldb-cache-size`, `--celldb-direct-io` and `--celldb-preload-all`
+8. Add valiator-console command to stop persistent state serialization
+9. Use `@` path separator for defining include path in fift and create-state utilities on Windows only.
+
+
+## 2024.04 Update
+
+1. Emulator: Single call optimized runGetMethod added
+2. Tonlib: a series of proof improvements, also breaking Change in `liteServer.getAllShardsInfo` method (see below)
+3. DB: usage statistics now collected, outdated persistent states are not serialized
+4. LS: fast `getOutMsgQueueSizes` added, preliminary support of non-final block requests
+5. Network: lz4 compression of block candidates (disabled by default).
+6. Overlays: add custom overlays
+7. Transaction Executor: fixed issue with due_payment collection
+
+* `liteServer.getAllShardsInfo` method was updated for better efficiency. Previously, field proof contained BoC with two roots: one for BlockState from block's root and another for ShardHashes from BlockState. Now, it returns a single-root proof BoC, specifically the merkle proof of ShardHashes directly from the block's root, streamlining data access and integrity. Checking of the proof requires to check that ShardHashes in the `data` correspond to ShardHashes from the block.
+
+Besides the work of the core team, this update is based on the efforts of @akifoq (due_payment issue).
+
+## 2024.03 Update
+
+1. Preparatory (not enabled yet) code for pre-compiled smart-contract.
+2. Minor fixes for fee-related opcodes.
+
+## 2024.02 Update
+
+1. Improvement of validator synchronisation:
+ * Better handling of block broadcasts -> faster sync
+ * Additional separate overlay among validators as second option for synchronisation
+2. Improvements in LS:
+ * c7 and library context is fully filled up for server-side rungetmethod
+ * Cache for runmethods and successfull external messages
+ * Logging of LS requests statistic
+3. Precise control of open files:
+ * almost instantaneous validator start
+ * `--max-archive-fd` option
+ * autoremoval of not used temp archive files
+ * `--archive-preload-period` option
+4. Preparatory (not enabled yet) code for addition on new TVM instructions for cheaper fee calculation onchain.
+
+## 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 amendment, 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 / consecutive 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
@@ -82,7 +233,7 @@ Besides the work of the core team, this update is based on the efforts of @vtama
Besides the work of the core team, this update is based on the efforts of @tvorogme (debug improvements), @AlexeyFSL (WASM builds) and third-party security auditors.
## 2022.08 Update
-* Blockchain state serialization now works via separate db-handler which simplfies memory clearing after serialization
+* Blockchain state serialization now works via separate db-handler which simplifies memory clearing after serialization
* CellDB now works asynchronously which substantially increase database access throughput
* Abseil-cpp and crc32 updated: solve issues with compilation on recent OS distributives
* Fixed a series of UBs and issues for exotic endianness hosts
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..f1b836bf
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,69 @@
+FROM ubuntu:22.04 AS builder
+ARG DEBIAN_FRONTEND=noninteractive
+RUN apt-get update && \
+ rm /var/lib/dpkg/info/libc-bin.* && \
+ apt-get clean && \
+ apt-get update && \
+ apt install libc-bin && \
+ apt-get install -y build-essential cmake clang openssl libssl-dev zlib1g-dev gperf wget git \
+ ninja-build libsodium-dev libmicrohttpd-dev liblz4-dev pkg-config autoconf automake libtool \
+ libjemalloc-dev lsb-release software-properties-common gnupg
+
+RUN wget https://apt.llvm.org/llvm.sh && \
+ chmod +x llvm.sh && \
+ ./llvm.sh 16 all && \
+ rm -rf /var/lib/apt/lists/*
+
+ENV CC=/usr/bin/clang-16
+ENV CXX=/usr/bin/clang++-16
+ENV CCACHE_DISABLE=1
+
+WORKDIR /
+RUN mkdir ton
+WORKDIR /ton
+
+COPY ./ ./
+
+RUN mkdir build && \
+ cd build && \
+ cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 -DTON_ARCH= -DTON_USE_JEMALLOC=ON .. && \
+ ninja storage-daemon storage-daemon-cli tonlibjson fift func validator-engine validator-engine-console \
+ generate-random-id dht-server lite-client tolk rldp-http-proxy dht-server proxy-liteserver create-state \
+ blockchain-explorer emulator tonlibjson http-proxy adnl-proxy
+
+FROM ubuntu:22.04
+ARG DEBIAN_FRONTEND=noninteractive
+RUN apt-get update && \
+ apt-get install -y wget curl libatomic1 openssl libsodium-dev libmicrohttpd-dev liblz4-dev libjemalloc-dev htop \
+ net-tools netcat iptraf-ng jq tcpdump pv plzip && \
+ rm -rf /var/lib/apt/lists/*
+
+RUN mkdir -p /var/ton-work/db /var/ton-work/scripts /usr/share/ton/smartcont/auto /usr/lib/fift/
+
+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/lite-client/lite-client /usr/local/bin/
+COPY --from=builder /ton/build/validator-engine/validator-engine /usr/local/bin/
+COPY --from=builder /ton/build/validator-engine-console/validator-engine-console /usr/local/bin/
+COPY --from=builder /ton/build/utils/generate-random-id /usr/local/bin/
+COPY --from=builder /ton/build/blockchain-explorer/blockchain-explorer /usr/local/bin/
+COPY --from=builder /ton/build/crypto/create-state /usr/local/bin/
+COPY --from=builder /ton/build/utils/proxy-liteserver /usr/local/bin/
+COPY --from=builder /ton/build/dht-server/dht-server /usr/local/bin/
+COPY --from=builder /ton/build/rldp-http-proxy/rldp-http-proxy /usr/local/bin/
+COPY --from=builder /ton/build/http/http-proxy /usr/local/bin/
+COPY --from=builder /ton/build/adnl/adnl-proxy /usr/local/bin/
+COPY --from=builder /ton/build/tonlib/libtonlibjson.so /usr/local/bin/
+COPY --from=builder /ton/build/emulator/libemulator.so /usr/local/bin/
+COPY --from=builder /ton/build/tolk/tolk /usr/local/bin/
+COPY --from=builder /ton/build/crypto/fift /usr/local/bin/
+COPY --from=builder /ton/build/crypto/func /usr/local/bin/
+COPY --from=builder /ton/crypto/smartcont/* /usr/share/ton/smartcont/
+COPY --from=builder /ton/crypto/smartcont/auto/* /usr/share/ton/smartcont/auto/
+COPY --from=builder /ton/crypto/fift/lib/* /usr/lib/fift/
+
+WORKDIR /var/ton-work/db
+COPY ./docker/init.sh ./docker/control.template /var/ton-work/scripts/
+RUN chmod +x /var/ton-work/scripts/init.sh
+
+ENTRYPOINT ["/var/ton-work/scripts/init.sh"]
diff --git a/README.md b/README.md
index 7e78bb04..897ba809 100644
--- a/README.md
+++ b/README.md
@@ -10,25 +10,33 @@
##
-[![TON Overflow Group][ton-overflow-badge]][ton-overflow-url]
-[![Stack Overflow Group][stack-overflow-badge]][stack-overflow-url]
-[![Telegram Community Chat][telegram-tondev-badge]][telegram-tondev-url]
-[![Telegram Community Group][telegram-community-badge]][telegram-community-url]
-[![Telegram Foundation Group][telegram-foundation-badge]][telegram-foundation-url]
-[![Twitter Group][twitter-badge]][twitter-url]
-[telegram-foundation-badge]: https://img.shields.io/badge/TON%20Foundation-2CA5E0?logo=telegram&logoColor=white&style=flat
-[telegram-community-badge]: https://img.shields.io/badge/TON%20Community-2CA5E0?logo=telegram&logoColor=white&style=flat
-[telegram-tondev-badge]: https://img.shields.io/badge/chat-TONDev-2CA5E0?logo=telegram&logoColor=white&style=flat
-[telegram-foundation-url]: https://t.me/tonblockchain
-[telegram-community-url]: https://t.me/toncoin
-[telegram-tondev-url]: https://t.me/tondev_eng
-[twitter-badge]: https://img.shields.io/twitter/follow/ton_blockchain
-[twitter-url]: https://twitter.com/ton_blockchain
-[stack-overflow-badge]: https://img.shields.io/badge/-Stack%20Overflow-FE7A16?style=flat&logo=stack-overflow&logoColor=white
-[stack-overflow-url]: https://stackoverflow.com/questions/tagged/ton
-[ton-overflow-badge]: https://img.shields.io/badge/-TON%20Overflow-FE7A16?style=flat&logo=stack-overflow&logoColor=white
-[ton-overflow-url]: https://answers.ton.org
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -39,11 +47,11 @@ Main TON monorepo, which includes the code of the node/validator, lite-client, t
__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](https://ton.org/docs)
- To run node, validator or lite-server check [Participate section](https://ton.org/docs/participate/nodes/run-node)
-- To develop decentralised apps check [Tutorials](https://ton.org/docs/develop/smart-contracts/), [FunC docs](https://ton.org/docs/develop/func/overview) and [DApp tutorials](https://ton.org/docs/develop/dapps/)
+- To develop decentralised apps check [Tutorials](https://docs.ton.org/v3/guidelines/smart-contracts/guidelines), [FunC docs](https://ton.org/docs/develop/func/overview) and [DApp tutorials](https://docs.ton.org/v3/guidelines/dapps/overview)
- 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://docs.ton.org/v3/guidelines/dapps/apis-sdks/overview)
-## Updates flow:
+## Updates flow
* **master branch** - mainnet is running on this stable branch.
@@ -61,13 +69,83 @@ 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 make sure that workflows are cleanly completed for your PR before considering merge
-## Workflows responsibility
-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:
+## Build TON blockchain
-* **C/C++ CI (ccpp-linux.yml)**: TBD
-* **C/C++ CI Win64 Compile (ccpp-win64.yml)**: TBD
+### Ubuntu 20.4, 22.04, 24.04 (x86-64, aarch64)
+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
+```
+
+### TON portable binaries
+
+Linux portable binaries are wrapped into AppImages, at the same time MacOS portable binaries are statically linked executables.
+Linux and MacOS binaries are available for both x86-64 and arm64 architectures.
## Running tests
-Tests are executed by running `ctest` in the build directory. See `doc/Tests.md` for more information.
\ No newline at end of file
+Tests are executed by running `ctest` in the build directory. See `doc/Tests.md` for more information.
diff --git a/adnl/CMakeLists.txt b/adnl/CMakeLists.txt
index 217a9624..111c4c50 100644
--- a/adnl/CMakeLists.txt
+++ b/adnl/CMakeLists.txt
@@ -88,17 +88,15 @@ target_link_libraries(adnl PUBLIC tdactor ton_crypto tl_api tdnet tddb keys keyr
add_executable(adnl-proxy ${ADNL_PROXY_SOURCE})
target_include_directories(adnl-proxy PUBLIC $)
-target_link_libraries(adnl-proxy PUBLIC tdactor ton_crypto tl_api tdnet common
- tl-utils git)
+target_link_libraries(adnl-proxy PUBLIC tdactor ton_crypto tl_api tdnet common tl-utils git)
add_executable(adnl-pong adnl-pong.cpp)
target_include_directories(adnl-pong PUBLIC $)
-target_link_libraries(adnl-pong PUBLIC tdactor ton_crypto tl_api tdnet common
- tl-utils adnl dht git)
+target_link_libraries(adnl-pong PUBLIC tdactor ton_crypto tl_api tdnet common tl-utils adnl dht git)
add_library(adnltest STATIC ${ADNL_TEST_SOURCE})
target_include_directories(adnltest PUBLIC $)
-target_link_libraries(adnltest PUBLIC adnl )
+target_link_libraries(adnltest PUBLIC adnl)
install(TARGETS adnl-proxy RUNTIME DESTINATION bin)
endif()
diff --git a/adnl/adnl-channel.cpp b/adnl/adnl-channel.cpp
index 5c8229ca..4da9d2ee 100644
--- a/adnl/adnl-channel.cpp
+++ b/adnl/adnl-channel.cpp
@@ -112,16 +112,16 @@ void AdnlChannelImpl::send_message(td::uint32 priority, td::actor::ActorId R) {
- if (R.is_error()) {
- VLOG(ADNL_WARNING) << id << ": dropping IN message: can not decrypt: " << R.move_as_error();
- } else {
- auto packet = R.move_as_ok();
- packet.set_remote_addr(addr);
- td::actor::send_closure(peer, &AdnlPeerPair::receive_packet_from_channel, channel_id, std::move(packet));
- }
- });
+ auto P = td::PromiseCreator::lambda([peer = peer_pair_, channel_id = channel_in_id_, addr, id = print_id(),
+ size = data.size()](td::Result R) {
+ if (R.is_error()) {
+ VLOG(ADNL_WARNING) << id << ": dropping IN message: can not decrypt: " << R.move_as_error();
+ } else {
+ auto packet = R.move_as_ok();
+ packet.set_remote_addr(addr);
+ td::actor::send_closure(peer, &AdnlPeerPair::receive_packet_from_channel, channel_id, std::move(packet), size);
+ }
+ });
decrypt(std::move(data), std::move(P));
}
diff --git a/adnl/adnl-ext-client.hpp b/adnl/adnl-ext-client.hpp
index 13339725..1dd7d2ba 100644
--- a/adnl/adnl-ext-client.hpp
+++ b/adnl/adnl-ext-client.hpp
@@ -43,7 +43,10 @@ class AdnlOutboundConnection : public AdnlExtConnection {
public:
AdnlOutboundConnection(td::SocketFd fd, std::unique_ptr callback, AdnlNodeIdFull dst,
td::actor::ActorId ext_client)
- : AdnlExtConnection(std::move(fd), std::move(callback), true), dst_(std::move(dst)), ext_client_(ext_client) {
+ : AdnlExtConnection(std::move(fd), std::move(callback), true)
+ , dst_(std::move(dst))
+ , local_id_(privkeys::Ed25519::random())
+ , ext_client_(ext_client) {
}
AdnlOutboundConnection(td::SocketFd fd, std::unique_ptr callback, AdnlNodeIdFull dst,
PrivateKey local_id, td::actor::ActorId ext_client)
diff --git a/adnl/adnl-ext-server.cpp b/adnl/adnl-ext-server.cpp
index ed04469c..162a53af 100644
--- a/adnl/adnl-ext-server.cpp
+++ b/adnl/adnl-ext-server.cpp
@@ -91,7 +91,7 @@ td::Status AdnlInboundConnection::process_custom_packet(td::BufferSlice &data, b
auto F = fetch_tl_object(data.clone(), true);
if (F.is_ok()) {
if (nonce_.size() > 0 || !remote_id_.is_zero()) {
- return td::Status::Error(ErrorCode::protoviolation, "duplicate authentificate");
+ return td::Status::Error(ErrorCode::protoviolation, "duplicate authenticate");
}
auto f = F.move_as_ok();
nonce_ = td::SecureString{f->nonce_.size() + 256};
diff --git a/adnl/adnl-local-id.cpp b/adnl/adnl-local-id.cpp
index b4818276..e0c62de7 100644
--- a/adnl/adnl-local-id.cpp
+++ b/adnl/adnl-local-id.cpp
@@ -41,20 +41,34 @@ AdnlAddressList AdnlLocalId::get_addr_list() const {
}
void AdnlLocalId::receive(td::IPAddress addr, td::BufferSlice data) {
- auto P = td::PromiseCreator::lambda(
- [peer_table = peer_table_, dst = short_id_, addr, id = print_id()](td::Result R) {
- if (R.is_error()) {
- VLOG(ADNL_WARNING) << id << ": dropping IN message: cannot decrypt: " << R.move_as_error();
- } else {
- auto packet = R.move_as_ok();
- packet.set_remote_addr(addr);
- td::actor::send_closure(peer_table, &AdnlPeerTable::receive_decrypted_packet, dst, std::move(packet));
- }
- });
-
+ InboundRateLimiter& rate_limiter = inbound_rate_limiter_[addr];
+ if (!rate_limiter.rate_limiter.take()) {
+ VLOG(ADNL_NOTICE) << this << ": dropping IN message: rate limit exceeded";
+ add_dropped_packet_stats(addr);
+ return;
+ }
+ ++rate_limiter.currently_decrypting_packets;
+ auto P = td::PromiseCreator::lambda([SelfId = actor_id(this), peer_table = peer_table_, dst = short_id_, addr,
+ id = print_id(), size = data.size()](td::Result R) {
+ td::actor::send_closure(SelfId, &AdnlLocalId::decrypt_packet_done, addr);
+ if (R.is_error()) {
+ VLOG(ADNL_WARNING) << id << ": dropping IN message: cannot decrypt: " << R.move_as_error();
+ } else {
+ auto packet = R.move_as_ok();
+ packet.set_remote_addr(addr);
+ td::actor::send_closure(peer_table, &AdnlPeerTable::receive_decrypted_packet, dst, std::move(packet), size);
+ }
+ });
decrypt(std::move(data), std::move(P));
}
+void AdnlLocalId::decrypt_packet_done(td::IPAddress addr) {
+ auto it = inbound_rate_limiter_.find(addr);
+ CHECK(it != inbound_rate_limiter_.end());
+ --it->second.currently_decrypting_packets;
+ add_decrypted_packet_stats(addr);
+}
+
void AdnlLocalId::deliver(AdnlNodeIdShort src, td::BufferSlice data) {
auto s = std::move(data);
for (auto &cb : cb_) {
@@ -292,6 +306,72 @@ void AdnlLocalId::update_packet(AdnlPacket packet, bool update_id, bool sign, td
}
}
+void AdnlLocalId::get_stats(bool all, td::Promise> promise) {
+ auto stats = create_tl_object();
+ stats->short_id_ = short_id_.bits256_value();
+ for (auto &[ip, x] : inbound_rate_limiter_) {
+ if (x.currently_decrypting_packets != 0) {
+ stats->current_decrypt_.push_back(create_tl_object(
+ ip.is_valid() ? PSTRING() << ip.get_ip_str() << ":" << ip.get_port() : "", x.currently_decrypting_packets));
+ }
+ }
+ prepare_packet_stats();
+ stats->packets_recent_ = packet_stats_prev_.tl();
+ stats->packets_total_ = packet_stats_total_.tl(all);
+ stats->packets_total_->ts_start_ = (double)Adnl::adnl_start_time();
+ stats->packets_total_->ts_end_ = td::Clocks::system();
+ promise.set_result(std::move(stats));
+}
+
+void AdnlLocalId::add_decrypted_packet_stats(td::IPAddress addr) {
+ prepare_packet_stats();
+ packet_stats_cur_.decrypted_packets[addr].inc();
+ packet_stats_total_.decrypted_packets[addr].inc();
+}
+
+void AdnlLocalId::add_dropped_packet_stats(td::IPAddress addr) {
+ prepare_packet_stats();
+ packet_stats_cur_.dropped_packets[addr].inc();
+ packet_stats_total_.dropped_packets[addr].inc();
+}
+
+void AdnlLocalId::prepare_packet_stats() {
+ double now = td::Clocks::system();
+ if (now >= packet_stats_cur_.ts_end) {
+ packet_stats_prev_ = std::move(packet_stats_cur_);
+ packet_stats_cur_ = {};
+ auto now_int = (int)td::Clocks::system();
+ packet_stats_cur_.ts_start = (double)(now_int / 60 * 60);
+ packet_stats_cur_.ts_end = packet_stats_cur_.ts_start + 60.0;
+ if (packet_stats_prev_.ts_end < now - 60.0) {
+ packet_stats_prev_ = {};
+ packet_stats_prev_.ts_end = packet_stats_cur_.ts_start;
+ packet_stats_prev_.ts_start = packet_stats_prev_.ts_end - 60.0;
+ }
+ }
+}
+
+tl_object_ptr AdnlLocalId::PacketStats::tl(bool all) const {
+ double threshold = all ? -1.0 : td::Clocks::system() - 600.0;
+ auto obj = create_tl_object();
+ obj->ts_start_ = ts_start;
+ obj->ts_end_ = ts_end;
+ for (const auto &[ip, packets] : decrypted_packets) {
+ if (packets.last_packet_ts >= threshold) {
+ obj->decrypted_packets_.push_back(create_tl_object(
+ ip.is_valid() ? PSTRING() << ip.get_ip_str() << ":" << ip.get_port() : "", packets.packets));
+ }
+ }
+ for (const auto &[ip, packets] : dropped_packets) {
+ if (packets.last_packet_ts >= threshold) {
+ obj->dropped_packets_.push_back(create_tl_object(
+ ip.is_valid() ? PSTRING() << ip.get_ip_str() << ":" << ip.get_port() : "", packets.packets));
+ }
+ }
+ return obj;
+}
+
+
} // namespace adnl
} // namespace ton
diff --git a/adnl/adnl-local-id.h b/adnl/adnl-local-id.h
index c9ecfff1..fa7f7f74 100644
--- a/adnl/adnl-local-id.h
+++ b/adnl/adnl-local-id.h
@@ -55,6 +55,7 @@ class AdnlLocalId : public td::actor::Actor {
void deliver(AdnlNodeIdShort src, td::BufferSlice data);
void deliver_query(AdnlNodeIdShort src, td::BufferSlice data, td::Promise promise);
void receive(td::IPAddress addr, td::BufferSlice data);
+ void decrypt_packet_done(td::IPAddress addr);
void subscribe(std::string prefix, std::unique_ptr callback);
void unsubscribe(std::string prefix);
@@ -77,6 +78,8 @@ class AdnlLocalId : public td::actor::Actor {
void update_packet(AdnlPacket packet, bool update_id, bool sign, td::int32 update_addr_list_if,
td::int32 update_priority_addr_list_if, td::Promise promise);
+ void get_stats(bool all, td::Promise> promise);
+
td::uint32 get_mode() {
return mode_;
}
@@ -101,6 +104,32 @@ class AdnlLocalId : public td::actor::Actor {
td::uint32 mode_;
+ struct InboundRateLimiter {
+ RateLimiter rate_limiter = RateLimiter(75, 0.33);
+ td::uint64 currently_decrypting_packets = 0;
+ };
+ std::map inbound_rate_limiter_;
+ struct PacketStats {
+ double ts_start = 0.0, ts_end = 0.0;
+
+ struct Counter {
+ td::uint64 packets = 0;
+ double last_packet_ts = 0.0;
+
+ void inc() {
+ ++packets;
+ last_packet_ts = td::Clocks::system();
+ }
+ };
+ std::map decrypted_packets;
+ std::map dropped_packets;
+
+ tl_object_ptr tl(bool all = true) const;
+ } packet_stats_cur_, packet_stats_prev_, packet_stats_total_;
+ void add_decrypted_packet_stats(td::IPAddress addr);
+ void add_dropped_packet_stats(td::IPAddress addr);
+ void prepare_packet_stats();
+
void publish_address_list();
};
diff --git a/adnl/adnl-peer-table.cpp b/adnl/adnl-peer-table.cpp
index 54891515..b8aab567 100644
--- a/adnl/adnl-peer-table.cpp
+++ b/adnl/adnl-peer-table.cpp
@@ -84,7 +84,7 @@ void AdnlPeerTableImpl::receive_packet(td::IPAddress addr, AdnlCategoryMask cat_
<< " (len=" << (data.size() + 32) << ")";
}
-void AdnlPeerTableImpl::receive_decrypted_packet(AdnlNodeIdShort dst, AdnlPacket packet) {
+void AdnlPeerTableImpl::receive_decrypted_packet(AdnlNodeIdShort dst, AdnlPacket packet, td::uint64 serialized_size) {
packet.run_basic_checks().ensure();
if (!packet.inited_from_short()) {
@@ -119,7 +119,7 @@ void AdnlPeerTableImpl::receive_decrypted_packet(AdnlNodeIdShort dst, AdnlPacket
return;
}
td::actor::send_closure(it->second, &AdnlPeer::receive_packet, dst, it2->second.mode, it2->second.local_id.get(),
- std::move(packet));
+ std::move(packet), serialized_size);
}
void AdnlPeerTableImpl::add_peer(AdnlNodeIdShort local_id, AdnlNodeIdFull id, AdnlAddressList addr_list) {
@@ -385,6 +385,88 @@ void AdnlPeerTableImpl::get_conn_ip_str(AdnlNodeIdShort l_id, AdnlNodeIdShort p_
td::actor::send_closure(it->second, &AdnlPeer::get_conn_ip_str, l_id, std::move(promise));
}
+void AdnlPeerTableImpl::get_stats(bool all, td::Promise> promise) {
+ class Cb : public td::actor::Actor {
+ public:
+ explicit Cb(td::Promise> promise) : promise_(std::move(promise)) {
+ }
+
+ void got_local_id_stats(tl_object_ptr local_id) {
+ auto &local_id_stats = local_id_stats_[local_id->short_id_];
+ if (local_id_stats) {
+ local_id->peers_ = std::move(local_id_stats->peers_);
+ }
+ local_id_stats = std::move(local_id);
+ dec_pending();
+ }
+
+ void got_peer_stats(std::vector> peer_pairs) {
+ for (auto &peer_pair : peer_pairs) {
+ auto &local_id_stats = local_id_stats_[peer_pair->local_id_];
+ if (local_id_stats == nullptr) {
+ local_id_stats = create_tl_object();
+ local_id_stats->short_id_ = peer_pair->local_id_;
+ }
+ local_id_stats->peers_.push_back(std::move(peer_pair));
+ }
+ dec_pending();
+ }
+
+ void inc_pending() {
+ ++pending_;
+ }
+
+ void dec_pending() {
+ CHECK(pending_ > 0);
+ --pending_;
+ if (pending_ == 0) {
+ auto stats = create_tl_object();
+ stats->timestamp_ = td::Clocks::system();
+ for (auto &[id, local_id_stats] : local_id_stats_) {
+ stats->local_ids_.push_back(std::move(local_id_stats));
+ }
+ promise_.set_result(std::move(stats));
+ stop();
+ }
+ }
+
+ private:
+ td::Promise> promise_;
+ size_t pending_ = 1;
+
+ std::map> local_id_stats_;
+ };
+ auto callback = td::actor::create_actor("adnlstats", std::move(promise)).release();
+
+ for (auto &[id, local_id] : local_ids_) {
+ td::actor::send_closure(callback, &Cb::inc_pending);
+ td::actor::send_closure(local_id.local_id, &AdnlLocalId::get_stats, all,
+ [id = id, callback](td::Result> R) {
+ if (R.is_error()) {
+ VLOG(ADNL_NOTICE)
+ << "failed to get stats for local id " << id << " : " << R.move_as_error();
+ td::actor::send_closure(callback, &Cb::dec_pending);
+ } else {
+ td::actor::send_closure(callback, &Cb::got_local_id_stats, R.move_as_ok());
+ }
+ });
+ }
+ for (auto &[id, peer] : peers_) {
+ td::actor::send_closure(callback, &Cb::inc_pending);
+ td::actor::send_closure(
+ peer, &AdnlPeer::get_stats, all,
+ [id = id, callback](td::Result>> R) {
+ if (R.is_error()) {
+ VLOG(ADNL_NOTICE) << "failed to get stats for peer " << id << " : " << R.move_as_error();
+ td::actor::send_closure(callback, &Cb::dec_pending);
+ } else {
+ td::actor::send_closure(callback, &Cb::got_peer_stats, R.move_as_ok());
+ }
+ });
+ }
+ td::actor::send_closure(callback, &Cb::dec_pending);
+}
+
} // namespace adnl
} // namespace ton
diff --git a/adnl/adnl-peer-table.h b/adnl/adnl-peer-table.h
index cb7da613..055f32ac 100644
--- a/adnl/adnl-peer-table.h
+++ b/adnl/adnl-peer-table.h
@@ -90,7 +90,7 @@ class AdnlPeerTable : public Adnl {
virtual void answer_query(AdnlNodeIdShort src, AdnlNodeIdShort dst, AdnlQueryId query_id, td::BufferSlice data) = 0;
virtual void receive_packet(td::IPAddress addr, AdnlCategoryMask cat_mask, td::BufferSlice data) = 0;
- virtual void receive_decrypted_packet(AdnlNodeIdShort dst, AdnlPacket packet) = 0;
+ virtual void receive_decrypted_packet(AdnlNodeIdShort dst, AdnlPacket packet, td::uint64 serialized_size) = 0;
virtual void send_message_in(AdnlNodeIdShort src, AdnlNodeIdShort dst, AdnlMessage message, td::uint32 flags) = 0;
virtual void register_channel(AdnlChannelIdShort id, AdnlNodeIdShort local_id,
diff --git a/adnl/adnl-peer-table.hpp b/adnl/adnl-peer-table.hpp
index 2a27a802..9ad61b65 100644
--- a/adnl/adnl-peer-table.hpp
+++ b/adnl/adnl-peer-table.hpp
@@ -44,7 +44,7 @@ class AdnlPeerTableImpl : public AdnlPeerTable {
void add_static_nodes_from_config(AdnlNodesList nodes) override;
void receive_packet(td::IPAddress addr, AdnlCategoryMask cat_mask, td::BufferSlice data) override;
- void receive_decrypted_packet(AdnlNodeIdShort dst, AdnlPacket data) override;
+ void receive_decrypted_packet(AdnlNodeIdShort dst, AdnlPacket data, td::uint64 serialized_size) override;
void send_message_in(AdnlNodeIdShort src, AdnlNodeIdShort dst, AdnlMessage message, td::uint32 flags) override;
void send_message(AdnlNodeIdShort src, AdnlNodeIdShort dst, td::BufferSlice data) override {
send_message_ex(src, dst, std::move(data), 0);
@@ -77,6 +77,10 @@ class AdnlPeerTableImpl : public AdnlPeerTable {
td::actor::ActorId channel) override;
void unregister_channel(AdnlChannelIdShort id) override;
+ void check_id_exists(AdnlNodeIdShort id, td::Promise promise) override {
+ promise.set_value(local_ids_.count(id));
+ }
+
void write_new_addr_list_to_db(AdnlNodeIdShort local_id, AdnlNodeIdShort peer_id, AdnlDbItem node,
td::Promise promise) override;
void get_addr_list_from_db(AdnlNodeIdShort local_id, AdnlNodeIdShort peer_id,
@@ -104,6 +108,8 @@ class AdnlPeerTableImpl : public AdnlPeerTable {
td::Promise, AdnlAddress>> promise) override;
void get_conn_ip_str(AdnlNodeIdShort l_id, AdnlNodeIdShort p_id, td::Promise promise) override;
+ void get_stats(bool all, td::Promise> promise) override;
+
struct PrintId {};
PrintId print_id() const {
return PrintId{};
diff --git a/adnl/adnl-peer.cpp b/adnl/adnl-peer.cpp
index 44979885..ab460058 100644
--- a/adnl/adnl-peer.cpp
+++ b/adnl/adnl-peer.cpp
@@ -26,6 +26,7 @@
#include "td/utils/base64.h"
#include "td/utils/Random.h"
#include "auto/tl/ton_api.h"
+#include "td/utils/overloaded.h"
namespace ton {
@@ -50,9 +51,13 @@ void AdnlPeerPairImpl::start_up() {
}
void AdnlPeerPairImpl::alarm() {
- if (next_dht_query_at_ && next_dht_query_at_.is_in_past()) {
- next_dht_query_at_ = td::Timestamp::never();
- discover();
+ if (!disable_dht_query_) {
+ disable_dht_query_ = true;
+ if (next_dht_query_at_ && next_dht_query_at_.is_in_past()) {
+ next_dht_query_at_ = td::Timestamp::never();
+ discover();
+ }
+ alarm_timestamp().relax(next_dht_query_at_);
}
if (next_db_update_at_ && next_db_update_at_.is_in_past()) {
if (received_from_db_ && received_from_static_nodes_ && !peer_id_.empty()) {
@@ -68,11 +73,8 @@ void AdnlPeerPairImpl::alarm() {
}
if (retry_send_at_ && retry_send_at_.is_in_past()) {
retry_send_at_ = td::Timestamp::never();
- auto messages = std::move(pending_messages_);
- pending_messages_.clear();
- send_messages_in(std::move(messages), false);
+ send_messages_from_queue();
}
- alarm_timestamp().relax(next_dht_query_at_);
alarm_timestamp().relax(next_db_update_at_);
alarm_timestamp().relax(retry_send_at_);
}
@@ -117,6 +119,7 @@ void AdnlPeerPairImpl::discover() {
void AdnlPeerPairImpl::receive_packet_checked(AdnlPacket packet) {
last_received_packet_ = td::Timestamp::now();
try_reinit_at_ = td::Timestamp::never();
+ drop_addr_list_at_ = td::Timestamp::never();
request_reverse_ping_after_ = td::Timestamp::in(15.0);
auto d = Adnl::adnl_start_time();
if (packet.dst_reinit_date() > d) {
@@ -207,16 +210,24 @@ void AdnlPeerPairImpl::receive_packet_checked(AdnlPacket packet) {
}
}
-void AdnlPeerPairImpl::receive_packet_from_channel(AdnlChannelIdShort id, AdnlPacket packet) {
+void AdnlPeerPairImpl::receive_packet_from_channel(AdnlChannelIdShort id, AdnlPacket packet,
+ td::uint64 serialized_size) {
+ add_packet_stats(serialized_size, /* in = */ true, /* channel = */ true);
if (id != channel_in_id_) {
VLOG(ADNL_NOTICE) << this << ": dropping IN message: outdated channel id" << id;
return;
}
- channel_ready_ = true;
+ if (channel_inited_ && !channel_ready_) {
+ channel_ready_ = true;
+ if (!out_messages_queue_.empty()) {
+ td::actor::send_closure(actor_id(this), &AdnlPeerPairImpl::send_messages_from_queue);
+ }
+ }
receive_packet_checked(std::move(packet));
}
-void AdnlPeerPairImpl::receive_packet(AdnlPacket packet) {
+void AdnlPeerPairImpl::receive_packet(AdnlPacket packet, td::uint64 serialized_size) {
+ add_packet_stats(serialized_size, /* in = */ true, /* channel = */ false);
packet.run_basic_checks().ensure();
if (!encryptor_) {
@@ -237,128 +248,132 @@ void AdnlPeerPairImpl::deliver_message(AdnlMessage message) {
message.visit([&](const auto &obj) { this->process_message(obj); });
}
-void AdnlPeerPairImpl::send_messages_in(std::vector messages, bool allow_postpone) {
- for (td::int32 idx = 0; idx < 2; idx++) {
- std::vector not_sent;
+void AdnlPeerPairImpl::send_messages_from_queue() {
+ while (!out_messages_queue_.empty() && out_messages_queue_.front().second.is_in_past()) {
+ out_messages_queue_total_size_ -= out_messages_queue_.front().first.size();
+ add_expired_msg_stats(out_messages_queue_.front().first.size());
+ out_messages_queue_.pop();
+ VLOG(ADNL_NOTICE) << this << ": dropping OUT message: message in queue expired";
+ }
+ if (out_messages_queue_.empty()) {
+ return;
+ }
- auto connR = get_conn(idx == 1);
- if (connR.is_error()) {
- if (!allow_postpone) {
- VLOG(ADNL_NOTICE) << this << ": dropping OUT messages: cannot get conn: " << connR.move_as_error();
- return;
- }
- VLOG(ADNL_INFO) << this << ": delaying OUT messages: cannot get conn: " << connR.move_as_error();
- if (!retry_send_at_) {
- retry_send_at_.relax(td::Timestamp::in(10.0));
- alarm_timestamp().relax(retry_send_at_);
- }
- for (auto &m : messages) {
- pending_messages_.push_back(std::move(m));
- }
+ auto connR = get_conn();
+ if (connR.is_error()) {
+ disable_dht_query_ = false;
+ retry_send_at_.relax(td::Timestamp::in(message_in_queue_ttl_ - 1.0));
+ alarm_timestamp().relax(retry_send_at_);
+ VLOG(ADNL_INFO) << this << ": delaying OUT messages: cannot get conn: " << connR.move_as_error();
+ return;
+ }
+ disable_dht_query_ = true;
+ auto C = connR.move_as_ok();
+ auto conn = std::move(C.first);
+ bool is_direct = C.second;
+
+ bool first = !skip_init_packet_;
+ while (!out_messages_queue_.empty()) {
+ bool try_reinit = try_reinit_at_ && try_reinit_at_.is_in_past();
+ bool via_channel = channel_ready_ && !try_reinit;
+ if (!via_channel && !nochannel_rate_limiter_.take()) {
+ alarm_timestamp().relax(retry_send_at_ = nochannel_rate_limiter_.ready_at());
return;
}
- auto C = connR.move_as_ok();
- bool is_direct = C.second;
- auto conn = std::move(C.first);
- if (idx == 1) {
- CHECK(is_direct);
+ if (try_reinit) {
+ try_reinit_at_ = td::Timestamp::in(td::Random::fast(0.5, 1.5));
+ }
+ respond_with_nop_after_ = td::Timestamp::in(td::Random::fast(1.0, 2.0));
+
+ size_t s = (via_channel ? channel_packet_header_max_size() : packet_header_max_size());
+ if (first) {
+ s += 2 * addr_list_max_size();
}
- size_t ptr = 0;
- bool first = true;
- do {
- bool try_reinit = try_reinit_at_ && try_reinit_at_.is_in_past();
- bool via_channel = channel_ready_ && !try_reinit;
- size_t s = (via_channel ? channel_packet_header_max_size() : packet_header_max_size());
- if (first) {
- s += 2 * addr_list_max_size();
- }
+ AdnlPacket packet;
+ packet.set_seqno(++out_seqno_);
+ packet.set_confirm_seqno(in_seqno_);
- AdnlPacket packet;
- packet.set_seqno(++out_seqno_);
- packet.set_confirm_seqno(in_seqno_);
-
- if (first) {
- if (!channel_inited_) {
- auto M = adnlmessage::AdnlMessageCreateChannel{channel_pub_, channel_pk_date_};
- s += M.size();
- packet.add_message(std::move(M));
- } else if (!channel_ready_) {
- auto M = adnlmessage::AdnlMessageConfirmChannel{channel_pub_, peer_channel_pub_, channel_pk_date_};
- s += M.size();
- packet.add_message(std::move(M));
- }
+ if (first) {
+ if (!channel_inited_) {
+ auto M = adnlmessage::AdnlMessageCreateChannel{channel_pub_, channel_pk_date_};
+ s += M.size();
+ packet.add_message(std::move(M));
+ } else if (!channel_ready_) {
+ auto M = adnlmessage::AdnlMessageConfirmChannel{channel_pub_, peer_channel_pub_, channel_pk_date_};
+ s += M.size();
+ packet.add_message(std::move(M));
}
+ }
- if (!addr_list_.empty()) {
- packet.set_received_addr_list_version(addr_list_.version());
- }
- if (!priority_addr_list_.empty()) {
- packet.set_received_priority_addr_list_version(priority_addr_list_.version());
- }
+ if (!addr_list_.empty()) {
+ packet.set_received_addr_list_version(addr_list_.version());
+ }
+ if (!priority_addr_list_.empty()) {
+ packet.set_received_priority_addr_list_version(priority_addr_list_.version());
+ }
- while (ptr < messages.size()) {
- auto &M = messages[ptr];
- if (!is_direct && (M.flags() & Adnl::SendFlags::direct_only)) {
- not_sent.push_back(std::move(M));
- continue;
- }
- CHECK(M.size() <= get_mtu());
+ skip_init_packet_ = true;
+ while (!out_messages_queue_.empty()) {
+ auto &M = out_messages_queue_.front().first;
+ if (!is_direct && (M.flags() & Adnl::SendFlags::direct_only)) {
+ out_messages_queue_total_size_ -= M.size();
+ out_messages_queue_.pop();
+ continue;
+ }
+ CHECK(M.size() <= get_mtu());
+ if (s + M.size() <= AdnlNetworkManager::get_mtu()) {
+ s += M.size();
+ out_messages_queue_total_size_ -= M.size();
+ packet.add_message(M.release());
+ out_messages_queue_.pop();
+ skip_init_packet_ = false;
+ } else {
+ break;
+ }
+ }
+
+ if (!via_channel) {
+ packet.set_reinit_date(Adnl::adnl_start_time(), reinit_date_);
+ packet.set_source(local_id_);
+ }
+
+ if (!first) {
+ if (!channel_inited_) {
+ auto M = adnlmessage::AdnlMessageCreateChannel{channel_pub_, channel_pk_date_};
if (s + M.size() <= AdnlNetworkManager::get_mtu()) {
s += M.size();
- packet.add_message(M.release());
- ptr++;
- } else {
- break;
+ packet.add_message(std::move(M));
+ }
+ } else if (!channel_ready_) {
+ auto M = adnlmessage::AdnlMessageConfirmChannel{channel_pub_, peer_channel_pub_, channel_pk_date_};
+ if (s + M.size() <= AdnlNetworkManager::get_mtu()) {
+ s += M.size();
+ packet.add_message(std::move(M));
}
}
-
- if (!via_channel) {
- packet.set_reinit_date(Adnl::adnl_start_time(), reinit_date_);
- packet.set_source(local_id_);
- }
-
- if (!first) {
- if (!channel_inited_) {
- auto M = adnlmessage::AdnlMessageCreateChannel{channel_pub_, channel_pk_date_};
- if (s + M.size() <= AdnlNetworkManager::get_mtu()) {
- s += M.size();
- packet.add_message(std::move(M));
- }
- } else if (!channel_ready_) {
- auto M = adnlmessage::AdnlMessageConfirmChannel{channel_pub_, peer_channel_pub_, channel_pk_date_};
- if (s + M.size() <= AdnlNetworkManager::get_mtu()) {
- s += M.size();
- packet.add_message(std::move(M));
- }
- }
- }
-
- packet.run_basic_checks().ensure();
- auto P = td::PromiseCreator::lambda([SelfId = actor_id(this), conn, id = print_id(),
- via_channel](td::Result res) {
- if (res.is_error()) {
- LOG(ERROR) << id << ": dropping OUT message: error while creating packet: " << res.move_as_error();
- } else {
- td::actor::send_closure(SelfId, &AdnlPeerPairImpl::send_packet_continue, res.move_as_ok(), conn, via_channel);
- }
- });
-
- td::actor::send_closure(local_actor_, &AdnlLocalId::update_packet, std::move(packet),
- (!channel_ready_ && ack_seqno_ == 0 && in_seqno_ == 0) || try_reinit, !via_channel,
- (first || s + addr_list_max_size() <= AdnlNetworkManager::get_mtu())
- ? (try_reinit ? 0 : peer_recv_addr_list_version_)
- : 0x7fffffff,
- (first || s + 2 * addr_list_max_size() <= AdnlNetworkManager::get_mtu())
- ? peer_recv_priority_addr_list_version_
- : 0x7fffffff,
- std::move(P));
- first = false;
- } while (ptr < messages.size());
- messages = std::move(not_sent);
- if (!messages.size()) {
- break;
}
+
+ packet.run_basic_checks().ensure();
+ auto P = td::PromiseCreator::lambda([SelfId = actor_id(this), conn, id = print_id(),
+ via_channel](td::Result res) {
+ if (res.is_error()) {
+ LOG(ERROR) << id << ": dropping OUT message: error while creating packet: " << res.move_as_error();
+ } else {
+ td::actor::send_closure(SelfId, &AdnlPeerPairImpl::send_packet_continue, res.move_as_ok(), conn, via_channel);
+ }
+ });
+
+ td::actor::send_closure(local_actor_, &AdnlLocalId::update_packet, std::move(packet),
+ (!channel_ready_ && ack_seqno_ == 0 && in_seqno_ == 0) || try_reinit, !via_channel,
+ (first || s + addr_list_max_size() <= AdnlNetworkManager::get_mtu())
+ ? (try_reinit ? 0 : peer_recv_addr_list_version_)
+ : 0x7fffffff,
+ (first || s + 2 * addr_list_max_size() <= AdnlNetworkManager::get_mtu())
+ ? peer_recv_priority_addr_list_version_
+ : 0x7fffffff,
+ std::move(P));
+ first = false;
}
}
@@ -389,7 +404,11 @@ void AdnlPeerPairImpl::send_messages(std::vector messages)
}
}
}
- send_messages_in(std::move(new_vec), true);
+ for (auto &m : new_vec) {
+ out_messages_queue_total_size_ += m.size();
+ out_messages_queue_.emplace(std::move(m), td::Timestamp::in(message_in_queue_ttl_));
+ }
+ send_messages_from_queue();
}
void AdnlPeerPairImpl::send_packet_continue(AdnlPacket packet, td::actor::ActorId conn,
@@ -397,10 +416,14 @@ void AdnlPeerPairImpl::send_packet_continue(AdnlPacket packet, td::actor::ActorI
if (!try_reinit_at_ && last_received_packet_ < td::Timestamp::in(-5.0)) {
try_reinit_at_ = td::Timestamp::in(10.0);
}
+ if (!drop_addr_list_at_ && last_received_packet_ < td::Timestamp::in(-60.0 * 9.0)) {
+ drop_addr_list_at_ = td::Timestamp::in(60.0);
+ }
packet.run_basic_checks().ensure();
auto B = serialize_tl_object(packet.tl(), true);
if (via_channel) {
if (channel_ready_) {
+ add_packet_stats(B.size(), /* in = */ false, /* channel = */ true);
td::actor::send_closure(channel_, &AdnlChannel::send_message, priority_, conn, std::move(B));
} else {
VLOG(ADNL_WARNING) << this << ": dropping OUT message [" << local_id_ << "->" << peer_id_short_
@@ -428,6 +451,7 @@ void AdnlPeerPairImpl::send_packet_continue(AdnlPacket packet, td::actor::ActorI
S.remove_prefix(32);
S.copy_from(X.as_slice());
+ add_packet_stats(B.size(), /* in = */ false, /* channel = */ false);
td::actor::send_closure(conn, &AdnlNetworkConnection::send, local_id_, peer_id_short_, priority_, std::move(enc));
}
@@ -514,10 +538,14 @@ void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageConfirmChan
VLOG(ADNL_NOTICE) << this << ": received adnl.message.confirmChannel with old key";
return;
}
- channel_ready_ = true;
+ if (!channel_ready_) {
+ channel_ready_ = true;
+ send_messages_from_queue();
+ }
}
void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageCustom &message) {
+ respond_with_nop();
td::actor::send_closure(local_actor_, &AdnlLocalId::deliver, peer_id_short_, message.data());
}
@@ -530,6 +558,7 @@ void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageReinit &mes
}
void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageQuery &message) {
+ respond_with_nop();
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this), query_id = message.query_id(),
flags = static_cast(0)](td::Result R) {
if (R.is_error()) {
@@ -548,6 +577,7 @@ void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageQuery &mess
}
void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageAnswer &message) {
+ respond_with_nop();
auto Q = out_queries_.find(message.query_id());
if (Q == out_queries_.end()) {
@@ -565,6 +595,7 @@ void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageAnswer &mes
}
void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessagePart &message) {
+ respond_with_nop();
auto size = message.total_size();
if (size > huge_packet_max_size()) {
VLOG(ADNL_WARNING) << this << ": dropping too big huge message: size=" << size;
@@ -627,6 +658,14 @@ void AdnlPeerPairImpl::delete_query(AdnlQueryId id) {
}
}
+void AdnlPeerPairImpl::respond_with_nop() {
+ if (respond_with_nop_after_.is_in_past()) {
+ std::vector messages;
+ messages.emplace_back(adnlmessage::AdnlMessageNop{}, 0);
+ send_messages(std::move(messages));
+ }
+}
+
void AdnlPeerPairImpl::reinit(td::int32 date) {
if (reinit_date_ == 0) {
reinit_date_ = date;
@@ -656,7 +695,17 @@ void AdnlPeerPairImpl::reinit(td::int32 date) {
}
}
-td::Result, bool>> AdnlPeerPairImpl::get_conn(bool direct_only) {
+td::Result, bool>> AdnlPeerPairImpl::get_conn() {
+ if (drop_addr_list_at_ && drop_addr_list_at_.is_in_past()) {
+ drop_addr_list_at_ = td::Timestamp::never();
+ priority_addr_list_ = AdnlAddressList{};
+ priority_conns_.clear();
+ addr_list_ = AdnlAddressList{};
+ conns_.clear();
+ has_reverse_addr_ = false;
+ return td::Status::Error(ErrorCode::notready, "no active connections");
+ }
+
if (!priority_addr_list_.empty() && priority_addr_list_.expire_at() < td::Clocks::system()) {
priority_addr_list_ = AdnlAddressList{};
priority_conns_.clear();
@@ -674,14 +723,18 @@ td::Result, bool>> AdnlPeerP
}
}
- for (auto &conn : priority_conns_) {
- if (conn.ready() && (!direct_only || conn.is_direct())) {
- return std::make_pair(conn.conn.get(), conn.is_direct());
+ for (int direct_only = 1; direct_only >= 0; --direct_only) {
+ for (auto &conn : priority_conns_) {
+ if (conn.ready() && (!direct_only || conn.is_direct())) {
+ return std::make_pair(conn.conn.get(), conn.is_direct());
+ }
}
}
- for (auto &conn : conns_) {
- if (conn.ready() && (!direct_only || conn.is_direct())) {
- return std::make_pair(conn.conn.get(), conn.is_direct());
+ for (int direct_only = 1; direct_only >= 0; --direct_only) {
+ for (auto &conn : conns_) {
+ if (conn.ready() && (!direct_only || conn.is_direct())) {
+ return std::make_pair(conn.conn.get(), conn.is_direct());
+ }
}
}
return td::Status::Error(ErrorCode::notready, "no active connections");
@@ -769,6 +822,55 @@ void AdnlPeerPairImpl::get_conn_ip_str(td::Promise promise) {
promise.set_value("undefined");
}
+void AdnlPeerPairImpl::get_stats(bool all, td::Promise> promise) {
+ if (!all) {
+ double threshold = td::Clocks::system() - 600.0;
+ if (last_in_packet_ts_ < threshold && last_out_packet_ts_ < threshold) {
+ promise.set_value(nullptr);
+ return;
+ }
+ }
+
+ auto stats = create_tl_object();
+ stats->local_id_ = local_id_.bits256_value();
+ stats->peer_id_ = peer_id_short_.bits256_value();
+ for (const AdnlAddress &addr : addr_list_.addrs()) {
+ ton_api::downcast_call(*addr->tl(), td::overloaded(
+ [&](const ton_api::adnl_address_udp &obj) {
+ stats->ip_str_ = PSTRING() << td::IPAddress::ipv4_to_str(obj.ip_) << ":"
+ << obj.port_;
+ },
+ [&](const auto &) {}));
+ if (!stats->ip_str_.empty()) {
+ break;
+ }
+ }
+
+ prepare_packet_stats();
+ stats->last_in_packet_ts_ = last_in_packet_ts_;
+ stats->last_out_packet_ts_ = last_out_packet_ts_;
+ stats->packets_total_ = packet_stats_total_.tl();
+ stats->packets_total_->ts_start_ = started_ts_;
+ stats->packets_total_->ts_end_ = td::Clocks::system();
+ stats->packets_recent_ = packet_stats_prev_.tl();
+
+ if (channel_ready_) {
+ stats->channel_status_ = 2;
+ } else if (channel_inited_) {
+ stats->channel_status_ = 1;
+ } else {
+ stats->channel_status_ = 0;
+ }
+ stats->try_reinit_at_ = (try_reinit_at_ ? try_reinit_at_.at_unix() : 0.0);
+ stats->connection_ready_ =
+ std::any_of(conns_.begin(), conns_.end(), [](const Conn &conn) { return conn.ready(); }) ||
+ std::any_of(priority_conns_.begin(), priority_conns_.end(), [](const Conn &conn) { return conn.ready(); });
+ stats->out_queue_messages_ = out_messages_queue_.size();
+ stats->out_queue_bytes_ = out_messages_queue_total_size_;
+
+ promise.set_result(std::move(stats));
+}
+
void AdnlPeerImpl::update_id(AdnlNodeIdFull id) {
CHECK(id.compute_short_id() == peer_id_short_);
if (!peer_id_.empty()) {
@@ -792,10 +894,8 @@ void AdnlPeerPairImpl::Conn::create_conn(td::actor::ActorId pe
void AdnlPeerPairImpl::conn_change_state(AdnlConnectionIdShort id, bool ready) {
if (ready) {
- if (pending_messages_.size() > 0) {
- auto messages = std::move(pending_messages_);
- pending_messages_.clear();
- send_messages_in(std::move(messages), true);
+ if (out_messages_queue_.empty()) {
+ send_messages_from_queue();
}
}
}
@@ -817,7 +917,7 @@ td::actor::ActorOwn AdnlPeer::create(td::actor::ActorId dst_actor,
- AdnlPacket packet) {
+ AdnlPacket packet, td::uint64 serialized_size) {
if (packet.inited_from()) {
update_id(packet.from());
}
@@ -835,7 +935,7 @@ void AdnlPeerImpl::receive_packet(AdnlNodeIdShort dst, td::uint32 dst_mode, td::
}
}
- td::actor::send_closure(it->second.get(), &AdnlPeerPair::receive_packet, std::move(packet));
+ td::actor::send_closure(it->second.get(), &AdnlPeerPair::receive_packet, std::move(packet), serialized_size);
}
void AdnlPeerImpl::send_messages(AdnlNodeIdShort src, td::uint32 src_mode, td::actor::ActorId src_actor,
@@ -915,6 +1015,58 @@ void AdnlPeerImpl::update_addr_list(AdnlNodeIdShort local_id, td::uint32 local_m
td::actor::send_closure(it->second, &AdnlPeerPair::update_addr_list, std::move(addr_list));
}
+void AdnlPeerImpl::get_stats(bool all, td::Promise>> promise) {
+ class Cb : public td::actor::Actor {
+ public:
+ explicit Cb(td::Promise>> promise)
+ : promise_(std::move(promise)) {
+ }
+
+ void got_peer_pair_stats(tl_object_ptr peer_pair) {
+ if (peer_pair) {
+ result_.push_back(std::move(peer_pair));
+ }
+ dec_pending();
+ }
+
+ void inc_pending() {
+ ++pending_;
+ }
+
+ void dec_pending() {
+ CHECK(pending_ > 0);
+ --pending_;
+ if (pending_ == 0) {
+ promise_.set_result(std::move(result_));
+ stop();
+ }
+ }
+
+ private:
+ td::Promise>> promise_;
+ size_t pending_ = 1;
+ std::vector> result_;
+ };
+ auto callback = td::actor::create_actor("adnlpeerstats", std::move(promise)).release();
+
+ for (auto &[local_id, peer_pair] : peer_pairs_) {
+ td::actor::send_closure(callback, &Cb::inc_pending);
+ td::actor::send_closure(peer_pair, &AdnlPeerPair::get_stats, all,
+ [local_id = local_id, peer_id = peer_id_short_,
+ callback](td::Result> R) {
+ if (R.is_error()) {
+ VLOG(ADNL_NOTICE) << "failed to get stats for peer pair " << peer_id << "->" << local_id
+ << " : " << R.move_as_error();
+ td::actor::send_closure(callback, &Cb::dec_pending);
+ } else {
+ td::actor::send_closure(callback, &Cb::got_peer_pair_stats, R.move_as_ok());
+ }
+ });
+ }
+ td::actor::send_closure(callback, &Cb::dec_pending);
+}
+
+
void AdnlPeerPairImpl::got_data_from_db(td::Result R) {
received_from_db_ = false;
if (R.is_error()) {
@@ -998,6 +1150,66 @@ void AdnlPeerPairImpl::request_reverse_ping_result(td::Result R) {
}
}
+void AdnlPeerPairImpl::add_packet_stats(td::uint64 bytes, bool in, bool channel) {
+ prepare_packet_stats();
+ auto add_stats = [&](PacketStats &stats) {
+ if (in) {
+ ++stats.in_packets;
+ stats.in_bytes += bytes;
+ if (channel) {
+ ++stats.in_packets_channel;
+ stats.in_bytes_channel += bytes;
+ }
+ } else {
+ ++stats.out_packets;
+ stats.out_bytes += bytes;
+ if (channel) {
+ ++stats.out_packets_channel;
+ stats.out_bytes_channel += bytes;
+ }
+ }
+ };
+ add_stats(packet_stats_cur_);
+ add_stats(packet_stats_total_);
+ if (in) {
+ last_in_packet_ts_ = td::Clocks::system();
+ } else {
+ last_out_packet_ts_ = td::Clocks::system();
+ }
+}
+
+void AdnlPeerPairImpl::add_expired_msg_stats(td::uint64 bytes) {
+ prepare_packet_stats();
+ auto add_stats = [&](PacketStats &stats) {
+ ++stats.out_expired_messages;
+ stats.out_expired_bytes += bytes;
+ };
+ add_stats(packet_stats_cur_);
+ add_stats(packet_stats_total_);
+}
+
+void AdnlPeerPairImpl::prepare_packet_stats() {
+ double now = td::Clocks::system();
+ if (now >= packet_stats_cur_.ts_end) {
+ packet_stats_prev_ = std::move(packet_stats_cur_);
+ packet_stats_cur_ = {};
+ auto now_int = (int)now;
+ packet_stats_cur_.ts_start = (double)(now_int / 60 * 60);
+ packet_stats_cur_.ts_end = packet_stats_cur_.ts_start + 60.0;
+ if (packet_stats_prev_.ts_end < now - 60.0) {
+ packet_stats_prev_ = {};
+ packet_stats_prev_.ts_end = packet_stats_cur_.ts_start;
+ packet_stats_prev_.ts_start = packet_stats_prev_.ts_end - 60.0;
+ }
+ }
+}
+
+tl_object_ptr AdnlPeerPairImpl::PacketStats::tl() const {
+ return create_tl_object(ts_start, ts_end, in_packets, in_bytes, in_packets_channel,
+ in_bytes_channel, out_packets, out_bytes, out_packets_channel,
+ out_bytes_channel, out_expired_messages, out_expired_bytes);
+}
+
} // namespace adnl
} // namespace ton
diff --git a/adnl/adnl-peer.h b/adnl/adnl-peer.h
index 8488e82e..1215f71d 100644
--- a/adnl/adnl-peer.h
+++ b/adnl/adnl-peer.h
@@ -39,9 +39,9 @@ class AdnlPeer;
class AdnlPeerPair : public td::actor::Actor {
public:
- virtual void receive_packet_from_channel(AdnlChannelIdShort id, AdnlPacket packet) = 0;
+ virtual void receive_packet_from_channel(AdnlChannelIdShort id, AdnlPacket packet, td::uint64 serialized_size) = 0;
virtual void receive_packet_checked(AdnlPacket packet) = 0;
- virtual void receive_packet(AdnlPacket packet) = 0;
+ virtual void receive_packet(AdnlPacket packet, td::uint64 serialized_size) = 0;
virtual void send_messages(std::vector message) = 0;
inline void send_message(OutboundAdnlMessage message) {
@@ -59,6 +59,7 @@ class AdnlPeerPair : public td::actor::Actor {
virtual void update_peer_id(AdnlNodeIdFull id) = 0;
virtual void update_addr_list(AdnlAddressList addr_list) = 0;
virtual void get_conn_ip_str(td::Promise promise) = 0;
+ virtual void get_stats(bool all, td::Promise> promise) = 0;
static td::actor::ActorOwn create(td::actor::ActorId network_manager,
td::actor::ActorId peer_table, td::uint32 local_mode,
@@ -71,7 +72,7 @@ class AdnlPeerPair : public td::actor::Actor {
class AdnlPeer : public td::actor::Actor {
public:
virtual void receive_packet(AdnlNodeIdShort dst, td::uint32 dst_mode, td::actor::ActorId dst_actor,
- AdnlPacket message) = 0;
+ AdnlPacket message, td::uint64 serialized_size) = 0;
virtual void send_messages(AdnlNodeIdShort src, td::uint32 src_mode, td::actor::ActorId src_actor,
std::vector messages) = 0;
virtual void send_query(AdnlNodeIdShort src, td::uint32 src_mode, td::actor::ActorId src_actor,
@@ -100,6 +101,7 @@ class AdnlPeer : public td::actor::Actor {
td::actor::ActorId local_actor, AdnlAddressList addr_list) = 0;
virtual void update_dht_node(td::actor::ActorId dht_node) = 0;
virtual void get_conn_ip_str(AdnlNodeIdShort l_id, td::Promise promise) = 0;
+ virtual void get_stats(bool all, td::Promise>> promise) = 0;
};
} // namespace adnl
diff --git a/adnl/adnl-peer.hpp b/adnl/adnl-peer.hpp
index 12ee01c6..243974ba 100644
--- a/adnl/adnl-peer.hpp
+++ b/adnl/adnl-peer.hpp
@@ -20,6 +20,7 @@
#include
#include