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

Merge branch 'testnet' into accelerator

This commit is contained in:
SpyCheese 2024-12-11 15:31:58 +03:00
commit 50ee01557f
10 changed files with 444 additions and 386 deletions

View file

@ -41,7 +41,7 @@ jobs:
id: docker_build id: docker_build
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
platforms: linux/amd64 platforms: linux/amd64,linux/arm64
push: true push: true
context: ./ context: ./
tags: | tags: |

View file

@ -5,6 +5,7 @@ if (NOT SECP256K1_LIBRARY)
set(SECP256K1_INCLUDE_DIR ${SECP256K1_BINARY_DIR}/include) set(SECP256K1_INCLUDE_DIR ${SECP256K1_BINARY_DIR}/include)
file(MAKE_DIRECTORY ${SECP256K1_BINARY_DIR}) file(MAKE_DIRECTORY ${SECP256K1_BINARY_DIR})
file(MAKE_DIRECTORY "${SECP256K1_BINARY_DIR}/include")
if (MSVC) if (MSVC)
set(SECP256K1_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third-party/secp256k1) set(SECP256K1_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third-party/secp256k1)

View file

@ -20,14 +20,17 @@ COPY ./ ./
RUN mkdir build && \ RUN mkdir build && \
cd build && \ cd build && \
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 -DTON_ARCH= -DTON_USE_JEMALLOC=ON .. && \ 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 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 FROM ubuntu:22.04
RUN apt-get update && \ 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 && \ 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/* rm -rf /var/lib/apt/lists/*
RUN mkdir -p /var/ton-work/db /var/ton-work/scripts /usr/share/ton/smartcont/ /usr/lib/fift/ 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 /usr/local/bin/
COPY --from=builder /ton/build/storage/storage-daemon/storage-daemon-cli /usr/local/bin/ COPY --from=builder /ton/build/storage/storage-daemon/storage-daemon-cli /usr/local/bin/
@ -35,9 +38,20 @@ 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/validator-engine /usr/local/bin/
COPY --from=builder /ton/build/validator-engine-console/validator-engine-console /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/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/fift /usr/local/bin/
COPY --from=builder /ton/build/crypto/func /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/* /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/ COPY --from=builder /ton/crypto/fift/lib/* /usr/lib/fift/
WORKDIR /var/ton-work/db WORKDIR /var/ton-work/db

View file

@ -26,106 +26,109 @@ IF %errorlevel% NEQ 0 (
exit /b %errorlevel% exit /b %errorlevel%
) )
if not exist "zlib" ( echo Installing nasm...
git clone https://github.com/madler/zlib.git choco install -y nasm
cd zlib where nasm
git checkout v1.3.1 SET PATH=%PATH%;C:\Program Files\NASM
cd contrib\vstudio\vc14
msbuild zlibstat.vcxproj /p:Configuration=ReleaseWithoutAsm /p:platform=x64 -p:PlatformToolset=v142
IF %errorlevel% NEQ 0 ( IF %errorlevel% NEQ 0 (
echo Can't install zlib echo Can't install nasm
exit /b %errorlevel% exit /b %errorlevel%
) )
cd ..\..\..\..
mkdir third_libs
cd third_libs
set third_libs=%cd%
echo %third_libs%
if not exist "zlib" (
git clone https://github.com/madler/zlib.git
cd zlib
git checkout v1.3.1
cd contrib\vstudio\vc14
msbuild zlibstat.vcxproj /p:Configuration=ReleaseWithoutAsm /p:platform=x64 -p:PlatformToolset=v142
cd ..\..\..\..
) else ( ) else (
echo Using zlib... echo Using zlib...
) )
if not exist "lz4" ( if not exist "lz4" (
git clone https://github.com/lz4/lz4.git git clone https://github.com/lz4/lz4.git
cd lz4 cd lz4
git checkout v1.9.4 git checkout v1.9.4
cd build\VS2017\liblz4 cd build\VS2017\liblz4
msbuild liblz4.vcxproj /p:Configuration=Release /p:platform=x64 -p:PlatformToolset=v142 msbuild liblz4.vcxproj /p:Configuration=Release /p:platform=x64 -p:PlatformToolset=v142
cd ..\..\..\..
IF %errorlevel% NEQ 0 (
echo Can't install lz4
exit /b %errorlevel%
)
cd ..\..\..\..
) else ( ) else (
echo Using lz4... echo Using lz4...
) )
curl --retry 5 --retry-delay 10 -Lo libsodium-1.0.18-stable-msvc.zip https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable-msvc.zip if not exist "libsodium" (
IF %errorlevel% NEQ 0 ( git clone https://github.com/jedisct1/libsodium
echo Can't download libsodium cd libsodium
exit /b %errorlevel% git checkout 1.0.18-RELEASE
) msbuild libsodium.vcxproj /p:Configuration=Release /p:platform=x64 -p:PlatformToolset=v142
unzip libsodium-1.0.18-stable-msvc.zip cd ..
) else ( ) else (
echo Using libsodium... echo Using libsodium...
) )
if not exist "openssl-3.1.4" ( if not exist "openssl" (
curl -Lo openssl-3.1.4.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/openssl-3.1.4.zip git clone https://github.com/openssl/openssl.git
IF %errorlevel% NEQ 0 ( cd openssl
echo Can't download OpenSSL git checkout openssl-3.1.4
exit /b %errorlevel% where perl
) perl Configure VC-WIN64A
unzip -q openssl-3.1.4.zip IF %errorlevel% NEQ 0 (
echo Can't configure openssl
exit /b %errorlevel%
)
nmake
cd ..
) else ( ) else (
echo Using openssl... echo Using openssl...
) )
if not exist "libmicrohttpd-0.9.77-w32-bin" ( if not exist "libmicrohttpd" (
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 git clone https://github.com/Karlson2k/libmicrohttpd.git
IF %errorlevel% NEQ 0 ( cd libmicrohttpd
echo Can't download libmicrohttpd git checkout v1.0.1
exit /b %errorlevel% cd w32\VS2019
) msbuild libmicrohttpd.vcxproj /p:Configuration=Release-static /p:platform=x64 -p:PlatformToolset=v142
unzip -q libmicrohttpd-0.9.77-w32-bin.zip IF %errorlevel% NEQ 0 (
echo Can't compile libmicrohttpd
exit /b %errorlevel%
)
cd ../../..
) else ( ) else (
echo Using libmicrohttpd... echo Using libmicrohttpd...
) )
if not exist "readline-5.0-1-lib" ( cd ..
curl -Lo readline-5.0-1-lib.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/readline-5.0-1-lib.zip echo Current dir %cd%
IF %errorlevel% NEQ 0 (
echo Can't download readline
exit /b %errorlevel%
)
unzip -q -d readline-5.0-1-lib readline-5.0-1-lib.zip
) else (
echo Using readline...
)
set root=%cd%
echo %root%
set SODIUM_DIR=%root%\libsodium
mkdir build mkdir build
cd build cd build
cmake -GNinja -DCMAKE_BUILD_TYPE=Release ^ cmake -GNinja -DCMAKE_BUILD_TYPE=Release ^
-DPORTABLE=1 ^ -DPORTABLE=1 ^
-DSODIUM_USE_STATIC_LIBS=1 ^ -DSODIUM_USE_STATIC_LIBS=1 ^
-DSODIUM_LIBRARY_RELEASE=%third_libs%\libsodium\Build\Release\x64\libsodium.lib ^
-DSODIUM_LIBRARY_DEBUG=%third_libs%\libsodium\Build\Release\x64\libsodium.lib ^
-DSODIUM_INCLUDE_DIR=%third_libs%\libsodium\src\libsodium\include ^
-DLZ4_FOUND=1 ^ -DLZ4_FOUND=1 ^
-DLZ4_INCLUDE_DIRS=%root%\lz4\lib ^ -DLZ4_INCLUDE_DIRS=%third_libs%\lz4\lib ^
-DLZ4_LIBRARIES=%root%\lz4\build\VS2017\liblz4\bin\x64_Release\liblz4_static.lib ^ -DLZ4_LIBRARIES=%third_libs%\lz4\build\VS2017\liblz4\bin\x64_Release\liblz4_static.lib ^
-DMHD_FOUND=1 ^ -DMHD_FOUND=1 ^
-DMHD_LIBRARY=%root%\libmicrohttpd-0.9.77-w32-bin\x86_64\VS2019\Release-static\libmicrohttpd.lib ^ -DMHD_LIBRARY=%third_libs%\libmicrohttpd\w32\VS2019\Output\x64\libmicrohttpd.lib ^
-DMHD_INCLUDE_DIR=%root%\libmicrohttpd-0.9.77-w32-bin\x86_64\VS2019\Release-static ^ -DMHD_INCLUDE_DIR=%third_libs%\libmicrohttpd\src\include ^
-DZLIB_FOUND=1 ^ -DZLIB_FOUND=1 ^
-DZLIB_INCLUDE_DIR=%root%\zlib ^ -DZLIB_INCLUDE_DIR=%third_libs%\zlib ^
-DZLIB_LIBRARIES=%root%\zlib\contrib\vstudio\vc14\x64\ZlibStatReleaseWithoutAsm\zlibstat.lib ^ -DZLIB_LIBRARIES=%third_libs%\zlib\contrib\vstudio\vc14\x64\ZlibStatReleaseWithoutAsm\zlibstat.lib ^
-DOPENSSL_FOUND=1 ^ -DOPENSSL_FOUND=1 ^
-DOPENSSL_INCLUDE_DIR=%root%\openssl-3.1.4\x64\include ^ -DOPENSSL_INCLUDE_DIR=%third_libs%\openssl\include ^
-DOPENSSL_CRYPTO_LIBRARY=%root%\openssl-3.1.4\x64\lib\libcrypto_static.lib ^ -DOPENSSL_CRYPTO_LIBRARY=%third_libs%\openssl\libcrypto_static.lib ^
-DREADLINE_INCLUDE_DIR=%root%\readline-5.0-1-lib\include ^
-DREADLINE_LIBRARY=%root%\readline-5.0-1-lib\lib\readline.lib ^
-DCMAKE_CXX_FLAGS="/DTD_WINDOWS=1 /EHsc /bigobj" .. -DCMAKE_CXX_FLAGS="/DTD_WINDOWS=1 /EHsc /bigobj" ..
IF %errorlevel% NEQ 0 ( IF %errorlevel% NEQ 0 (
echo Can't configure TON echo Can't configure TON
exit /b %errorlevel% exit /b %errorlevel%
@ -168,33 +171,38 @@ REM ctest -C Release --output-on-failure -E "test-catchain|test-actors|test-val
) )
) )
echo Strip and copy artifacts
echo Creating artifacts...
cd .. cd ..
echo where strip
where strip
mkdir artifacts mkdir artifacts
mkdir artifacts\smartcont mkdir artifacts\smartcont
mkdir artifacts\lib mkdir artifacts\lib
for %%I in (build\storage\storage-daemon\storage-daemon.exe ^ for %%I in (build\storage\storage-daemon\storage-daemon.exe ^
build\storage\storage-daemon\storage-daemon-cli.exe ^ build\storage\storage-daemon\storage-daemon-cli.exe ^
build\blockchain-explorer\blockchain-explorer.exe ^ build\blockchain-explorer\blockchain-explorer.exe ^
build\crypto\fift.exe ^ build\crypto\fift.exe ^
build\crypto\tlbc.exe ^ build\crypto\tlbc.exe ^
build\crypto\func.exe ^ build\crypto\func.exe ^
build\tolk\tolk.exe ^ build\tolk\tolk.exe ^
build\crypto\create-state.exe ^ build\crypto\create-state.exe ^
build\validator-engine-console\validator-engine-console.exe ^ build\validator-engine-console\validator-engine-console.exe ^
build\tonlib\tonlib-cli.exe ^ build\tonlib\tonlib-cli.exe ^
build\tonlib\tonlibjson.dll ^ build\tonlib\tonlibjson.dll ^
build\http\http-proxy.exe ^ build\http\http-proxy.exe ^
build\rldp-http-proxy\rldp-http-proxy.exe ^ build\rldp-http-proxy\rldp-http-proxy.exe ^
build\dht-server\dht-server.exe ^ build\dht-server\dht-server.exe ^
build\lite-client\lite-client.exe ^ build\lite-client\lite-client.exe ^
build\validator-engine\validator-engine.exe ^ build\validator-engine\validator-engine.exe ^
build\utils\generate-random-id.exe ^ build\utils\generate-random-id.exe ^
build\utils\json2tlo.exe ^ build\utils\json2tlo.exe ^
build\utils\proxy-liteserver.exe ^ build\utils\proxy-liteserver.exe ^
build\adnl\adnl-proxy.exe ^ build\adnl\adnl-proxy.exe ^
build\emulator\emulator.dll) do (strip -s %%I & copy %%I artifacts\) build\emulator\emulator.dll) do (
echo strip -s %%I & copy %%I artifacts\
strip -s %%I & copy %%I artifacts\
)
xcopy /e /k /h /i crypto\smartcont artifacts\smartcont xcopy /e /k /h /i crypto\smartcont artifacts\smartcont
xcopy /e /k /h /i crypto\fift\lib artifacts\lib xcopy /e /k /h /i crypto\fift\lib artifacts\lib

View file

@ -26,109 +26,109 @@ IF %errorlevel% NEQ 0 (
exit /b %errorlevel% exit /b %errorlevel%
) )
rd /s /q ".\third-party\secp256k1\build" echo Installing nasm...
choco install -y nasm
if not exist "zlib" ( where nasm
git clone https://github.com/madler/zlib.git SET PATH=%PATH%;C:\Program Files\NASM
cd zlib
git checkout v1.3.1
cd contrib\vstudio\vc14
msbuild zlibstat.vcxproj /p:Configuration=ReleaseWithoutAsm /p:platform=x64 -p:PlatformToolset=v143
IF %errorlevel% NEQ 0 ( IF %errorlevel% NEQ 0 (
echo Can't install zlib echo Can't install nasm
exit /b %errorlevel% exit /b %errorlevel%
) )
cd ..\..\..\..
mkdir third_libs
cd third_libs
set third_libs=%cd%
echo %third_libs%
if not exist "zlib" (
git clone https://github.com/madler/zlib.git
cd zlib
git checkout v1.3.1
cd contrib\vstudio\vc14
msbuild zlibstat.vcxproj /p:Configuration=ReleaseWithoutAsm /p:platform=x64 -p:PlatformToolset=v143
cd ..\..\..\..
) else ( ) else (
echo Using zlib... echo Using zlib...
) )
if not exist "lz4" ( if not exist "lz4" (
git clone https://github.com/lz4/lz4.git git clone https://github.com/lz4/lz4.git
cd lz4 cd lz4
git checkout v1.9.4 git checkout v1.9.4
cd build\VS2017\liblz4 cd build\VS2022\liblz4
msbuild liblz4.vcxproj /p:Configuration=Release /p:platform=x64 -p:PlatformToolset=v143 msbuild liblz4.vcxproj /p:Configuration=Release /p:platform=x64 -p:PlatformToolset=v143
dir /s cd ..\..\..\..
IF %errorlevel% NEQ 0 (
echo Can't install lz4
exit /b %errorlevel%
)
cd ..\..\..\..
) else ( ) else (
echo Using lz4... echo Using lz4...
) )
if not exist "libsodium" ( if not exist "libsodium" (
curl -Lo libsodium-1.0.18-stable-msvc.zip https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable-msvc.zip git clone https://github.com/jedisct1/libsodium
IF %errorlevel% NEQ 0 ( cd libsodium
echo Can't download libsodium git checkout 1.0.18-RELEASE
exit /b %errorlevel% msbuild libsodium.vcxproj /p:Configuration=Release /p:platform=x64 -p:PlatformToolset=v143
) cd ..
unzip libsodium-1.0.18-stable-msvc.zip
) else ( ) else (
echo Using libsodium... echo Using libsodium...
) )
if not exist "openssl-3.1.4" ( if not exist "openssl" (
curl -Lo openssl-3.1.4.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/openssl-3.1.4.zip git clone https://github.com/openssl/openssl.git
IF %errorlevel% NEQ 0 ( cd openssl
echo Can't download OpenSSL git checkout openssl-3.1.4
exit /b %errorlevel% where perl
) perl Configure VC-WIN64A
unzip -q openssl-3.1.4.zip IF %errorlevel% NEQ 0 (
echo Can't configure openssl
exit /b %errorlevel%
)
nmake
cd ..
) else ( ) else (
echo Using openssl... echo Using openssl...
) )
if not exist "libmicrohttpd-0.9.77-w32-bin" ( if not exist "libmicrohttpd" (
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 git clone https://github.com/Karlson2k/libmicrohttpd.git
IF %errorlevel% NEQ 0 ( cd libmicrohttpd
echo Can't download libmicrohttpd git checkout v1.0.1
exit /b %errorlevel% cd w32\VS2022
) msbuild libmicrohttpd.vcxproj /p:Configuration=Release-static /p:platform=x64 -p:PlatformToolset=v143
unzip -q libmicrohttpd-0.9.77-w32-bin.zip IF %errorlevel% NEQ 0 (
echo Can't compile libmicrohttpd
exit /b %errorlevel%
)
cd ../../..
) else ( ) else (
echo Using libmicrohttpd... echo Using libmicrohttpd...
) )
if not exist "readline-5.0-1-lib" ( cd ..
curl -Lo readline-5.0-1-lib.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/readline-5.0-1-lib.zip echo Current dir %cd%
IF %errorlevel% NEQ 0 (
echo Can't download readline
exit /b %errorlevel%
)
unzip -q -d readline-5.0-1-lib readline-5.0-1-lib.zip
) else (
echo Using readline...
)
set root=%cd%
echo %root%
set SODIUM_DIR=%root%\libsodium
mkdir build mkdir build
cd build cd build
cmake -GNinja -DCMAKE_BUILD_TYPE=Release ^ cmake -GNinja -DCMAKE_BUILD_TYPE=Release ^
-DPORTABLE=1 ^ -DPORTABLE=1 ^
-DSODIUM_USE_STATIC_LIBS=1 ^ -DSODIUM_USE_STATIC_LIBS=1 ^
-DSODIUM_LIBRARY_RELEASE=%third_libs%\libsodium\Build\Release\x64\libsodium.lib ^
-DSODIUM_LIBRARY_DEBUG=%third_libs%\libsodium\Build\Release\x64\libsodium.lib ^
-DSODIUM_INCLUDE_DIR=%third_libs%\libsodium\src\libsodium\include ^
-DLZ4_FOUND=1 ^ -DLZ4_FOUND=1 ^
-DLZ4_INCLUDE_DIRS=%root%\lz4\lib ^ -DLZ4_INCLUDE_DIRS=%third_libs%\lz4\lib ^
-DLZ4_LIBRARIES=%root%\lz4\build\VS2017\liblz4\bin\x64_Release\liblz4_static.lib ^ -DLZ4_LIBRARIES=%third_libs%\lz4\build\VS2022\liblz4\bin\x64_Release\liblz4_static.lib ^
-DMHD_FOUND=1 ^ -DMHD_FOUND=1 ^
-DMHD_LIBRARY=%root%\libmicrohttpd-0.9.77-w32-bin\x86_64\VS2019\Release-static\libmicrohttpd.lib ^ -DMHD_LIBRARY=%third_libs%\libmicrohttpd\w32\VS2022\Output\x64\libmicrohttpd.lib ^
-DMHD_INCLUDE_DIR=%root%\libmicrohttpd-0.9.77-w32-bin\x86_64\VS2019\Release-static ^ -DMHD_INCLUDE_DIR=%third_libs%\libmicrohttpd\src\include ^
-DZLIB_FOUND=1 ^ -DZLIB_FOUND=1 ^
-DZLIB_INCLUDE_DIR=%root%\zlib ^ -DZLIB_INCLUDE_DIR=%third_libs%\zlib ^
-DZLIB_LIBRARIES=%root%\zlib\contrib\vstudio\vc14\x64\ZlibStatReleaseWithoutAsm\zlibstat.lib ^ -DZLIB_LIBRARIES=%third_libs%\zlib\contrib\vstudio\vc14\x64\ZlibStatReleaseWithoutAsm\zlibstat.lib ^
-DOPENSSL_FOUND=1 ^ -DOPENSSL_FOUND=1 ^
-DOPENSSL_INCLUDE_DIR=%root%\openssl-3.1.4\x64\include ^ -DOPENSSL_INCLUDE_DIR=%third_libs%\openssl\include ^
-DOPENSSL_CRYPTO_LIBRARY=%root%\openssl-3.1.4\x64\lib\libcrypto_static.lib ^ -DOPENSSL_CRYPTO_LIBRARY=%third_libs%\openssl\libcrypto_static.lib ^
-DREADLINE_INCLUDE_DIR=%root%\readline-5.0-1-lib\include ^
-DREADLINE_LIBRARY=%root%\readline-5.0-1-lib\lib\readline.lib ^
-DCMAKE_CXX_FLAGS="/DTD_WINDOWS=1 /EHsc /bigobj" .. -DCMAKE_CXX_FLAGS="/DTD_WINDOWS=1 /EHsc /bigobj" ..
IF %errorlevel% NEQ 0 ( IF %errorlevel% NEQ 0 (
echo Can't configure TON echo Can't configure TON
exit /b %errorlevel% exit /b %errorlevel%
@ -171,32 +171,38 @@ REM ctest -C Release --output-on-failure -E "test-catchain|test-actors|test-val
) )
) )
echo Strip and copy artifacts
echo Creating artifacts...
cd .. cd ..
echo where strip
where strip
mkdir artifacts mkdir artifacts
mkdir artifacts\smartcont mkdir artifacts\smartcont
mkdir artifacts\lib mkdir artifacts\lib
for %%I in (build\storage\storage-daemon\storage-daemon.exe ^ for %%I in (build\storage\storage-daemon\storage-daemon.exe ^
build\storage\storage-daemon\storage-daemon-cli.exe ^ build\storage\storage-daemon\storage-daemon-cli.exe ^
build\blockchain-explorer\blockchain-explorer.exe ^ build\blockchain-explorer\blockchain-explorer.exe ^
build\crypto\fift.exe ^ build\crypto\fift.exe ^
build\crypto\tlbc.exe ^ build\crypto\tlbc.exe ^
build\crypto\func.exe ^ build\crypto\func.exe ^
build\tolk\tolk.exe ^ build\tolk\tolk.exe ^
build\crypto\create-state.exe ^ build\crypto\create-state.exe ^
build\validator-engine-console\validator-engine-console.exe ^ build\validator-engine-console\validator-engine-console.exe ^
build\tonlib\tonlib-cli.exe ^ build\tonlib\tonlib-cli.exe ^
build\tonlib\tonlibjson.dll ^ build\tonlib\tonlibjson.dll ^
build\http\http-proxy.exe ^ build\http\http-proxy.exe ^
build\rldp-http-proxy\rldp-http-proxy.exe ^ build\rldp-http-proxy\rldp-http-proxy.exe ^
build\dht-server\dht-server.exe ^ build\dht-server\dht-server.exe ^
build\lite-client\lite-client.exe ^ build\lite-client\lite-client.exe ^
build\validator-engine\validator-engine.exe ^ build\validator-engine\validator-engine.exe ^
build\utils\generate-random-id.exe ^ build\utils\generate-random-id.exe ^
build\utils\json2tlo.exe ^ build\utils\json2tlo.exe ^
build\adnl\adnl-proxy.exe ^ build\utils\proxy-liteserver.exe ^
build\emulator\emulator.dll) do (strip -s %%I & copy %%I artifacts\) build\adnl\adnl-proxy.exe ^
build\emulator\emulator.dll) do (
echo strip -s %%I & copy %%I artifacts\
strip -s %%I & copy %%I artifacts\
)
xcopy /e /k /h /i crypto\smartcont artifacts\smartcont xcopy /e /k /h /i crypto\smartcont artifacts\smartcont
xcopy /e /k /h /i crypto\fift\lib artifacts\lib xcopy /e /k /h /i crypto\fift\lib artifacts\lib

View file

@ -121,6 +121,26 @@ struct ShardIdFull {
char buffer[64]; char buffer[64];
return std::string{buffer, (unsigned)snprintf(buffer, 63, "(%d,%016llx)", workchain, (unsigned long long)shard)}; return std::string{buffer, (unsigned)snprintf(buffer, 63, "(%d,%016llx)", workchain, (unsigned long long)shard)};
} }
static td::Result<ShardIdFull> parse(td::Slice s) {
// Formats: (0,2000000000000000) (0:2000000000000000) 0,2000000000000000 0:2000000000000000
if (s.empty()) {
return td::Status::Error("empty string");
}
if (s[0] == '(' && s.back() == ')') {
s = s.substr(1, s.size() - 2);
}
auto sep = s.find(':');
if (sep == td::Slice::npos) {
sep = s.find(',');
}
if (sep == td::Slice::npos || s.size() - sep - 1 != 16) {
return td::Status::Error(PSTRING() << "invalid shard " << s);
}
ShardIdFull shard;
TRY_RESULT_ASSIGN(shard.workchain, td::to_integer_safe<td::int32>(s.substr(0, sep)));
TRY_RESULT_ASSIGN(shard.shard, td::hex_to_integer_safe<td::uint64>(s.substr(sep + 1)));
return shard;
}
}; };
struct AccountIdPrefixFull { struct AccountIdPrefixFull {

View file

@ -1035,8 +1035,7 @@ td::Status ImportCertificateQuery::receive(td::BufferSlice data) {
} }
td::Status SignShardOverlayCertificateQuery::run() { td::Status SignShardOverlayCertificateQuery::run() {
TRY_RESULT_ASSIGN(wc_, tokenizer_.get_token<td::int32>()); TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token<ton::ShardIdFull>() );
TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token<td::int64>());
TRY_RESULT_ASSIGN(key_, tokenizer_.get_token<ton::PublicKeyHash>()); TRY_RESULT_ASSIGN(key_, tokenizer_.get_token<ton::PublicKeyHash>());
TRY_RESULT_ASSIGN(expire_at_, tokenizer_.get_token<td::int32>()); TRY_RESULT_ASSIGN(expire_at_, tokenizer_.get_token<td::int32>());
TRY_RESULT_ASSIGN(max_size_, tokenizer_.get_token<td::uint32>()); TRY_RESULT_ASSIGN(max_size_, tokenizer_.get_token<td::uint32>());
@ -1047,7 +1046,8 @@ td::Status SignShardOverlayCertificateQuery::run() {
td::Status SignShardOverlayCertificateQuery::send() { td::Status SignShardOverlayCertificateQuery::send() {
auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_signShardOverlayCertificate>( auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_signShardOverlayCertificate>(
wc_, shard_, ton::create_tl_object<ton::ton_api::engine_validator_keyHash>(key_.tl()), expire_at_, max_size_); shard_.workchain, shard_.shard, ton::create_tl_object<ton::ton_api::engine_validator_keyHash>(key_.tl()),
expire_at_, max_size_);
td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise()); td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise());
return td::Status::OK(); return td::Status::OK();
} }
@ -1065,8 +1065,7 @@ td::Status SignShardOverlayCertificateQuery::receive(td::BufferSlice data) {
} }
td::Status ImportShardOverlayCertificateQuery::run() { td::Status ImportShardOverlayCertificateQuery::run() {
TRY_RESULT_ASSIGN(wc_, tokenizer_.get_token<td::int32>()); TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token<ton::ShardIdFull>());
TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token<td::int64>());
TRY_RESULT_ASSIGN(key_, tokenizer_.get_token<ton::PublicKeyHash>()); TRY_RESULT_ASSIGN(key_, tokenizer_.get_token<ton::PublicKeyHash>());
TRY_RESULT_ASSIGN(in_file_, tokenizer_.get_token<std::string>()); TRY_RESULT_ASSIGN(in_file_, tokenizer_.get_token<std::string>());
@ -1078,7 +1077,8 @@ td::Status ImportShardOverlayCertificateQuery::send() {
TRY_RESULT_PREFIX(cert, ton::fetch_tl_object<ton::ton_api::overlay_Certificate>(data.as_slice(), true), TRY_RESULT_PREFIX(cert, ton::fetch_tl_object<ton::ton_api::overlay_Certificate>(data.as_slice(), true),
"incorrect certificate"); "incorrect certificate");
auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_importShardOverlayCertificate>( auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_importShardOverlayCertificate>(
wc_, shard_, ton::create_tl_object<ton::ton_api::engine_validator_keyHash>(key_.tl()), std::move(cert)); shard_.workchain, shard_.shard, ton::create_tl_object<ton::ton_api::engine_validator_keyHash>(key_.tl()),
std::move(cert));
td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise()); td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise());
return td::Status::OK(); return td::Status::OK();
} }
@ -1167,14 +1167,12 @@ td::Status GetPerfTimerStatsJsonQuery::receive(td::BufferSlice data) {
} }
td::Status GetShardOutQueueSizeQuery::run() { td::Status GetShardOutQueueSizeQuery::run() {
TRY_RESULT_ASSIGN(block_id_.workchain, tokenizer_.get_token<int>()); TRY_RESULT(shard, tokenizer_.get_token<ton::ShardIdFull>());
TRY_RESULT_ASSIGN(block_id_.shard, tokenizer_.get_token<long long>()); block_id_.workchain = shard.workchain;
block_id_.shard = shard.shard;
TRY_RESULT_ASSIGN(block_id_.seqno, tokenizer_.get_token<int>()); TRY_RESULT_ASSIGN(block_id_.seqno, tokenizer_.get_token<int>());
if (!tokenizer_.endl()) { if (!tokenizer_.endl()) {
ton::ShardIdFull dest; TRY_RESULT_ASSIGN(dest_, tokenizer_.get_token<ton::ShardIdFull>());
TRY_RESULT_ASSIGN(dest.workchain, tokenizer_.get_token<int>());
TRY_RESULT_ASSIGN(dest.shard, tokenizer_.get_token<long long>());
dest_ = dest;
} }
TRY_STATUS(tokenizer_.check_endl()); TRY_STATUS(tokenizer_.check_endl());
return td::Status::OK(); return td::Status::OK();
@ -1182,8 +1180,7 @@ td::Status GetShardOutQueueSizeQuery::run() {
td::Status GetShardOutQueueSizeQuery::send() { td::Status GetShardOutQueueSizeQuery::send() {
auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_getShardOutQueueSize>( auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_getShardOutQueueSize>(
dest_ ? 1 : 0, ton::create_tl_block_id_simple(block_id_), dest_ ? dest_.value().workchain : 0, dest_.is_valid() ? 1 : 0, ton::create_tl_block_id_simple(block_id_), dest_.workchain, dest_.shard);
dest_ ? dest_.value().shard : 0);
td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise()); td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise());
return td::Status::OK(); return td::Status::OK();
} }
@ -1557,14 +1554,13 @@ td::Status GetAdnlStatsQuery::receive(td::BufferSlice data) {
} }
td::Status AddShardQuery::run() { td::Status AddShardQuery::run() {
TRY_RESULT_ASSIGN(wc_, tokenizer_.get_token<td::int32>()); TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token<ton::ShardIdFull>());
TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token<td::int64>()); TRY_STATUS(tokenizer_.check_endl());
return td::Status::OK(); return td::Status::OK();
} }
td::Status AddShardQuery::send() { td::Status AddShardQuery::send() {
auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_addShard>( auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_addShard>(ton::create_tl_shard_id(shard_));
ton::create_tl_shard_id(ton::ShardIdFull(wc_, shard_)));
td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise()); td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise());
return td::Status::OK(); return td::Status::OK();
} }
@ -1577,14 +1573,13 @@ td::Status AddShardQuery::receive(td::BufferSlice data) {
} }
td::Status DelShardQuery::run() { td::Status DelShardQuery::run() {
TRY_RESULT_ASSIGN(wc_, tokenizer_.get_token<td::int32>()); TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token<ton::ShardIdFull>());
TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token<td::int64>()); TRY_STATUS(tokenizer_.check_endl());
return td::Status::OK(); return td::Status::OK();
} }
td::Status DelShardQuery::send() { td::Status DelShardQuery::send() {
auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_delShard>( auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_delShard>(ton::create_tl_shard_id(shard_));
ton::create_tl_shard_id(ton::ShardIdFull(wc_, shard_)));
td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise()); td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise());
return td::Status::OK(); return td::Status::OK();
} }
@ -1598,14 +1593,13 @@ td::Status DelShardQuery::receive(td::BufferSlice data) {
td::Status AddCollatorQuery::run() { td::Status AddCollatorQuery::run() {
TRY_RESULT_ASSIGN(adnl_id_, tokenizer_.get_token<ton::PublicKeyHash>()); TRY_RESULT_ASSIGN(adnl_id_, tokenizer_.get_token<ton::PublicKeyHash>());
TRY_RESULT_ASSIGN(wc_, tokenizer_.get_token<td::int32>()); TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token<ton::ShardIdFull>());
TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token<td::int64>());
return td::Status::OK(); return td::Status::OK();
} }
td::Status AddCollatorQuery::send() { td::Status AddCollatorQuery::send() {
auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_addCollator>( auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_addCollator>(adnl_id_.tl(),
adnl_id_.tl(), ton::create_tl_shard_id(ton::ShardIdFull(wc_, shard_))); ton::create_tl_shard_id(shard_));
td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise()); td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise());
return td::Status::OK(); return td::Status::OK();
} }
@ -1619,14 +1613,13 @@ td::Status AddCollatorQuery::receive(td::BufferSlice data) {
td::Status DelCollatorQuery::run() { td::Status DelCollatorQuery::run() {
TRY_RESULT_ASSIGN(adnl_id_, tokenizer_.get_token<ton::PublicKeyHash>()); TRY_RESULT_ASSIGN(adnl_id_, tokenizer_.get_token<ton::PublicKeyHash>());
TRY_RESULT_ASSIGN(wc_, tokenizer_.get_token<td::int32>()); TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token<ton::ShardIdFull>());
TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token<td::int64>());
return td::Status::OK(); return td::Status::OK();
} }
td::Status DelCollatorQuery::send() { td::Status DelCollatorQuery::send() {
auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_delCollator>( auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_delCollator>(adnl_id_.tl(),
adnl_id_.tl(), ton::create_tl_shard_id(ton::ShardIdFull(wc_, shard_))); ton::create_tl_shard_id(shard_));
td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise()); td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise());
return td::Status::OK(); return td::Status::OK();
} }

View file

@ -36,6 +36,7 @@
#include "ton/ton-types.h" #include "ton/ton-types.h"
#include "keys/keys.hpp" #include "keys/keys.hpp"
#include "td/utils/base64.h"
class ValidatorEngineConsole; class ValidatorEngineConsole;
@ -95,27 +96,25 @@ inline td::Result<td::SharedSlice> Tokenizer::get_token() {
} }
template <> template <>
inline td::Result<ton::PublicKeyHash> Tokenizer::get_token() { inline td::Result<td::Bits256> Tokenizer::get_token() {
TRY_RESULT(S, get_raw_token()); TRY_RESULT(word, get_raw_token());
TRY_RESULT(F, td::hex_decode(S)); std::string data;
if (F.size() == 32) { if (word.size() == 64) {
return ton::PublicKeyHash{td::Slice{F}}; TRY_RESULT_ASSIGN(data, td::hex_decode(word));
} else if (word.size() == 44) {
TRY_RESULT_ASSIGN(data, td::base64_decode(word));
} else { } else {
return td::Status::Error("cannot parse keyhash: bad length"); return td::Status::Error("cannot parse keyhash: bad length");
} }
td::Bits256 v;
v.as_slice().copy_from(data);
return v;
} }
template <> template <>
inline td::Result<td::Bits256> Tokenizer::get_token() { inline td::Result<ton::PublicKeyHash> Tokenizer::get_token() {
TRY_RESULT(S, get_raw_token()); TRY_RESULT(x, get_token<td::Bits256>());
TRY_RESULT(F, td::hex_decode(S)); return ton::PublicKeyHash{x};
if (F.size() == 32) {
td::Bits256 v;
v.as_slice().copy_from(F);
return v;
} else {
return td::Status::Error("cannot parse keyhash: bad length");
}
} }
template <> template <>
@ -146,6 +145,18 @@ inline td::Result<std::vector<T>> Tokenizer::get_token_vector() {
} }
} }
template <>
inline td::Result<ton::ShardIdFull> Tokenizer::get_token() {
TRY_RESULT(word, get_raw_token());
auto r_wc = td::to_integer_safe<ton::WorkchainId>(word);
if (r_wc.is_ok()) {
TRY_RESULT_ASSIGN(word, get_raw_token());
TRY_RESULT(shard, td::to_integer_safe<ton::ShardId>(word));
return ton::ShardIdFull{r_wc.move_as_ok(), shard};
}
return ton::ShardIdFull::parse(word);
}
class QueryRunner { class QueryRunner {
public: public:
virtual ~QueryRunner() = default; virtual ~QueryRunner() = default;
@ -222,10 +233,10 @@ class GetTimeQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice R) override; td::Status receive(td::BufferSlice R) override;
static std::string get_name() { static std::string get_name() {
return "gettime"; return "get-time";
} }
static std::string get_help() { static std::string get_help() {
return "gettime\tshows current server unixtime"; return "get-time\tshows current server unixtime";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -287,10 +298,10 @@ class NewKeyQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice R) override; td::Status receive(td::BufferSlice R) override;
static std::string get_name() { static std::string get_name() {
return "newkey"; return "new-key";
} }
static std::string get_help() { static std::string get_help() {
return "newkey\tgenerates new key pair on server"; return "new-key\tgenerates new key pair on server";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -308,10 +319,10 @@ class ImportPrivateKeyFileQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice R) override; td::Status receive(td::BufferSlice R) override;
static std::string get_name() { static std::string get_name() {
return "importf"; return "import-f";
} }
static std::string get_help() { static std::string get_help() {
return "importf <filename>\timport private key"; return "import-f <filename>\timport private key";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -330,10 +341,10 @@ class ExportPublicKeyQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice R) override; td::Status receive(td::BufferSlice R) override;
static std::string get_name() { static std::string get_name() {
return "exportpub"; return "export-pub";
} }
static std::string get_help() { static std::string get_help() {
return "exportpub <keyhash>\texports public key by key hash"; return "export-pub <keyhash>\texports public key by key hash";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -352,10 +363,10 @@ class ExportPublicKeyFileQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice R) override; td::Status receive(td::BufferSlice R) override;
static std::string get_name() { static std::string get_name() {
return "exportpubf"; return "export-pubf";
} }
static std::string get_help() { static std::string get_help() {
return "exportpubf <keyhash> <filename>\texports public key by key hash"; return "export-pub-f <keyhash> <filename>\texports public key by key hash";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -398,10 +409,10 @@ class SignFileQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "signf"; return "sign-f";
} }
static std::string get_help() { static std::string get_help() {
return "signf <keyhash> <infile> <outfile>\tsigns bytestring with privkey"; return "sign-f <keyhash> <infile> <outfile>\tsigns bytestring with privkey";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -422,10 +433,10 @@ class ExportAllPrivateKeysQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice R) override; td::Status receive(td::BufferSlice R) override;
static std::string get_name() { static std::string get_name() {
return "exportallprivatekeys"; return "export-all-private-keys";
} }
static std::string get_help() { static std::string get_help() {
return "exportallprivatekeys <directory>\texports all private keys from validator engine and stores them to " return "export-all-private-keys <directory>\texports all private keys from validator engine and stores them to "
"<directory>"; "<directory>";
} }
std::string name() const override { std::string name() const override {
@ -446,10 +457,10 @@ class AddAdnlAddrQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "addadnl"; return "add-adnl";
} }
static std::string get_help() { static std::string get_help() {
return "addadnl <keyhash> <category>\tuse key as ADNL addr"; return "add-adnl <keyhash> <category>\tuse key as ADNL addr";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -469,10 +480,10 @@ class AddDhtIdQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "adddht"; return "add-dht";
} }
static std::string get_help() { static std::string get_help() {
return "adddht <keyhash>\tcreate DHT node with specified ADNL addr"; return "add-dht <keyhash>\tcreate DHT node with specified ADNL addr";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -491,10 +502,10 @@ class AddValidatorPermanentKeyQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "addpermkey"; return "add-perm-key";
} }
static std::string get_help() { static std::string get_help() {
return "addpermkey <keyhash> <election-date> <expire-at>\tadd validator permanent key"; return "add-perm-key <keyhash> <election-date> <expire-at>\tadd validator permanent key";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -515,10 +526,10 @@ class AddValidatorTempKeyQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "addtempkey"; return "add-temp-key";
} }
static std::string get_help() { static std::string get_help() {
return "addtempkey <permkeyhash> <keyhash> <expireat>\tadd validator temp key"; return "add-temp-key <permkeyhash> <keyhash> <expireat>\tadd validator temp key";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -539,10 +550,10 @@ class AddValidatorAdnlAddrQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "addvalidatoraddr"; return "add-validator-addr";
} }
static std::string get_help() { static std::string get_help() {
return "addvalidatoraddr <permkeyhash> <keyhash> <expireat>\tadd validator ADNL addr"; return "add-validator-addr <permkeyhash> <keyhash> <expireat>\tadd validator ADNL addr";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -563,10 +574,10 @@ class ChangeFullNodeAdnlAddrQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "changefullnodeaddr"; return "change-full-node-addr";
} }
static std::string get_help() { static std::string get_help() {
return "changefullnodeaddr <keyhash>\tchanges fullnode ADNL address"; return "change-full-node-addr <keyhash>\tchanges fullnode ADNL address";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -585,10 +596,10 @@ class AddLiteServerQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "addliteserver"; return "add-liteserver";
} }
static std::string get_help() { static std::string get_help() {
return "addliteserver <port> <keyhash>\tadd liteserver"; return "add-liteserver <port> <keyhash>\tadd liteserver";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -608,10 +619,10 @@ class DelAdnlAddrQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "deladnl"; return "del-adnl";
} }
static std::string get_help() { static std::string get_help() {
return "deladnl <keyhash>\tdel unused ADNL addr"; return "del-adnl <keyhash>\tdel unused ADNL addr";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -630,10 +641,10 @@ class DelDhtIdQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "deldht"; return "del-dht";
} }
static std::string get_help() { static std::string get_help() {
return "deldht <keyhash>\tdel unused DHT node"; return "del-dht <keyhash>\tdel unused DHT node";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -652,10 +663,10 @@ class DelValidatorPermanentKeyQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "delpermkey"; return "del-perm-key";
} }
static std::string get_help() { static std::string get_help() {
return "delpermkey <keyhash>\tforce del unused validator permanent key"; return "del-perm-key <keyhash>\tforce del unused validator permanent key";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -674,10 +685,10 @@ class DelValidatorTempKeyQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "deltempkey"; return "del-temp-key";
} }
static std::string get_help() { static std::string get_help() {
return "deltempkey <permkeyhash> <keyhash>\tforce del unused validator temp key"; return "del-temp-key <permkeyhash> <keyhash>\tforce del unused validator temp key";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -697,10 +708,10 @@ class DelValidatorAdnlAddrQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "delvalidatoraddr"; return "del-validator-addr";
} }
static std::string get_help() { static std::string get_help() {
return "delvalidatoraddr <permkeyhash> <keyhash>\tforce del unused validator ADNL addr"; return "del-validator-addr <permkeyhash> <keyhash>\tforce del unused validator ADNL addr";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -720,10 +731,10 @@ class GetConfigQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "getconfig"; return "get-config";
} }
static std::string get_help() { static std::string get_help() {
return "getconfig\tdownloads current config"; return "get-config\tdownloads current config";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -741,10 +752,10 @@ class SetVerbosityQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "setverbosity"; return "set-verbosity";
} }
static std::string get_help() { static std::string get_help() {
return "setverbosity <value>\tchanges verbosity level"; return "set-verbosity <value>\tchanges verbosity level";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -763,10 +774,10 @@ class GetStatsQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "getstats"; return "get-stats";
} }
static std::string get_help() { static std::string get_help() {
return "getstats\tprints stats"; return "get-stats\tprints stats";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -807,10 +818,10 @@ class AddNetworkAddressQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "addaddr"; return "add-addr";
} }
static std::string get_help() { static std::string get_help() {
return "addaddr <ip> {cats...} {priocats...}\tadds ip address to address list"; return "add-addr <ip> {cats...} {priocats...}\tadds ip address to address list";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -831,10 +842,10 @@ class AddNetworkProxyAddressQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "addproxyaddr"; return "add-proxy-addr";
} }
static std::string get_help() { static std::string get_help() {
return "addproxyaddr <inip> <outip> <id> <secret> {cats...} {priocats...}\tadds ip address to address list"; return "add-proxy-addr <inip> <outip> <id> <secret> {cats...} {priocats...}\tadds ip address to address list";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -858,10 +869,10 @@ class CreateElectionBidQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "createelectionbid"; return "create-election-bid";
} }
static std::string get_help() { static std::string get_help() {
return "createelectionbid <date> <elector> <wallet> <fname>\tcreate election bid"; return "create-election-bid <date> <elector> <wallet> <fname>\tcreate election bid";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -883,10 +894,10 @@ class CreateProposalVoteQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "createproposalvote"; return "create-proposal-vote";
} }
static std::string get_help() { static std::string get_help() {
return "createproposalvote <data> <fname>\tcreate proposal vote"; return "create-proposal-vote <data> <fname>\tcreate proposal vote";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -906,10 +917,10 @@ class CreateComplaintVoteQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "createcomplaintvote"; return "create-complaint-vote";
} }
static std::string get_help() { static std::string get_help() {
return "createcomplaintvote <election-id> <data> <fname>\tcreate proposal vote"; return "create-complaint-vote <election-id> <data> <fname>\tcreate proposal vote";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -930,10 +941,10 @@ class CheckDhtServersQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "checkdht"; return "check-dht";
} }
static std::string get_help() { static std::string get_help() {
return "checkdht <adnlid>\tchecks, which root DHT servers are accessible from this ADNL addr"; return "check-dht <adnlid>\tchecks, which root DHT servers are accessible from this ADNL addr";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -952,10 +963,10 @@ class GetOverlaysStatsQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "getoverlaysstats"; return "get-overlays-stats";
} }
static std::string get_help() { static std::string get_help() {
return "getoverlaysstats\tgets stats for all overlays"; return "get-overlays-stats\tgets stats for all overlays";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -971,10 +982,10 @@ class GetOverlaysStatsJsonQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "getoverlaysstatsjson"; return "get-overlays-stats-json";
} }
static std::string get_help() { static std::string get_help() {
return "getoverlaysstatsjson <outfile>\tgets stats for all overlays and writes to json file"; return "get-overlays-stats-json <outfile>\tgets stats for all overlays and writes to json file";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -993,10 +1004,10 @@ class SignCertificateQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "signcert"; return "sign-cert";
} }
static std::string get_help() { static std::string get_help() {
return "signcert <overlayid> <adnlid> <expireat> <maxsize> <signwith> <outfile>\tsign overlay certificate by " return "sign-cert <overlayid> <adnlid> <expireat> <maxsize> <signwith> <outfile>\tsign overlay certificate by "
"<signwith> key"; "<signwith> key";
} }
std::string name() const override { std::string name() const override {
@ -1029,10 +1040,10 @@ class ImportCertificateQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "importcert"; return "import-cert";
} }
static std::string get_help() { static std::string get_help() {
return "importcert <overlayid> <adnlid> <key> <certfile>\timport overlay certificate for specific key"; return "import-cert <overlayid> <adnlid> <key> <certfile>\timport overlay certificate for specific key";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1054,19 +1065,18 @@ class SignShardOverlayCertificateQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "signshardoverlaycert"; return "sign-shard-overlay-cert";
} }
static std::string get_help() { static std::string get_help() {
return "signshardoverlaycert <workchain> <shardprefix> <key> <expireat> <maxsize> <outfile>\tsign certificate for " return "sign-shard-overlay-cert <wc>:<shard> <key> <expireat> <maxsize> <outfile>\tsign certificate "
"<key> in currently active shard overlay"; "for <key> in currently active shard overlay";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
} }
private: private:
td::int32 wc_; ton::ShardIdFull shard_;
td::int64 shard_;
td::int32 expire_at_; td::int32 expire_at_;
ton::PublicKeyHash key_; ton::PublicKeyHash key_;
td::uint32 max_size_; td::uint32 max_size_;
@ -1082,10 +1092,10 @@ class ImportShardOverlayCertificateQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "importshardoverlaycert"; return "import-shard-overlay-cert";
} }
static std::string get_help() { static std::string get_help() {
return "importshardoverlaycert <workchain> <shardprefix> <key> <certfile>\timport certificate for <key> in " return "import-shard-overlay-cert <wc>:<shard> <key> <certfile>\timport certificate for <key> in "
"currently active shard overlay"; "currently active shard overlay";
} }
std::string name() const override { std::string name() const override {
@ -1093,8 +1103,7 @@ class ImportShardOverlayCertificateQuery : public Query {
} }
private: private:
td::int32 wc_; ton::ShardIdFull shard_;
td::int64 shard_;
ton::PublicKeyHash key_; ton::PublicKeyHash key_;
std::string in_file_; std::string in_file_;
}; };
@ -1108,10 +1117,10 @@ class GetActorStatsQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "getactorstats"; return "get-actor-stats";
} }
static std::string get_help() { static std::string get_help() {
return "getactorstats [<outfile>]\tget actor stats and print it either in stdout or in <outfile>"; return "get-actor-stats [<outfile>]\tget actor stats and print it either in stdout or in <outfile>";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1130,11 +1139,11 @@ class GetPerfTimerStatsJsonQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "getperftimerstatsjson"; return "get-perf-timer-stats-json";
} }
static std::string get_help() { static std::string get_help() {
return "getperftimerstatsjson <outfile>\tgets min, average and max event processing time for last 60, 300 and 3600 " return "get-perf-timer-stats-json <outfile>\tgets min, average and max event processing time for last 60, 300 and "
"seconds and writes to json file"; "3600 seconds and writes to json file";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1153,10 +1162,10 @@ class GetShardOutQueueSizeQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "getshardoutqueuesize"; return "get-shard-out-queue-size";
} }
static std::string get_help() { static std::string get_help() {
return "getshardoutqueuesize <wc> <shard> <seqno> [<dest_wc> <dest_shard>]\treturns number of messages in the " return "get-shard-out-queue-size <wc>:<shard> <seqno> [<dest_wc>:<dest_shard>]\treturns number of messages in the "
"queue of the given shard. Destination shard is optional."; "queue of the given shard. Destination shard is optional.";
} }
std::string name() const override { std::string name() const override {
@ -1165,7 +1174,7 @@ class GetShardOutQueueSizeQuery : public Query {
private: private:
ton::BlockId block_id_; ton::BlockId block_id_;
td::optional<ton::ShardIdFull> dest_; ton::ShardIdFull dest_ = ton::ShardIdFull{ton::workchainInvalid};
}; };
class SetExtMessagesBroadcastDisabledQuery : public Query { class SetExtMessagesBroadcastDisabledQuery : public Query {
@ -1177,11 +1186,11 @@ class SetExtMessagesBroadcastDisabledQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "setextmessagesbroadcastdisabled"; return "set-ext-messages-broadcast-disabled";
} }
static std::string get_help() { static std::string get_help() {
return "setextmessagesbroadcastdisabled <value>\tdisable broadcasting and rebroadcasting ext messages; value is 0 " return "set-ext-messages-broadcast-disabled <value>\tdisable broadcasting and rebroadcasting ext messages; value "
"or 1."; "is 0 or 1.";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1200,10 +1209,10 @@ class AddCustomOverlayQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "addcustomoverlay"; return "add-custom-overlay";
} }
static std::string get_help() { static std::string get_help() {
return "addcustomoverlay <filename>\tadd custom overlay with config from file <filename>"; return "add-custom-overlay <filename>\tadd custom overlay with config from file <filename>";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1222,10 +1231,10 @@ class DelCustomOverlayQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "delcustomoverlay"; return "del-custom-overlay";
} }
static std::string get_help() { static std::string get_help() {
return "delcustomoverlay <name>\tdelete custom overlay with name <name>"; return "del-custom-overlay <name>\tdelete custom overlay with name <name>";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1244,10 +1253,10 @@ class ShowCustomOverlaysQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "showcustomoverlays"; return "show-custom-overlays";
} }
static std::string get_help() { static std::string get_help() {
return "showcustomoverlays\tshow all custom overlays"; return "show-custom-overlays\tshow all custom overlays";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1263,10 +1272,10 @@ class SetStateSerializerEnabledQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "setstateserializerenabled"; return "set-state-serializer-enabled";
} }
static std::string get_help() { static std::string get_help() {
return "setstateserializerenabled <value>\tdisable or enable persistent state serializer; value is 0 or 1"; return "set-state-serializer-enabled <value>\tdisable or enable persistent state serializer; value is 0 or 1";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1285,10 +1294,10 @@ class SetCollatorOptionsJsonQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "setcollatoroptionsjson"; return "set-collator-options-json";
} }
static std::string get_help() { static std::string get_help() {
return "setcollatoroptionsjson <filename>\tset collator options from file <filename>"; return "set-collator-options-json <filename>\tset collator options from file <filename>";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1307,10 +1316,10 @@ class ResetCollatorOptionsQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "resetcollatoroptions"; return "reset-collator-options";
} }
static std::string get_help() { static std::string get_help() {
return "resetcollatoroptions\tset collator options to default values"; return "reset-collator-options\tset collator options to default values";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1326,10 +1335,10 @@ class GetCollatorOptionsJsonQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "getcollatoroptionsjson"; return "get-collator-options-json";
} }
static std::string get_help() { static std::string get_help() {
return "getcollatoroptionsjson <filename>\tsave current collator options to file <filename>"; return "get-collator-options-json <filename>\tsave current collator options to file <filename>";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1348,11 +1357,11 @@ class GetAdnlStatsJsonQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "getadnlstatsjson"; return "get-adnl-stats-json";
} }
static std::string get_help() { static std::string get_help() {
return "getadnlstatsjson <filename> [all]\tsave adnl stats to <filename>. all - returns all peers (default - only " return "get-adnl-stats-json <filename> [all]\tsave adnl stats to <filename>. all - returns all peers (default - "
"peers with traffic in the last 10 minutes)"; "only peers with traffic in the last 10 minutes)";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1372,11 +1381,11 @@ class GetAdnlStatsQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "getadnlstats"; return "get-adnl-stats";
} }
static std::string get_help() { static std::string get_help() {
return "getadnlstats [all]\tdisplay adnl stats. all - returns all peers (default - only peers with traffic in the " return "get-adnl-stats [all]\tdisplay adnl stats. all - returns all peers (default - only peers with traffic in "
"last 10 minutes)"; "the last 10 minutes)";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1396,18 +1405,17 @@ class AddShardQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "addshard"; return "add-shard";
} }
static std::string get_help() { static std::string get_help() {
return "addshard <workchain> <shard>\tstart monitoring shard"; return "add-shard <wc>:<shard>\tstart monitoring shard";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
} }
private: private:
td::int32 wc_; ton::ShardIdFull shard_;
td::int64 shard_;
}; };
class DelShardQuery : public Query { class DelShardQuery : public Query {
@ -1419,18 +1427,17 @@ class DelShardQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "delshard"; return "del-shard";
} }
static std::string get_help() { static std::string get_help() {
return "delshard <workchain> <shard>\tstop monitoring shard"; return "del-shard <wc>:<shard>\tstop monitoring shard";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
} }
private: private:
td::int32 wc_; ton::ShardIdFull shard_;
td::int64 shard_;
}; };
class AddCollatorQuery : public Query { class AddCollatorQuery : public Query {
@ -1442,10 +1449,10 @@ class AddCollatorQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "addcollator"; return "add-collator";
} }
static std::string get_help() { static std::string get_help() {
return "addcollator <adnl_id> <workchain> <shard>\tadd collator with given adnl_id and shard"; return "add-collator <adnl_id> <workchain> <shard>\tadd collator with given adnl_id and shard";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1453,8 +1460,7 @@ class AddCollatorQuery : public Query {
private: private:
ton::PublicKeyHash adnl_id_; ton::PublicKeyHash adnl_id_;
td::int32 wc_; ton::ShardIdFull shard_;
td::int64 shard_;
}; };
class DelCollatorQuery : public Query { class DelCollatorQuery : public Query {
@ -1466,10 +1472,10 @@ class DelCollatorQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "delcollator"; return "del-collator";
} }
static std::string get_help() { static std::string get_help() {
return "delcollator <adnl_id> <workchain> <shard>\tremove collator with given adnl_id and shard"; return "del-collator <adnl_id> <workchain> <shard>\tremove collator with given adnl_id and shard";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1477,8 +1483,7 @@ class DelCollatorQuery : public Query {
private: private:
ton::PublicKeyHash adnl_id_; ton::PublicKeyHash adnl_id_;
td::int32 wc_; ton::ShardIdFull shard_;
td::int64 shard_;
}; };
class CollatorNodeAddWhitelistedValidatorQuery : public Query { class CollatorNodeAddWhitelistedValidatorQuery : public Query {
@ -1490,10 +1495,10 @@ class CollatorNodeAddWhitelistedValidatorQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "collatorwhitelistadd"; return "collator-whitelist-add";
} }
static std::string get_help() { static std::string get_help() {
return "collatorwhitelistadd <adnl_id>\tadd validator adnl id to collator node whitelist"; return "collator-whitelist-add <adnl_id>\tadd validator adnl id to collator node whitelist";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1512,10 +1517,10 @@ class CollatorNodeDelWhitelistedValidatorQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "collatorwhitelistdel"; return "collator-whitelist-del";
} }
static std::string get_help() { static std::string get_help() {
return "collatorwhitelistdel <adnl_id>\tremove validator adnl id from collator node whitelist"; return "collator-whitelist-del <adnl_id>\tremove validator adnl id from collator node whitelist";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1534,10 +1539,10 @@ class CollatorNodeEnableWhitelistQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "collatorwhitelistenable"; return "collator-whitelist-enable";
} }
static std::string get_help() { static std::string get_help() {
return "collatorwhitelistenable <value>\tenable or disable collator node whiltelist (value is 0 or 1)"; return "collator-whitelist-enable <value>\tenable or disable collator node whiltelist (value is 0 or 1)";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1556,10 +1561,10 @@ class CollatorNodeShowWhitelistQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "collatorwhitelistshow"; return "collator-whitelist-show";
} }
static std::string get_help() { static std::string get_help() {
return "collatorwhitelistshow\tshow collator node whitelist"; return "collator-whitelist-show\tshow collator node whitelist";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1575,10 +1580,10 @@ class SetCollatorsListQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "setcollatorslist"; return "set-collators-list";
} }
static std::string get_help() { static std::string get_help() {
return "setcollatorslist <filename>\tset list of collators from file <filename>"; return "set-collators-list <filename>\tset list of collators from file <filename>";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1597,10 +1602,10 @@ class ClearCollatorsListQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "clearcollatorslist"; return "clear-collators-list";
} }
static std::string get_help() { static std::string get_help() {
return "clearcollatorslist\tclear list of collators"; return "clear-collators-list\tclear list of collators";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1616,10 +1621,10 @@ class ShowCollatorsListQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "showcollatorslist"; return "show-collators-list";
} }
static std::string get_help() { static std::string get_help() {
return "showcollatorslist\tshow list of collators"; return "show-collators-list\tshow list of collators";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1635,10 +1640,10 @@ class GetCollationManagerStatsQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "collationmanagerstats"; return "collation-manager-stats";
} }
static std::string get_help() { static std::string get_help() {
return "collationmanagerstats\tshow stats of collation manager"; return "collation-manager-stats\tshow stats of collation manager";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1654,10 +1659,10 @@ class SignOverlayMemberCertificateQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "signoverlaymembercertificate"; return "sign-overlay-member-certificate";
} }
static std::string get_help() { static std::string get_help() {
return "signoverlaymembercertificate <key_hash> <adnl_id> <slot> <expire_at> <filename>\tsign overlay member " return "sign-overlay-member-certificate <key_hash> <adnl_id> <slot> <expire_at> <filename>\tsign overlay member "
"certificate for <adnl_id> (hex) with <key_hash> (hex) in slot <slot>, valid until <expire_at>, " "certificate for <adnl_id> (hex) with <key_hash> (hex) in slot <slot>, valid until <expire_at>, "
"save to <filename>"; "save to <filename>";
} }
@ -1682,10 +1687,10 @@ class ImportFastSyncMemberCertificateQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "importfastsyncmembercertificate"; return "import-fast-sync-member-certificate";
} }
static std::string get_help() { static std::string get_help() {
return "importfastsyncmembercertificate <adnl_id> <filename>\timport member certificate for fast sync overlay " return "import-fast-sync-membe-rcertificate <adnl_id> <filename>\timport member certificate for fast sync overlay "
"for <adnl_id> (hex) from <filename>"; "for <adnl_id> (hex) from <filename>";
} }
std::string name() const override { std::string name() const override {
@ -1706,11 +1711,11 @@ class AddFastSyncOverlayClientQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "addfastsyncoverlayclient"; return "add-fast-sync-overlay-client";
} }
static std::string get_help() { static std::string get_help() {
return "addfastsyncoverlayclient <adnl_id> <slot>\tstarts issuing member certificates " return "add-fast-sync-overlay-client <adnl_id> <slot>\tstarts issuing member certificates to <adnl_id> (hex) on "
"to <adnl_id> (hex) on slot (int)"; "slot (int)";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();
@ -1730,11 +1735,10 @@ class DelFastSyncOverlayClientQuery : public Query {
td::Status send() override; td::Status send() override;
td::Status receive(td::BufferSlice data) override; td::Status receive(td::BufferSlice data) override;
static std::string get_name() { static std::string get_name() {
return "delfastsyncoverlayclient"; return "del-fast-sync-overlay-client";
} }
static std::string get_help() { static std::string get_help() {
return "delfastsyncoverlayclient <adnl_id> <slot>\tstops issuing member certificates " return "del-fast-sync-overlay-client <adnl_id> <slot>\tstops issuing member certificates to <adnl_id> (hex)";
"to <adnl_id> (hex)";
} }
std::string name() const override { std::string name() const override {
return get_name(); return get_name();

View file

@ -220,9 +220,8 @@ void ValidatorEngineConsole::show_help(std::string command, td::Promise<td::Buff
td::TerminalIO::out() << cmd.second->help() << "\n"; td::TerminalIO::out() << cmd.second->help() << "\n";
} }
} else { } else {
auto it = query_runners_.find(command); if (auto query = get_query(command)) {
if (it != query_runners_.end()) { td::TerminalIO::out() << query->help() << "\n";
td::TerminalIO::out() << it->second->help() << "\n";
} else { } else {
td::TerminalIO::out() << "unknown command '" << command << "'\n"; td::TerminalIO::out() << "unknown command '" << command << "'\n";
} }
@ -246,10 +245,9 @@ void ValidatorEngineConsole::parse_line(td::BufferSlice data) {
} }
auto name = tokenizer.get_token<std::string>().move_as_ok(); auto name = tokenizer.get_token<std::string>().move_as_ok();
auto it = query_runners_.find(name); if (auto query = get_query(name)) {
if (it != query_runners_.end()) {
running_queries_++; running_queries_++;
it->second->run(actor_id(this), std::move(tokenizer)); query->run(actor_id(this), std::move(tokenizer));
} else { } else {
td::TerminalIO::out() << "unknown command '" << name << "'\n"; td::TerminalIO::out() << "unknown command '" << name << "'\n";
} }

View file

@ -57,9 +57,23 @@ class ValidatorEngineConsole : public td::actor::Actor {
std::unique_ptr<ton::adnl::AdnlExtClient::Callback> make_callback(); std::unique_ptr<ton::adnl::AdnlExtClient::Callback> make_callback();
std::map<std::string, std::unique_ptr<QueryRunner>> query_runners_; std::map<std::string, std::unique_ptr<QueryRunner>> query_runners_;
std::map<std::string, std::string> alternate_names_;
static std::string simplify_name(std::string name) {
std::erase_if(name, [](char c) { return c == '-'; });
return name;
}
void add_query_runner(std::unique_ptr<QueryRunner> runner) { void add_query_runner(std::unique_ptr<QueryRunner> runner) {
auto name = runner->name(); auto name = runner->name();
query_runners_[name] = std::move(runner); query_runners_[name] = std::move(runner);
alternate_names_[simplify_name(name)] = name;
}
QueryRunner* get_query(std::string name) {
auto it = alternate_names_.find(name);
if (it != alternate_names_.end()) {
name = it->second;
}
auto it2 = query_runners_.find(name);
return it2 == query_runners_.end() ? nullptr : it2->second.get();
} }
public: public: