diff --git a/.github/workflows/docker-ubuntu-branch-image.yml b/.github/workflows/docker-ubuntu-branch-image.yml index d749afa2e..afde104a5 100644 --- a/.github/workflows/docker-ubuntu-branch-image.yml +++ b/.github/workflows/docker-ubuntu-branch-image.yml @@ -41,7 +41,7 @@ jobs: id: docker_build uses: docker/build-push-action@v6 with: - platforms: linux/amd64 + platforms: linux/amd64,linux/arm64 push: true context: ./ tags: | diff --git a/CMake/BuildSECP256K1.cmake b/CMake/BuildSECP256K1.cmake index ac70b2559..f8b3c8ca6 100644 --- a/CMake/BuildSECP256K1.cmake +++ b/CMake/BuildSECP256K1.cmake @@ -5,6 +5,7 @@ if (NOT SECP256K1_LIBRARY) 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) diff --git a/Dockerfile b/Dockerfile index 1ba1460ee..61e18c0b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,14 +20,17 @@ 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 + 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 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/* -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-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-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 diff --git a/assembly/native/build-windows-2019.bat b/assembly/native/build-windows-2019.bat index 9f11be059..844c09fcd 100644 --- a/assembly/native/build-windows-2019.bat +++ b/assembly/native/build-windows-2019.bat @@ -26,106 +26,109 @@ IF %errorlevel% NEQ 0 ( exit /b %errorlevel% ) -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 - +echo Installing nasm... +choco install -y nasm +where nasm +SET PATH=%PATH%;C:\Program Files\NASM IF %errorlevel% NEQ 0 ( - echo Can't install zlib + echo Can't install nasm exit /b %errorlevel% ) -cd ..\..\..\.. -) else ( -echo Using zlib... -) -if not exist "lz4" ( -git clone https://github.com/lz4/lz4.git -cd lz4 -git checkout v1.9.4 -cd build\VS2017\liblz4 -msbuild liblz4.vcxproj /p:Configuration=Release /p:platform=x64 -p:PlatformToolset=v142 +mkdir third_libs +cd third_libs -IF %errorlevel% NEQ 0 ( - echo Can't install lz4 - exit /b %errorlevel% -) -cd ..\..\..\.. +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 ( -echo Using lz4... + echo Using zlib... ) -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 %errorlevel% NEQ 0 ( - echo Can't download libsodium - exit /b %errorlevel% -) -unzip libsodium-1.0.18-stable-msvc.zip +if not exist "lz4" ( + git clone https://github.com/lz4/lz4.git + cd lz4 + git checkout v1.9.4 + cd build\VS2017\liblz4 + msbuild liblz4.vcxproj /p:Configuration=Release /p:platform=x64 -p:PlatformToolset=v142 + cd ..\..\..\.. ) else ( -echo Using libsodium... + echo Using lz4... ) -if not exist "openssl-3.1.4" ( -curl -Lo openssl-3.1.4.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/openssl-3.1.4.zip -IF %errorlevel% NEQ 0 ( - echo Can't download OpenSSL - exit /b %errorlevel% -) -unzip -q openssl-3.1.4.zip +if not exist "libsodium" ( + git clone https://github.com/jedisct1/libsodium + cd libsodium + git checkout 1.0.18-RELEASE + msbuild libsodium.vcxproj /p:Configuration=Release /p:platform=x64 -p:PlatformToolset=v142 + cd .. ) else ( -echo Using openssl... + echo Using libsodium... ) -if not exist "libmicrohttpd-0.9.77-w32-bin" ( -curl -Lo libmicrohttpd-0.9.77-w32-bin.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/libmicrohttpd-0.9.77-w32-bin.zip -IF %errorlevel% NEQ 0 ( - echo Can't download libmicrohttpd - exit /b %errorlevel% -) -unzip -q libmicrohttpd-0.9.77-w32-bin.zip +if not exist "openssl" ( + git clone https://github.com/openssl/openssl.git + cd openssl + git checkout openssl-3.1.4 + where perl + perl Configure VC-WIN64A + IF %errorlevel% NEQ 0 ( + echo Can't configure openssl + exit /b %errorlevel% + ) + nmake + cd .. ) else ( -echo Using libmicrohttpd... + echo Using openssl... ) -if not exist "readline-5.0-1-lib" ( -curl -Lo readline-5.0-1-lib.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/readline-5.0-1-lib.zip -IF %errorlevel% NEQ 0 ( - echo Can't download readline - exit /b %errorlevel% -) -unzip -q -d readline-5.0-1-lib readline-5.0-1-lib.zip +if not exist "libmicrohttpd" ( + git clone https://github.com/Karlson2k/libmicrohttpd.git + cd libmicrohttpd + git checkout v1.0.1 + cd w32\VS2019 + msbuild libmicrohttpd.vcxproj /p:Configuration=Release-static /p:platform=x64 -p:PlatformToolset=v142 + IF %errorlevel% NEQ 0 ( + echo Can't compile libmicrohttpd + exit /b %errorlevel% + ) + cd ../../.. ) else ( -echo Using readline... + echo Using libmicrohttpd... ) - -set root=%cd% -echo %root% -set SODIUM_DIR=%root%\libsodium +cd .. +echo Current dir %cd% mkdir build cd build cmake -GNinja -DCMAKE_BUILD_TYPE=Release ^ -DPORTABLE=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_INCLUDE_DIRS=%root%\lz4\lib ^ --DLZ4_LIBRARIES=%root%\lz4\build\VS2017\liblz4\bin\x64_Release\liblz4_static.lib ^ +-DLZ4_INCLUDE_DIRS=%third_libs%\lz4\lib ^ +-DLZ4_LIBRARIES=%third_libs%\lz4\build\VS2017\liblz4\bin\x64_Release\liblz4_static.lib ^ -DMHD_FOUND=1 ^ --DMHD_LIBRARY=%root%\libmicrohttpd-0.9.77-w32-bin\x86_64\VS2019\Release-static\libmicrohttpd.lib ^ --DMHD_INCLUDE_DIR=%root%\libmicrohttpd-0.9.77-w32-bin\x86_64\VS2019\Release-static ^ +-DMHD_LIBRARY=%third_libs%\libmicrohttpd\w32\VS2019\Output\x64\libmicrohttpd.lib ^ +-DMHD_INCLUDE_DIR=%third_libs%\libmicrohttpd\src\include ^ -DZLIB_FOUND=1 ^ --DZLIB_INCLUDE_DIR=%root%\zlib ^ --DZLIB_LIBRARIES=%root%\zlib\contrib\vstudio\vc14\x64\ZlibStatReleaseWithoutAsm\zlibstat.lib ^ +-DZLIB_INCLUDE_DIR=%third_libs%\zlib ^ +-DZLIB_LIBRARIES=%third_libs%\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 ^ --DREADLINE_INCLUDE_DIR=%root%\readline-5.0-1-lib\include ^ --DREADLINE_LIBRARY=%root%\readline-5.0-1-lib\lib\readline.lib ^ +-DOPENSSL_INCLUDE_DIR=%third_libs%\openssl\include ^ +-DOPENSSL_CRYPTO_LIBRARY=%third_libs%\openssl\libcrypto_static.lib ^ -DCMAKE_CXX_FLAGS="/DTD_WINDOWS=1 /EHsc /bigobj" .. + IF %errorlevel% NEQ 0 ( echo Can't configure TON exit /b %errorlevel% @@ -168,33 +171,38 @@ REM ctest -C Release --output-on-failure -E "test-catchain|test-actors|test-val ) ) - -echo Creating artifacts... +echo Strip and copy artifacts cd .. +echo where strip +where strip mkdir artifacts mkdir artifacts\smartcont mkdir artifacts\lib for %%I in (build\storage\storage-daemon\storage-daemon.exe ^ -build\storage\storage-daemon\storage-daemon-cli.exe ^ -build\blockchain-explorer\blockchain-explorer.exe ^ -build\crypto\fift.exe ^ -build\crypto\tlbc.exe ^ -build\crypto\func.exe ^ -build\tolk\tolk.exe ^ -build\crypto\create-state.exe ^ -build\validator-engine-console\validator-engine-console.exe ^ -build\tonlib\tonlib-cli.exe ^ -build\tonlib\tonlibjson.dll ^ -build\http\http-proxy.exe ^ -build\rldp-http-proxy\rldp-http-proxy.exe ^ -build\dht-server\dht-server.exe ^ -build\lite-client\lite-client.exe ^ -build\validator-engine\validator-engine.exe ^ -build\utils\generate-random-id.exe ^ -build\utils\json2tlo.exe ^ -build\utils\proxy-liteserver.exe ^ -build\adnl\adnl-proxy.exe ^ -build\emulator\emulator.dll) do (strip -s %%I & copy %%I artifacts\) + build\storage\storage-daemon\storage-daemon-cli.exe ^ + build\blockchain-explorer\blockchain-explorer.exe ^ + build\crypto\fift.exe ^ + build\crypto\tlbc.exe ^ + build\crypto\func.exe ^ + build\tolk\tolk.exe ^ + build\crypto\create-state.exe ^ + build\validator-engine-console\validator-engine-console.exe ^ + build\tonlib\tonlib-cli.exe ^ + build\tonlib\tonlibjson.dll ^ + build\http\http-proxy.exe ^ + build\rldp-http-proxy\rldp-http-proxy.exe ^ + build\dht-server\dht-server.exe ^ + build\lite-client\lite-client.exe ^ + build\validator-engine\validator-engine.exe ^ + build\utils\generate-random-id.exe ^ + build\utils\json2tlo.exe ^ + build\utils\proxy-liteserver.exe ^ + 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\fift\lib artifacts\lib diff --git a/assembly/native/build-windows.bat b/assembly/native/build-windows.bat index 0a1d999bf..68f83c394 100644 --- a/assembly/native/build-windows.bat +++ b/assembly/native/build-windows.bat @@ -26,109 +26,109 @@ IF %errorlevel% NEQ 0 ( exit /b %errorlevel% ) -rd /s /q ".\third-party\secp256k1\build" - -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 - +echo Installing nasm... +choco install -y nasm +where nasm +SET PATH=%PATH%;C:\Program Files\NASM IF %errorlevel% NEQ 0 ( - echo Can't install zlib + echo Can't install nasm 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 ( -echo Using zlib... + echo Using zlib... ) if not exist "lz4" ( -git clone https://github.com/lz4/lz4.git -cd lz4 -git checkout v1.9.4 -cd build\VS2017\liblz4 -msbuild liblz4.vcxproj /p:Configuration=Release /p:platform=x64 -p:PlatformToolset=v143 -dir /s -IF %errorlevel% NEQ 0 ( - echo Can't install lz4 - exit /b %errorlevel% -) -cd ..\..\..\.. + git clone https://github.com/lz4/lz4.git + cd lz4 + git checkout v1.9.4 + cd build\VS2022\liblz4 + msbuild liblz4.vcxproj /p:Configuration=Release /p:platform=x64 -p:PlatformToolset=v143 + cd ..\..\..\.. ) else ( -echo Using lz4... + echo Using lz4... ) if not exist "libsodium" ( -curl -Lo libsodium-1.0.18-stable-msvc.zip https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable-msvc.zip -IF %errorlevel% NEQ 0 ( - echo Can't download libsodium - exit /b %errorlevel% -) -unzip libsodium-1.0.18-stable-msvc.zip -) else ( -echo Using libsodium... -) - -if not exist "openssl-3.1.4" ( -curl -Lo openssl-3.1.4.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/openssl-3.1.4.zip -IF %errorlevel% NEQ 0 ( - echo Can't download OpenSSL - exit /b %errorlevel% -) -unzip -q openssl-3.1.4.zip + git clone https://github.com/jedisct1/libsodium + cd libsodium + git checkout 1.0.18-RELEASE + msbuild libsodium.vcxproj /p:Configuration=Release /p:platform=x64 -p:PlatformToolset=v143 + cd .. ) else ( -echo Using openssl... + echo Using libsodium... ) -if not exist "libmicrohttpd-0.9.77-w32-bin" ( -curl -Lo libmicrohttpd-0.9.77-w32-bin.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/libmicrohttpd-0.9.77-w32-bin.zip -IF %errorlevel% NEQ 0 ( - echo Can't download libmicrohttpd - exit /b %errorlevel% -) -unzip -q libmicrohttpd-0.9.77-w32-bin.zip +if not exist "openssl" ( + git clone https://github.com/openssl/openssl.git + cd openssl + git checkout openssl-3.1.4 + where perl + perl Configure VC-WIN64A + IF %errorlevel% NEQ 0 ( + echo Can't configure openssl + exit /b %errorlevel% + ) + nmake + cd .. ) else ( -echo Using libmicrohttpd... + echo Using openssl... ) -if not exist "readline-5.0-1-lib" ( -curl -Lo readline-5.0-1-lib.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/readline-5.0-1-lib.zip -IF %errorlevel% NEQ 0 ( - echo Can't download readline - exit /b %errorlevel% -) -unzip -q -d readline-5.0-1-lib readline-5.0-1-lib.zip +if not exist "libmicrohttpd" ( + git clone https://github.com/Karlson2k/libmicrohttpd.git + cd libmicrohttpd + git checkout v1.0.1 + cd w32\VS2022 + msbuild libmicrohttpd.vcxproj /p:Configuration=Release-static /p:platform=x64 -p:PlatformToolset=v143 + IF %errorlevel% NEQ 0 ( + echo Can't compile libmicrohttpd + exit /b %errorlevel% + ) + cd ../../.. ) else ( -echo Using readline... + echo Using libmicrohttpd... ) - -set root=%cd% -echo %root% -set SODIUM_DIR=%root%\libsodium +cd .. +echo Current dir %cd% mkdir build cd build cmake -GNinja -DCMAKE_BUILD_TYPE=Release ^ -DPORTABLE=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_INCLUDE_DIRS=%root%\lz4\lib ^ --DLZ4_LIBRARIES=%root%\lz4\build\VS2017\liblz4\bin\x64_Release\liblz4_static.lib ^ +-DLZ4_INCLUDE_DIRS=%third_libs%\lz4\lib ^ +-DLZ4_LIBRARIES=%third_libs%\lz4\build\VS2022\liblz4\bin\x64_Release\liblz4_static.lib ^ -DMHD_FOUND=1 ^ --DMHD_LIBRARY=%root%\libmicrohttpd-0.9.77-w32-bin\x86_64\VS2019\Release-static\libmicrohttpd.lib ^ --DMHD_INCLUDE_DIR=%root%\libmicrohttpd-0.9.77-w32-bin\x86_64\VS2019\Release-static ^ +-DMHD_LIBRARY=%third_libs%\libmicrohttpd\w32\VS2022\Output\x64\libmicrohttpd.lib ^ +-DMHD_INCLUDE_DIR=%third_libs%\libmicrohttpd\src\include ^ -DZLIB_FOUND=1 ^ --DZLIB_INCLUDE_DIR=%root%\zlib ^ --DZLIB_LIBRARIES=%root%\zlib\contrib\vstudio\vc14\x64\ZlibStatReleaseWithoutAsm\zlibstat.lib ^ +-DZLIB_INCLUDE_DIR=%third_libs%\zlib ^ +-DZLIB_LIBRARIES=%third_libs%\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 ^ --DREADLINE_INCLUDE_DIR=%root%\readline-5.0-1-lib\include ^ --DREADLINE_LIBRARY=%root%\readline-5.0-1-lib\lib\readline.lib ^ +-DOPENSSL_INCLUDE_DIR=%third_libs%\openssl\include ^ +-DOPENSSL_CRYPTO_LIBRARY=%third_libs%\openssl\libcrypto_static.lib ^ -DCMAKE_CXX_FLAGS="/DTD_WINDOWS=1 /EHsc /bigobj" .. + IF %errorlevel% NEQ 0 ( echo Can't configure TON exit /b %errorlevel% @@ -171,32 +171,38 @@ REM ctest -C Release --output-on-failure -E "test-catchain|test-actors|test-val ) ) - -echo Creating artifacts... +echo Strip and copy artifacts cd .. +echo where strip +where strip mkdir artifacts mkdir artifacts\smartcont mkdir artifacts\lib for %%I in (build\storage\storage-daemon\storage-daemon.exe ^ -build\storage\storage-daemon\storage-daemon-cli.exe ^ -build\blockchain-explorer\blockchain-explorer.exe ^ -build\crypto\fift.exe ^ -build\crypto\tlbc.exe ^ -build\crypto\func.exe ^ -build\tolk\tolk.exe ^ -build\crypto\create-state.exe ^ -build\validator-engine-console\validator-engine-console.exe ^ -build\tonlib\tonlib-cli.exe ^ -build\tonlib\tonlibjson.dll ^ -build\http\http-proxy.exe ^ -build\rldp-http-proxy\rldp-http-proxy.exe ^ -build\dht-server\dht-server.exe ^ -build\lite-client\lite-client.exe ^ -build\validator-engine\validator-engine.exe ^ -build\utils\generate-random-id.exe ^ -build\utils\json2tlo.exe ^ -build\adnl\adnl-proxy.exe ^ -build\emulator\emulator.dll) do (strip -s %%I & copy %%I artifacts\) + build\storage\storage-daemon\storage-daemon-cli.exe ^ + build\blockchain-explorer\blockchain-explorer.exe ^ + build\crypto\fift.exe ^ + build\crypto\tlbc.exe ^ + build\crypto\func.exe ^ + build\tolk\tolk.exe ^ + build\crypto\create-state.exe ^ + build\validator-engine-console\validator-engine-console.exe ^ + build\tonlib\tonlib-cli.exe ^ + build\tonlib\tonlibjson.dll ^ + build\http\http-proxy.exe ^ + build\rldp-http-proxy\rldp-http-proxy.exe ^ + build\dht-server\dht-server.exe ^ + build\lite-client\lite-client.exe ^ + build\validator-engine\validator-engine.exe ^ + build\utils\generate-random-id.exe ^ + build\utils\json2tlo.exe ^ + build\utils\proxy-liteserver.exe ^ + 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\fift\lib artifacts\lib diff --git a/ton/ton-types.h b/ton/ton-types.h index f8eb49df1..220af6e02 100644 --- a/ton/ton-types.h +++ b/ton/ton-types.h @@ -121,6 +121,26 @@ struct ShardIdFull { char buffer[64]; return std::string{buffer, (unsigned)snprintf(buffer, 63, "(%d,%016llx)", workchain, (unsigned long long)shard)}; } + static td::Result 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(s.substr(0, sep))); + TRY_RESULT_ASSIGN(shard.shard, td::hex_to_integer_safe(s.substr(sep + 1))); + return shard; + } }; struct AccountIdPrefixFull { diff --git a/validator-engine-console/validator-engine-console-query.cpp b/validator-engine-console/validator-engine-console-query.cpp index c0170a067..d229b9329 100644 --- a/validator-engine-console/validator-engine-console-query.cpp +++ b/validator-engine-console/validator-engine-console-query.cpp @@ -1035,8 +1035,7 @@ td::Status ImportCertificateQuery::receive(td::BufferSlice data) { } td::Status SignShardOverlayCertificateQuery::run() { - TRY_RESULT_ASSIGN(wc_, tokenizer_.get_token()); - TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token()); + TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token() ); TRY_RESULT_ASSIGN(key_, tokenizer_.get_token()); TRY_RESULT_ASSIGN(expire_at_, tokenizer_.get_token()); TRY_RESULT_ASSIGN(max_size_, tokenizer_.get_token()); @@ -1047,7 +1046,8 @@ td::Status SignShardOverlayCertificateQuery::run() { td::Status SignShardOverlayCertificateQuery::send() { auto b = ton::create_serialize_tl_object( - wc_, shard_, ton::create_tl_object(key_.tl()), expire_at_, max_size_); + shard_.workchain, shard_.shard, ton::create_tl_object(key_.tl()), + expire_at_, max_size_); td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise()); return td::Status::OK(); } @@ -1065,8 +1065,7 @@ td::Status SignShardOverlayCertificateQuery::receive(td::BufferSlice data) { } td::Status ImportShardOverlayCertificateQuery::run() { - TRY_RESULT_ASSIGN(wc_, tokenizer_.get_token()); - TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token()); + TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token()); TRY_RESULT_ASSIGN(key_, tokenizer_.get_token()); TRY_RESULT_ASSIGN(in_file_, tokenizer_.get_token()); @@ -1078,7 +1077,8 @@ td::Status ImportShardOverlayCertificateQuery::send() { TRY_RESULT_PREFIX(cert, ton::fetch_tl_object(data.as_slice(), true), "incorrect certificate"); auto b = ton::create_serialize_tl_object( - wc_, shard_, ton::create_tl_object(key_.tl()), std::move(cert)); + shard_.workchain, shard_.shard, ton::create_tl_object(key_.tl()), + std::move(cert)); td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise()); return td::Status::OK(); } @@ -1167,14 +1167,12 @@ td::Status GetPerfTimerStatsJsonQuery::receive(td::BufferSlice data) { } td::Status GetShardOutQueueSizeQuery::run() { - TRY_RESULT_ASSIGN(block_id_.workchain, tokenizer_.get_token()); - TRY_RESULT_ASSIGN(block_id_.shard, tokenizer_.get_token()); + TRY_RESULT(shard, tokenizer_.get_token()); + block_id_.workchain = shard.workchain; + block_id_.shard = shard.shard; TRY_RESULT_ASSIGN(block_id_.seqno, tokenizer_.get_token()); if (!tokenizer_.endl()) { - ton::ShardIdFull dest; - TRY_RESULT_ASSIGN(dest.workchain, tokenizer_.get_token()); - TRY_RESULT_ASSIGN(dest.shard, tokenizer_.get_token()); - dest_ = dest; + TRY_RESULT_ASSIGN(dest_, tokenizer_.get_token()); } TRY_STATUS(tokenizer_.check_endl()); return td::Status::OK(); @@ -1182,8 +1180,7 @@ td::Status GetShardOutQueueSizeQuery::run() { td::Status GetShardOutQueueSizeQuery::send() { auto b = ton::create_serialize_tl_object( - dest_ ? 1 : 0, ton::create_tl_block_id_simple(block_id_), dest_ ? dest_.value().workchain : 0, - dest_ ? dest_.value().shard : 0); + dest_.is_valid() ? 1 : 0, ton::create_tl_block_id_simple(block_id_), dest_.workchain, dest_.shard); td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise()); return td::Status::OK(); } @@ -1557,14 +1554,13 @@ td::Status GetAdnlStatsQuery::receive(td::BufferSlice data) { } td::Status AddShardQuery::run() { - TRY_RESULT_ASSIGN(wc_, tokenizer_.get_token()); - TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token()); + TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token()); + TRY_STATUS(tokenizer_.check_endl()); return td::Status::OK(); } td::Status AddShardQuery::send() { - auto b = ton::create_serialize_tl_object( - ton::create_tl_shard_id(ton::ShardIdFull(wc_, shard_))); + auto b = ton::create_serialize_tl_object(ton::create_tl_shard_id(shard_)); td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise()); return td::Status::OK(); } @@ -1577,14 +1573,13 @@ td::Status AddShardQuery::receive(td::BufferSlice data) { } td::Status DelShardQuery::run() { - TRY_RESULT_ASSIGN(wc_, tokenizer_.get_token()); - TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token()); + TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token()); + TRY_STATUS(tokenizer_.check_endl()); return td::Status::OK(); } td::Status DelShardQuery::send() { - auto b = ton::create_serialize_tl_object( - ton::create_tl_shard_id(ton::ShardIdFull(wc_, shard_))); + auto b = ton::create_serialize_tl_object(ton::create_tl_shard_id(shard_)); td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise()); return td::Status::OK(); } @@ -1598,14 +1593,13 @@ td::Status DelShardQuery::receive(td::BufferSlice data) { td::Status AddCollatorQuery::run() { TRY_RESULT_ASSIGN(adnl_id_, tokenizer_.get_token()); - TRY_RESULT_ASSIGN(wc_, tokenizer_.get_token()); - TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token()); + TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token()); return td::Status::OK(); } td::Status AddCollatorQuery::send() { - auto b = ton::create_serialize_tl_object( - adnl_id_.tl(), ton::create_tl_shard_id(ton::ShardIdFull(wc_, shard_))); + auto b = ton::create_serialize_tl_object(adnl_id_.tl(), + ton::create_tl_shard_id(shard_)); td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise()); return td::Status::OK(); } @@ -1619,14 +1613,13 @@ td::Status AddCollatorQuery::receive(td::BufferSlice data) { td::Status DelCollatorQuery::run() { TRY_RESULT_ASSIGN(adnl_id_, tokenizer_.get_token()); - TRY_RESULT_ASSIGN(wc_, tokenizer_.get_token()); - TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token()); + TRY_RESULT_ASSIGN(shard_, tokenizer_.get_token()); return td::Status::OK(); } td::Status DelCollatorQuery::send() { - auto b = ton::create_serialize_tl_object( - adnl_id_.tl(), ton::create_tl_shard_id(ton::ShardIdFull(wc_, shard_))); + auto b = ton::create_serialize_tl_object(adnl_id_.tl(), + ton::create_tl_shard_id(shard_)); td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise()); return td::Status::OK(); } diff --git a/validator-engine-console/validator-engine-console-query.h b/validator-engine-console/validator-engine-console-query.h index 60e05d59c..417374518 100644 --- a/validator-engine-console/validator-engine-console-query.h +++ b/validator-engine-console/validator-engine-console-query.h @@ -36,6 +36,7 @@ #include "ton/ton-types.h" #include "keys/keys.hpp" +#include "td/utils/base64.h" class ValidatorEngineConsole; @@ -95,27 +96,25 @@ inline td::Result Tokenizer::get_token() { } template <> -inline td::Result Tokenizer::get_token() { - TRY_RESULT(S, get_raw_token()); - TRY_RESULT(F, td::hex_decode(S)); - if (F.size() == 32) { - return ton::PublicKeyHash{td::Slice{F}}; +inline td::Result Tokenizer::get_token() { + TRY_RESULT(word, get_raw_token()); + std::string data; + if (word.size() == 64) { + TRY_RESULT_ASSIGN(data, td::hex_decode(word)); + } else if (word.size() == 44) { + TRY_RESULT_ASSIGN(data, td::base64_decode(word)); } else { return td::Status::Error("cannot parse keyhash: bad length"); } + td::Bits256 v; + v.as_slice().copy_from(data); + return v; } template <> -inline td::Result Tokenizer::get_token() { - TRY_RESULT(S, get_raw_token()); - TRY_RESULT(F, td::hex_decode(S)); - 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"); - } +inline td::Result Tokenizer::get_token() { + TRY_RESULT(x, get_token()); + return ton::PublicKeyHash{x}; } template <> @@ -146,6 +145,18 @@ inline td::Result> Tokenizer::get_token_vector() { } } +template <> +inline td::Result Tokenizer::get_token() { + TRY_RESULT(word, get_raw_token()); + auto r_wc = td::to_integer_safe(word); + if (r_wc.is_ok()) { + TRY_RESULT_ASSIGN(word, get_raw_token()); + TRY_RESULT(shard, td::to_integer_safe(word)); + return ton::ShardIdFull{r_wc.move_as_ok(), shard}; + } + return ton::ShardIdFull::parse(word); +} + class QueryRunner { public: virtual ~QueryRunner() = default; @@ -222,10 +233,10 @@ class GetTimeQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice R) override; static std::string get_name() { - return "gettime"; + return "get-time"; } static std::string get_help() { - return "gettime\tshows current server unixtime"; + return "get-time\tshows current server unixtime"; } std::string name() const override { return get_name(); @@ -287,10 +298,10 @@ class NewKeyQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice R) override; static std::string get_name() { - return "newkey"; + return "new-key"; } 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 { return get_name(); @@ -308,10 +319,10 @@ class ImportPrivateKeyFileQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice R) override; static std::string get_name() { - return "importf"; + return "import-f"; } static std::string get_help() { - return "importf \timport private key"; + return "import-f \timport private key"; } std::string name() const override { return get_name(); @@ -330,10 +341,10 @@ class ExportPublicKeyQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice R) override; static std::string get_name() { - return "exportpub"; + return "export-pub"; } static std::string get_help() { - return "exportpub \texports public key by key hash"; + return "export-pub \texports public key by key hash"; } std::string name() const override { return get_name(); @@ -352,10 +363,10 @@ class ExportPublicKeyFileQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice R) override; static std::string get_name() { - return "exportpubf"; + return "export-pubf"; } static std::string get_help() { - return "exportpubf \texports public key by key hash"; + return "export-pub-f \texports public key by key hash"; } std::string name() const override { return get_name(); @@ -398,10 +409,10 @@ class SignFileQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "signf"; + return "sign-f"; } static std::string get_help() { - return "signf \tsigns bytestring with privkey"; + return "sign-f \tsigns bytestring with privkey"; } std::string name() const override { return get_name(); @@ -422,10 +433,10 @@ class ExportAllPrivateKeysQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice R) override; static std::string get_name() { - return "exportallprivatekeys"; + return "export-all-private-keys"; } static std::string get_help() { - return "exportallprivatekeys \texports all private keys from validator engine and stores them to " + return "export-all-private-keys \texports all private keys from validator engine and stores them to " ""; } std::string name() const override { @@ -446,10 +457,10 @@ class AddAdnlAddrQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "addadnl"; + return "add-adnl"; } static std::string get_help() { - return "addadnl \tuse key as ADNL addr"; + return "add-adnl \tuse key as ADNL addr"; } std::string name() const override { return get_name(); @@ -469,10 +480,10 @@ class AddDhtIdQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "adddht"; + return "add-dht"; } static std::string get_help() { - return "adddht \tcreate DHT node with specified ADNL addr"; + return "add-dht \tcreate DHT node with specified ADNL addr"; } std::string name() const override { return get_name(); @@ -491,10 +502,10 @@ class AddValidatorPermanentKeyQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "addpermkey"; + return "add-perm-key"; } static std::string get_help() { - return "addpermkey \tadd validator permanent key"; + return "add-perm-key \tadd validator permanent key"; } std::string name() const override { return get_name(); @@ -515,10 +526,10 @@ class AddValidatorTempKeyQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "addtempkey"; + return "add-temp-key"; } static std::string get_help() { - return "addtempkey \tadd validator temp key"; + return "add-temp-key \tadd validator temp key"; } std::string name() const override { return get_name(); @@ -539,10 +550,10 @@ class AddValidatorAdnlAddrQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "addvalidatoraddr"; + return "add-validator-addr"; } static std::string get_help() { - return "addvalidatoraddr \tadd validator ADNL addr"; + return "add-validator-addr \tadd validator ADNL addr"; } std::string name() const override { return get_name(); @@ -563,10 +574,10 @@ class ChangeFullNodeAdnlAddrQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "changefullnodeaddr"; + return "change-full-node-addr"; } static std::string get_help() { - return "changefullnodeaddr \tchanges fullnode ADNL address"; + return "change-full-node-addr \tchanges fullnode ADNL address"; } std::string name() const override { return get_name(); @@ -585,10 +596,10 @@ class AddLiteServerQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "addliteserver"; + return "add-liteserver"; } static std::string get_help() { - return "addliteserver \tadd liteserver"; + return "add-liteserver \tadd liteserver"; } std::string name() const override { return get_name(); @@ -608,10 +619,10 @@ class DelAdnlAddrQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "deladnl"; + return "del-adnl"; } static std::string get_help() { - return "deladnl \tdel unused ADNL addr"; + return "del-adnl \tdel unused ADNL addr"; } std::string name() const override { return get_name(); @@ -630,10 +641,10 @@ class DelDhtIdQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "deldht"; + return "del-dht"; } static std::string get_help() { - return "deldht \tdel unused DHT node"; + return "del-dht \tdel unused DHT node"; } std::string name() const override { return get_name(); @@ -652,10 +663,10 @@ class DelValidatorPermanentKeyQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "delpermkey"; + return "del-perm-key"; } static std::string get_help() { - return "delpermkey \tforce del unused validator permanent key"; + return "del-perm-key \tforce del unused validator permanent key"; } std::string name() const override { return get_name(); @@ -674,10 +685,10 @@ class DelValidatorTempKeyQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "deltempkey"; + return "del-temp-key"; } static std::string get_help() { - return "deltempkey \tforce del unused validator temp key"; + return "del-temp-key \tforce del unused validator temp key"; } std::string name() const override { return get_name(); @@ -697,10 +708,10 @@ class DelValidatorAdnlAddrQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "delvalidatoraddr"; + return "del-validator-addr"; } static std::string get_help() { - return "delvalidatoraddr \tforce del unused validator ADNL addr"; + return "del-validator-addr \tforce del unused validator ADNL addr"; } std::string name() const override { return get_name(); @@ -720,10 +731,10 @@ class GetConfigQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "getconfig"; + return "get-config"; } static std::string get_help() { - return "getconfig\tdownloads current config"; + return "get-config\tdownloads current config"; } std::string name() const override { return get_name(); @@ -741,10 +752,10 @@ class SetVerbosityQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "setverbosity"; + return "set-verbosity"; } static std::string get_help() { - return "setverbosity \tchanges verbosity level"; + return "set-verbosity \tchanges verbosity level"; } std::string name() const override { return get_name(); @@ -763,10 +774,10 @@ class GetStatsQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "getstats"; + return "get-stats"; } static std::string get_help() { - return "getstats\tprints stats"; + return "get-stats\tprints stats"; } std::string name() const override { return get_name(); @@ -807,10 +818,10 @@ class AddNetworkAddressQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "addaddr"; + return "add-addr"; } static std::string get_help() { - return "addaddr {cats...} {priocats...}\tadds ip address to address list"; + return "add-addr {cats...} {priocats...}\tadds ip address to address list"; } std::string name() const override { return get_name(); @@ -831,10 +842,10 @@ class AddNetworkProxyAddressQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "addproxyaddr"; + return "add-proxy-addr"; } static std::string get_help() { - return "addproxyaddr {cats...} {priocats...}\tadds ip address to address list"; + return "add-proxy-addr {cats...} {priocats...}\tadds ip address to address list"; } std::string name() const override { return get_name(); @@ -858,10 +869,10 @@ class CreateElectionBidQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "createelectionbid"; + return "create-election-bid"; } static std::string get_help() { - return "createelectionbid \tcreate election bid"; + return "create-election-bid \tcreate election bid"; } std::string name() const override { return get_name(); @@ -883,10 +894,10 @@ class CreateProposalVoteQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "createproposalvote"; + return "create-proposal-vote"; } static std::string get_help() { - return "createproposalvote \tcreate proposal vote"; + return "create-proposal-vote \tcreate proposal vote"; } std::string name() const override { return get_name(); @@ -906,10 +917,10 @@ class CreateComplaintVoteQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "createcomplaintvote"; + return "create-complaint-vote"; } static std::string get_help() { - return "createcomplaintvote \tcreate proposal vote"; + return "create-complaint-vote \tcreate proposal vote"; } std::string name() const override { return get_name(); @@ -930,10 +941,10 @@ class CheckDhtServersQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "checkdht"; + return "check-dht"; } static std::string get_help() { - return "checkdht \tchecks, which root DHT servers are accessible from this ADNL addr"; + return "check-dht \tchecks, which root DHT servers are accessible from this ADNL addr"; } std::string name() const override { return get_name(); @@ -952,10 +963,10 @@ class GetOverlaysStatsQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "getoverlaysstats"; + return "get-overlays-stats"; } 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 { return get_name(); @@ -971,10 +982,10 @@ class GetOverlaysStatsJsonQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "getoverlaysstatsjson"; + return "get-overlays-stats-json"; } static std::string get_help() { - return "getoverlaysstatsjson \tgets stats for all overlays and writes to json file"; + return "get-overlays-stats-json \tgets stats for all overlays and writes to json file"; } std::string name() const override { return get_name(); @@ -993,10 +1004,10 @@ class SignCertificateQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "signcert"; + return "sign-cert"; } static std::string get_help() { - return "signcert \tsign overlay certificate by " + return "sign-cert \tsign overlay certificate by " " key"; } std::string name() const override { @@ -1029,10 +1040,10 @@ class ImportCertificateQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "importcert"; + return "import-cert"; } static std::string get_help() { - return "importcert \timport overlay certificate for specific key"; + return "import-cert \timport overlay certificate for specific key"; } std::string name() const override { return get_name(); @@ -1054,19 +1065,18 @@ class SignShardOverlayCertificateQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "signshardoverlaycert"; + return "sign-shard-overlay-cert"; } static std::string get_help() { - return "signshardoverlaycert \tsign certificate for " - " in currently active shard overlay"; + return "sign-shard-overlay-cert : \tsign certificate " + "for in currently active shard overlay"; } std::string name() const override { return get_name(); } private: - td::int32 wc_; - td::int64 shard_; + ton::ShardIdFull shard_; td::int32 expire_at_; ton::PublicKeyHash key_; td::uint32 max_size_; @@ -1082,10 +1092,10 @@ class ImportShardOverlayCertificateQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "importshardoverlaycert"; + return "import-shard-overlay-cert"; } static std::string get_help() { - return "importshardoverlaycert \timport certificate for in " + return "import-shard-overlay-cert : \timport certificate for in " "currently active shard overlay"; } std::string name() const override { @@ -1093,8 +1103,7 @@ class ImportShardOverlayCertificateQuery : public Query { } private: - td::int32 wc_; - td::int64 shard_; + ton::ShardIdFull shard_; ton::PublicKeyHash key_; std::string in_file_; }; @@ -1108,10 +1117,10 @@ class GetActorStatsQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "getactorstats"; + return "get-actor-stats"; } static std::string get_help() { - return "getactorstats []\tget actor stats and print it either in stdout or in "; + return "get-actor-stats []\tget actor stats and print it either in stdout or in "; } std::string name() const override { return get_name(); @@ -1130,11 +1139,11 @@ class GetPerfTimerStatsJsonQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "getperftimerstatsjson"; + return "get-perf-timer-stats-json"; } static std::string get_help() { - return "getperftimerstatsjson \tgets min, average and max event processing time for last 60, 300 and 3600 " - "seconds and writes to json file"; + return "get-perf-timer-stats-json \tgets min, average and max event processing time for last 60, 300 and " + "3600 seconds and writes to json file"; } std::string name() const override { return get_name(); @@ -1153,10 +1162,10 @@ class GetShardOutQueueSizeQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "getshardoutqueuesize"; + return "get-shard-out-queue-size"; } static std::string get_help() { - return "getshardoutqueuesize [ ]\treturns number of messages in the " + return "get-shard-out-queue-size : [:]\treturns number of messages in the " "queue of the given shard. Destination shard is optional."; } std::string name() const override { @@ -1165,7 +1174,7 @@ class GetShardOutQueueSizeQuery : public Query { private: ton::BlockId block_id_; - td::optional dest_; + ton::ShardIdFull dest_ = ton::ShardIdFull{ton::workchainInvalid}; }; class SetExtMessagesBroadcastDisabledQuery : public Query { @@ -1177,11 +1186,11 @@ class SetExtMessagesBroadcastDisabledQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "setextmessagesbroadcastdisabled"; + return "set-ext-messages-broadcast-disabled"; } static std::string get_help() { - return "setextmessagesbroadcastdisabled \tdisable broadcasting and rebroadcasting ext messages; value is 0 " - "or 1."; + return "set-ext-messages-broadcast-disabled \tdisable broadcasting and rebroadcasting ext messages; value " + "is 0 or 1."; } std::string name() const override { return get_name(); @@ -1200,10 +1209,10 @@ class AddCustomOverlayQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "addcustomoverlay"; + return "add-custom-overlay"; } static std::string get_help() { - return "addcustomoverlay \tadd custom overlay with config from file "; + return "add-custom-overlay \tadd custom overlay with config from file "; } std::string name() const override { return get_name(); @@ -1222,10 +1231,10 @@ class DelCustomOverlayQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "delcustomoverlay"; + return "del-custom-overlay"; } static std::string get_help() { - return "delcustomoverlay \tdelete custom overlay with name "; + return "del-custom-overlay \tdelete custom overlay with name "; } std::string name() const override { return get_name(); @@ -1244,10 +1253,10 @@ class ShowCustomOverlaysQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "showcustomoverlays"; + return "show-custom-overlays"; } static std::string get_help() { - return "showcustomoverlays\tshow all custom overlays"; + return "show-custom-overlays\tshow all custom overlays"; } std::string name() const override { return get_name(); @@ -1263,10 +1272,10 @@ class SetStateSerializerEnabledQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "setstateserializerenabled"; + return "set-state-serializer-enabled"; } static std::string get_help() { - return "setstateserializerenabled \tdisable or enable persistent state serializer; value is 0 or 1"; + return "set-state-serializer-enabled \tdisable or enable persistent state serializer; value is 0 or 1"; } std::string name() const override { return get_name(); @@ -1285,10 +1294,10 @@ class SetCollatorOptionsJsonQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "setcollatoroptionsjson"; + return "set-collator-options-json"; } static std::string get_help() { - return "setcollatoroptionsjson \tset collator options from file "; + return "set-collator-options-json \tset collator options from file "; } std::string name() const override { return get_name(); @@ -1307,10 +1316,10 @@ class ResetCollatorOptionsQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "resetcollatoroptions"; + return "reset-collator-options"; } 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 { return get_name(); @@ -1326,10 +1335,10 @@ class GetCollatorOptionsJsonQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "getcollatoroptionsjson"; + return "get-collator-options-json"; } static std::string get_help() { - return "getcollatoroptionsjson \tsave current collator options to file "; + return "get-collator-options-json \tsave current collator options to file "; } std::string name() const override { return get_name(); @@ -1348,11 +1357,11 @@ class GetAdnlStatsJsonQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "getadnlstatsjson"; + return "get-adnl-stats-json"; } static std::string get_help() { - return "getadnlstatsjson [all]\tsave adnl stats to . all - returns all peers (default - only " - "peers with traffic in the last 10 minutes)"; + return "get-adnl-stats-json [all]\tsave adnl stats to . all - returns all peers (default - " + "only peers with traffic in the last 10 minutes)"; } std::string name() const override { return get_name(); @@ -1372,11 +1381,11 @@ class GetAdnlStatsQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "getadnlstats"; + return "get-adnl-stats"; } static std::string get_help() { - return "getadnlstats [all]\tdisplay adnl stats. all - returns all peers (default - only peers with traffic in the " - "last 10 minutes)"; + return "get-adnl-stats [all]\tdisplay adnl stats. all - returns all peers (default - only peers with traffic in " + "the last 10 minutes)"; } std::string name() const override { return get_name(); @@ -1396,18 +1405,17 @@ class AddShardQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "addshard"; + return "add-shard"; } static std::string get_help() { - return "addshard \tstart monitoring shard"; + return "add-shard :\tstart monitoring shard"; } std::string name() const override { return get_name(); } private: - td::int32 wc_; - td::int64 shard_; + ton::ShardIdFull shard_; }; class DelShardQuery : public Query { @@ -1419,18 +1427,17 @@ class DelShardQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "delshard"; + return "del-shard"; } static std::string get_help() { - return "delshard \tstop monitoring shard"; + return "del-shard :\tstop monitoring shard"; } std::string name() const override { return get_name(); } private: - td::int32 wc_; - td::int64 shard_; + ton::ShardIdFull shard_; }; class AddCollatorQuery : public Query { @@ -1442,10 +1449,10 @@ class AddCollatorQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "addcollator"; + return "add-collator"; } static std::string get_help() { - return "addcollator \tadd collator with given adnl_id and shard"; + return "add-collator \tadd collator with given adnl_id and shard"; } std::string name() const override { return get_name(); @@ -1453,8 +1460,7 @@ class AddCollatorQuery : public Query { private: ton::PublicKeyHash adnl_id_; - td::int32 wc_; - td::int64 shard_; + ton::ShardIdFull shard_; }; class DelCollatorQuery : public Query { @@ -1466,10 +1472,10 @@ class DelCollatorQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "delcollator"; + return "del-collator"; } static std::string get_help() { - return "delcollator \tremove collator with given adnl_id and shard"; + return "del-collator \tremove collator with given adnl_id and shard"; } std::string name() const override { return get_name(); @@ -1477,8 +1483,7 @@ class DelCollatorQuery : public Query { private: ton::PublicKeyHash adnl_id_; - td::int32 wc_; - td::int64 shard_; + ton::ShardIdFull shard_; }; class CollatorNodeAddWhitelistedValidatorQuery : public Query { @@ -1490,10 +1495,10 @@ class CollatorNodeAddWhitelistedValidatorQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "collatorwhitelistadd"; + return "collator-whitelist-add"; } static std::string get_help() { - return "collatorwhitelistadd \tadd validator adnl id to collator node whitelist"; + return "collator-whitelist-add \tadd validator adnl id to collator node whitelist"; } std::string name() const override { return get_name(); @@ -1512,10 +1517,10 @@ class CollatorNodeDelWhitelistedValidatorQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "collatorwhitelistdel"; + return "collator-whitelist-del"; } static std::string get_help() { - return "collatorwhitelistdel \tremove validator adnl id from collator node whitelist"; + return "collator-whitelist-del \tremove validator adnl id from collator node whitelist"; } std::string name() const override { return get_name(); @@ -1534,10 +1539,10 @@ class CollatorNodeEnableWhitelistQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "collatorwhitelistenable"; + return "collator-whitelist-enable"; } static std::string get_help() { - return "collatorwhitelistenable \tenable or disable collator node whiltelist (value is 0 or 1)"; + return "collator-whitelist-enable \tenable or disable collator node whiltelist (value is 0 or 1)"; } std::string name() const override { return get_name(); @@ -1556,10 +1561,10 @@ class CollatorNodeShowWhitelistQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "collatorwhitelistshow"; + return "collator-whitelist-show"; } static std::string get_help() { - return "collatorwhitelistshow\tshow collator node whitelist"; + return "collator-whitelist-show\tshow collator node whitelist"; } std::string name() const override { return get_name(); @@ -1575,10 +1580,10 @@ class SetCollatorsListQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "setcollatorslist"; + return "set-collators-list"; } static std::string get_help() { - return "setcollatorslist \tset list of collators from file "; + return "set-collators-list \tset list of collators from file "; } std::string name() const override { return get_name(); @@ -1597,10 +1602,10 @@ class ClearCollatorsListQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "clearcollatorslist"; + return "clear-collators-list"; } static std::string get_help() { - return "clearcollatorslist\tclear list of collators"; + return "clear-collators-list\tclear list of collators"; } std::string name() const override { return get_name(); @@ -1616,10 +1621,10 @@ class ShowCollatorsListQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "showcollatorslist"; + return "show-collators-list"; } static std::string get_help() { - return "showcollatorslist\tshow list of collators"; + return "show-collators-list\tshow list of collators"; } std::string name() const override { return get_name(); @@ -1635,10 +1640,10 @@ class GetCollationManagerStatsQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "collationmanagerstats"; + return "collation-manager-stats"; } 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 { return get_name(); @@ -1654,10 +1659,10 @@ class SignOverlayMemberCertificateQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "signoverlaymembercertificate"; + return "sign-overlay-member-certificate"; } static std::string get_help() { - return "signoverlaymembercertificate \tsign overlay member " + return "sign-overlay-member-certificate \tsign overlay member " "certificate for (hex) with (hex) in slot , valid until , " "save to "; } @@ -1682,10 +1687,10 @@ class ImportFastSyncMemberCertificateQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "importfastsyncmembercertificate"; + return "import-fast-sync-member-certificate"; } static std::string get_help() { - return "importfastsyncmembercertificate \timport member certificate for fast sync overlay " + return "import-fast-sync-membe-rcertificate \timport member certificate for fast sync overlay " "for (hex) from "; } std::string name() const override { @@ -1706,11 +1711,11 @@ class AddFastSyncOverlayClientQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "addfastsyncoverlayclient"; + return "add-fast-sync-overlay-client"; } static std::string get_help() { - return "addfastsyncoverlayclient \tstarts issuing member certificates " - "to (hex) on slot (int)"; + return "add-fast-sync-overlay-client \tstarts issuing member certificates to (hex) on " + "slot (int)"; } std::string name() const override { return get_name(); @@ -1730,11 +1735,10 @@ class DelFastSyncOverlayClientQuery : public Query { td::Status send() override; td::Status receive(td::BufferSlice data) override; static std::string get_name() { - return "delfastsyncoverlayclient"; + return "del-fast-sync-overlay-client"; } static std::string get_help() { - return "delfastsyncoverlayclient \tstops issuing member certificates " - "to (hex)"; + return "del-fast-sync-overlay-client \tstops issuing member certificates to (hex)"; } std::string name() const override { return get_name(); diff --git a/validator-engine-console/validator-engine-console.cpp b/validator-engine-console/validator-engine-console.cpp index d80316812..9520dd111 100644 --- a/validator-engine-console/validator-engine-console.cpp +++ b/validator-engine-console/validator-engine-console.cpp @@ -220,9 +220,8 @@ void ValidatorEngineConsole::show_help(std::string command, td::Promisehelp() << "\n"; } } else { - auto it = query_runners_.find(command); - if (it != query_runners_.end()) { - td::TerminalIO::out() << it->second->help() << "\n"; + if (auto query = get_query(command)) { + td::TerminalIO::out() << query->help() << "\n"; } else { td::TerminalIO::out() << "unknown command '" << command << "'\n"; } @@ -246,10 +245,9 @@ void ValidatorEngineConsole::parse_line(td::BufferSlice data) { } auto name = tokenizer.get_token().move_as_ok(); - auto it = query_runners_.find(name); - if (it != query_runners_.end()) { + if (auto query = get_query(name)) { running_queries_++; - it->second->run(actor_id(this), std::move(tokenizer)); + query->run(actor_id(this), std::move(tokenizer)); } else { td::TerminalIO::out() << "unknown command '" << name << "'\n"; } diff --git a/validator-engine-console/validator-engine-console.h b/validator-engine-console/validator-engine-console.h index 7a3842769..c802794ef 100644 --- a/validator-engine-console/validator-engine-console.h +++ b/validator-engine-console/validator-engine-console.h @@ -57,9 +57,23 @@ class ValidatorEngineConsole : public td::actor::Actor { std::unique_ptr make_callback(); std::map> query_runners_; + std::map 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 runner) { auto name = runner->name(); 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: