mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Compare commits
305 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0439613bff | ||
|
|
cf50b4b5da | ||
|
|
6eeae5d78b | ||
|
|
faf58118a4 | ||
|
|
f67e9f4b6f | ||
|
|
ef0328837f | ||
|
|
7bcb8b895f | ||
|
|
f3e620f48c | ||
|
|
44e7e091b2 | ||
|
|
b3b2bd1c3c | ||
|
|
1389ff6789 | ||
|
|
1b70e48327 | ||
|
|
3ff951c225 | ||
|
|
901467f424 | ||
|
|
1e8fdc0561 | ||
|
|
61b9155d15 | ||
|
|
8a08bf67a2 | ||
|
|
04f2bc1360 | ||
|
|
aca51a8dae | ||
|
|
9d94e04d20 | ||
|
|
ce6c29941e | ||
|
|
2a68c8610b | ||
|
|
aef538114a | ||
|
|
050a984163 | ||
|
|
3c245c6146 | ||
|
|
c7271d97ae | ||
|
|
e5feb76b90 | ||
|
|
b1c9466df4 | ||
|
|
e9d8f1611b | ||
|
|
5b44e01455 | ||
|
|
7a1602f591 | ||
|
|
565bc59735 | ||
|
|
989629a832 | ||
|
|
c720204199 | ||
|
|
294db69227 | ||
|
|
6f1feb43d5 | ||
|
|
8ffa3dd9dc | ||
|
|
2a02b54786 | ||
|
|
ed88f55a3d | ||
|
|
818a254126 | ||
|
|
99b78f78d7 | ||
|
|
7d9ef6e0bf | ||
|
|
59a8cf0ae5 | ||
|
|
e7e57f8e6d | ||
|
|
da5644e758 | ||
|
|
0f6cf13d45 | ||
|
|
fe46f0e238 | ||
|
|
e0605156de | ||
|
|
e42b0cba26 | ||
|
|
1b7c46f496 | ||
|
|
a224491179 | ||
|
|
2d603f1f47 | ||
|
|
77e5a2f4a2 | ||
|
|
d3485e42b9 | ||
|
|
710514b8f1 | ||
|
|
2997c027a2 | ||
|
|
974d76c5f6 | ||
|
|
799e2d1265 | ||
|
|
987c7ca04b | ||
|
|
2ebc6d6a3c | ||
|
|
62838571eb | ||
|
|
f6fa986b33 | ||
|
|
652f4f0141 | ||
|
|
8b68210db7 | ||
|
|
87c4b4a5d4 | ||
|
|
cae9ccfacf | ||
|
|
4ddb14c136 | ||
|
|
dc2f0dad81 | ||
|
|
3540424aa1 | ||
|
|
46d4e12b4c | ||
|
|
0fff1bd8c7 | ||
|
|
a01c7e2e75 | ||
|
|
f03f6ce7ca | ||
|
|
ce58805104 | ||
|
|
ea0dc16163 | ||
|
|
540d1fb4b7 | ||
|
|
d3d050a319 | ||
|
|
7df2ea9f06 | ||
|
|
fd095403d7 | ||
|
|
645d26a1f3 | ||
|
|
7bc50e63d7 | ||
|
|
9ae88d87e3 | ||
|
|
4aa6412f9c | ||
|
|
ed7ac6312a | ||
|
|
531b6ceccc | ||
|
|
25b4c6794a | ||
|
|
954a96a077 | ||
|
|
62444100f5 | ||
|
|
8a41ee8ffb | ||
|
|
061c82f89c | ||
|
|
52b010ff34 | ||
|
|
413da6cd20 | ||
|
|
f00ff75548 | ||
|
|
89f136e670 | ||
|
|
a904a0a195 | ||
|
|
3ce6118c3f | ||
|
|
a5f1f7d73e | ||
|
|
7151ff2627 | ||
|
|
d110022731 | ||
|
|
16824fcfe3 | ||
|
|
d9dba320cc | ||
|
|
12ff28ac94 | ||
|
|
e2edadba92 | ||
|
|
5a3e3595d6 | ||
|
|
80001d1756 | ||
|
|
6c30e5a7eb | ||
|
|
f0e6470d0b | ||
|
|
0bcc0b3c12 | ||
|
|
ebbab54cda | ||
|
|
82648ebd6a | ||
|
|
eed3153ace | ||
|
|
0862cca295 | ||
|
|
d4de286f1b | ||
|
|
f82827e79e | ||
|
|
66e81f59cd | ||
|
|
8daf5c335a | ||
|
|
c1ee18c902 | ||
|
|
96ddbcd674 | ||
|
|
603d1d14b9 | ||
|
|
5920f800de | ||
|
|
3e806bf46e | ||
|
|
97398b7db0 | ||
|
|
8f55efbc01 | ||
|
|
2ce2c8fc49 | ||
|
|
d04cdfa0dc | ||
|
|
fd1735f6ec | ||
|
|
b69214b6af | ||
|
|
1da94e62ad | ||
|
|
8364a2425f | ||
|
|
f94d1bee0c | ||
|
|
257cd8cd9c | ||
|
|
fc5e71fc15 | ||
|
|
921aa29eb5 | ||
|
|
6755b8314a | ||
|
|
b78199370e | ||
|
|
72020c04c4 | ||
|
|
5f51d3d04f | ||
|
|
2cca7fddcc | ||
|
|
e04965c400 | ||
|
|
b5734d2e30 | ||
|
|
eea95aeebb | ||
|
|
b304b1c7be | ||
|
|
9f203890f4 | ||
|
|
76cda01af9 | ||
|
|
1a5bbf30f1 | ||
|
|
1e5d84a9d8 | ||
|
|
e55c132178 | ||
|
|
1bef6df455 | ||
|
|
feff73c4be | ||
|
|
89e1cd9738 | ||
|
|
e32a74e9c5 | ||
|
|
cb69f307e9 | ||
|
|
e35b34de22 | ||
|
|
b2b79fead1 | ||
|
|
e08111159f | ||
|
|
0c21ce2ee4 | ||
|
|
97c57c3386 | ||
|
|
48d94d500a | ||
|
|
e9bd482382 | ||
|
|
b5fd8fa610 | ||
|
|
31840a7aa3 | ||
|
|
18305ab2e6 | ||
|
|
9803d004c4 | ||
|
|
dc26c3be67 | ||
|
|
b70090dae3 | ||
|
|
622dc8676a | ||
|
|
a71d413202 | ||
|
|
6515136061 | ||
|
|
f7e189f272 | ||
|
|
be55da5fde | ||
|
|
6038147afe | ||
|
|
16a2ced4d3 | ||
|
|
cba92777a4 | ||
|
|
1af2d3776f | ||
|
|
908415d00b | ||
|
|
9a10f79fba | ||
|
|
9c3dc22b78 | ||
|
|
5bdcb5e2ce | ||
|
|
06515c3735 | ||
|
|
9661676646 | ||
|
|
77a816e461 | ||
|
|
0cff1c88f7 | ||
|
|
140320b0db | ||
|
|
7cbe20c440 | ||
|
|
489721eab5 | ||
|
|
e985ac0358 | ||
|
|
8714477ccb | ||
|
|
db1ba2ea82 | ||
|
|
e7a26f58ab | ||
|
|
25386f5b00 | ||
|
|
b3828f8eb2 | ||
|
|
679e6be294 | ||
|
|
28f9a9b159 | ||
|
|
a5521a60aa | ||
|
|
1b9372804f | ||
|
|
58ca7b44ff | ||
|
|
015e2e55d3 | ||
|
|
b9e89d4c66 | ||
|
|
00cd053dbc | ||
|
|
5380e6fb8d | ||
|
|
2792fc22f1 | ||
|
|
57f95cc282 | ||
|
|
c54f095c1b | ||
|
|
d46261c110 | ||
|
|
c15d878fee | ||
|
|
0bf7febf9f | ||
|
|
7f837014f1 | ||
|
|
fae7763ec7 | ||
|
|
06f503dd02 | ||
|
|
0daee1d887 | ||
|
|
38fc1d5456 | ||
|
|
11f39acef5 | ||
|
|
2634e63e4f | ||
|
|
c56e65739b | ||
|
|
c2e7278fcd | ||
|
|
94c9fece0d | ||
|
|
773ebe0765 | ||
|
|
bd23029d0a | ||
|
|
6250662d56 | ||
|
|
5c392e0f2d | ||
|
|
7841d751c0 | ||
|
|
ec00ccc482 | ||
|
|
0a0a92c6b0 | ||
|
|
5186c4755c | ||
|
|
f9b6d21620 | ||
|
|
0301e9fbb7 | ||
|
|
3d7e85bafd | ||
|
|
74801d00b8 | ||
|
|
229d6a8ee9 | ||
|
|
8a4d44de1e | ||
|
|
ceefac74cf | ||
|
|
d80ce8d3eb | ||
|
|
db505f45b2 | ||
|
|
539d5dd2de | ||
|
|
7a74888d2f | ||
|
|
3827409957 | ||
|
|
3a802fa67a | ||
|
|
561f342639 | ||
|
|
816dd9cf2d | ||
|
|
c7fd75ce56 | ||
|
|
1433f23eff | ||
|
|
136b99b8d1 | ||
|
|
d5c09936cf | ||
|
|
6fb2019a4f | ||
|
|
037053fffe | ||
|
|
9a543c6b28 | ||
|
|
d2b012c883 | ||
|
|
25f61dff16 | ||
|
|
190aa6bd4a | ||
|
|
4cfe1d1a96 | ||
|
|
c07356062a | ||
|
|
2b45b09211 | ||
|
|
8acf37ccbc | ||
|
|
a2bd695b89 | ||
|
|
b8111d8b5b | ||
|
|
cc4244f5a4 | ||
|
|
8390d887d3 | ||
|
|
f7907bdd58 | ||
|
|
0434eadc1f | ||
|
|
46ca0e6014 | ||
|
|
576cf9d19f | ||
|
|
b7849249c6 | ||
|
|
10487b1c71 | ||
|
|
b07614335c | ||
|
|
438e59a324 | ||
|
|
43ad9947b9 | ||
|
|
0bcebe8a0e | ||
|
|
9452c367e4 | ||
|
|
0feaaf591c | ||
|
|
7a6bfa7e7a | ||
|
|
bf9848c60f | ||
|
|
14f319d29c | ||
|
|
0a82a19313 | ||
|
|
f1592641de | ||
|
|
dd5540d69e | ||
|
|
69de1cb621 | ||
|
|
fc69377f9c | ||
|
|
4969176ec9 | ||
|
|
79a75d575e | ||
|
|
200508cf8f | ||
|
|
132a6030f9 | ||
|
|
0d8abea534 | ||
|
|
9d05696452 | ||
|
|
b09f910bf2 | ||
|
|
692211fe91 | ||
|
|
310dd6dec1 | ||
|
|
17c3477f71 | ||
|
|
c7302bc4a3 | ||
|
|
73621f626e | ||
|
|
71c650692d | ||
|
|
21dfad866b | ||
|
|
af71dae31b | ||
|
|
a4d618b0fc | ||
|
|
eb4831d7d6 | ||
|
|
4d39772e40 | ||
|
|
f344aa46c3 | ||
|
|
79c48ebbba | ||
|
|
12c1b1a2e6 | ||
|
|
e723213d5c | ||
|
|
c38b2928ec | ||
|
|
957ecd7231 | ||
|
|
59927ba534 | ||
|
|
a11ffb1637 | ||
|
|
51d30e2f2b | ||
|
|
64b04e46d7 |
792 changed files with 76674 additions and 7443 deletions
20
.github/script/amd64-20.04.Dockerfile
vendored
20
.github/script/amd64-20.04.Dockerfile
vendored
|
|
@ -1,20 +0,0 @@
|
||||||
FROM ubuntu:20.04
|
|
||||||
|
|
||||||
RUN apt update
|
|
||||||
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
|
|
||||||
RUN apt install -y build-essential cmake clang openssl libssl-dev zlib1g-dev gperf wget git curl libreadline-dev ccache libmicrohttpd-dev ninja-build libsecp256k1-dev libsodium-dev pkg-config
|
|
||||||
|
|
||||||
WORKDIR /
|
|
||||||
|
|
||||||
ARG BRANCH
|
|
||||||
ARG REPO
|
|
||||||
RUN git clone --recurse-submodules https://github.com/$REPO ton && cd ton && git checkout $BRANCH && git submodule update
|
|
||||||
|
|
||||||
WORKDIR /ton
|
|
||||||
RUN mkdir /ton/build
|
|
||||||
WORKDIR /ton/build
|
|
||||||
ENV CC clang
|
|
||||||
ENV CXX clang++
|
|
||||||
ENV CCACHE_DISABLE 1
|
|
||||||
RUN cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 -DTON_ARCH= -DCMAKE_CXX_FLAGS="-mavx2" ..
|
|
||||||
RUN ninja storage-daemon storage-daemon-cli tonlibjson blockchain-explorer fift func validator-engine validator-engine-console create-state generate-random-id create-hardfork dht-server lite-client
|
|
||||||
20
.github/script/amd64-22.04.Dockerfile
vendored
20
.github/script/amd64-22.04.Dockerfile
vendored
|
|
@ -1,20 +0,0 @@
|
||||||
FROM ubuntu:22.04
|
|
||||||
|
|
||||||
RUN apt update
|
|
||||||
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
|
|
||||||
RUN apt install -y build-essential cmake clang openssl libssl-dev zlib1g-dev gperf wget git curl libreadline-dev ccache libmicrohttpd-dev ninja-build libsecp256k1-dev libsodium-dev pkg-config
|
|
||||||
|
|
||||||
WORKDIR /
|
|
||||||
|
|
||||||
ARG BRANCH
|
|
||||||
ARG REPO
|
|
||||||
RUN git clone --recurse-submodules https://github.com/$REPO ton && cd ton && git checkout $BRANCH && git submodule update
|
|
||||||
|
|
||||||
WORKDIR /ton
|
|
||||||
RUN mkdir /ton/build
|
|
||||||
WORKDIR /ton/build
|
|
||||||
ENV CC clang
|
|
||||||
ENV CXX clang++
|
|
||||||
ENV CCACHE_DISABLE 1
|
|
||||||
RUN cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 -DTON_ARCH= -DCMAKE_CXX_FLAGS="-mavx2" ..
|
|
||||||
RUN ninja storage-daemon storage-daemon-cli tonlibjson blockchain-explorer fift func validator-engine validator-engine-console create-state generate-random-id create-hardfork dht-server lite-client
|
|
||||||
20
.github/script/arm64-20.04.Dockerfile
vendored
20
.github/script/arm64-20.04.Dockerfile
vendored
|
|
@ -1,20 +0,0 @@
|
||||||
FROM ubuntu:20.04
|
|
||||||
|
|
||||||
RUN apt update
|
|
||||||
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
|
|
||||||
RUN apt install -y build-essential cmake clang openssl libssl-dev zlib1g-dev gperf wget git curl libreadline-dev ccache libmicrohttpd-dev ninja-build libsecp256k1-dev libsodium-dev pkg-config
|
|
||||||
|
|
||||||
WORKDIR /
|
|
||||||
|
|
||||||
ARG BRANCH
|
|
||||||
ARG REPO
|
|
||||||
RUN git clone --recurse-submodules https://github.com/$REPO ton && cd ton && git checkout $BRANCH && git submodule update
|
|
||||||
|
|
||||||
WORKDIR /ton
|
|
||||||
RUN mkdir /ton/build
|
|
||||||
WORKDIR /ton/build
|
|
||||||
ENV CC clang
|
|
||||||
ENV CXX clang++
|
|
||||||
ENV CCACHE_DISABLE 1
|
|
||||||
RUN cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 -DTON_ARCH= ..
|
|
||||||
RUN ninja storage-daemon storage-daemon-cli tonlibjson blockchain-explorer fift func validator-engine validator-engine-console create-state generate-random-id dht-server lite-client
|
|
||||||
20
.github/script/arm64-22.04.Dockerfile
vendored
20
.github/script/arm64-22.04.Dockerfile
vendored
|
|
@ -1,20 +0,0 @@
|
||||||
FROM ubuntu:22.04
|
|
||||||
|
|
||||||
RUN apt update
|
|
||||||
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
|
|
||||||
RUN apt install -y build-essential cmake clang openssl libssl-dev zlib1g-dev gperf wget git curl libreadline-dev ccache libmicrohttpd-dev ninja-build libsecp256k1-dev libsodium-dev pkg-config
|
|
||||||
|
|
||||||
WORKDIR /
|
|
||||||
|
|
||||||
ARG BRANCH
|
|
||||||
ARG REPO
|
|
||||||
RUN git clone --recurse-submodules https://github.com/$REPO ton && cd ton && git checkout $BRANCH && git submodule update
|
|
||||||
|
|
||||||
WORKDIR /ton
|
|
||||||
RUN mkdir /ton/build
|
|
||||||
WORKDIR /ton/build
|
|
||||||
ENV CC clang
|
|
||||||
ENV CXX clang++
|
|
||||||
ENV CCACHE_DISABLE 1
|
|
||||||
RUN cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 -DTON_ARCH= ..
|
|
||||||
RUN ninja storage-daemon storage-daemon-cli tonlibjson blockchain-explorer fift func validator-engine validator-engine-console create-state generate-random-id dht-server lite-client
|
|
||||||
|
|
@ -17,10 +17,12 @@ jobs:
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y build-essential git cmake ninja-build automake libtool texinfo autoconf libgflags-dev \
|
sudo apt-get install -y build-essential git cmake ninja-build automake libtool texinfo autoconf libgflags-dev \
|
||||||
zlib1g-dev libssl-dev libreadline-dev libmicrohttpd-dev pkg-config libgsl-dev python3 python3-dev \
|
zlib1g-dev libssl-dev libreadline-dev libmicrohttpd-dev pkg-config libgsl-dev python3 python3-dev \
|
||||||
libtool autoconf libsodium-dev libsecp256k1-dev
|
libtool autoconf libsodium-dev libsecp256k1-dev liblz4-dev
|
||||||
|
|
||||||
- name: Build TON
|
- name: Build TON
|
||||||
run: |
|
run: |
|
||||||
|
git submodule sync --recursive
|
||||||
|
git submodule update
|
||||||
cp assembly/android/build-android-tonlib.sh .
|
cp assembly/android/build-android-tonlib.sh .
|
||||||
chmod +x build-android-tonlib.sh
|
chmod +x build-android-tonlib.sh
|
||||||
./build-android-tonlib.sh -a
|
./build-android-tonlib.sh -a
|
||||||
|
|
@ -28,5 +30,5 @@ jobs:
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@master
|
uses: actions/upload-artifact@master
|
||||||
with:
|
with:
|
||||||
name: tonlib-android
|
name: ton-android-tonlib
|
||||||
path: artifacts
|
path: artifacts
|
||||||
|
|
|
||||||
57
.github/workflows/build-ton-linux-arm64-appimage.yml
vendored
Normal file
57
.github/workflows/build-ton-linux-arm64-appimage.yml
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
name: Ubuntu TON build (AppImages, arm64)
|
||||||
|
|
||||||
|
on: [push,workflow_dispatch,workflow_call]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-22.04-arm
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: 'recursive'
|
||||||
|
|
||||||
|
- name: Install system libraries
|
||||||
|
run: |
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install -y build-essential git cmake ninja-build zlib1g-dev libsecp256k1-dev libmicrohttpd-dev libsodium-dev liblz4-dev
|
||||||
|
sudo apt remove libgsl-dev
|
||||||
|
|
||||||
|
- name: Install clang-16
|
||||||
|
run: |
|
||||||
|
wget https://apt.llvm.org/llvm.sh
|
||||||
|
chmod +x llvm.sh
|
||||||
|
sudo ./llvm.sh 16 all
|
||||||
|
|
||||||
|
- name: Build TON
|
||||||
|
run: |
|
||||||
|
git submodule sync --recursive
|
||||||
|
git submodule update
|
||||||
|
cp assembly/native/build-ubuntu-appimages.sh .
|
||||||
|
chmod +x build-ubuntu-appimages.sh
|
||||||
|
./build-ubuntu-appimages.sh -a
|
||||||
|
|
||||||
|
- name: Make AppImages
|
||||||
|
run: |
|
||||||
|
cp assembly/appimage/create-appimages.sh .
|
||||||
|
cp assembly/appimage/AppRun .
|
||||||
|
cp assembly/appimage/ton.png .
|
||||||
|
chmod +x create-appimages.sh
|
||||||
|
./create-appimages.sh aarch64
|
||||||
|
rm -rf artifacts
|
||||||
|
|
||||||
|
|
||||||
|
- name: Build TON libs
|
||||||
|
run: |
|
||||||
|
cp assembly/native/build-ubuntu-portable-libs.sh .
|
||||||
|
chmod +x build-ubuntu-portable-libs.sh
|
||||||
|
./build-ubuntu-portable-libs.sh -a
|
||||||
|
cp ./artifacts/libtonlibjson.so appimages/artifacts/
|
||||||
|
cp ./artifacts/libemulator.so appimages/artifacts/
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@master
|
||||||
|
with:
|
||||||
|
name: ton-arm64-linux
|
||||||
|
path: appimages/artifacts
|
||||||
43
.github/workflows/build-ton-linux-arm64-shared.yml
vendored
Normal file
43
.github/workflows/build-ton-linux-arm64-shared.yml
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
name: Ubuntu TON build (shared, arm64)
|
||||||
|
|
||||||
|
on: [push,workflow_dispatch,workflow_call]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-22.04-arm, ubuntu-24.04-arm]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: 'recursive'
|
||||||
|
|
||||||
|
- name: Install system libraries
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y build-essential git cmake ninja-build zlib1g-dev libsecp256k1-dev libmicrohttpd-dev libsodium-dev liblz4-dev libjemalloc-dev
|
||||||
|
|
||||||
|
- if: matrix.os != 'ubuntu-24.04-arm'
|
||||||
|
name: Install llvm-16
|
||||||
|
run: |
|
||||||
|
wget https://apt.llvm.org/llvm.sh
|
||||||
|
chmod +x llvm.sh
|
||||||
|
sudo ./llvm.sh 16 all
|
||||||
|
|
||||||
|
- name: Build TON
|
||||||
|
run: |
|
||||||
|
git submodule sync --recursive
|
||||||
|
git submodule update
|
||||||
|
cp assembly/native/build-ubuntu-shared.sh .
|
||||||
|
chmod +x build-ubuntu-shared.sh
|
||||||
|
./build-ubuntu-shared.sh -t -a
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@master
|
||||||
|
with:
|
||||||
|
name: ton-binaries-${{ matrix.os }}
|
||||||
|
path: artifacts
|
||||||
63
.github/workflows/build-ton-linux-x86-64-appimage.yml
vendored
Normal file
63
.github/workflows/build-ton-linux-x86-64-appimage.yml
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
name: Ubuntu TON build (AppImages, x86-64)
|
||||||
|
|
||||||
|
on: [push,workflow_dispatch,workflow_call]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: 'recursive'
|
||||||
|
|
||||||
|
- name: Install system libraries
|
||||||
|
run: |
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install -y build-essential git cmake ninja-build zlib1g-dev libsecp256k1-dev libmicrohttpd-dev libsodium-dev liblz4-dev
|
||||||
|
sudo apt remove libgsl-dev
|
||||||
|
|
||||||
|
- name: Install gcc-11 g++-11
|
||||||
|
run: |
|
||||||
|
sudo apt install -y manpages-dev software-properties-common
|
||||||
|
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
|
||||||
|
sudo apt update && sudo apt install gcc-11 g++-11
|
||||||
|
|
||||||
|
- name: Install clang-16
|
||||||
|
run: |
|
||||||
|
wget https://apt.llvm.org/llvm.sh
|
||||||
|
chmod +x llvm.sh
|
||||||
|
sudo ./llvm.sh 16 all
|
||||||
|
|
||||||
|
- name: Build TON
|
||||||
|
run: |
|
||||||
|
git submodule sync --recursive
|
||||||
|
git submodule update
|
||||||
|
cp assembly/native/build-ubuntu-appimages.sh .
|
||||||
|
chmod +x build-ubuntu-appimages.sh
|
||||||
|
./build-ubuntu-appimages.sh -a
|
||||||
|
|
||||||
|
- name: Make AppImages
|
||||||
|
run: |
|
||||||
|
cp assembly/appimage/create-appimages.sh .
|
||||||
|
cp assembly/appimage/AppRun .
|
||||||
|
cp assembly/appimage/ton.png .
|
||||||
|
chmod +x create-appimages.sh
|
||||||
|
./create-appimages.sh x86_64
|
||||||
|
rm -rf artifacts
|
||||||
|
|
||||||
|
|
||||||
|
- name: Build TON libs
|
||||||
|
run: |
|
||||||
|
cp assembly/native/build-ubuntu-portable-libs.sh .
|
||||||
|
chmod +x build-ubuntu-portable-libs.sh
|
||||||
|
./build-ubuntu-portable-libs.sh -a
|
||||||
|
cp ./artifacts/libtonlibjson.so appimages/artifacts/
|
||||||
|
cp ./artifacts/libemulator.so appimages/artifacts/
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@master
|
||||||
|
with:
|
||||||
|
name: ton-x86_64-linux
|
||||||
|
path: appimages/artifacts
|
||||||
|
|
@ -7,7 +7,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-20.04, ubuntu-22.04]
|
os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -19,9 +19,15 @@ jobs:
|
||||||
- name: Install system libraries
|
- name: Install system libraries
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y build-essential git cmake ninja-build zlib1g-dev libsecp256k1-dev libmicrohttpd-dev libsodium-dev
|
sudo apt-get install -y build-essential git cmake ninja-build zlib1g-dev libsecp256k1-dev libmicrohttpd-dev libsodium-dev liblz4-dev libjemalloc-dev
|
||||||
|
|
||||||
- name: Install clang-16
|
- if: matrix.os == 'ubuntu-20.04'
|
||||||
|
run: |
|
||||||
|
sudo apt install -y manpages-dev software-properties-common
|
||||||
|
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
|
||||||
|
sudo apt update && sudo apt install gcc-11 g++-11
|
||||||
|
|
||||||
|
- if: matrix.os != 'ubuntu-24.04'
|
||||||
run: |
|
run: |
|
||||||
wget https://apt.llvm.org/llvm.sh
|
wget https://apt.llvm.org/llvm.sh
|
||||||
chmod +x llvm.sh
|
chmod +x llvm.sh
|
||||||
|
|
@ -29,6 +35,8 @@ jobs:
|
||||||
|
|
||||||
- name: Build TON
|
- name: Build TON
|
||||||
run: |
|
run: |
|
||||||
|
git submodule sync --recursive
|
||||||
|
git submodule update
|
||||||
cp assembly/native/build-ubuntu-shared.sh .
|
cp assembly/native/build-ubuntu-shared.sh .
|
||||||
chmod +x build-ubuntu-shared.sh
|
chmod +x build-ubuntu-shared.sh
|
||||||
./build-ubuntu-shared.sh -t -a
|
./build-ubuntu-shared.sh -t -a
|
||||||
|
|
|
||||||
27
.github/workflows/build-ton-macos-13-x86-64-portable.yml
vendored
Normal file
27
.github/workflows/build-ton-macos-13-x86-64-portable.yml
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
name: MacOS-13 TON build (portable, x86-64)
|
||||||
|
|
||||||
|
on: [push,workflow_dispatch,workflow_call]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: macos-13
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: 'recursive'
|
||||||
|
|
||||||
|
- name: Build TON
|
||||||
|
run: |
|
||||||
|
git submodule sync --recursive
|
||||||
|
git submodule update
|
||||||
|
cp assembly/native/build-macos-portable.sh .
|
||||||
|
chmod +x build-macos-portable.sh
|
||||||
|
./build-macos-portable.sh -t -a
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@master
|
||||||
|
with:
|
||||||
|
name: ton-x86_64-macos
|
||||||
|
path: artifacts
|
||||||
27
.github/workflows/build-ton-macos-14-arm64-portable.yml
vendored
Normal file
27
.github/workflows/build-ton-macos-14-arm64-portable.yml
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
name: MacOS-14 TON build (portable, arm64)
|
||||||
|
|
||||||
|
on: [push,workflow_dispatch,workflow_call]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: macos-14
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: 'recursive'
|
||||||
|
|
||||||
|
- name: Build TON
|
||||||
|
run: |
|
||||||
|
git submodule sync --recursive
|
||||||
|
git submodule update
|
||||||
|
cp assembly/native/build-macos-portable.sh .
|
||||||
|
chmod +x build-macos-portable.sh
|
||||||
|
./build-macos-portable.sh -t -a
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@master
|
||||||
|
with:
|
||||||
|
name: ton-arm64-macos
|
||||||
|
path: artifacts
|
||||||
27
.github/workflows/build-ton-macos-15-arm64-shared.yml
vendored
Normal file
27
.github/workflows/build-ton-macos-15-arm64-shared.yml
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
name: MacOS-15 TON build (shared, arm64)
|
||||||
|
|
||||||
|
on: [push,workflow_dispatch,workflow_call]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: macos-15
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: 'recursive'
|
||||||
|
|
||||||
|
- name: Build TON
|
||||||
|
run: |
|
||||||
|
git submodule sync --recursive
|
||||||
|
git submodule update
|
||||||
|
cp assembly/native/build-macos-shared.sh .
|
||||||
|
chmod +x build-macos-shared.sh
|
||||||
|
./build-macos-shared.sh -t -a
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@master
|
||||||
|
with:
|
||||||
|
name: ton-binaries-macos-15
|
||||||
|
path: artifacts
|
||||||
27
.github/workflows/build-ton-macos-arm64-shared.yml
vendored
Normal file
27
.github/workflows/build-ton-macos-arm64-shared.yml
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
name: MacOS-14 TON build (shared, arm64)
|
||||||
|
|
||||||
|
on: [push,workflow_dispatch,workflow_call]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: macos-14
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: 'recursive'
|
||||||
|
|
||||||
|
- name: Build TON
|
||||||
|
run: |
|
||||||
|
git submodule sync --recursive
|
||||||
|
git submodule update
|
||||||
|
cp assembly/native/build-macos-shared.sh .
|
||||||
|
chmod +x build-macos-shared.sh
|
||||||
|
./build-macos-shared.sh -t -a
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@master
|
||||||
|
with:
|
||||||
|
name: ton-binaries-macos-14
|
||||||
|
path: artifacts
|
||||||
|
|
@ -4,7 +4,7 @@ on: [push,workflow_dispatch,workflow_call]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: macos-12
|
runs-on: macos-13
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repository
|
- name: Check out repository
|
||||||
|
|
@ -14,6 +14,8 @@ jobs:
|
||||||
|
|
||||||
- name: Build TON
|
- name: Build TON
|
||||||
run: |
|
run: |
|
||||||
|
git submodule sync --recursive
|
||||||
|
git submodule update
|
||||||
cp assembly/native/build-macos-shared.sh .
|
cp assembly/native/build-macos-shared.sh .
|
||||||
chmod +x build-macos-shared.sh
|
chmod +x build-macos-shared.sh
|
||||||
./build-macos-shared.sh -t -a
|
./build-macos-shared.sh -t -a
|
||||||
|
|
@ -21,5 +23,5 @@ jobs:
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@master
|
uses: actions/upload-artifact@master
|
||||||
with:
|
with:
|
||||||
name: ton-binaries-macos-12
|
name: ton-binaries-macos-13
|
||||||
path: artifacts
|
path: artifacts
|
||||||
|
|
|
||||||
29
.github/workflows/build-ton-wasm-emscripten.yml
vendored
29
.github/workflows/build-ton-wasm-emscripten.yml
vendored
|
|
@ -15,16 +15,37 @@ jobs:
|
||||||
- name: Install system libraries
|
- name: Install system libraries
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y build-essential git openssl cmake ninja-build zlib1g-dev libssl-dev libsecp256k1-dev libmicrohttpd-dev libsodium-dev
|
sudo apt-get install -y build-essential git openssl cmake ninja-build zlib1g-dev libssl-dev libsecp256k1-dev libmicrohttpd-dev libsodium-dev liblz4-dev libjemalloc-dev
|
||||||
|
|
||||||
- name: Build TON WASM artifacts
|
- name: Build TON WASM artifacts
|
||||||
run: |
|
run: |
|
||||||
cd assembly/wasm
|
git submodule sync --recursive
|
||||||
|
git submodule update
|
||||||
|
cp assembly/wasm/fift-func-wasm-build-ubuntu.sh .
|
||||||
chmod +x fift-func-wasm-build-ubuntu.sh
|
chmod +x fift-func-wasm-build-ubuntu.sh
|
||||||
./fift-func-wasm-build-ubuntu.sh -a
|
./fift-func-wasm-build-ubuntu.sh -a
|
||||||
|
|
||||||
|
- name: Prepare test
|
||||||
|
run: |
|
||||||
|
cp assembly/wasm/*.fc .
|
||||||
|
git clone https://github.com/ton-community/func-js.git
|
||||||
|
cd func-js
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
npm link
|
||||||
|
|
||||||
|
- name: Test TON WASM artifacts
|
||||||
|
run: |
|
||||||
|
base64 -w 0 artifacts/funcfiftlib.wasm > artifacts/funcfiftlib.wasm.js
|
||||||
|
printf "module.exports = { FuncFiftLibWasm: '" | cat - artifacts/funcfiftlib.wasm.js > temp.txt && mv temp.txt artifacts/funcfiftlib.wasm.js
|
||||||
|
echo "'}" >> artifacts/funcfiftlib.wasm.js
|
||||||
|
cp artifacts/funcfiftlib.wasm.js func-js/node_modules/@ton-community/func-js-bin/dist/funcfiftlib.wasm.js
|
||||||
|
cp artifacts/funcfiftlib.js func-js/node_modules/@ton-community/func-js-bin/dist/funcfiftlib.js
|
||||||
|
npx func-js stdlib.fc intrinsics.fc --fift ./output.f
|
||||||
|
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@master
|
uses: actions/upload-artifact@master
|
||||||
with:
|
with:
|
||||||
name: ton-wasm-binaries
|
name: ton-wasm
|
||||||
path: artifacts
|
path: artifacts
|
||||||
|
|
|
||||||
446
.github/workflows/create-release.yml
vendored
446
.github/workflows/create-release.yml
vendored
|
|
@ -4,6 +4,9 @@ on: [workflow_dispatch]
|
||||||
|
|
||||||
permissions: write-all
|
permissions: write-all
|
||||||
|
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
create-release:
|
create-release:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
|
|
@ -11,60 +14,112 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Download Linux x86-64 artifacts
|
- name: Download Linux arm64 artifacts
|
||||||
uses: dawidd6/action-download-artifact@v2
|
uses: dawidd6/action-download-artifact@v6
|
||||||
with:
|
with:
|
||||||
workflow: ton-x86-64-linux.yml
|
workflow: build-ton-linux-arm64-appimage.yml
|
||||||
path: artifacts
|
path: artifacts
|
||||||
workflow_conclusion: success
|
workflow_conclusion: success
|
||||||
|
branch: master
|
||||||
|
skip_unpack: true
|
||||||
|
|
||||||
|
- name: Download and unzip Linux arm64 artifacts
|
||||||
|
uses: dawidd6/action-download-artifact@v6
|
||||||
|
with:
|
||||||
|
workflow: build-ton-linux-arm64-appimage.yml
|
||||||
|
path: artifacts
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: master
|
||||||
|
skip_unpack: false
|
||||||
|
|
||||||
|
- name: Download Linux x86-64 artifacts
|
||||||
|
uses: dawidd6/action-download-artifact@v6
|
||||||
|
with:
|
||||||
|
workflow: build-ton-linux-x86-64-appimage.yml
|
||||||
|
path: artifacts
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: master
|
||||||
skip_unpack: true
|
skip_unpack: true
|
||||||
|
|
||||||
- name: Download and unzip Linux x86-64 artifacts
|
- name: Download and unzip Linux x86-64 artifacts
|
||||||
uses: dawidd6/action-download-artifact@v2
|
uses: dawidd6/action-download-artifact@v6
|
||||||
with:
|
with:
|
||||||
workflow: ton-x86-64-linux.yml
|
workflow: build-ton-linux-x86-64-appimage.yml
|
||||||
path: artifacts
|
path: artifacts
|
||||||
workflow_conclusion: success
|
workflow_conclusion: success
|
||||||
|
branch: master
|
||||||
skip_unpack: false
|
skip_unpack: false
|
||||||
|
|
||||||
- name: Download Mac x86-64 artifacts
|
- name: Download Mac x86-64 artifacts
|
||||||
uses: dawidd6/action-download-artifact@v2
|
uses: dawidd6/action-download-artifact@v6
|
||||||
with:
|
with:
|
||||||
workflow: ton-x86-64-macos.yml
|
workflow: build-ton-macos-13-x86-64-portable.yml
|
||||||
path: artifacts
|
path: artifacts
|
||||||
workflow_conclusion: success
|
workflow_conclusion: success
|
||||||
|
branch: master
|
||||||
|
skip_unpack: true
|
||||||
|
|
||||||
|
- name: Download Mac arm64 artifacts
|
||||||
|
uses: dawidd6/action-download-artifact@v6
|
||||||
|
with:
|
||||||
|
workflow: build-ton-macos-14-arm64-portable.yml
|
||||||
|
path: artifacts
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: master
|
||||||
skip_unpack: true
|
skip_unpack: true
|
||||||
|
|
||||||
- name: Download and unzip Mac x86-64 artifacts
|
- name: Download and unzip Mac x86-64 artifacts
|
||||||
uses: dawidd6/action-download-artifact@v2
|
uses: dawidd6/action-download-artifact@v6
|
||||||
with:
|
with:
|
||||||
workflow: ton-x86-64-macos.yml
|
workflow: build-ton-macos-13-x86-64-portable.yml
|
||||||
path: artifacts
|
path: artifacts
|
||||||
workflow_conclusion: success
|
workflow_conclusion: success
|
||||||
|
branch: master
|
||||||
|
skip_unpack: false
|
||||||
|
|
||||||
|
- name: Download and unzip arm64 artifacts
|
||||||
|
uses: dawidd6/action-download-artifact@v6
|
||||||
|
with:
|
||||||
|
workflow: build-ton-macos-14-arm64-portable.yml
|
||||||
|
path: artifacts
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: master
|
||||||
skip_unpack: false
|
skip_unpack: false
|
||||||
|
|
||||||
- name: Download Windows artifacts
|
- name: Download Windows artifacts
|
||||||
uses: dawidd6/action-download-artifact@v2
|
uses: dawidd6/action-download-artifact@v6
|
||||||
with:
|
with:
|
||||||
workflow: ton-x86-64-windows.yml
|
workflow: ton-x86-64-windows.yml
|
||||||
path: artifacts
|
path: artifacts
|
||||||
workflow_conclusion: success
|
workflow_conclusion: success
|
||||||
|
branch: master
|
||||||
skip_unpack: true
|
skip_unpack: true
|
||||||
|
|
||||||
- name: Download and unzip Windows artifacts
|
- name: Download and unzip Windows artifacts
|
||||||
uses: dawidd6/action-download-artifact@v2
|
uses: dawidd6/action-download-artifact@v6
|
||||||
with:
|
with:
|
||||||
workflow: ton-x86-64-windows.yml
|
workflow: ton-x86-64-windows.yml
|
||||||
path: artifacts
|
path: artifacts
|
||||||
workflow_conclusion: success
|
workflow_conclusion: success
|
||||||
|
branch: master
|
||||||
skip_unpack: false
|
skip_unpack: false
|
||||||
|
|
||||||
- name: Download WASM artifacts
|
- name: Download WASM artifacts
|
||||||
uses: dawidd6/action-download-artifact@v2
|
uses: dawidd6/action-download-artifact@v6
|
||||||
with:
|
with:
|
||||||
workflow: build-ton-wasm-emscripten.yml
|
workflow: build-ton-wasm-emscripten.yml
|
||||||
path: artifacts
|
path: artifacts
|
||||||
workflow_conclusion: success
|
workflow_conclusion: success
|
||||||
|
branch: master
|
||||||
|
skip_unpack: true
|
||||||
|
|
||||||
|
- name: Download Android Tonlib artifacts
|
||||||
|
uses: dawidd6/action-download-artifact@v6
|
||||||
|
with:
|
||||||
|
workflow: build-ton-linux-android-tonlib.yml
|
||||||
|
path: artifacts
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: master
|
||||||
skip_unpack: true
|
skip_unpack: true
|
||||||
|
|
||||||
- name: Show all artifacts
|
- name: Show all artifacts
|
||||||
|
|
@ -123,7 +178,7 @@ jobs:
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-win-binaries.zip
|
file: artifacts/ton-x86-64-windows.zip
|
||||||
asset_name: ton-win-x86-64.zip
|
asset_name: ton-win-x86-64.zip
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
@ -131,7 +186,7 @@ jobs:
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-win-binaries/fift.exe
|
file: artifacts/ton-x86-64-windows/fift.exe
|
||||||
asset_name: fift.exe
|
asset_name: fift.exe
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
@ -139,23 +194,39 @@ jobs:
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-win-binaries/func.exe
|
file: artifacts/ton-x86-64-windows/func.exe
|
||||||
asset_name: func.exe
|
asset_name: func.exe
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Windows 2019 single artifact - tolk
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-x86-64-windows/tolk.exe
|
||||||
|
asset_name: tolk.exe
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
- name: Upload Windows 2019 single artifact - lite-client
|
- name: Upload Windows 2019 single artifact - lite-client
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-win-binaries/lite-client.exe
|
file: artifacts/ton-x86-64-windows/lite-client.exe
|
||||||
asset_name: lite-client.exe
|
asset_name: lite-client.exe
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Windows 2019 single artifact - proxy-liteserver
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-x86-64-windows/proxy-liteserver.exe
|
||||||
|
asset_name: proxy-liteserver.exe
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
- name: Upload Windows 2019 single artifact - rldp-http-proxy
|
- name: Upload Windows 2019 single artifact - rldp-http-proxy
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-win-binaries/rldp-http-proxy.exe
|
file: artifacts/ton-x86-64-windows/rldp-http-proxy.exe
|
||||||
asset_name: rldp-http-proxy.exe
|
asset_name: rldp-http-proxy.exe
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
@ -163,7 +234,7 @@ jobs:
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-win-binaries/http-proxy.exe
|
file: artifacts/ton-x86-64-windows/http-proxy.exe
|
||||||
asset_name: http-proxy.exe
|
asset_name: http-proxy.exe
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
@ -171,7 +242,7 @@ jobs:
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-win-binaries/storage-daemon-cli.exe
|
file: artifacts/ton-x86-64-windows/storage-daemon-cli.exe
|
||||||
asset_name: storage-daemon-cli.exe
|
asset_name: storage-daemon-cli.exe
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
@ -179,7 +250,7 @@ jobs:
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-win-binaries/storage-daemon.exe
|
file: artifacts/ton-x86-64-windows/storage-daemon.exe
|
||||||
asset_name: storage-daemon.exe
|
asset_name: storage-daemon.exe
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
@ -187,15 +258,23 @@ jobs:
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-win-binaries/tonlibjson.dll
|
file: artifacts/ton-x86-64-windows/tonlibjson.dll
|
||||||
asset_name: tonlibjson.dll
|
asset_name: tonlibjson.dll
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Windows 2019 single artifact - libemulator
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-x86-64-windows/emulator.dll
|
||||||
|
asset_name: libemulator.dll
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
- name: Upload Windows 2019 single artifact - tonlib-cli
|
- name: Upload Windows 2019 single artifact - tonlib-cli
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-win-binaries/tonlib-cli.exe
|
file: artifacts/ton-x86-64-windows/tonlib-cli.exe
|
||||||
asset_name: tonlib-cli.exe
|
asset_name: tonlib-cli.exe
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
@ -205,7 +284,7 @@ jobs:
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-x86_64-macos-binaries.zip
|
file: artifacts/ton-x86_64-macos.zip
|
||||||
asset_name: ton-mac-x86-64.zip
|
asset_name: ton-mac-x86-64.zip
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
@ -213,7 +292,7 @@ jobs:
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-x86_64-macos-binaries/fift
|
file: artifacts/ton-x86_64-macos/fift
|
||||||
asset_name: fift-mac-x86-64
|
asset_name: fift-mac-x86-64
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
@ -221,23 +300,39 @@ jobs:
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-x86_64-macos-binaries/func
|
file: artifacts/ton-x86_64-macos/func
|
||||||
asset_name: func-mac-x86-64
|
asset_name: func-mac-x86-64
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Mac x86-64 single artifact - tolk
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-x86_64-macos/tolk
|
||||||
|
asset_name: tolk-mac-x86-64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
- name: Upload Mac x86-64 single artifact - lite-client
|
- name: Upload Mac x86-64 single artifact - lite-client
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-x86_64-macos-binaries/lite-client
|
file: artifacts/ton-x86_64-macos/lite-client
|
||||||
asset_name: lite-client-mac-x86-64
|
asset_name: lite-client-mac-x86-64
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Mac x86-64 single artifact - proxy-liteserver
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-x86_64-macos/proxy-liteserver
|
||||||
|
asset_name: proxy-liteserver-mac-x86-64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
- name: Upload Mac x86-64 single artifact - rldp-http-proxy
|
- name: Upload Mac x86-64 single artifact - rldp-http-proxy
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-x86_64-macos-binaries/rldp-http-proxy
|
file: artifacts/ton-x86_64-macos/rldp-http-proxy
|
||||||
asset_name: rldp-http-proxy-mac-x86-64
|
asset_name: rldp-http-proxy-mac-x86-64
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
@ -245,7 +340,7 @@ jobs:
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-x86_64-macos-binaries/http-proxy
|
file: artifacts/ton-x86_64-macos/http-proxy
|
||||||
asset_name: http-proxy-mac-x86-64
|
asset_name: http-proxy-mac-x86-64
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
@ -253,7 +348,7 @@ jobs:
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-x86_64-macos-binaries/storage-daemon-cli
|
file: artifacts/ton-x86_64-macos/storage-daemon-cli
|
||||||
asset_name: storage-daemon-cli-mac-x86-64
|
asset_name: storage-daemon-cli-mac-x86-64
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
@ -261,7 +356,7 @@ jobs:
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-x86_64-macos-binaries/storage-daemon
|
file: artifacts/ton-x86_64-macos/storage-daemon
|
||||||
asset_name: storage-daemon-mac-x86-64
|
asset_name: storage-daemon-mac-x86-64
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
@ -269,33 +364,156 @@ jobs:
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-x86_64-macos-binaries/libtonlibjson.dylib
|
file: artifacts/ton-x86_64-macos/libtonlibjson.dylib
|
||||||
asset_name: tonlibjson-mac-x86-64.dylib
|
asset_name: tonlibjson-mac-x86-64.dylib
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Mac x86-64 single artifact - libemulator
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-x86_64-macos/libemulator.dylib
|
||||||
|
asset_name: libemulator-mac-x86-64.dylib
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
- name: Upload Mac x86-64 single artifact - tonlib-cli
|
- name: Upload Mac x86-64 single artifact - tonlib-cli
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-x86_64-macos-binaries/tonlib-cli
|
file: artifacts/ton-x86_64-macos/tonlib-cli
|
||||||
asset_name: tonlib-cli-mac-x86-64
|
asset_name: tonlib-cli-mac-x86-64
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
||||||
|
# mac arm64
|
||||||
|
|
||||||
|
- name: Upload Mac arm64 artifacts
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-macos.zip
|
||||||
|
asset_name: ton-mac-arm64.zip
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Mac arm64 single artifact - fift
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-macos/fift
|
||||||
|
asset_name: fift-mac-arm64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Mac arm64 single artifact - func
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-macos/func
|
||||||
|
asset_name: func-mac-arm64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Mac arm64 single artifact - tolk
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-macos/tolk
|
||||||
|
asset_name: tolk-mac-arm64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Mac arm64 single artifact - lite-client
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-macos/lite-client
|
||||||
|
asset_name: lite-client-mac-arm64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Mac arm64 single artifact - proxy-liteserver
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-macos/proxy-liteserver
|
||||||
|
asset_name: proxy-liteserver-mac-arm64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Mac arm64 single artifact - rldp-http-proxy
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-macos/rldp-http-proxy
|
||||||
|
asset_name: rldp-http-proxy-mac-arm64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Mac arm64 single artifact - http-proxy
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-macos/http-proxy
|
||||||
|
asset_name: http-proxy-mac-arm64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Mac arm64 single artifact - storage-daemon-cli
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-macos/storage-daemon-cli
|
||||||
|
asset_name: storage-daemon-cli-mac-arm64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Mac arm64 single artifact - storage-daemon
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-macos/storage-daemon
|
||||||
|
asset_name: storage-daemon-mac-arm64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Mac arm64 single artifact - tonlibjson
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-macos/libtonlibjson.dylib
|
||||||
|
asset_name: tonlibjson-mac-arm64.dylib
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Mac arm64 single artifact - libemulator
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-macos/libemulator.dylib
|
||||||
|
asset_name: libemulator-mac-arm64.dylib
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Mac arm64 single artifact - tonlib-cli
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-macos/tonlib-cli
|
||||||
|
asset_name: tonlib-cli-mac-arm64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
# linux x86-64
|
# linux x86-64
|
||||||
|
|
||||||
- name: Upload Linux x86-64 artifacts
|
- name: Upload Linux x86-64 artifacts
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-x86_64-linux-binaries.zip
|
file: artifacts/ton-x86_64-linux.zip
|
||||||
asset_name: ton-linux-x86_64.zip
|
asset_name: ton-linux-x86_64.zip
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload generic smartcont+lib artifact
|
||||||
|
run: |
|
||||||
|
mkdir smartcont_lib
|
||||||
|
cd smartcont_lib
|
||||||
|
cp -r ../artifacts/ton-x86_64-linux/{smartcont,lib} .
|
||||||
|
zip -r smartcont_lib.zip .
|
||||||
|
gh release upload ${{ steps.tag.outputs.TAG }} smartcont_lib.zip
|
||||||
|
|
||||||
- name: Upload Linux x86-64 single artifact - fift
|
- name: Upload Linux x86-64 single artifact - fift
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-x86_64-linux-binaries/fift
|
file: artifacts/ton-x86_64-linux/fift
|
||||||
asset_name: fift-linux-x86_64
|
asset_name: fift-linux-x86_64
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
@ -303,23 +521,39 @@ jobs:
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-x86_64-linux-binaries/func
|
file: artifacts/ton-x86_64-linux/func
|
||||||
asset_name: func-linux-x86_64
|
asset_name: func-linux-x86_64
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Linux x86-64 single artifact - tolk
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-x86_64-linux/tolk
|
||||||
|
asset_name: tolk-linux-x86_64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
- name: Upload Linux x86-64 single artifact - lite-client
|
- name: Upload Linux x86-64 single artifact - lite-client
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-x86_64-linux-binaries/lite-client
|
file: artifacts/ton-x86_64-linux/lite-client
|
||||||
asset_name: lite-client-linux-x86_64
|
asset_name: lite-client-linux-x86_64
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Linux x86-64 single artifact - proxy-liteserver
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-x86_64-linux/proxy-liteserver
|
||||||
|
asset_name: proxy-liteserver-linux-x86_64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
- name: Upload Linux x86-64 single artifact - rldp-http-proxy
|
- name: Upload Linux x86-64 single artifact - rldp-http-proxy
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-x86_64-linux-binaries/rldp-http-proxy
|
file: artifacts/ton-x86_64-linux/rldp-http-proxy
|
||||||
asset_name: rldp-http-proxy-linux-x86_64
|
asset_name: rldp-http-proxy-linux-x86_64
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
@ -327,7 +561,7 @@ jobs:
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-x86_64-linux-binaries/http-proxy
|
file: artifacts/ton-x86_64-linux/http-proxy
|
||||||
asset_name: http-proxy-linux-x86_64
|
asset_name: http-proxy-linux-x86_64
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
@ -335,7 +569,7 @@ jobs:
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-x86_64-linux-binaries/storage-daemon-cli
|
file: artifacts/ton-x86_64-linux/storage-daemon-cli
|
||||||
asset_name: storage-daemon-cli-linux-x86_64
|
asset_name: storage-daemon-cli-linux-x86_64
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
@ -343,7 +577,7 @@ jobs:
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-x86_64-linux-binaries/storage-daemon
|
file: artifacts/ton-x86_64-linux/storage-daemon
|
||||||
asset_name: storage-daemon-linux-x86_64
|
asset_name: storage-daemon-linux-x86_64
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
@ -351,22 +585,146 @@ jobs:
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-x86_64-linux-binaries/libtonlibjson.so
|
file: artifacts/ton-x86_64-linux/libtonlibjson.so
|
||||||
asset_name: tonlibjson-linux-x86_64.so
|
asset_name: tonlibjson-linux-x86_64.so
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Linux x86-64 single artifact - libemulator
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-x86_64-linux/libemulator.so
|
||||||
|
asset_name: libemulator-linux-x86_64.so
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
- name: Upload Linux x86-64 single artifact - tonlib-cli
|
- name: Upload Linux x86-64 single artifact - tonlib-cli
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-x86_64-linux-binaries/tonlib-cli
|
file: artifacts/ton-x86_64-linux/tonlib-cli
|
||||||
asset_name: tonlib-cli-linux-x86_64
|
asset_name: tonlib-cli-linux-x86_64
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
||||||
|
# linux arm64
|
||||||
|
|
||||||
|
- name: Upload Linux arm64 artifacts
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-linux.zip
|
||||||
|
asset_name: ton-linux-arm64.zip
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Linux arm64 single artifact - fift
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-linux/fift
|
||||||
|
asset_name: fift-linux-arm64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Linux arm64 single artifact - func
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-linux/func
|
||||||
|
asset_name: func-linux-arm64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Linux arm64 single artifact - tolk
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-linux/tolk
|
||||||
|
asset_name: tolk-linux-arm64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Linux arm64 single artifact - lite-client
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-linux/lite-client
|
||||||
|
asset_name: lite-client-linux-arm64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Linux arm64 single artifact - proxy-liteserver
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-linux/proxy-liteserver
|
||||||
|
asset_name: proxy-liteserver-linux-arm64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Linux arm64 single artifact - rldp-http-proxy
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-linux/rldp-http-proxy
|
||||||
|
asset_name: rldp-http-proxy-linux-arm64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Linux arm64 single artifact - http-proxy
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-linux/http-proxy
|
||||||
|
asset_name: http-proxy-linux-arm64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Linux arm64 single artifact - storage-daemon-cli
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-linux/storage-daemon-cli
|
||||||
|
asset_name: storage-daemon-cli-linux-arm64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Linux arm64 single artifact - storage-daemon
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-linux/storage-daemon
|
||||||
|
asset_name: storage-daemon-linux-arm64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Linux arm64 single artifact - tonlibjson
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-linux/libtonlibjson.so
|
||||||
|
asset_name: tonlibjson-linux-arm64.so
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Linux arm64 single artifact - libemulator
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-linux/libemulator.so
|
||||||
|
asset_name: libemulator-linux-arm64.so
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Linux arm64 single artifact - tonlib-cli
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-linux/tonlib-cli
|
||||||
|
asset_name: tonlib-cli-linux-arm64
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|
||||||
- name: Upload WASM artifacts
|
- name: Upload WASM artifacts
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: artifacts/ton-wasm-binaries.zip
|
file: artifacts/ton-wasm.zip
|
||||||
asset_name: ton-wasm-binaries.zip
|
asset_name: ton-wasm.zip
|
||||||
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
||||||
|
- name: Upload Android Tonlib artifacts
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-android-tonlib.zip
|
||||||
|
asset_name: ton-android-tonlib.zip
|
||||||
tag: ${{ steps.tag.outputs.TAG }}
|
tag: ${{ steps.tag.outputs.TAG }}
|
||||||
|
|
|
||||||
154
.github/workflows/create-tolk-release.yml
vendored
Normal file
154
.github/workflows/create-tolk-release.yml
vendored
Normal file
|
|
@ -0,0 +1,154 @@
|
||||||
|
name: Create tolk release
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: 'tolk release and tag name'
|
||||||
|
required: true
|
||||||
|
|
||||||
|
permissions: write-all
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
create-release:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Download and unzip Linux arm64 artifacts
|
||||||
|
uses: dawidd6/action-download-artifact@v6
|
||||||
|
with:
|
||||||
|
workflow: build-ton-linux-arm64-appimage.yml
|
||||||
|
path: artifacts
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: master
|
||||||
|
skip_unpack: false
|
||||||
|
|
||||||
|
- name: Download and unzip Linux x86-64 artifacts
|
||||||
|
uses: dawidd6/action-download-artifact@v6
|
||||||
|
with:
|
||||||
|
workflow: build-ton-linux-x86-64-appimage.yml
|
||||||
|
path: artifacts
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: master
|
||||||
|
skip_unpack: false
|
||||||
|
|
||||||
|
- name: Download and unzip Mac x86-64 artifacts
|
||||||
|
uses: dawidd6/action-download-artifact@v6
|
||||||
|
with:
|
||||||
|
workflow: build-ton-macos-13-x86-64-portable.yml
|
||||||
|
path: artifacts
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: master
|
||||||
|
skip_unpack: false
|
||||||
|
|
||||||
|
- name: Download and unzip arm64 artifacts
|
||||||
|
uses: dawidd6/action-download-artifact@v6
|
||||||
|
with:
|
||||||
|
workflow: build-ton-macos-14-arm64-portable.yml
|
||||||
|
path: artifacts
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: master
|
||||||
|
skip_unpack: false
|
||||||
|
|
||||||
|
- name: Download and unzip Windows artifacts
|
||||||
|
uses: dawidd6/action-download-artifact@v6
|
||||||
|
with:
|
||||||
|
workflow: ton-x86-64-windows.yml
|
||||||
|
path: artifacts
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: master
|
||||||
|
skip_unpack: false
|
||||||
|
|
||||||
|
- name: Download WASM artifacts
|
||||||
|
uses: dawidd6/action-download-artifact@v6
|
||||||
|
with:
|
||||||
|
workflow: build-ton-wasm-emscripten.yml
|
||||||
|
path: artifacts
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: master
|
||||||
|
skip_unpack: true
|
||||||
|
|
||||||
|
- name: Show all artifacts
|
||||||
|
run: |
|
||||||
|
tree artifacts
|
||||||
|
|
||||||
|
|
||||||
|
# create release
|
||||||
|
- name: Get registration token
|
||||||
|
id: getRegToken
|
||||||
|
run: |
|
||||||
|
curl -X POST -H \"Accept: application/vnd.github+json\" -H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' https://api.github.com/repos/ton-blockchain/ton/actions/runners/registration-token
|
||||||
|
|
||||||
|
- name: Create release
|
||||||
|
id: create_release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ inputs.tag }}
|
||||||
|
release_name: ${{ inputs.tag }}
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
|
||||||
|
# upload
|
||||||
|
|
||||||
|
# win
|
||||||
|
|
||||||
|
- name: Upload Windows 2019 single artifact - tolk
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-x86-64-windows/tolk.exe
|
||||||
|
asset_name: tolk.exe
|
||||||
|
tag: ${{ inputs.tag }}
|
||||||
|
|
||||||
|
# mac x86-64
|
||||||
|
|
||||||
|
- name: Upload Mac x86-64 single artifact - tolk
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-x86_64-macos/tolk
|
||||||
|
asset_name: tolk-mac-x86-64
|
||||||
|
tag: ${{ inputs.tag }}
|
||||||
|
|
||||||
|
# mac arm64
|
||||||
|
|
||||||
|
- name: Upload Mac arm64 single artifact - tolk
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-macos/tolk
|
||||||
|
asset_name: tolk-mac-arm64
|
||||||
|
tag: ${{ inputs.tag }}
|
||||||
|
|
||||||
|
# linux x86-64
|
||||||
|
|
||||||
|
- name: Upload Linux x86-64 single artifact - tolk
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-x86_64-linux/tolk
|
||||||
|
asset_name: tolk-linux-x86_64
|
||||||
|
tag: ${{ inputs.tag }}
|
||||||
|
|
||||||
|
# linux arm64
|
||||||
|
|
||||||
|
- name: Upload Linux arm64 single artifact - tolk
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-arm64-linux/tolk
|
||||||
|
asset_name: tolk-linux-arm64
|
||||||
|
tag: ${{ inputs.tag }}
|
||||||
|
|
||||||
|
- name: Upload WASM artifacts
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file: artifacts/ton-wasm.zip
|
||||||
|
asset_name: ton-wasm.zip
|
||||||
|
tag: ${{ inputs.tag }}
|
||||||
|
|
||||||
61
.github/workflows/docker-ubuntu-branch-image.yml
vendored
Normal file
61
.github/workflows/docker-ubuntu-branch-image.yml
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
name: Docker Ubuntu 22.04 branch image
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches-ignore:
|
||||||
|
- master
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: 'recursive'
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3.5.0
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3.10.0
|
||||||
|
with:
|
||||||
|
driver-opts: image=moby/buildkit:v0.11.0
|
||||||
|
|
||||||
|
- name: Login to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and export to Docker
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
load: true
|
||||||
|
context: ./
|
||||||
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: |
|
||||||
|
docker run --rm -e "TEST=1" ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test
|
||||||
|
|
||||||
|
- name: Get tag as branch name
|
||||||
|
id: tag
|
||||||
|
run: |
|
||||||
|
echo "TAG=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
context: ./
|
||||||
|
tags: |
|
||||||
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.TAG }}
|
||||||
39
.github/workflows/docker-ubuntu-image.yml
vendored
39
.github/workflows/docker-ubuntu-image.yml
vendored
|
|
@ -20,22 +20,49 @@ jobs:
|
||||||
submodules: 'recursive'
|
submodules: 'recursive'
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v3.5.0
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v3.10.0
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and export to Docker
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
load: true
|
||||||
|
context: ./
|
||||||
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: |
|
||||||
|
docker run --rm -e "TEST=1" ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test
|
||||||
|
|
||||||
|
- name: Get next tag
|
||||||
|
id: tag
|
||||||
|
run: |
|
||||||
|
git fetch --all --tags
|
||||||
|
git tag -l
|
||||||
|
NEW_TAG=v$(date +'%Y.%m')
|
||||||
|
FOUND=$(git tag -l | grep $NEW_TAG | wc -l)
|
||||||
|
if [ $FOUND -eq 0 ]; then
|
||||||
|
echo "TAG=$NEW_TAG" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "TAG=$NEW_TAG-$FOUND" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
id: docker_build
|
id: docker_build
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: true
|
||||||
context: ./
|
context: ./
|
||||||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
tags: |
|
||||||
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||||
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.TAG }}
|
||||||
|
|
|
||||||
2
.github/workflows/ton-ccpcheck.yml
vendored
2
.github/workflows/ton-ccpcheck.yml
vendored
|
|
@ -20,7 +20,7 @@ jobs:
|
||||||
generate report: true
|
generate report: true
|
||||||
|
|
||||||
- name: Upload report
|
- name: Upload report
|
||||||
uses: actions/upload-artifact@v1
|
uses: actions/upload-artifact@master
|
||||||
with:
|
with:
|
||||||
name: ton-ccpcheck-report
|
name: ton-ccpcheck-report
|
||||||
path: output
|
path: output
|
||||||
|
|
|
||||||
41
.github/workflows/ton-x86-64-linux.yml
vendored
41
.github/workflows/ton-x86-64-linux.yml
vendored
|
|
@ -1,41 +0,0 @@
|
||||||
name: Ubuntu TON build (portable, x86-64)
|
|
||||||
|
|
||||||
on: [push,workflow_dispatch,workflow_call]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- run: |
|
|
||||||
sudo apt update
|
|
||||||
sudo apt install -y apt-utils
|
|
||||||
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
submodules: 'recursive'
|
|
||||||
|
|
||||||
- uses: cachix/install-nix-action@v23
|
|
||||||
with:
|
|
||||||
extra_nix_config: |
|
|
||||||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Build TON
|
|
||||||
run: |
|
|
||||||
cp assembly/nix/build-linux-x86-64-nix.sh .
|
|
||||||
chmod +x build-linux-x86-64-nix.sh
|
|
||||||
./build-linux-x86-64-nix.sh -t
|
|
||||||
|
|
||||||
- name: Simple binaries test
|
|
||||||
run: |
|
|
||||||
sudo mv /nix/store /nix/store2
|
|
||||||
artifacts/validator-engine -V
|
|
||||||
artifacts/lite-client -V
|
|
||||||
artifacts/fift -V
|
|
||||||
artifacts/func -V
|
|
||||||
|
|
||||||
- name: Upload artifacts
|
|
||||||
uses: actions/upload-artifact@master
|
|
||||||
with:
|
|
||||||
name: ton-x86_64-linux-binaries
|
|
||||||
path: artifacts
|
|
||||||
37
.github/workflows/ton-x86-64-macos.yml
vendored
37
.github/workflows/ton-x86-64-macos.yml
vendored
|
|
@ -1,37 +0,0 @@
|
||||||
name: MacOS TON build (portable, x86-64)
|
|
||||||
|
|
||||||
on: [push,workflow_dispatch,workflow_call]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: macos-12
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
submodules: 'recursive'
|
|
||||||
|
|
||||||
- uses: cachix/install-nix-action@v23
|
|
||||||
with:
|
|
||||||
extra_nix_config: |
|
|
||||||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Build TON
|
|
||||||
run: |
|
|
||||||
cp assembly/nix/build-macos-nix.sh .
|
|
||||||
chmod +x build-macos-nix.sh
|
|
||||||
./build-macos-nix.sh -t
|
|
||||||
|
|
||||||
- name: Simple binaries test
|
|
||||||
run: |
|
|
||||||
sudo mv /nix/store /nix/store2
|
|
||||||
artifacts/validator-engine -V
|
|
||||||
artifacts/lite-client -V
|
|
||||||
artifacts/fift -V
|
|
||||||
artifacts/func -V
|
|
||||||
|
|
||||||
- name: Upload artifacts
|
|
||||||
uses: actions/upload-artifact@master
|
|
||||||
with:
|
|
||||||
name: ton-x86_64-macos-binaries
|
|
||||||
path: artifacts
|
|
||||||
12
.github/workflows/ton-x86-64-windows.yml
vendored
12
.github/workflows/ton-x86-64-windows.yml
vendored
|
|
@ -9,7 +9,7 @@ defaults:
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
||||||
runs-on: windows-2022
|
runs-on: windows-2019
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Get Current OS version
|
- name: Get Current OS version
|
||||||
|
|
@ -23,12 +23,14 @@ jobs:
|
||||||
|
|
||||||
- name: Build TON
|
- name: Build TON
|
||||||
run: |
|
run: |
|
||||||
copy assembly\native\build-windows-github.bat .
|
git submodule sync --recursive
|
||||||
copy assembly\native\build-windows.bat .
|
git submodule update
|
||||||
build-windows-github.bat Enterprise
|
copy assembly\native\build-windows-github-2019.bat .
|
||||||
|
copy assembly\native\build-windows-2019.bat .
|
||||||
|
build-windows-github-2019.bat Enterprise
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@master
|
uses: actions/upload-artifact@master
|
||||||
with:
|
with:
|
||||||
name: ton-win-binaries
|
name: ton-x86-64-windows
|
||||||
path: artifacts
|
path: artifacts
|
||||||
|
|
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -13,11 +13,12 @@ test/regression-tests.cache/
|
||||||
**/*build*/
|
**/*build*/
|
||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
|
.DS_Store
|
||||||
|
dev/
|
||||||
zlib/
|
zlib/
|
||||||
libsodium/
|
libsodium/
|
||||||
libmicrohttpd-0.9.77-w32-bin/
|
libmicrohttpd-0.9.77-w32-bin/
|
||||||
readline-5.0-1-lib/
|
readline-5.0-1-lib/
|
||||||
secp256k1/
|
|
||||||
openssl-3.1.4/
|
openssl-3.1.4/
|
||||||
libsodium-1.0.18-stable-msvc.zip
|
libsodium-1.0.18-stable-msvc.zip
|
||||||
libmicrohttpd-0.9.77-w32-bin.zip
|
libmicrohttpd-0.9.77-w32-bin.zip
|
||||||
|
|
|
||||||
4
.gitmodules
vendored
4
.gitmodules
vendored
|
|
@ -13,3 +13,7 @@
|
||||||
[submodule "third-party/blst"]
|
[submodule "third-party/blst"]
|
||||||
path = third-party/blst
|
path = third-party/blst
|
||||||
url = https://github.com/supranational/blst.git
|
url = https://github.com/supranational/blst.git
|
||||||
|
[submodule "third-party/secp256k1"]
|
||||||
|
path = third-party/secp256k1
|
||||||
|
url = https://github.com/bitcoin-core/secp256k1
|
||||||
|
branch = v0.3.2
|
||||||
|
|
|
||||||
55
CMake/BuildSECP256K1.cmake
Normal file
55
CMake/BuildSECP256K1.cmake
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
if (NOT SECP256K1_LIBRARY)
|
||||||
|
|
||||||
|
set(SECP256K1_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third-party/secp256k1)
|
||||||
|
set(SECP256K1_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/third-party/secp256k1)
|
||||||
|
set(SECP256K1_INCLUDE_DIR ${SECP256K1_BINARY_DIR}/include)
|
||||||
|
|
||||||
|
file(MAKE_DIRECTORY ${SECP256K1_BINARY_DIR})
|
||||||
|
file(MAKE_DIRECTORY "${SECP256K1_BINARY_DIR}/include")
|
||||||
|
|
||||||
|
if (MSVC)
|
||||||
|
set(SECP256K1_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third-party/secp256k1)
|
||||||
|
set(SECP256K1_LIBRARY ${SECP256K1_SOURCE_DIR}/build/src/Release/libsecp256k1.lib)
|
||||||
|
set(SECP256K1_INCLUDE_DIR ${SECP256K1_BINARY_DIR}/include)
|
||||||
|
add_custom_command(
|
||||||
|
WORKING_DIRECTORY ${SECP256K1_SOURCE_DIR}
|
||||||
|
COMMAND cmake -E env CFLAGS="/WX" cmake -A x64 -B build -DSECP256K1_ENABLE_MODULE_RECOVERY=ON -DSECP256K1_ENABLE_MODULE_EXTRAKEYS=ON -DSECP256K1_BUILD_EXAMPLES=OFF -DBUILD_SHARED_LIBS=OFF
|
||||||
|
COMMAND cmake --build build --config Release
|
||||||
|
COMMENT "Build Secp256k1"
|
||||||
|
DEPENDS ${SECP256K1_SOURCE_DIR}
|
||||||
|
OUTPUT ${SECP256K1_LIBRARY}
|
||||||
|
)
|
||||||
|
elseif (EMSCRIPTEN)
|
||||||
|
set(SECP256K1_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third-party/secp256k1)
|
||||||
|
set(SECP256K1_LIBRARY ${SECP256K1_BINARY_DIR}/.libs/libsecp256k1.a)
|
||||||
|
set(SECP256K1_INCLUDE_DIR ${SECP256K1_SOURCE_DIR}/include)
|
||||||
|
add_custom_command(
|
||||||
|
WORKING_DIRECTORY ${SECP256K1_SOURCE_DIR}
|
||||||
|
COMMAND ./autogen.sh
|
||||||
|
COMMAND emconfigure ./configure --enable-module-recovery --enable-module-extrakeys --disable-tests --disable-benchmark
|
||||||
|
COMMAND emmake make clean
|
||||||
|
COMMAND emmake make
|
||||||
|
COMMENT "Build Secp256k1 with emscripten"
|
||||||
|
DEPENDS ${SECP256K1_SOURCE_DIR}
|
||||||
|
OUTPUT ${SECP256K1_LIBRARY}
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
if (NOT NIX)
|
||||||
|
set(SECP256K1_LIBRARY ${SECP256K1_BINARY_DIR}/lib/libsecp256k1.a)
|
||||||
|
add_custom_command(
|
||||||
|
WORKING_DIRECTORY ${SECP256K1_SOURCE_DIR}
|
||||||
|
COMMAND ./autogen.sh
|
||||||
|
COMMAND ./configure -q --disable-option-checking --enable-module-recovery --enable-module-extrakeys --prefix ${SECP256K1_BINARY_DIR} --with-pic --disable-shared --enable-static --disable-tests --disable-benchmark
|
||||||
|
COMMAND make -j16
|
||||||
|
COMMAND make install
|
||||||
|
COMMENT "Build secp256k1"
|
||||||
|
DEPENDS ${SECP256K1_SOURCE_DIR}
|
||||||
|
OUTPUT ${SECP256K1_LIBRARY}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(STATUS "Use Secp256k1: ${SECP256K1_LIBRARY}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_custom_target(secp256k1 DEPENDS ${SECP256K1_LIBRARY})
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
# - Try to find SECP256K1
|
# - Try to find Secp256k1
|
||||||
# Once done this will define
|
# Once done this will define
|
||||||
#
|
#
|
||||||
# SECP256K1_FOUND - system has SECP256K1
|
# SECP256K1_INCLUDE_DIR - the Secp256k1 include directory
|
||||||
# SECP256K1_INCLUDE_DIR - the SECP256K1 include directory
|
# SECP256K1_LIBRARY - Link these to use Secp256k1
|
||||||
# SECP256K1_LIBRARY - Link these to use SECP256K1
|
|
||||||
|
|
||||||
if (NOT SECP256K1_LIBRARY)
|
if (NOT SECP256K1_LIBRARY)
|
||||||
find_path(
|
find_path(
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,14 @@ if (NOT DEFINED SODIUM_USE_STATIC_LIBS)
|
||||||
option(SODIUM_USE_STATIC_LIBS "enable to statically link against sodium" OFF)
|
option(SODIUM_USE_STATIC_LIBS "enable to statically link against sodium" OFF)
|
||||||
endif()
|
endif()
|
||||||
if(NOT (SODIUM_USE_STATIC_LIBS EQUAL SODIUM_USE_STATIC_LIBS_LAST))
|
if(NOT (SODIUM_USE_STATIC_LIBS EQUAL SODIUM_USE_STATIC_LIBS_LAST))
|
||||||
unset(sodium_LIBRARY CACHE)
|
if (NOT SODIUM_LIBRARY_RELEASE)
|
||||||
unset(SODIUM_LIBRARY_DEBUG CACHE)
|
unset(sodium_LIBRARY CACHE)
|
||||||
unset(SODIUM_LIBRARY_RELEASE CACHE)
|
unset(SODIUM_LIBRARY_DEBUG CACHE)
|
||||||
unset(sodium_DLL_DEBUG CACHE)
|
unset(SODIUM_LIBRARY_RELEASE CACHE)
|
||||||
unset(sodium_DLL_RELEASE CACHE)
|
unset(sodium_DLL_DEBUG CACHE)
|
||||||
set(SODIUM_USE_STATIC_LIBS_LAST ${SODIUM_USE_STATIC_LIBS} CACHE INTERNAL "internal change tracking variable")
|
unset(sodium_DLL_RELEASE CACHE)
|
||||||
|
set(SODIUM_USE_STATIC_LIBS_LAST ${SODIUM_USE_STATIC_LIBS} CACHE INTERNAL "internal change tracking variable")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -125,10 +127,16 @@ elseif (WIN32)
|
||||||
endif()
|
endif()
|
||||||
string(APPEND _PLATFORM_PATH "/$$CONFIG$$")
|
string(APPEND _PLATFORM_PATH "/$$CONFIG$$")
|
||||||
|
|
||||||
|
message(STATUS "MSVC_VERSION ${MSVC_VERSION}")
|
||||||
if (MSVC_VERSION LESS 1900)
|
if (MSVC_VERSION LESS 1900)
|
||||||
math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 60")
|
math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 60")
|
||||||
else()
|
else()
|
||||||
math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 50")
|
if (MSVC_VERSION EQUAL 1941)
|
||||||
|
math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 51")
|
||||||
|
else()
|
||||||
|
math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 50")
|
||||||
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
string(APPEND _PLATFORM_PATH "/v${_VS_VERSION}")
|
string(APPEND _PLATFORM_PATH "/v${_VS_VERSION}")
|
||||||
|
|
||||||
|
|
@ -295,4 +303,4 @@ else()
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -79,11 +79,12 @@ else()
|
||||||
set(HAVE_SSE42 FALSE)
|
set(HAVE_SSE42 FALSE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
||||||
set(CMAKE_CXX_EXTENSIONS FALSE)
|
set(CMAKE_CXX_EXTENSIONS FALSE)
|
||||||
|
|
||||||
#BEGIN internal
|
#BEGIN internal
|
||||||
|
option(BUILD_SHARED_LIBS "Use \"ON\" to build shared libraries instead of static where it's not specified (not recommended)" OFF)
|
||||||
option(USE_EMSCRIPTEN "Use \"ON\" for config building wasm." OFF)
|
option(USE_EMSCRIPTEN "Use \"ON\" for config building wasm." OFF)
|
||||||
option(TON_ONLY_TONLIB "Use \"ON\" to build only tonlib." OFF)
|
option(TON_ONLY_TONLIB "Use \"ON\" to build only tonlib." OFF)
|
||||||
if (USE_EMSCRIPTEN)
|
if (USE_EMSCRIPTEN)
|
||||||
|
|
@ -183,6 +184,7 @@ message("Add ton")
|
||||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
|
||||||
|
|
||||||
include(BuildBLST)
|
include(BuildBLST)
|
||||||
|
include(BuildSECP256K1)
|
||||||
|
|
||||||
# Configure CCache if available
|
# Configure CCache if available
|
||||||
find_program(CCACHE_FOUND ccache)
|
find_program(CCACHE_FOUND ccache)
|
||||||
|
|
@ -234,9 +236,14 @@ if (THREADS_HAVE_PTHREAD_ARG)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (TON_USE_JEMALLOC)
|
if (TON_USE_JEMALLOC)
|
||||||
find_package(JeMalloc REQUIRED)
|
find_package(jemalloc REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (NIX)
|
||||||
|
find_package(Secp256k1 REQUIRED)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
set(MEMPROF "" CACHE STRING "Use one of \"ON\", \"FAST\" or \"SAFE\" to enable memory profiling. \
|
set(MEMPROF "" CACHE STRING "Use one of \"ON\", \"FAST\" or \"SAFE\" to enable memory profiling. \
|
||||||
Works under macOS and Linux when compiled using glibc. \
|
Works under macOS and Linux when compiled using glibc. \
|
||||||
In FAST mode stack is unwinded only using frame pointers, which may fail. \
|
In FAST mode stack is unwinded only using frame pointers, which may fail. \
|
||||||
|
|
@ -333,6 +340,10 @@ add_cxx_compiler_flag("-Wno-sign-conversion")
|
||||||
add_cxx_compiler_flag("-Qunused-arguments")
|
add_cxx_compiler_flag("-Qunused-arguments")
|
||||||
add_cxx_compiler_flag("-Wno-unused-private-field")
|
add_cxx_compiler_flag("-Wno-unused-private-field")
|
||||||
add_cxx_compiler_flag("-Wno-redundant-move")
|
add_cxx_compiler_flag("-Wno-redundant-move")
|
||||||
|
|
||||||
|
#add_cxx_compiler_flag("-Wno-unused-function")
|
||||||
|
#add_cxx_compiler_flag("-Wno-unused-variable")
|
||||||
|
#add_cxx_compiler_flag("-Wno-shorten-64-to-32")
|
||||||
#add_cxx_compiler_flag("-Werror")
|
#add_cxx_compiler_flag("-Werror")
|
||||||
|
|
||||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem /usr/include/c++/v1")
|
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem /usr/include/c++/v1")
|
||||||
|
|
@ -409,6 +420,7 @@ add_subdirectory(adnl)
|
||||||
add_subdirectory(crypto)
|
add_subdirectory(crypto)
|
||||||
add_subdirectory(lite-client)
|
add_subdirectory(lite-client)
|
||||||
add_subdirectory(emulator)
|
add_subdirectory(emulator)
|
||||||
|
add_subdirectory(tolk)
|
||||||
|
|
||||||
#BEGIN tonlib
|
#BEGIN tonlib
|
||||||
add_subdirectory(tonlib)
|
add_subdirectory(tonlib)
|
||||||
|
|
@ -484,10 +496,10 @@ target_link_libraries(test-net PRIVATE tdnet tdutils ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
|
||||||
#BEGIN tonlib
|
#BEGIN tonlib
|
||||||
add_executable(test-tonlib ${TONLIB_ONLINE_TEST_SOURCE})
|
add_executable(test-tonlib ${TONLIB_ONLINE_TEST_SOURCE})
|
||||||
target_link_libraries(test-tonlib tdutils tdactor adnllite tl_api ton_crypto ton_block tl_tonlib_api tonlib)
|
target_link_libraries(test-tonlib tdactor adnllite tl_api ton_crypto tl_tonlib_api tonlib)
|
||||||
|
|
||||||
add_executable(test-tonlib-offline test/test-td-main.cpp ${TONLIB_OFFLINE_TEST_SOURCE})
|
add_executable(test-tonlib-offline test/test-td-main.cpp ${TONLIB_OFFLINE_TEST_SOURCE})
|
||||||
target_link_libraries(test-tonlib-offline tdutils tdactor adnllite tl_api ton_crypto ton_block fift-lib tl_tonlib_api tonlib)
|
target_link_libraries(test-tonlib-offline tdactor adnllite tl_api ton_crypto fift-lib tl_tonlib_api tonlib)
|
||||||
|
|
||||||
if (NOT CMAKE_CROSSCOMPILING)
|
if (NOT CMAKE_CROSSCOMPILING)
|
||||||
add_dependencies(test-tonlib-offline gen_fif)
|
add_dependencies(test-tonlib-offline gen_fif)
|
||||||
|
|
@ -529,6 +541,8 @@ target_link_libraries(test-rldp2 adnl adnltest dht rldp2 tl_api)
|
||||||
add_executable(test-validator-session-state test/test-validator-session-state.cpp)
|
add_executable(test-validator-session-state test/test-validator-session-state.cpp)
|
||||||
target_link_libraries(test-validator-session-state adnl dht rldp validatorsession tl_api)
|
target_link_libraries(test-validator-session-state adnl dht rldp validatorsession tl_api)
|
||||||
|
|
||||||
|
add_executable(test-overlay test/test-overlay.cpp)
|
||||||
|
target_link_libraries(test-overlay overlay tdutils tdactor adnl adnltest tl_api dht )
|
||||||
add_executable(test-catchain test/test-catchain.cpp)
|
add_executable(test-catchain test/test-catchain.cpp)
|
||||||
target_link_libraries(test-catchain overlay tdutils tdactor adnl adnltest rldp tl_api dht
|
target_link_libraries(test-catchain overlay tdutils tdactor adnl adnltest rldp tl_api dht
|
||||||
catchain )
|
catchain )
|
||||||
|
|
@ -539,6 +553,9 @@ target_link_libraries(test-ton-collator overlay tdutils tdactor adnl tl_api dht
|
||||||
add_executable(test-http test/test-http.cpp)
|
add_executable(test-http test/test-http.cpp)
|
||||||
target_link_libraries(test-http PRIVATE tonhttp)
|
target_link_libraries(test-http PRIVATE tonhttp)
|
||||||
|
|
||||||
|
add_executable(test-emulator test/test-td-main.cpp emulator/test/emulator-tests.cpp)
|
||||||
|
target_link_libraries(test-emulator PRIVATE emulator)
|
||||||
|
|
||||||
get_directory_property(HAS_PARENT PARENT_DIRECTORY)
|
get_directory_property(HAS_PARENT PARENT_DIRECTORY)
|
||||||
if (HAS_PARENT)
|
if (HAS_PARENT)
|
||||||
set(ALL_TEST_SOURCE
|
set(ALL_TEST_SOURCE
|
||||||
|
|
@ -570,6 +587,7 @@ add_test(test-cells test-cells ${TEST_OPTIONS})
|
||||||
add_test(test-smartcont test-smartcont)
|
add_test(test-smartcont test-smartcont)
|
||||||
add_test(test-net test-net)
|
add_test(test-net test-net)
|
||||||
add_test(test-actors test-tdactor)
|
add_test(test-actors test-tdactor)
|
||||||
|
add_test(test-emulator test-emulator)
|
||||||
|
|
||||||
#BEGIN tonlib
|
#BEGIN tonlib
|
||||||
add_test(test-tdutils test-tdutils)
|
add_test(test-tdutils test-tdutils)
|
||||||
|
|
@ -616,6 +634,30 @@ if (NOT NIX)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Tolk tests
|
||||||
|
if (NOT NIX)
|
||||||
|
if (MSVC)
|
||||||
|
set(PYTHON_VER "python")
|
||||||
|
else()
|
||||||
|
set(PYTHON_VER "python3")
|
||||||
|
endif()
|
||||||
|
add_test(
|
||||||
|
NAME test-tolk
|
||||||
|
COMMAND ${PYTHON_VER} tolk-tester.py tests/
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tolk-tester)
|
||||||
|
if (WIN32)
|
||||||
|
set_property(TEST test-tolk PROPERTY ENVIRONMENT
|
||||||
|
"TOLK_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/tolk/tolk.exe"
|
||||||
|
"FIFT_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/crypto/fift.exe"
|
||||||
|
"FIFTPATH=${CMAKE_CURRENT_SOURCE_DIR}/crypto/fift/lib/")
|
||||||
|
else()
|
||||||
|
set_property(TEST test-tolk PROPERTY ENVIRONMENT
|
||||||
|
"TOLK_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/tolk/tolk"
|
||||||
|
"FIFT_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/crypto/fift"
|
||||||
|
"FIFTPATH=${CMAKE_CURRENT_SOURCE_DIR}/crypto/fift/lib/")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
#BEGIN internal
|
#BEGIN internal
|
||||||
if (NOT TON_ONLY_TONLIB)
|
if (NOT TON_ONLY_TONLIB)
|
||||||
add_test(test-adnl test-adnl)
|
add_test(test-adnl test-adnl)
|
||||||
|
|
|
||||||
128
Changelog.md
128
Changelog.md
|
|
@ -1,3 +1,125 @@
|
||||||
|
## 2025.03 Update
|
||||||
|
1. New extracurrency behavior introduced, check [GlobalVersions.md](./doc/GlobalVersions.md#version-10)
|
||||||
|
2. Optmization of validation process, in particular CellStorageStat.
|
||||||
|
3. Flag for speeding up broadcasts in various overlays.
|
||||||
|
4. Fixes for static builds for emulator and tonlibjson
|
||||||
|
5. Improving getstats output: adds
|
||||||
|
* Liteserver queries count
|
||||||
|
* Collated/validated blocks count, number of active sessions
|
||||||
|
* Persistent state sizes
|
||||||
|
* Initial sync progress
|
||||||
|
6. Fixes in logging, TON Storage, external message checking, persistent state downloading, UB in tonlib
|
||||||
|
|
||||||
|
Besides the work of the core team, this update is based on the efforts of @Sild from StonFi(UB in tonlib).
|
||||||
|
|
||||||
|
## 2025.02 Update
|
||||||
|
1. Series of improvement/fixes for `Config8.version >= 9`, check [GlobalVersions.md](./doc/GlobalVersions.md)
|
||||||
|
2. Fix for better discovery of updated nodes' (validators') IPs: retry dht queries
|
||||||
|
3. Series of improvements for extra currency adoption: fixed c7 in rungetmethod, reserve modes
|
||||||
|
4. TVM: Fix processing continuation control data on deep jump
|
||||||
|
5. A few fixes of tl-b schemes: crc computation, incorrect tag for merkle proofs, advance_ext, NatWidth print
|
||||||
|
6. Emulator improvements: fix setting libraries, extracurrency support
|
||||||
|
7. Increase of gas limit for unlocking highload-v2 wallets locked in the beginning of 2024
|
||||||
|
8. Validator console improvement: dashed names, better shard formats
|
||||||
|
|
||||||
|
|
||||||
|
Besides the work of the core team, this update is based on the efforts of @dbaranovstonfi from StonFi(libraries in emulator), @Rexagon (ret on deep jumps), @tvorogme from DTon (`advance_ext`), Nan from Zellic (`stk_und` and JNI)
|
||||||
|
|
||||||
|
## 2024.12 Update
|
||||||
|
|
||||||
|
1. FunC 0.4.6: Fix in try/catch handling, fixing pure flag for functions stored in variables
|
||||||
|
2. Merging parts of Accelerator: support of specific shard monitoring, archive/liteserver slice format, support for partial liteservers, proxy liteserver, on-demand neighbour queue loading
|
||||||
|
3. Fix of asynchronous cell loading
|
||||||
|
4. Various improvements: caching certificates checks, better block overloading detection, `_malloc` in emulator
|
||||||
|
5. Introduction of telemetry in overlays
|
||||||
|
6. Use non-null local-id for tonlib-LS interaction - mitigates MitM attack.
|
||||||
|
7. Adding `SECP256K1_XONLY_PUBKEY_TWEAK_ADD`, `SETCONTCTRMANY` instructions to TVM (activated by `Config8.version >= 9`)
|
||||||
|
8. Private keys export via validator-engine-console - required for better backups
|
||||||
|
9. Fix proof checking in tonlib, `hash` in `raw.Message` in tonlib_api
|
||||||
|
|
||||||
|
Besides the work of the core team, this update is based on the efforts of OtterSec and LayerZero (FunC), tg:@throwunless (FunC), Aviv Frenkel and Dima Kogan from Fordefi (LS MitM), @hacker-volodya (Tonlib), OKX team (async cell loading), @krigga (emulator)
|
||||||
|
|
||||||
|
## 2024.10 Update
|
||||||
|
|
||||||
|
1. Parallel write to celldb: substantial improvement of sync and GC speed, especially with slow disks.
|
||||||
|
2. Decreased network traffic: only first block candidate is sent optimistically.
|
||||||
|
3. Improved channel creation and dht lookups, introduction of semi-private overlays
|
||||||
|
4. New LS dispatch queue related methods and improvement security
|
||||||
|
5. Fixing recursion in TVM continuations
|
||||||
|
6. Improved stats for actors, validator sessions, perf counters, overlays, adnl, rocksdb
|
||||||
|
7. Migration to C++20
|
||||||
|
8. Improved block size estimates: account for depth in various structures
|
||||||
|
9. Fix bug with `<<` optimization in FunC
|
||||||
|
10. Minor changes of TVM which will be activated by `Config8.version >= 9`
|
||||||
|
11. Multiple minor improvements
|
||||||
|
|
||||||
|
Besides the work of the core team, this update is based on the efforts of @krigga (emulator), Arayz @ TonBit (LS security, TVM recursion), @ret2happy (UB in BLST).
|
||||||
|
|
||||||
|
## 2024.08 Update
|
||||||
|
|
||||||
|
1. Introduction of dispatch queues, message envelopes with transaction chain metadata, and explicitly stored msg_queue size, which will be activated by `Config8.version >= 8` and new `Config8.capabilities` bits: `capStoreOutMsgQueueSize`, `capMsgMetadata`, `capDeferMessages`.
|
||||||
|
2. A number of changes to transaction executor which will activated for `Config8.version >= 8`:
|
||||||
|
- Check mode on invalid `action_send_msg`. Ignore action if `IGNORE_ERROR` (+2) bit is set, bounce if `BOUNCE_ON_FAIL` (+16) bit is set.
|
||||||
|
- Slightly change random seed generation to fix mix of `addr_rewrite` and `addr`.
|
||||||
|
- Fill in `skipped_actions` for both invalid and valid messages with `IGNORE_ERROR` mode that can't be sent.
|
||||||
|
- Allow unfreeze through external messages.
|
||||||
|
- Don't use user-provided `fwd_fee` and `ihr_fee` for internal messages.
|
||||||
|
3. A few issues with broadcasts were fixed: stop on receiving last piece, response to AdnlMessageCreateChannel
|
||||||
|
4. A number of fixes and improvements for emulator and tonlib: correct work with config_addr, not accepted externals, bounces, debug ops gas consumption, added version and c5 dump, fixed tonlib crashes
|
||||||
|
5. Added new flags and commands to the node, in particular `--fast-state-serializer`, `getcollatoroptionsjson`, `setcollatoroptionsjson`
|
||||||
|
|
||||||
|
Besides the work of the core team, this update is based on the efforts of @krigga (emulator), stonfi team, in particular @dbaranovstonfi and @hey-researcher (emulator), and @loeul, @xiaoxianBoy, @simlecode (typos in comments and docs).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 2024.06 Update
|
||||||
|
|
||||||
|
1. Make Jemalloc default allocator
|
||||||
|
2. Add candidate broadcasting and caching
|
||||||
|
3. Limit per address speed for external messages broadcast by reasonably large number
|
||||||
|
4. Overlay improvements: fix dropping peers in small custom overlays, fix wrong certificate on missed keyblocks
|
||||||
|
5. Extended statistics and logs for celldb usage, session stats, persistent state serialization
|
||||||
|
6. Tonlib and explorer fixes
|
||||||
|
7. Flags for precize control of Celldb: `--celldb-cache-size`, `--celldb-direct-io` and `--celldb-preload-all`
|
||||||
|
8. Add valiator-console command to stop persistent state serialization
|
||||||
|
9. Use `@` path separator for defining include path in fift and create-state utilities on Windows only.
|
||||||
|
|
||||||
|
|
||||||
|
## 2024.04 Update
|
||||||
|
|
||||||
|
1. Emulator: Single call optimized runGetMethod added
|
||||||
|
2. Tonlib: a series of proof improvements, also breaking Change in `liteServer.getAllShardsInfo` method (see below)
|
||||||
|
3. DB: usage statistics now collected, outdated persistent states are not serialized
|
||||||
|
4. LS: fast `getOutMsgQueueSizes` added, preliminary support of non-final block requests
|
||||||
|
5. Network: lz4 compression of block candidates (disabled by default).
|
||||||
|
6. Overlays: add custom overlays
|
||||||
|
7. Transaction Executor: fixed issue with due_payment collection
|
||||||
|
|
||||||
|
* `liteServer.getAllShardsInfo` method was updated for better efficiency. Previously, field proof contained BoC with two roots: one for BlockState from block's root and another for ShardHashes from BlockState. Now, it returns a single-root proof BoC, specifically the merkle proof of ShardHashes directly from the block's root, streamlining data access and integrity. Checking of the proof requires to check that ShardHashes in the `data` correspond to ShardHashes from the block.
|
||||||
|
|
||||||
|
Besides the work of the core team, this update is based on the efforts of @akifoq (due_payment issue).
|
||||||
|
|
||||||
|
## 2024.03 Update
|
||||||
|
|
||||||
|
1. Preparatory (not enabled yet) code for pre-compiled smart-contract.
|
||||||
|
2. Minor fixes for fee-related opcodes.
|
||||||
|
|
||||||
|
## 2024.02 Update
|
||||||
|
|
||||||
|
1. Improvement of validator synchronisation:
|
||||||
|
* Better handling of block broadcasts -> faster sync
|
||||||
|
* Additional separate overlay among validators as second option for synchronisation
|
||||||
|
2. Improvements in LS:
|
||||||
|
* c7 and library context is fully filled up for server-side rungetmethod
|
||||||
|
* Cache for runmethods and successfull external messages
|
||||||
|
* Logging of LS requests statistic
|
||||||
|
3. Precise control of open files:
|
||||||
|
* almost instantaneous validator start
|
||||||
|
* `--max-archive-fd` option
|
||||||
|
* autoremoval of not used temp archive files
|
||||||
|
* `--archive-preload-period` option
|
||||||
|
4. Preparatory (not enabled yet) code for addition on new TVM instructions for cheaper fee calculation onchain.
|
||||||
|
|
||||||
## 2024.01 Update
|
## 2024.01 Update
|
||||||
|
|
||||||
1. Fixes in how gas in transactions on special accounts is accounted in block limit. Previously, gas was counted as usual, so to conduct elections that costs >30m gas block limit in masterchain was set to 37m gas. To lower the limit for safety reasons it is proposed to caunt gas on special accounts separately. Besides `gas_max` is set to `special_gas_limit` for all types of transactions on special accounts. New behavior is activated through setting `version >= 5` in `ConfigParam 8;`.
|
1. Fixes in how gas in transactions on special accounts is accounted in block limit. Previously, gas was counted as usual, so to conduct elections that costs >30m gas block limit in masterchain was set to 37m gas. To lower the limit for safety reasons it is proposed to caunt gas on special accounts separately. Besides `gas_max` is set to `special_gas_limit` for all types of transactions on special accounts. New behavior is activated through setting `version >= 5` in `ConfigParam 8;`.
|
||||||
|
|
@ -8,7 +130,7 @@
|
||||||
* Fix error in proof generation for blocks after merge
|
* Fix error in proof generation for blocks after merge
|
||||||
* Fix most of `block is not applied` issues related to sending too recent block in Proofs
|
* Fix most of `block is not applied` issues related to sending too recent block in Proofs
|
||||||
* LS now check external messages till `accept_message` (`set_gas`).
|
* LS now check external messages till `accept_message` (`set_gas`).
|
||||||
3. Improvements in DHT work and storage, CellDb, config.json ammendment, peer misbehavior detection, validator session stats collection, emulator.
|
3. Improvements in DHT work and storage, CellDb, config.json amendment, peer misbehavior detection, validator session stats collection, emulator.
|
||||||
4. Change in CTOS and XLOAD behavior activated through setting `version >= 5` in `ConfigParam 8;`:
|
4. Change in CTOS and XLOAD behavior activated through setting `version >= 5` in `ConfigParam 8;`:
|
||||||
* Loading "nested libraries" (i.e. a library cell that points to another library cell) throws an exception.
|
* Loading "nested libraries" (i.e. a library cell that points to another library cell) throws an exception.
|
||||||
* Loading a library consumes gas for cell load only once (for the library cell), not twice (both for the library cell and the cell in the library).
|
* Loading a library consumes gas for cell load only once (for the library cell), not twice (both for the library cell and the cell in the library).
|
||||||
|
|
@ -19,7 +141,7 @@ Besides the work of the Core team, this update is based on the efforts of @XaBbl
|
||||||
## 2023.12 Update
|
## 2023.12 Update
|
||||||
|
|
||||||
1. Optimized message queue handling, now queue cleaning speed doesn't depend on total queue size
|
1. Optimized message queue handling, now queue cleaning speed doesn't depend on total queue size
|
||||||
* Cleaning delivered messages using lt augmentation instead of random search / consequtive walk
|
* Cleaning delivered messages using lt augmentation instead of random search / consecutive walk
|
||||||
* Keeping root cell of queue message in memory until outdated (caching)
|
* Keeping root cell of queue message in memory until outdated (caching)
|
||||||
2. Changes to block collation/validation limits
|
2. Changes to block collation/validation limits
|
||||||
3. Stop accepting new external message if message queue is overloaded
|
3. Stop accepting new external message if message queue is overloaded
|
||||||
|
|
@ -111,7 +233,7 @@ Besides the work of the core team, this update is based on the efforts of @vtama
|
||||||
Besides the work of the core team, this update is based on the efforts of @tvorogme (debug improvements), @AlexeyFSL (WASM builds) and third-party security auditors.
|
Besides the work of the core team, this update is based on the efforts of @tvorogme (debug improvements), @AlexeyFSL (WASM builds) and third-party security auditors.
|
||||||
|
|
||||||
## 2022.08 Update
|
## 2022.08 Update
|
||||||
* Blockchain state serialization now works via separate db-handler which simplfies memory clearing after serialization
|
* Blockchain state serialization now works via separate db-handler which simplifies memory clearing after serialization
|
||||||
* CellDB now works asynchronously which substantially increase database access throughput
|
* CellDB now works asynchronously which substantially increase database access throughput
|
||||||
* Abseil-cpp and crc32 updated: solve issues with compilation on recent OS distributives
|
* Abseil-cpp and crc32 updated: solve issues with compilation on recent OS distributives
|
||||||
* Fixed a series of UBs and issues for exotic endianness hosts
|
* Fixed a series of UBs and issues for exotic endianness hosts
|
||||||
|
|
|
||||||
60
Dockerfile
60
Dockerfile
|
|
@ -1,10 +1,22 @@
|
||||||
FROM ubuntu:22.04 as builder
|
FROM ubuntu:22.04 AS builder
|
||||||
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential cmake clang openssl libssl-dev zlib1g-dev gperf wget git ninja-build libsecp256k1-dev libsodium-dev libmicrohttpd-dev pkg-config autoconf automake libtool && \
|
rm /var/lib/dpkg/info/libc-bin.* && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
apt-get clean && \
|
||||||
ENV CC clang
|
apt-get update && \
|
||||||
ENV CXX clang++
|
apt install libc-bin && \
|
||||||
ENV CCACHE_DISABLE 1
|
apt-get install -y build-essential cmake clang openssl libssl-dev zlib1g-dev gperf wget git \
|
||||||
|
ninja-build libsodium-dev libmicrohttpd-dev liblz4-dev pkg-config autoconf automake libtool \
|
||||||
|
libjemalloc-dev lsb-release software-properties-common gnupg
|
||||||
|
|
||||||
|
RUN wget https://apt.llvm.org/llvm.sh && \
|
||||||
|
chmod +x llvm.sh && \
|
||||||
|
./llvm.sh 16 all && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
ENV CC=/usr/bin/clang-16
|
||||||
|
ENV CXX=/usr/bin/clang++-16
|
||||||
|
ENV CCACHE_DISABLE=1
|
||||||
|
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
RUN mkdir ton
|
RUN mkdir ton
|
||||||
|
|
@ -13,17 +25,20 @@ WORKDIR /ton
|
||||||
COPY ./ ./
|
COPY ./ ./
|
||||||
|
|
||||||
RUN mkdir build && \
|
RUN mkdir build && \
|
||||||
cd build && \
|
cd build && \
|
||||||
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 -DTON_ARCH= .. && \
|
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
|
||||||
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y wget libatomic1 openssl libsecp256k1-dev libsodium-dev libmicrohttpd-dev && \
|
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 && \
|
RUN mkdir -p /var/ton-work/db /var/ton-work/scripts /usr/share/ton/smartcont/auto /usr/lib/fift/
|
||||||
mkdir -p /var/ton-work/db/static
|
|
||||||
|
|
||||||
COPY --from=builder /ton/build/storage/storage-daemon/storage-daemon /usr/local/bin/
|
COPY --from=builder /ton/build/storage/storage-daemon/storage-daemon /usr/local/bin/
|
||||||
COPY --from=builder /ton/build/storage/storage-daemon/storage-daemon-cli /usr/local/bin/
|
COPY --from=builder /ton/build/storage/storage-daemon/storage-daemon-cli /usr/local/bin/
|
||||||
|
|
@ -31,9 +46,24 @@ 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/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
|
WORKDIR /var/ton-work/db
|
||||||
COPY ./docker/init.sh ./docker/control.template ./
|
COPY ./docker/init.sh ./docker/control.template /var/ton-work/scripts/
|
||||||
RUN chmod +x init.sh
|
RUN chmod +x /var/ton-work/scripts/init.sh
|
||||||
|
|
||||||
ENTRYPOINT ["/var/ton-work/db/init.sh"]
|
ENTRYPOINT ["/var/ton-work/scripts/init.sh"]
|
||||||
|
|
|
||||||
68
README.md
68
README.md
|
|
@ -10,25 +10,33 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
##
|
##
|
||||||
[![TON Overflow Group][ton-overflow-badge]][ton-overflow-url]
|
|
||||||
[![Stack Overflow Group][stack-overflow-badge]][stack-overflow-url]
|
|
||||||
[![Telegram Community Chat][telegram-tondev-badge]][telegram-tondev-url]
|
|
||||||
[![Telegram Community Group][telegram-community-badge]][telegram-community-url]
|
|
||||||
[![Telegram Foundation Group][telegram-foundation-badge]][telegram-foundation-url]
|
|
||||||
[![Twitter Group][twitter-badge]][twitter-url]
|
|
||||||
|
|
||||||
[telegram-foundation-badge]: https://img.shields.io/badge/TON%20Foundation-2CA5E0?logo=telegram&logoColor=white&style=flat
|
<p align="center">
|
||||||
[telegram-community-badge]: https://img.shields.io/badge/TON%20Community-2CA5E0?logo=telegram&logoColor=white&style=flat
|
<a href="https://tonresear.ch">
|
||||||
[telegram-tondev-badge]: https://img.shields.io/badge/chat-TONDev-2CA5E0?logo=telegram&logoColor=white&style=flat
|
<img src="https://img.shields.io/badge/TON%20Research-0098EA?style=flat&logo=discourse&label=Forum&labelColor=gray" alt="Ton Research">
|
||||||
[telegram-foundation-url]: https://t.me/tonblockchain
|
</a>
|
||||||
[telegram-community-url]: https://t.me/toncoin
|
<a href="https://t.me/toncoin">
|
||||||
[telegram-tondev-url]: https://t.me/tondev_eng
|
<img src="https://img.shields.io/badge/TON%20Community-0098EA?logo=telegram&logoColor=white&style=flat" alt="Telegram Community Group">
|
||||||
[twitter-badge]: https://img.shields.io/twitter/follow/ton_blockchain
|
</a>
|
||||||
[twitter-url]: https://twitter.com/ton_blockchain
|
<a href="https://t.me/tonblockchain">
|
||||||
[stack-overflow-badge]: https://img.shields.io/badge/-Stack%20Overflow-FE7A16?style=flat&logo=stack-overflow&logoColor=white
|
<img src="https://img.shields.io/badge/TON%20Foundation-0098EA?logo=telegram&logoColor=white&style=flat" alt="Telegram Foundation Group">
|
||||||
[stack-overflow-url]: https://stackoverflow.com/questions/tagged/ton
|
</a>
|
||||||
[ton-overflow-badge]: https://img.shields.io/badge/-TON%20Overflow-FE7A16?style=flat&logo=stack-overflow&logoColor=white
|
<a href="https://t.me/tondev_eng">
|
||||||
[ton-overflow-url]: https://answers.ton.org
|
<img src="https://img.shields.io/badge/chat-TONDev-0098EA?logo=telegram&logoColor=white&style=flat" alt="Telegram Community Chat">
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://twitter.com/ton_blockchain">
|
||||||
|
<img src="https://img.shields.io/twitter/follow/ton_blockchain" alt="Twitter Group">
|
||||||
|
</a>
|
||||||
|
<a href="https://answers.ton.org">
|
||||||
|
<img src="https://img.shields.io/badge/-TON%20Overflow-FE7A16?style=flat&logo=stack-overflow&logoColor=white" alt="TON Overflow Group">
|
||||||
|
</a>
|
||||||
|
<a href="https://stackoverflow.com/questions/tagged/ton">
|
||||||
|
<img src="https://img.shields.io/badge/-Stack%20Overflow-FE7A16?style=flat&logo=stack-overflow&logoColor=white" alt="Stack Overflow Group">
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -39,9 +47,9 @@ Main TON monorepo, which includes the code of the node/validator, lite-client, t
|
||||||
__The Open Network (TON)__ is a fast, secure, scalable blockchain focused on handling _millions of transactions per second_ (TPS) with the goal of reaching hundreds of millions of blockchain users.
|
__The Open Network (TON)__ is a fast, secure, scalable blockchain focused on handling _millions of transactions per second_ (TPS) with the goal of reaching hundreds of millions of blockchain users.
|
||||||
- To learn more about different aspects of TON blockchain and its underlying ecosystem check [documentation](https://ton.org/docs)
|
- To learn more about different aspects of TON blockchain and its underlying ecosystem check [documentation](https://ton.org/docs)
|
||||||
- To run node, validator or lite-server check [Participate section](https://ton.org/docs/participate/nodes/run-node)
|
- To run node, validator or lite-server check [Participate section](https://ton.org/docs/participate/nodes/run-node)
|
||||||
- To develop decentralised apps check [Tutorials](https://ton.org/docs/develop/smart-contracts/), [FunC docs](https://ton.org/docs/develop/func/overview) and [DApp tutorials](https://ton.org/docs/develop/dapps/)
|
- To develop decentralised apps check [Tutorials](https://docs.ton.org/v3/guidelines/smart-contracts/guidelines), [FunC docs](https://ton.org/docs/develop/func/overview) and [DApp tutorials](https://docs.ton.org/v3/guidelines/dapps/overview)
|
||||||
- To work on TON check [wallets](https://ton.app/wallets), [explorers](https://ton.app/explorers), [DEXes](https://ton.app/dex) and [utilities](https://ton.app/utilities)
|
- To work on TON check [wallets](https://ton.app/wallets), [explorers](https://ton.app/explorers), [DEXes](https://ton.app/dex) and [utilities](https://ton.app/utilities)
|
||||||
- To interact with TON check [APIs](https://ton.org/docs/develop/dapps/apis/)
|
- To interact with TON check [APIs](https://docs.ton.org/v3/guidelines/dapps/apis-sdks/overview)
|
||||||
|
|
||||||
## Updates flow
|
## Updates flow
|
||||||
|
|
||||||
|
|
@ -63,7 +71,7 @@ Usually, the response to your pull request will indicate which section it falls
|
||||||
|
|
||||||
## Build TON blockchain
|
## Build TON blockchain
|
||||||
|
|
||||||
### Ubuntu 20.4, 22.04 (x86-64, aarch64)
|
### Ubuntu 20.4, 22.04, 24.04 (x86-64, aarch64)
|
||||||
Install additional system libraries
|
Install additional system libraries
|
||||||
```bash
|
```bash
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
|
|
@ -133,19 +141,11 @@ Compile TON tonlib library
|
||||||
./build-android-tonlib.sh
|
./build-android-tonlib.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
### Build TON portable binaries with Nix package manager
|
### TON portable binaries
|
||||||
You need to install Nix first.
|
|
||||||
```bash
|
Linux portable binaries are wrapped into AppImages, at the same time MacOS portable binaries are statically linked executables.
|
||||||
sh <(curl -L https://nixos.org/nix/install) --daemon
|
Linux and MacOS binaries are available for both x86-64 and arm64 architectures.
|
||||||
```
|
|
||||||
Then compile TON with Nix by executing below command from the root folder:
|
|
||||||
```bash
|
|
||||||
cp -r assembly/nix/* .
|
|
||||||
export NIX_PATH=nixpkgs=https://github.com/nixOS/nixpkgs/archive/23.05.tar.gz
|
|
||||||
nix-build linux-x86-64-static.nix
|
|
||||||
```
|
|
||||||
More examples for other platforms can be found under `assembly/nix`.
|
|
||||||
|
|
||||||
## Running tests
|
## Running tests
|
||||||
|
|
||||||
Tests are executed by running `ctest` in the build directory. See `doc/Tests.md` for more information.
|
Tests are executed by running `ctest` in the build directory. See `doc/Tests.md` for more information.
|
||||||
|
|
|
||||||
|
|
@ -88,17 +88,15 @@ target_link_libraries(adnl PUBLIC tdactor ton_crypto tl_api tdnet tddb keys keyr
|
||||||
|
|
||||||
add_executable(adnl-proxy ${ADNL_PROXY_SOURCE})
|
add_executable(adnl-proxy ${ADNL_PROXY_SOURCE})
|
||||||
target_include_directories(adnl-proxy PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
target_include_directories(adnl-proxy PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||||
target_link_libraries(adnl-proxy PUBLIC tdactor ton_crypto tl_api tdnet common
|
target_link_libraries(adnl-proxy PUBLIC tdactor ton_crypto tl_api tdnet common tl-utils git)
|
||||||
tl-utils git)
|
|
||||||
|
|
||||||
add_executable(adnl-pong adnl-pong.cpp)
|
add_executable(adnl-pong adnl-pong.cpp)
|
||||||
target_include_directories(adnl-pong PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
target_include_directories(adnl-pong PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||||
target_link_libraries(adnl-pong PUBLIC tdactor ton_crypto tl_api tdnet common
|
target_link_libraries(adnl-pong PUBLIC tdactor ton_crypto tl_api tdnet common tl-utils adnl dht git)
|
||||||
tl-utils adnl dht git)
|
|
||||||
|
|
||||||
add_library(adnltest STATIC ${ADNL_TEST_SOURCE})
|
add_library(adnltest STATIC ${ADNL_TEST_SOURCE})
|
||||||
target_include_directories(adnltest PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
target_include_directories(adnltest PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||||
target_link_libraries(adnltest PUBLIC adnl )
|
target_link_libraries(adnltest PUBLIC adnl)
|
||||||
|
|
||||||
install(TARGETS adnl-proxy RUNTIME DESTINATION bin)
|
install(TARGETS adnl-proxy RUNTIME DESTINATION bin)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -112,16 +112,16 @@ void AdnlChannelImpl::send_message(td::uint32 priority, td::actor::ActorId<AdnlN
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdnlChannelImpl::receive(td::IPAddress addr, td::BufferSlice data) {
|
void AdnlChannelImpl::receive(td::IPAddress addr, td::BufferSlice data) {
|
||||||
auto P = td::PromiseCreator::lambda(
|
auto P = td::PromiseCreator::lambda([peer = peer_pair_, channel_id = channel_in_id_, addr, id = print_id(),
|
||||||
[peer = peer_pair_, channel_id = channel_in_id_, addr, id = print_id()](td::Result<AdnlPacket> R) {
|
size = data.size()](td::Result<AdnlPacket> R) {
|
||||||
if (R.is_error()) {
|
if (R.is_error()) {
|
||||||
VLOG(ADNL_WARNING) << id << ": dropping IN message: can not decrypt: " << R.move_as_error();
|
VLOG(ADNL_WARNING) << id << ": dropping IN message: can not decrypt: " << R.move_as_error();
|
||||||
} else {
|
} else {
|
||||||
auto packet = R.move_as_ok();
|
auto packet = R.move_as_ok();
|
||||||
packet.set_remote_addr(addr);
|
packet.set_remote_addr(addr);
|
||||||
td::actor::send_closure(peer, &AdnlPeerPair::receive_packet_from_channel, channel_id, std::move(packet));
|
td::actor::send_closure(peer, &AdnlPeerPair::receive_packet_from_channel, channel_id, std::move(packet), size);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
decrypt(std::move(data), std::move(P));
|
decrypt(std::move(data), std::move(P));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,10 @@ class AdnlOutboundConnection : public AdnlExtConnection {
|
||||||
public:
|
public:
|
||||||
AdnlOutboundConnection(td::SocketFd fd, std::unique_ptr<AdnlExtConnection::Callback> callback, AdnlNodeIdFull dst,
|
AdnlOutboundConnection(td::SocketFd fd, std::unique_ptr<AdnlExtConnection::Callback> callback, AdnlNodeIdFull dst,
|
||||||
td::actor::ActorId<AdnlExtClientImpl> ext_client)
|
td::actor::ActorId<AdnlExtClientImpl> ext_client)
|
||||||
: AdnlExtConnection(std::move(fd), std::move(callback), true), dst_(std::move(dst)), ext_client_(ext_client) {
|
: AdnlExtConnection(std::move(fd), std::move(callback), true)
|
||||||
|
, dst_(std::move(dst))
|
||||||
|
, local_id_(privkeys::Ed25519::random())
|
||||||
|
, ext_client_(ext_client) {
|
||||||
}
|
}
|
||||||
AdnlOutboundConnection(td::SocketFd fd, std::unique_ptr<AdnlExtConnection::Callback> callback, AdnlNodeIdFull dst,
|
AdnlOutboundConnection(td::SocketFd fd, std::unique_ptr<AdnlExtConnection::Callback> callback, AdnlNodeIdFull dst,
|
||||||
PrivateKey local_id, td::actor::ActorId<AdnlExtClientImpl> ext_client)
|
PrivateKey local_id, td::actor::ActorId<AdnlExtClientImpl> ext_client)
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ td::Status AdnlInboundConnection::process_custom_packet(td::BufferSlice &data, b
|
||||||
auto F = fetch_tl_object<ton_api::tcp_authentificate>(data.clone(), true);
|
auto F = fetch_tl_object<ton_api::tcp_authentificate>(data.clone(), true);
|
||||||
if (F.is_ok()) {
|
if (F.is_ok()) {
|
||||||
if (nonce_.size() > 0 || !remote_id_.is_zero()) {
|
if (nonce_.size() > 0 || !remote_id_.is_zero()) {
|
||||||
return td::Status::Error(ErrorCode::protoviolation, "duplicate authentificate");
|
return td::Status::Error(ErrorCode::protoviolation, "duplicate authenticate");
|
||||||
}
|
}
|
||||||
auto f = F.move_as_ok();
|
auto f = F.move_as_ok();
|
||||||
nonce_ = td::SecureString{f->nonce_.size() + 256};
|
nonce_ = td::SecureString{f->nonce_.size() + 256};
|
||||||
|
|
|
||||||
|
|
@ -41,20 +41,34 @@ AdnlAddressList AdnlLocalId::get_addr_list() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdnlLocalId::receive(td::IPAddress addr, td::BufferSlice data) {
|
void AdnlLocalId::receive(td::IPAddress addr, td::BufferSlice data) {
|
||||||
auto P = td::PromiseCreator::lambda(
|
InboundRateLimiter& rate_limiter = inbound_rate_limiter_[addr];
|
||||||
[peer_table = peer_table_, dst = short_id_, addr, id = print_id()](td::Result<AdnlPacket> R) {
|
if (!rate_limiter.rate_limiter.take()) {
|
||||||
if (R.is_error()) {
|
VLOG(ADNL_NOTICE) << this << ": dropping IN message: rate limit exceeded";
|
||||||
VLOG(ADNL_WARNING) << id << ": dropping IN message: cannot decrypt: " << R.move_as_error();
|
add_dropped_packet_stats(addr);
|
||||||
} else {
|
return;
|
||||||
auto packet = R.move_as_ok();
|
}
|
||||||
packet.set_remote_addr(addr);
|
++rate_limiter.currently_decrypting_packets;
|
||||||
td::actor::send_closure(peer_table, &AdnlPeerTable::receive_decrypted_packet, dst, std::move(packet));
|
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this), peer_table = peer_table_, dst = short_id_, addr,
|
||||||
}
|
id = print_id(), size = data.size()](td::Result<AdnlPacket> R) {
|
||||||
});
|
td::actor::send_closure(SelfId, &AdnlLocalId::decrypt_packet_done, addr);
|
||||||
|
if (R.is_error()) {
|
||||||
|
VLOG(ADNL_WARNING) << id << ": dropping IN message: cannot decrypt: " << R.move_as_error();
|
||||||
|
} else {
|
||||||
|
auto packet = R.move_as_ok();
|
||||||
|
packet.set_remote_addr(addr);
|
||||||
|
td::actor::send_closure(peer_table, &AdnlPeerTable::receive_decrypted_packet, dst, std::move(packet), size);
|
||||||
|
}
|
||||||
|
});
|
||||||
decrypt(std::move(data), std::move(P));
|
decrypt(std::move(data), std::move(P));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AdnlLocalId::decrypt_packet_done(td::IPAddress addr) {
|
||||||
|
auto it = inbound_rate_limiter_.find(addr);
|
||||||
|
CHECK(it != inbound_rate_limiter_.end());
|
||||||
|
--it->second.currently_decrypting_packets;
|
||||||
|
add_decrypted_packet_stats(addr);
|
||||||
|
}
|
||||||
|
|
||||||
void AdnlLocalId::deliver(AdnlNodeIdShort src, td::BufferSlice data) {
|
void AdnlLocalId::deliver(AdnlNodeIdShort src, td::BufferSlice data) {
|
||||||
auto s = std::move(data);
|
auto s = std::move(data);
|
||||||
for (auto &cb : cb_) {
|
for (auto &cb : cb_) {
|
||||||
|
|
@ -292,6 +306,72 @@ void AdnlLocalId::update_packet(AdnlPacket packet, bool update_id, bool sign, td
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AdnlLocalId::get_stats(bool all, td::Promise<tl_object_ptr<ton_api::adnl_stats_localId>> promise) {
|
||||||
|
auto stats = create_tl_object<ton_api::adnl_stats_localId>();
|
||||||
|
stats->short_id_ = short_id_.bits256_value();
|
||||||
|
for (auto &[ip, x] : inbound_rate_limiter_) {
|
||||||
|
if (x.currently_decrypting_packets != 0) {
|
||||||
|
stats->current_decrypt_.push_back(create_tl_object<ton_api::adnl_stats_ipPackets>(
|
||||||
|
ip.is_valid() ? PSTRING() << ip.get_ip_str() << ":" << ip.get_port() : "", x.currently_decrypting_packets));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
prepare_packet_stats();
|
||||||
|
stats->packets_recent_ = packet_stats_prev_.tl();
|
||||||
|
stats->packets_total_ = packet_stats_total_.tl(all);
|
||||||
|
stats->packets_total_->ts_start_ = (double)Adnl::adnl_start_time();
|
||||||
|
stats->packets_total_->ts_end_ = td::Clocks::system();
|
||||||
|
promise.set_result(std::move(stats));
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdnlLocalId::add_decrypted_packet_stats(td::IPAddress addr) {
|
||||||
|
prepare_packet_stats();
|
||||||
|
packet_stats_cur_.decrypted_packets[addr].inc();
|
||||||
|
packet_stats_total_.decrypted_packets[addr].inc();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdnlLocalId::add_dropped_packet_stats(td::IPAddress addr) {
|
||||||
|
prepare_packet_stats();
|
||||||
|
packet_stats_cur_.dropped_packets[addr].inc();
|
||||||
|
packet_stats_total_.dropped_packets[addr].inc();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdnlLocalId::prepare_packet_stats() {
|
||||||
|
double now = td::Clocks::system();
|
||||||
|
if (now >= packet_stats_cur_.ts_end) {
|
||||||
|
packet_stats_prev_ = std::move(packet_stats_cur_);
|
||||||
|
packet_stats_cur_ = {};
|
||||||
|
auto now_int = (int)td::Clocks::system();
|
||||||
|
packet_stats_cur_.ts_start = (double)(now_int / 60 * 60);
|
||||||
|
packet_stats_cur_.ts_end = packet_stats_cur_.ts_start + 60.0;
|
||||||
|
if (packet_stats_prev_.ts_end < now - 60.0) {
|
||||||
|
packet_stats_prev_ = {};
|
||||||
|
packet_stats_prev_.ts_end = packet_stats_cur_.ts_start;
|
||||||
|
packet_stats_prev_.ts_start = packet_stats_prev_.ts_end - 60.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tl_object_ptr<ton_api::adnl_stats_localIdPackets> AdnlLocalId::PacketStats::tl(bool all) const {
|
||||||
|
double threshold = all ? -1.0 : td::Clocks::system() - 600.0;
|
||||||
|
auto obj = create_tl_object<ton_api::adnl_stats_localIdPackets>();
|
||||||
|
obj->ts_start_ = ts_start;
|
||||||
|
obj->ts_end_ = ts_end;
|
||||||
|
for (const auto &[ip, packets] : decrypted_packets) {
|
||||||
|
if (packets.last_packet_ts >= threshold) {
|
||||||
|
obj->decrypted_packets_.push_back(create_tl_object<ton_api::adnl_stats_ipPackets>(
|
||||||
|
ip.is_valid() ? PSTRING() << ip.get_ip_str() << ":" << ip.get_port() : "", packets.packets));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const auto &[ip, packets] : dropped_packets) {
|
||||||
|
if (packets.last_packet_ts >= threshold) {
|
||||||
|
obj->dropped_packets_.push_back(create_tl_object<ton_api::adnl_stats_ipPackets>(
|
||||||
|
ip.is_valid() ? PSTRING() << ip.get_ip_str() << ":" << ip.get_port() : "", packets.packets));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace adnl
|
} // namespace adnl
|
||||||
|
|
||||||
} // namespace ton
|
} // namespace ton
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ class AdnlLocalId : public td::actor::Actor {
|
||||||
void deliver(AdnlNodeIdShort src, td::BufferSlice data);
|
void deliver(AdnlNodeIdShort src, td::BufferSlice data);
|
||||||
void deliver_query(AdnlNodeIdShort src, td::BufferSlice data, td::Promise<td::BufferSlice> promise);
|
void deliver_query(AdnlNodeIdShort src, td::BufferSlice data, td::Promise<td::BufferSlice> promise);
|
||||||
void receive(td::IPAddress addr, td::BufferSlice data);
|
void receive(td::IPAddress addr, td::BufferSlice data);
|
||||||
|
void decrypt_packet_done(td::IPAddress addr);
|
||||||
|
|
||||||
void subscribe(std::string prefix, std::unique_ptr<AdnlPeerTable::Callback> callback);
|
void subscribe(std::string prefix, std::unique_ptr<AdnlPeerTable::Callback> callback);
|
||||||
void unsubscribe(std::string prefix);
|
void unsubscribe(std::string prefix);
|
||||||
|
|
@ -77,6 +78,8 @@ class AdnlLocalId : public td::actor::Actor {
|
||||||
void update_packet(AdnlPacket packet, bool update_id, bool sign, td::int32 update_addr_list_if,
|
void update_packet(AdnlPacket packet, bool update_id, bool sign, td::int32 update_addr_list_if,
|
||||||
td::int32 update_priority_addr_list_if, td::Promise<AdnlPacket> promise);
|
td::int32 update_priority_addr_list_if, td::Promise<AdnlPacket> promise);
|
||||||
|
|
||||||
|
void get_stats(bool all, td::Promise<tl_object_ptr<ton_api::adnl_stats_localId>> promise);
|
||||||
|
|
||||||
td::uint32 get_mode() {
|
td::uint32 get_mode() {
|
||||||
return mode_;
|
return mode_;
|
||||||
}
|
}
|
||||||
|
|
@ -101,6 +104,32 @@ class AdnlLocalId : public td::actor::Actor {
|
||||||
|
|
||||||
td::uint32 mode_;
|
td::uint32 mode_;
|
||||||
|
|
||||||
|
struct InboundRateLimiter {
|
||||||
|
RateLimiter rate_limiter = RateLimiter(75, 0.33);
|
||||||
|
td::uint64 currently_decrypting_packets = 0;
|
||||||
|
};
|
||||||
|
std::map<td::IPAddress, InboundRateLimiter> inbound_rate_limiter_;
|
||||||
|
struct PacketStats {
|
||||||
|
double ts_start = 0.0, ts_end = 0.0;
|
||||||
|
|
||||||
|
struct Counter {
|
||||||
|
td::uint64 packets = 0;
|
||||||
|
double last_packet_ts = 0.0;
|
||||||
|
|
||||||
|
void inc() {
|
||||||
|
++packets;
|
||||||
|
last_packet_ts = td::Clocks::system();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
std::map<td::IPAddress, Counter> decrypted_packets;
|
||||||
|
std::map<td::IPAddress, Counter> dropped_packets;
|
||||||
|
|
||||||
|
tl_object_ptr<ton_api::adnl_stats_localIdPackets> tl(bool all = true) const;
|
||||||
|
} packet_stats_cur_, packet_stats_prev_, packet_stats_total_;
|
||||||
|
void add_decrypted_packet_stats(td::IPAddress addr);
|
||||||
|
void add_dropped_packet_stats(td::IPAddress addr);
|
||||||
|
void prepare_packet_stats();
|
||||||
|
|
||||||
void publish_address_list();
|
void publish_address_list();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ void AdnlPeerTableImpl::receive_packet(td::IPAddress addr, AdnlCategoryMask cat_
|
||||||
<< " (len=" << (data.size() + 32) << ")";
|
<< " (len=" << (data.size() + 32) << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdnlPeerTableImpl::receive_decrypted_packet(AdnlNodeIdShort dst, AdnlPacket packet) {
|
void AdnlPeerTableImpl::receive_decrypted_packet(AdnlNodeIdShort dst, AdnlPacket packet, td::uint64 serialized_size) {
|
||||||
packet.run_basic_checks().ensure();
|
packet.run_basic_checks().ensure();
|
||||||
|
|
||||||
if (!packet.inited_from_short()) {
|
if (!packet.inited_from_short()) {
|
||||||
|
|
@ -119,7 +119,7 @@ void AdnlPeerTableImpl::receive_decrypted_packet(AdnlNodeIdShort dst, AdnlPacket
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
td::actor::send_closure(it->second, &AdnlPeer::receive_packet, dst, it2->second.mode, it2->second.local_id.get(),
|
td::actor::send_closure(it->second, &AdnlPeer::receive_packet, dst, it2->second.mode, it2->second.local_id.get(),
|
||||||
std::move(packet));
|
std::move(packet), serialized_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdnlPeerTableImpl::add_peer(AdnlNodeIdShort local_id, AdnlNodeIdFull id, AdnlAddressList addr_list) {
|
void AdnlPeerTableImpl::add_peer(AdnlNodeIdShort local_id, AdnlNodeIdFull id, AdnlAddressList addr_list) {
|
||||||
|
|
@ -385,6 +385,88 @@ void AdnlPeerTableImpl::get_conn_ip_str(AdnlNodeIdShort l_id, AdnlNodeIdShort p_
|
||||||
td::actor::send_closure(it->second, &AdnlPeer::get_conn_ip_str, l_id, std::move(promise));
|
td::actor::send_closure(it->second, &AdnlPeer::get_conn_ip_str, l_id, std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AdnlPeerTableImpl::get_stats(bool all, td::Promise<tl_object_ptr<ton_api::adnl_stats>> promise) {
|
||||||
|
class Cb : public td::actor::Actor {
|
||||||
|
public:
|
||||||
|
explicit Cb(td::Promise<tl_object_ptr<ton_api::adnl_stats>> promise) : promise_(std::move(promise)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void got_local_id_stats(tl_object_ptr<ton_api::adnl_stats_localId> local_id) {
|
||||||
|
auto &local_id_stats = local_id_stats_[local_id->short_id_];
|
||||||
|
if (local_id_stats) {
|
||||||
|
local_id->peers_ = std::move(local_id_stats->peers_);
|
||||||
|
}
|
||||||
|
local_id_stats = std::move(local_id);
|
||||||
|
dec_pending();
|
||||||
|
}
|
||||||
|
|
||||||
|
void got_peer_stats(std::vector<tl_object_ptr<ton_api::adnl_stats_peerPair>> peer_pairs) {
|
||||||
|
for (auto &peer_pair : peer_pairs) {
|
||||||
|
auto &local_id_stats = local_id_stats_[peer_pair->local_id_];
|
||||||
|
if (local_id_stats == nullptr) {
|
||||||
|
local_id_stats = create_tl_object<ton_api::adnl_stats_localId>();
|
||||||
|
local_id_stats->short_id_ = peer_pair->local_id_;
|
||||||
|
}
|
||||||
|
local_id_stats->peers_.push_back(std::move(peer_pair));
|
||||||
|
}
|
||||||
|
dec_pending();
|
||||||
|
}
|
||||||
|
|
||||||
|
void inc_pending() {
|
||||||
|
++pending_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dec_pending() {
|
||||||
|
CHECK(pending_ > 0);
|
||||||
|
--pending_;
|
||||||
|
if (pending_ == 0) {
|
||||||
|
auto stats = create_tl_object<ton_api::adnl_stats>();
|
||||||
|
stats->timestamp_ = td::Clocks::system();
|
||||||
|
for (auto &[id, local_id_stats] : local_id_stats_) {
|
||||||
|
stats->local_ids_.push_back(std::move(local_id_stats));
|
||||||
|
}
|
||||||
|
promise_.set_result(std::move(stats));
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
td::Promise<tl_object_ptr<ton_api::adnl_stats>> promise_;
|
||||||
|
size_t pending_ = 1;
|
||||||
|
|
||||||
|
std::map<td::Bits256, tl_object_ptr<ton_api::adnl_stats_localId>> local_id_stats_;
|
||||||
|
};
|
||||||
|
auto callback = td::actor::create_actor<Cb>("adnlstats", std::move(promise)).release();
|
||||||
|
|
||||||
|
for (auto &[id, local_id] : local_ids_) {
|
||||||
|
td::actor::send_closure(callback, &Cb::inc_pending);
|
||||||
|
td::actor::send_closure(local_id.local_id, &AdnlLocalId::get_stats, all,
|
||||||
|
[id = id, callback](td::Result<tl_object_ptr<ton_api::adnl_stats_localId>> R) {
|
||||||
|
if (R.is_error()) {
|
||||||
|
VLOG(ADNL_NOTICE)
|
||||||
|
<< "failed to get stats for local id " << id << " : " << R.move_as_error();
|
||||||
|
td::actor::send_closure(callback, &Cb::dec_pending);
|
||||||
|
} else {
|
||||||
|
td::actor::send_closure(callback, &Cb::got_local_id_stats, R.move_as_ok());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
for (auto &[id, peer] : peers_) {
|
||||||
|
td::actor::send_closure(callback, &Cb::inc_pending);
|
||||||
|
td::actor::send_closure(
|
||||||
|
peer, &AdnlPeer::get_stats, all,
|
||||||
|
[id = id, callback](td::Result<std::vector<tl_object_ptr<ton_api::adnl_stats_peerPair>>> R) {
|
||||||
|
if (R.is_error()) {
|
||||||
|
VLOG(ADNL_NOTICE) << "failed to get stats for peer " << id << " : " << R.move_as_error();
|
||||||
|
td::actor::send_closure(callback, &Cb::dec_pending);
|
||||||
|
} else {
|
||||||
|
td::actor::send_closure(callback, &Cb::got_peer_stats, R.move_as_ok());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
td::actor::send_closure(callback, &Cb::dec_pending);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace adnl
|
} // namespace adnl
|
||||||
|
|
||||||
} // namespace ton
|
} // namespace ton
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ class AdnlPeerTable : public Adnl {
|
||||||
virtual void answer_query(AdnlNodeIdShort src, AdnlNodeIdShort dst, AdnlQueryId query_id, td::BufferSlice data) = 0;
|
virtual void answer_query(AdnlNodeIdShort src, AdnlNodeIdShort dst, AdnlQueryId query_id, td::BufferSlice data) = 0;
|
||||||
|
|
||||||
virtual void receive_packet(td::IPAddress addr, AdnlCategoryMask cat_mask, td::BufferSlice data) = 0;
|
virtual void receive_packet(td::IPAddress addr, AdnlCategoryMask cat_mask, td::BufferSlice data) = 0;
|
||||||
virtual void receive_decrypted_packet(AdnlNodeIdShort dst, AdnlPacket packet) = 0;
|
virtual void receive_decrypted_packet(AdnlNodeIdShort dst, AdnlPacket packet, td::uint64 serialized_size) = 0;
|
||||||
virtual void send_message_in(AdnlNodeIdShort src, AdnlNodeIdShort dst, AdnlMessage message, td::uint32 flags) = 0;
|
virtual void send_message_in(AdnlNodeIdShort src, AdnlNodeIdShort dst, AdnlMessage message, td::uint32 flags) = 0;
|
||||||
|
|
||||||
virtual void register_channel(AdnlChannelIdShort id, AdnlNodeIdShort local_id,
|
virtual void register_channel(AdnlChannelIdShort id, AdnlNodeIdShort local_id,
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class AdnlPeerTableImpl : public AdnlPeerTable {
|
||||||
void add_static_nodes_from_config(AdnlNodesList nodes) override;
|
void add_static_nodes_from_config(AdnlNodesList nodes) override;
|
||||||
|
|
||||||
void receive_packet(td::IPAddress addr, AdnlCategoryMask cat_mask, td::BufferSlice data) override;
|
void receive_packet(td::IPAddress addr, AdnlCategoryMask cat_mask, td::BufferSlice data) override;
|
||||||
void receive_decrypted_packet(AdnlNodeIdShort dst, AdnlPacket data) override;
|
void receive_decrypted_packet(AdnlNodeIdShort dst, AdnlPacket data, td::uint64 serialized_size) override;
|
||||||
void send_message_in(AdnlNodeIdShort src, AdnlNodeIdShort dst, AdnlMessage message, td::uint32 flags) override;
|
void send_message_in(AdnlNodeIdShort src, AdnlNodeIdShort dst, AdnlMessage message, td::uint32 flags) override;
|
||||||
void send_message(AdnlNodeIdShort src, AdnlNodeIdShort dst, td::BufferSlice data) override {
|
void send_message(AdnlNodeIdShort src, AdnlNodeIdShort dst, td::BufferSlice data) override {
|
||||||
send_message_ex(src, dst, std::move(data), 0);
|
send_message_ex(src, dst, std::move(data), 0);
|
||||||
|
|
@ -77,6 +77,10 @@ class AdnlPeerTableImpl : public AdnlPeerTable {
|
||||||
td::actor::ActorId<AdnlChannel> channel) override;
|
td::actor::ActorId<AdnlChannel> channel) override;
|
||||||
void unregister_channel(AdnlChannelIdShort id) override;
|
void unregister_channel(AdnlChannelIdShort id) override;
|
||||||
|
|
||||||
|
void check_id_exists(AdnlNodeIdShort id, td::Promise<bool> promise) override {
|
||||||
|
promise.set_value(local_ids_.count(id));
|
||||||
|
}
|
||||||
|
|
||||||
void write_new_addr_list_to_db(AdnlNodeIdShort local_id, AdnlNodeIdShort peer_id, AdnlDbItem node,
|
void write_new_addr_list_to_db(AdnlNodeIdShort local_id, AdnlNodeIdShort peer_id, AdnlDbItem node,
|
||||||
td::Promise<td::Unit> promise) override;
|
td::Promise<td::Unit> promise) override;
|
||||||
void get_addr_list_from_db(AdnlNodeIdShort local_id, AdnlNodeIdShort peer_id,
|
void get_addr_list_from_db(AdnlNodeIdShort local_id, AdnlNodeIdShort peer_id,
|
||||||
|
|
@ -104,6 +108,8 @@ class AdnlPeerTableImpl : public AdnlPeerTable {
|
||||||
td::Promise<std::pair<td::actor::ActorOwn<AdnlTunnel>, AdnlAddress>> promise) override;
|
td::Promise<std::pair<td::actor::ActorOwn<AdnlTunnel>, AdnlAddress>> promise) override;
|
||||||
void get_conn_ip_str(AdnlNodeIdShort l_id, AdnlNodeIdShort p_id, td::Promise<td::string> promise) override;
|
void get_conn_ip_str(AdnlNodeIdShort l_id, AdnlNodeIdShort p_id, td::Promise<td::string> promise) override;
|
||||||
|
|
||||||
|
void get_stats(bool all, td::Promise<tl_object_ptr<ton_api::adnl_stats>> promise) override;
|
||||||
|
|
||||||
struct PrintId {};
|
struct PrintId {};
|
||||||
PrintId print_id() const {
|
PrintId print_id() const {
|
||||||
return PrintId{};
|
return PrintId{};
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include "td/utils/base64.h"
|
#include "td/utils/base64.h"
|
||||||
#include "td/utils/Random.h"
|
#include "td/utils/Random.h"
|
||||||
#include "auto/tl/ton_api.h"
|
#include "auto/tl/ton_api.h"
|
||||||
|
#include "td/utils/overloaded.h"
|
||||||
|
|
||||||
namespace ton {
|
namespace ton {
|
||||||
|
|
||||||
|
|
@ -50,9 +51,13 @@ void AdnlPeerPairImpl::start_up() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdnlPeerPairImpl::alarm() {
|
void AdnlPeerPairImpl::alarm() {
|
||||||
if (next_dht_query_at_ && next_dht_query_at_.is_in_past()) {
|
if (!disable_dht_query_) {
|
||||||
next_dht_query_at_ = td::Timestamp::never();
|
disable_dht_query_ = true;
|
||||||
discover();
|
if (next_dht_query_at_ && next_dht_query_at_.is_in_past()) {
|
||||||
|
next_dht_query_at_ = td::Timestamp::never();
|
||||||
|
discover();
|
||||||
|
}
|
||||||
|
alarm_timestamp().relax(next_dht_query_at_);
|
||||||
}
|
}
|
||||||
if (next_db_update_at_ && next_db_update_at_.is_in_past()) {
|
if (next_db_update_at_ && next_db_update_at_.is_in_past()) {
|
||||||
if (received_from_db_ && received_from_static_nodes_ && !peer_id_.empty()) {
|
if (received_from_db_ && received_from_static_nodes_ && !peer_id_.empty()) {
|
||||||
|
|
@ -68,11 +73,8 @@ void AdnlPeerPairImpl::alarm() {
|
||||||
}
|
}
|
||||||
if (retry_send_at_ && retry_send_at_.is_in_past()) {
|
if (retry_send_at_ && retry_send_at_.is_in_past()) {
|
||||||
retry_send_at_ = td::Timestamp::never();
|
retry_send_at_ = td::Timestamp::never();
|
||||||
auto messages = std::move(pending_messages_);
|
send_messages_from_queue();
|
||||||
pending_messages_.clear();
|
|
||||||
send_messages_in(std::move(messages), false);
|
|
||||||
}
|
}
|
||||||
alarm_timestamp().relax(next_dht_query_at_);
|
|
||||||
alarm_timestamp().relax(next_db_update_at_);
|
alarm_timestamp().relax(next_db_update_at_);
|
||||||
alarm_timestamp().relax(retry_send_at_);
|
alarm_timestamp().relax(retry_send_at_);
|
||||||
}
|
}
|
||||||
|
|
@ -117,6 +119,7 @@ void AdnlPeerPairImpl::discover() {
|
||||||
void AdnlPeerPairImpl::receive_packet_checked(AdnlPacket packet) {
|
void AdnlPeerPairImpl::receive_packet_checked(AdnlPacket packet) {
|
||||||
last_received_packet_ = td::Timestamp::now();
|
last_received_packet_ = td::Timestamp::now();
|
||||||
try_reinit_at_ = td::Timestamp::never();
|
try_reinit_at_ = td::Timestamp::never();
|
||||||
|
drop_addr_list_at_ = td::Timestamp::never();
|
||||||
request_reverse_ping_after_ = td::Timestamp::in(15.0);
|
request_reverse_ping_after_ = td::Timestamp::in(15.0);
|
||||||
auto d = Adnl::adnl_start_time();
|
auto d = Adnl::adnl_start_time();
|
||||||
if (packet.dst_reinit_date() > d) {
|
if (packet.dst_reinit_date() > d) {
|
||||||
|
|
@ -207,16 +210,24 @@ void AdnlPeerPairImpl::receive_packet_checked(AdnlPacket packet) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdnlPeerPairImpl::receive_packet_from_channel(AdnlChannelIdShort id, AdnlPacket packet) {
|
void AdnlPeerPairImpl::receive_packet_from_channel(AdnlChannelIdShort id, AdnlPacket packet,
|
||||||
|
td::uint64 serialized_size) {
|
||||||
|
add_packet_stats(serialized_size, /* in = */ true, /* channel = */ true);
|
||||||
if (id != channel_in_id_) {
|
if (id != channel_in_id_) {
|
||||||
VLOG(ADNL_NOTICE) << this << ": dropping IN message: outdated channel id" << id;
|
VLOG(ADNL_NOTICE) << this << ": dropping IN message: outdated channel id" << id;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
channel_ready_ = true;
|
if (channel_inited_ && !channel_ready_) {
|
||||||
|
channel_ready_ = true;
|
||||||
|
if (!out_messages_queue_.empty()) {
|
||||||
|
td::actor::send_closure(actor_id(this), &AdnlPeerPairImpl::send_messages_from_queue);
|
||||||
|
}
|
||||||
|
}
|
||||||
receive_packet_checked(std::move(packet));
|
receive_packet_checked(std::move(packet));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdnlPeerPairImpl::receive_packet(AdnlPacket packet) {
|
void AdnlPeerPairImpl::receive_packet(AdnlPacket packet, td::uint64 serialized_size) {
|
||||||
|
add_packet_stats(serialized_size, /* in = */ true, /* channel = */ false);
|
||||||
packet.run_basic_checks().ensure();
|
packet.run_basic_checks().ensure();
|
||||||
|
|
||||||
if (!encryptor_) {
|
if (!encryptor_) {
|
||||||
|
|
@ -237,128 +248,132 @@ void AdnlPeerPairImpl::deliver_message(AdnlMessage message) {
|
||||||
message.visit([&](const auto &obj) { this->process_message(obj); });
|
message.visit([&](const auto &obj) { this->process_message(obj); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdnlPeerPairImpl::send_messages_in(std::vector<OutboundAdnlMessage> messages, bool allow_postpone) {
|
void AdnlPeerPairImpl::send_messages_from_queue() {
|
||||||
for (td::int32 idx = 0; idx < 2; idx++) {
|
while (!out_messages_queue_.empty() && out_messages_queue_.front().second.is_in_past()) {
|
||||||
std::vector<OutboundAdnlMessage> not_sent;
|
out_messages_queue_total_size_ -= out_messages_queue_.front().first.size();
|
||||||
|
add_expired_msg_stats(out_messages_queue_.front().first.size());
|
||||||
|
out_messages_queue_.pop();
|
||||||
|
VLOG(ADNL_NOTICE) << this << ": dropping OUT message: message in queue expired";
|
||||||
|
}
|
||||||
|
if (out_messages_queue_.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto connR = get_conn(idx == 1);
|
auto connR = get_conn();
|
||||||
if (connR.is_error()) {
|
if (connR.is_error()) {
|
||||||
if (!allow_postpone) {
|
disable_dht_query_ = false;
|
||||||
VLOG(ADNL_NOTICE) << this << ": dropping OUT messages: cannot get conn: " << connR.move_as_error();
|
retry_send_at_.relax(td::Timestamp::in(message_in_queue_ttl_ - 1.0));
|
||||||
return;
|
alarm_timestamp().relax(retry_send_at_);
|
||||||
}
|
VLOG(ADNL_INFO) << this << ": delaying OUT messages: cannot get conn: " << connR.move_as_error();
|
||||||
VLOG(ADNL_INFO) << this << ": delaying OUT messages: cannot get conn: " << connR.move_as_error();
|
return;
|
||||||
if (!retry_send_at_) {
|
}
|
||||||
retry_send_at_.relax(td::Timestamp::in(10.0));
|
disable_dht_query_ = true;
|
||||||
alarm_timestamp().relax(retry_send_at_);
|
auto C = connR.move_as_ok();
|
||||||
}
|
auto conn = std::move(C.first);
|
||||||
for (auto &m : messages) {
|
bool is_direct = C.second;
|
||||||
pending_messages_.push_back(std::move(m));
|
|
||||||
}
|
bool first = !skip_init_packet_;
|
||||||
|
while (!out_messages_queue_.empty()) {
|
||||||
|
bool try_reinit = try_reinit_at_ && try_reinit_at_.is_in_past();
|
||||||
|
bool via_channel = channel_ready_ && !try_reinit;
|
||||||
|
if (!via_channel && !nochannel_rate_limiter_.take()) {
|
||||||
|
alarm_timestamp().relax(retry_send_at_ = nochannel_rate_limiter_.ready_at());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto C = connR.move_as_ok();
|
if (try_reinit) {
|
||||||
bool is_direct = C.second;
|
try_reinit_at_ = td::Timestamp::in(td::Random::fast(0.5, 1.5));
|
||||||
auto conn = std::move(C.first);
|
}
|
||||||
if (idx == 1) {
|
respond_with_nop_after_ = td::Timestamp::in(td::Random::fast(1.0, 2.0));
|
||||||
CHECK(is_direct);
|
|
||||||
|
size_t s = (via_channel ? channel_packet_header_max_size() : packet_header_max_size());
|
||||||
|
if (first) {
|
||||||
|
s += 2 * addr_list_max_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ptr = 0;
|
AdnlPacket packet;
|
||||||
bool first = true;
|
packet.set_seqno(++out_seqno_);
|
||||||
do {
|
packet.set_confirm_seqno(in_seqno_);
|
||||||
bool try_reinit = try_reinit_at_ && try_reinit_at_.is_in_past();
|
|
||||||
bool via_channel = channel_ready_ && !try_reinit;
|
|
||||||
size_t s = (via_channel ? channel_packet_header_max_size() : packet_header_max_size());
|
|
||||||
if (first) {
|
|
||||||
s += 2 * addr_list_max_size();
|
|
||||||
}
|
|
||||||
|
|
||||||
AdnlPacket packet;
|
if (first) {
|
||||||
packet.set_seqno(++out_seqno_);
|
if (!channel_inited_) {
|
||||||
packet.set_confirm_seqno(in_seqno_);
|
auto M = adnlmessage::AdnlMessageCreateChannel{channel_pub_, channel_pk_date_};
|
||||||
|
s += M.size();
|
||||||
if (first) {
|
packet.add_message(std::move(M));
|
||||||
if (!channel_inited_) {
|
} else if (!channel_ready_) {
|
||||||
auto M = adnlmessage::AdnlMessageCreateChannel{channel_pub_, channel_pk_date_};
|
auto M = adnlmessage::AdnlMessageConfirmChannel{channel_pub_, peer_channel_pub_, channel_pk_date_};
|
||||||
s += M.size();
|
s += M.size();
|
||||||
packet.add_message(std::move(M));
|
packet.add_message(std::move(M));
|
||||||
} else if (!channel_ready_) {
|
|
||||||
auto M = adnlmessage::AdnlMessageConfirmChannel{channel_pub_, peer_channel_pub_, channel_pk_date_};
|
|
||||||
s += M.size();
|
|
||||||
packet.add_message(std::move(M));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!addr_list_.empty()) {
|
if (!addr_list_.empty()) {
|
||||||
packet.set_received_addr_list_version(addr_list_.version());
|
packet.set_received_addr_list_version(addr_list_.version());
|
||||||
}
|
}
|
||||||
if (!priority_addr_list_.empty()) {
|
if (!priority_addr_list_.empty()) {
|
||||||
packet.set_received_priority_addr_list_version(priority_addr_list_.version());
|
packet.set_received_priority_addr_list_version(priority_addr_list_.version());
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ptr < messages.size()) {
|
skip_init_packet_ = true;
|
||||||
auto &M = messages[ptr];
|
while (!out_messages_queue_.empty()) {
|
||||||
if (!is_direct && (M.flags() & Adnl::SendFlags::direct_only)) {
|
auto &M = out_messages_queue_.front().first;
|
||||||
not_sent.push_back(std::move(M));
|
if (!is_direct && (M.flags() & Adnl::SendFlags::direct_only)) {
|
||||||
continue;
|
out_messages_queue_total_size_ -= M.size();
|
||||||
}
|
out_messages_queue_.pop();
|
||||||
CHECK(M.size() <= get_mtu());
|
continue;
|
||||||
|
}
|
||||||
|
CHECK(M.size() <= get_mtu());
|
||||||
|
if (s + M.size() <= AdnlNetworkManager::get_mtu()) {
|
||||||
|
s += M.size();
|
||||||
|
out_messages_queue_total_size_ -= M.size();
|
||||||
|
packet.add_message(M.release());
|
||||||
|
out_messages_queue_.pop();
|
||||||
|
skip_init_packet_ = false;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!via_channel) {
|
||||||
|
packet.set_reinit_date(Adnl::adnl_start_time(), reinit_date_);
|
||||||
|
packet.set_source(local_id_);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!first) {
|
||||||
|
if (!channel_inited_) {
|
||||||
|
auto M = adnlmessage::AdnlMessageCreateChannel{channel_pub_, channel_pk_date_};
|
||||||
if (s + M.size() <= AdnlNetworkManager::get_mtu()) {
|
if (s + M.size() <= AdnlNetworkManager::get_mtu()) {
|
||||||
s += M.size();
|
s += M.size();
|
||||||
packet.add_message(M.release());
|
packet.add_message(std::move(M));
|
||||||
ptr++;
|
}
|
||||||
} else {
|
} else if (!channel_ready_) {
|
||||||
break;
|
auto M = adnlmessage::AdnlMessageConfirmChannel{channel_pub_, peer_channel_pub_, channel_pk_date_};
|
||||||
|
if (s + M.size() <= AdnlNetworkManager::get_mtu()) {
|
||||||
|
s += M.size();
|
||||||
|
packet.add_message(std::move(M));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!via_channel) {
|
|
||||||
packet.set_reinit_date(Adnl::adnl_start_time(), reinit_date_);
|
|
||||||
packet.set_source(local_id_);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!first) {
|
|
||||||
if (!channel_inited_) {
|
|
||||||
auto M = adnlmessage::AdnlMessageCreateChannel{channel_pub_, channel_pk_date_};
|
|
||||||
if (s + M.size() <= AdnlNetworkManager::get_mtu()) {
|
|
||||||
s += M.size();
|
|
||||||
packet.add_message(std::move(M));
|
|
||||||
}
|
|
||||||
} else if (!channel_ready_) {
|
|
||||||
auto M = adnlmessage::AdnlMessageConfirmChannel{channel_pub_, peer_channel_pub_, channel_pk_date_};
|
|
||||||
if (s + M.size() <= AdnlNetworkManager::get_mtu()) {
|
|
||||||
s += M.size();
|
|
||||||
packet.add_message(std::move(M));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
packet.run_basic_checks().ensure();
|
|
||||||
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this), conn, id = print_id(),
|
|
||||||
via_channel](td::Result<AdnlPacket> res) {
|
|
||||||
if (res.is_error()) {
|
|
||||||
LOG(ERROR) << id << ": dropping OUT message: error while creating packet: " << res.move_as_error();
|
|
||||||
} else {
|
|
||||||
td::actor::send_closure(SelfId, &AdnlPeerPairImpl::send_packet_continue, res.move_as_ok(), conn, via_channel);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
td::actor::send_closure(local_actor_, &AdnlLocalId::update_packet, std::move(packet),
|
|
||||||
(!channel_ready_ && ack_seqno_ == 0 && in_seqno_ == 0) || try_reinit, !via_channel,
|
|
||||||
(first || s + addr_list_max_size() <= AdnlNetworkManager::get_mtu())
|
|
||||||
? (try_reinit ? 0 : peer_recv_addr_list_version_)
|
|
||||||
: 0x7fffffff,
|
|
||||||
(first || s + 2 * addr_list_max_size() <= AdnlNetworkManager::get_mtu())
|
|
||||||
? peer_recv_priority_addr_list_version_
|
|
||||||
: 0x7fffffff,
|
|
||||||
std::move(P));
|
|
||||||
first = false;
|
|
||||||
} while (ptr < messages.size());
|
|
||||||
messages = std::move(not_sent);
|
|
||||||
if (!messages.size()) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
packet.run_basic_checks().ensure();
|
||||||
|
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this), conn, id = print_id(),
|
||||||
|
via_channel](td::Result<AdnlPacket> res) {
|
||||||
|
if (res.is_error()) {
|
||||||
|
LOG(ERROR) << id << ": dropping OUT message: error while creating packet: " << res.move_as_error();
|
||||||
|
} else {
|
||||||
|
td::actor::send_closure(SelfId, &AdnlPeerPairImpl::send_packet_continue, res.move_as_ok(), conn, via_channel);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
td::actor::send_closure(local_actor_, &AdnlLocalId::update_packet, std::move(packet),
|
||||||
|
(!channel_ready_ && ack_seqno_ == 0 && in_seqno_ == 0) || try_reinit, !via_channel,
|
||||||
|
(first || s + addr_list_max_size() <= AdnlNetworkManager::get_mtu())
|
||||||
|
? (try_reinit ? 0 : peer_recv_addr_list_version_)
|
||||||
|
: 0x7fffffff,
|
||||||
|
(first || s + 2 * addr_list_max_size() <= AdnlNetworkManager::get_mtu())
|
||||||
|
? peer_recv_priority_addr_list_version_
|
||||||
|
: 0x7fffffff,
|
||||||
|
std::move(P));
|
||||||
|
first = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -389,7 +404,11 @@ void AdnlPeerPairImpl::send_messages(std::vector<OutboundAdnlMessage> messages)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
send_messages_in(std::move(new_vec), true);
|
for (auto &m : new_vec) {
|
||||||
|
out_messages_queue_total_size_ += m.size();
|
||||||
|
out_messages_queue_.emplace(std::move(m), td::Timestamp::in(message_in_queue_ttl_));
|
||||||
|
}
|
||||||
|
send_messages_from_queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdnlPeerPairImpl::send_packet_continue(AdnlPacket packet, td::actor::ActorId<AdnlNetworkConnection> conn,
|
void AdnlPeerPairImpl::send_packet_continue(AdnlPacket packet, td::actor::ActorId<AdnlNetworkConnection> conn,
|
||||||
|
|
@ -397,10 +416,14 @@ void AdnlPeerPairImpl::send_packet_continue(AdnlPacket packet, td::actor::ActorI
|
||||||
if (!try_reinit_at_ && last_received_packet_ < td::Timestamp::in(-5.0)) {
|
if (!try_reinit_at_ && last_received_packet_ < td::Timestamp::in(-5.0)) {
|
||||||
try_reinit_at_ = td::Timestamp::in(10.0);
|
try_reinit_at_ = td::Timestamp::in(10.0);
|
||||||
}
|
}
|
||||||
|
if (!drop_addr_list_at_ && last_received_packet_ < td::Timestamp::in(-60.0 * 9.0)) {
|
||||||
|
drop_addr_list_at_ = td::Timestamp::in(60.0);
|
||||||
|
}
|
||||||
packet.run_basic_checks().ensure();
|
packet.run_basic_checks().ensure();
|
||||||
auto B = serialize_tl_object(packet.tl(), true);
|
auto B = serialize_tl_object(packet.tl(), true);
|
||||||
if (via_channel) {
|
if (via_channel) {
|
||||||
if (channel_ready_) {
|
if (channel_ready_) {
|
||||||
|
add_packet_stats(B.size(), /* in = */ false, /* channel = */ true);
|
||||||
td::actor::send_closure(channel_, &AdnlChannel::send_message, priority_, conn, std::move(B));
|
td::actor::send_closure(channel_, &AdnlChannel::send_message, priority_, conn, std::move(B));
|
||||||
} else {
|
} else {
|
||||||
VLOG(ADNL_WARNING) << this << ": dropping OUT message [" << local_id_ << "->" << peer_id_short_
|
VLOG(ADNL_WARNING) << this << ": dropping OUT message [" << local_id_ << "->" << peer_id_short_
|
||||||
|
|
@ -428,6 +451,7 @@ void AdnlPeerPairImpl::send_packet_continue(AdnlPacket packet, td::actor::ActorI
|
||||||
S.remove_prefix(32);
|
S.remove_prefix(32);
|
||||||
S.copy_from(X.as_slice());
|
S.copy_from(X.as_slice());
|
||||||
|
|
||||||
|
add_packet_stats(B.size(), /* in = */ false, /* channel = */ false);
|
||||||
td::actor::send_closure(conn, &AdnlNetworkConnection::send, local_id_, peer_id_short_, priority_, std::move(enc));
|
td::actor::send_closure(conn, &AdnlNetworkConnection::send, local_id_, peer_id_short_, priority_, std::move(enc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -514,10 +538,14 @@ void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageConfirmChan
|
||||||
VLOG(ADNL_NOTICE) << this << ": received adnl.message.confirmChannel with old key";
|
VLOG(ADNL_NOTICE) << this << ": received adnl.message.confirmChannel with old key";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
channel_ready_ = true;
|
if (!channel_ready_) {
|
||||||
|
channel_ready_ = true;
|
||||||
|
send_messages_from_queue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageCustom &message) {
|
void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageCustom &message) {
|
||||||
|
respond_with_nop();
|
||||||
td::actor::send_closure(local_actor_, &AdnlLocalId::deliver, peer_id_short_, message.data());
|
td::actor::send_closure(local_actor_, &AdnlLocalId::deliver, peer_id_short_, message.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -530,6 +558,7 @@ void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageReinit &mes
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageQuery &message) {
|
void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageQuery &message) {
|
||||||
|
respond_with_nop();
|
||||||
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this), query_id = message.query_id(),
|
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this), query_id = message.query_id(),
|
||||||
flags = static_cast<td::uint32>(0)](td::Result<td::BufferSlice> R) {
|
flags = static_cast<td::uint32>(0)](td::Result<td::BufferSlice> R) {
|
||||||
if (R.is_error()) {
|
if (R.is_error()) {
|
||||||
|
|
@ -548,6 +577,7 @@ void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageQuery &mess
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageAnswer &message) {
|
void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageAnswer &message) {
|
||||||
|
respond_with_nop();
|
||||||
auto Q = out_queries_.find(message.query_id());
|
auto Q = out_queries_.find(message.query_id());
|
||||||
|
|
||||||
if (Q == out_queries_.end()) {
|
if (Q == out_queries_.end()) {
|
||||||
|
|
@ -565,6 +595,7 @@ void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageAnswer &mes
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessagePart &message) {
|
void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessagePart &message) {
|
||||||
|
respond_with_nop();
|
||||||
auto size = message.total_size();
|
auto size = message.total_size();
|
||||||
if (size > huge_packet_max_size()) {
|
if (size > huge_packet_max_size()) {
|
||||||
VLOG(ADNL_WARNING) << this << ": dropping too big huge message: size=" << size;
|
VLOG(ADNL_WARNING) << this << ": dropping too big huge message: size=" << size;
|
||||||
|
|
@ -627,6 +658,14 @@ void AdnlPeerPairImpl::delete_query(AdnlQueryId id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AdnlPeerPairImpl::respond_with_nop() {
|
||||||
|
if (respond_with_nop_after_.is_in_past()) {
|
||||||
|
std::vector<OutboundAdnlMessage> messages;
|
||||||
|
messages.emplace_back(adnlmessage::AdnlMessageNop{}, 0);
|
||||||
|
send_messages(std::move(messages));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AdnlPeerPairImpl::reinit(td::int32 date) {
|
void AdnlPeerPairImpl::reinit(td::int32 date) {
|
||||||
if (reinit_date_ == 0) {
|
if (reinit_date_ == 0) {
|
||||||
reinit_date_ = date;
|
reinit_date_ = date;
|
||||||
|
|
@ -656,7 +695,17 @@ void AdnlPeerPairImpl::reinit(td::int32 date) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
td::Result<std::pair<td::actor::ActorId<AdnlNetworkConnection>, bool>> AdnlPeerPairImpl::get_conn(bool direct_only) {
|
td::Result<std::pair<td::actor::ActorId<AdnlNetworkConnection>, bool>> AdnlPeerPairImpl::get_conn() {
|
||||||
|
if (drop_addr_list_at_ && drop_addr_list_at_.is_in_past()) {
|
||||||
|
drop_addr_list_at_ = td::Timestamp::never();
|
||||||
|
priority_addr_list_ = AdnlAddressList{};
|
||||||
|
priority_conns_.clear();
|
||||||
|
addr_list_ = AdnlAddressList{};
|
||||||
|
conns_.clear();
|
||||||
|
has_reverse_addr_ = false;
|
||||||
|
return td::Status::Error(ErrorCode::notready, "no active connections");
|
||||||
|
}
|
||||||
|
|
||||||
if (!priority_addr_list_.empty() && priority_addr_list_.expire_at() < td::Clocks::system()) {
|
if (!priority_addr_list_.empty() && priority_addr_list_.expire_at() < td::Clocks::system()) {
|
||||||
priority_addr_list_ = AdnlAddressList{};
|
priority_addr_list_ = AdnlAddressList{};
|
||||||
priority_conns_.clear();
|
priority_conns_.clear();
|
||||||
|
|
@ -674,14 +723,18 @@ td::Result<std::pair<td::actor::ActorId<AdnlNetworkConnection>, bool>> AdnlPeerP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &conn : priority_conns_) {
|
for (int direct_only = 1; direct_only >= 0; --direct_only) {
|
||||||
if (conn.ready() && (!direct_only || conn.is_direct())) {
|
for (auto &conn : priority_conns_) {
|
||||||
return std::make_pair(conn.conn.get(), conn.is_direct());
|
if (conn.ready() && (!direct_only || conn.is_direct())) {
|
||||||
|
return std::make_pair(conn.conn.get(), conn.is_direct());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto &conn : conns_) {
|
for (int direct_only = 1; direct_only >= 0; --direct_only) {
|
||||||
if (conn.ready() && (!direct_only || conn.is_direct())) {
|
for (auto &conn : conns_) {
|
||||||
return std::make_pair(conn.conn.get(), conn.is_direct());
|
if (conn.ready() && (!direct_only || conn.is_direct())) {
|
||||||
|
return std::make_pair(conn.conn.get(), conn.is_direct());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return td::Status::Error(ErrorCode::notready, "no active connections");
|
return td::Status::Error(ErrorCode::notready, "no active connections");
|
||||||
|
|
@ -769,6 +822,55 @@ void AdnlPeerPairImpl::get_conn_ip_str(td::Promise<td::string> promise) {
|
||||||
promise.set_value("undefined");
|
promise.set_value("undefined");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AdnlPeerPairImpl::get_stats(bool all, td::Promise<tl_object_ptr<ton_api::adnl_stats_peerPair>> promise) {
|
||||||
|
if (!all) {
|
||||||
|
double threshold = td::Clocks::system() - 600.0;
|
||||||
|
if (last_in_packet_ts_ < threshold && last_out_packet_ts_ < threshold) {
|
||||||
|
promise.set_value(nullptr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto stats = create_tl_object<ton_api::adnl_stats_peerPair>();
|
||||||
|
stats->local_id_ = local_id_.bits256_value();
|
||||||
|
stats->peer_id_ = peer_id_short_.bits256_value();
|
||||||
|
for (const AdnlAddress &addr : addr_list_.addrs()) {
|
||||||
|
ton_api::downcast_call(*addr->tl(), td::overloaded(
|
||||||
|
[&](const ton_api::adnl_address_udp &obj) {
|
||||||
|
stats->ip_str_ = PSTRING() << td::IPAddress::ipv4_to_str(obj.ip_) << ":"
|
||||||
|
<< obj.port_;
|
||||||
|
},
|
||||||
|
[&](const auto &) {}));
|
||||||
|
if (!stats->ip_str_.empty()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
prepare_packet_stats();
|
||||||
|
stats->last_in_packet_ts_ = last_in_packet_ts_;
|
||||||
|
stats->last_out_packet_ts_ = last_out_packet_ts_;
|
||||||
|
stats->packets_total_ = packet_stats_total_.tl();
|
||||||
|
stats->packets_total_->ts_start_ = started_ts_;
|
||||||
|
stats->packets_total_->ts_end_ = td::Clocks::system();
|
||||||
|
stats->packets_recent_ = packet_stats_prev_.tl();
|
||||||
|
|
||||||
|
if (channel_ready_) {
|
||||||
|
stats->channel_status_ = 2;
|
||||||
|
} else if (channel_inited_) {
|
||||||
|
stats->channel_status_ = 1;
|
||||||
|
} else {
|
||||||
|
stats->channel_status_ = 0;
|
||||||
|
}
|
||||||
|
stats->try_reinit_at_ = (try_reinit_at_ ? try_reinit_at_.at_unix() : 0.0);
|
||||||
|
stats->connection_ready_ =
|
||||||
|
std::any_of(conns_.begin(), conns_.end(), [](const Conn &conn) { return conn.ready(); }) ||
|
||||||
|
std::any_of(priority_conns_.begin(), priority_conns_.end(), [](const Conn &conn) { return conn.ready(); });
|
||||||
|
stats->out_queue_messages_ = out_messages_queue_.size();
|
||||||
|
stats->out_queue_bytes_ = out_messages_queue_total_size_;
|
||||||
|
|
||||||
|
promise.set_result(std::move(stats));
|
||||||
|
}
|
||||||
|
|
||||||
void AdnlPeerImpl::update_id(AdnlNodeIdFull id) {
|
void AdnlPeerImpl::update_id(AdnlNodeIdFull id) {
|
||||||
CHECK(id.compute_short_id() == peer_id_short_);
|
CHECK(id.compute_short_id() == peer_id_short_);
|
||||||
if (!peer_id_.empty()) {
|
if (!peer_id_.empty()) {
|
||||||
|
|
@ -792,10 +894,8 @@ void AdnlPeerPairImpl::Conn::create_conn(td::actor::ActorId<AdnlPeerPairImpl> pe
|
||||||
|
|
||||||
void AdnlPeerPairImpl::conn_change_state(AdnlConnectionIdShort id, bool ready) {
|
void AdnlPeerPairImpl::conn_change_state(AdnlConnectionIdShort id, bool ready) {
|
||||||
if (ready) {
|
if (ready) {
|
||||||
if (pending_messages_.size() > 0) {
|
if (out_messages_queue_.empty()) {
|
||||||
auto messages = std::move(pending_messages_);
|
send_messages_from_queue();
|
||||||
pending_messages_.clear();
|
|
||||||
send_messages_in(std::move(messages), true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -817,7 +917,7 @@ td::actor::ActorOwn<AdnlPeer> AdnlPeer::create(td::actor::ActorId<AdnlNetworkMan
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdnlPeerImpl::receive_packet(AdnlNodeIdShort dst, td::uint32 dst_mode, td::actor::ActorId<AdnlLocalId> dst_actor,
|
void AdnlPeerImpl::receive_packet(AdnlNodeIdShort dst, td::uint32 dst_mode, td::actor::ActorId<AdnlLocalId> dst_actor,
|
||||||
AdnlPacket packet) {
|
AdnlPacket packet, td::uint64 serialized_size) {
|
||||||
if (packet.inited_from()) {
|
if (packet.inited_from()) {
|
||||||
update_id(packet.from());
|
update_id(packet.from());
|
||||||
}
|
}
|
||||||
|
|
@ -835,7 +935,7 @@ void AdnlPeerImpl::receive_packet(AdnlNodeIdShort dst, td::uint32 dst_mode, td::
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
td::actor::send_closure(it->second.get(), &AdnlPeerPair::receive_packet, std::move(packet));
|
td::actor::send_closure(it->second.get(), &AdnlPeerPair::receive_packet, std::move(packet), serialized_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdnlPeerImpl::send_messages(AdnlNodeIdShort src, td::uint32 src_mode, td::actor::ActorId<AdnlLocalId> src_actor,
|
void AdnlPeerImpl::send_messages(AdnlNodeIdShort src, td::uint32 src_mode, td::actor::ActorId<AdnlLocalId> src_actor,
|
||||||
|
|
@ -915,6 +1015,58 @@ void AdnlPeerImpl::update_addr_list(AdnlNodeIdShort local_id, td::uint32 local_m
|
||||||
td::actor::send_closure(it->second, &AdnlPeerPair::update_addr_list, std::move(addr_list));
|
td::actor::send_closure(it->second, &AdnlPeerPair::update_addr_list, std::move(addr_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AdnlPeerImpl::get_stats(bool all, td::Promise<std::vector<tl_object_ptr<ton_api::adnl_stats_peerPair>>> promise) {
|
||||||
|
class Cb : public td::actor::Actor {
|
||||||
|
public:
|
||||||
|
explicit Cb(td::Promise<std::vector<tl_object_ptr<ton_api::adnl_stats_peerPair>>> promise)
|
||||||
|
: promise_(std::move(promise)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void got_peer_pair_stats(tl_object_ptr<ton_api::adnl_stats_peerPair> peer_pair) {
|
||||||
|
if (peer_pair) {
|
||||||
|
result_.push_back(std::move(peer_pair));
|
||||||
|
}
|
||||||
|
dec_pending();
|
||||||
|
}
|
||||||
|
|
||||||
|
void inc_pending() {
|
||||||
|
++pending_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dec_pending() {
|
||||||
|
CHECK(pending_ > 0);
|
||||||
|
--pending_;
|
||||||
|
if (pending_ == 0) {
|
||||||
|
promise_.set_result(std::move(result_));
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
td::Promise<std::vector<tl_object_ptr<ton_api::adnl_stats_peerPair>>> promise_;
|
||||||
|
size_t pending_ = 1;
|
||||||
|
std::vector<tl_object_ptr<ton_api::adnl_stats_peerPair>> result_;
|
||||||
|
};
|
||||||
|
auto callback = td::actor::create_actor<Cb>("adnlpeerstats", std::move(promise)).release();
|
||||||
|
|
||||||
|
for (auto &[local_id, peer_pair] : peer_pairs_) {
|
||||||
|
td::actor::send_closure(callback, &Cb::inc_pending);
|
||||||
|
td::actor::send_closure(peer_pair, &AdnlPeerPair::get_stats, all,
|
||||||
|
[local_id = local_id, peer_id = peer_id_short_,
|
||||||
|
callback](td::Result<tl_object_ptr<ton_api::adnl_stats_peerPair>> R) {
|
||||||
|
if (R.is_error()) {
|
||||||
|
VLOG(ADNL_NOTICE) << "failed to get stats for peer pair " << peer_id << "->" << local_id
|
||||||
|
<< " : " << R.move_as_error();
|
||||||
|
td::actor::send_closure(callback, &Cb::dec_pending);
|
||||||
|
} else {
|
||||||
|
td::actor::send_closure(callback, &Cb::got_peer_pair_stats, R.move_as_ok());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
td::actor::send_closure(callback, &Cb::dec_pending);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void AdnlPeerPairImpl::got_data_from_db(td::Result<AdnlDbItem> R) {
|
void AdnlPeerPairImpl::got_data_from_db(td::Result<AdnlDbItem> R) {
|
||||||
received_from_db_ = false;
|
received_from_db_ = false;
|
||||||
if (R.is_error()) {
|
if (R.is_error()) {
|
||||||
|
|
@ -998,6 +1150,66 @@ void AdnlPeerPairImpl::request_reverse_ping_result(td::Result<td::Unit> R) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AdnlPeerPairImpl::add_packet_stats(td::uint64 bytes, bool in, bool channel) {
|
||||||
|
prepare_packet_stats();
|
||||||
|
auto add_stats = [&](PacketStats &stats) {
|
||||||
|
if (in) {
|
||||||
|
++stats.in_packets;
|
||||||
|
stats.in_bytes += bytes;
|
||||||
|
if (channel) {
|
||||||
|
++stats.in_packets_channel;
|
||||||
|
stats.in_bytes_channel += bytes;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
++stats.out_packets;
|
||||||
|
stats.out_bytes += bytes;
|
||||||
|
if (channel) {
|
||||||
|
++stats.out_packets_channel;
|
||||||
|
stats.out_bytes_channel += bytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
add_stats(packet_stats_cur_);
|
||||||
|
add_stats(packet_stats_total_);
|
||||||
|
if (in) {
|
||||||
|
last_in_packet_ts_ = td::Clocks::system();
|
||||||
|
} else {
|
||||||
|
last_out_packet_ts_ = td::Clocks::system();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdnlPeerPairImpl::add_expired_msg_stats(td::uint64 bytes) {
|
||||||
|
prepare_packet_stats();
|
||||||
|
auto add_stats = [&](PacketStats &stats) {
|
||||||
|
++stats.out_expired_messages;
|
||||||
|
stats.out_expired_bytes += bytes;
|
||||||
|
};
|
||||||
|
add_stats(packet_stats_cur_);
|
||||||
|
add_stats(packet_stats_total_);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdnlPeerPairImpl::prepare_packet_stats() {
|
||||||
|
double now = td::Clocks::system();
|
||||||
|
if (now >= packet_stats_cur_.ts_end) {
|
||||||
|
packet_stats_prev_ = std::move(packet_stats_cur_);
|
||||||
|
packet_stats_cur_ = {};
|
||||||
|
auto now_int = (int)now;
|
||||||
|
packet_stats_cur_.ts_start = (double)(now_int / 60 * 60);
|
||||||
|
packet_stats_cur_.ts_end = packet_stats_cur_.ts_start + 60.0;
|
||||||
|
if (packet_stats_prev_.ts_end < now - 60.0) {
|
||||||
|
packet_stats_prev_ = {};
|
||||||
|
packet_stats_prev_.ts_end = packet_stats_cur_.ts_start;
|
||||||
|
packet_stats_prev_.ts_start = packet_stats_prev_.ts_end - 60.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tl_object_ptr<ton_api::adnl_stats_packets> AdnlPeerPairImpl::PacketStats::tl() const {
|
||||||
|
return create_tl_object<ton_api::adnl_stats_packets>(ts_start, ts_end, in_packets, in_bytes, in_packets_channel,
|
||||||
|
in_bytes_channel, out_packets, out_bytes, out_packets_channel,
|
||||||
|
out_bytes_channel, out_expired_messages, out_expired_bytes);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace adnl
|
} // namespace adnl
|
||||||
|
|
||||||
} // namespace ton
|
} // namespace ton
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,9 @@ class AdnlPeer;
|
||||||
|
|
||||||
class AdnlPeerPair : public td::actor::Actor {
|
class AdnlPeerPair : public td::actor::Actor {
|
||||||
public:
|
public:
|
||||||
virtual void receive_packet_from_channel(AdnlChannelIdShort id, AdnlPacket packet) = 0;
|
virtual void receive_packet_from_channel(AdnlChannelIdShort id, AdnlPacket packet, td::uint64 serialized_size) = 0;
|
||||||
virtual void receive_packet_checked(AdnlPacket packet) = 0;
|
virtual void receive_packet_checked(AdnlPacket packet) = 0;
|
||||||
virtual void receive_packet(AdnlPacket packet) = 0;
|
virtual void receive_packet(AdnlPacket packet, td::uint64 serialized_size) = 0;
|
||||||
|
|
||||||
virtual void send_messages(std::vector<OutboundAdnlMessage> message) = 0;
|
virtual void send_messages(std::vector<OutboundAdnlMessage> message) = 0;
|
||||||
inline void send_message(OutboundAdnlMessage message) {
|
inline void send_message(OutboundAdnlMessage message) {
|
||||||
|
|
@ -59,6 +59,7 @@ class AdnlPeerPair : public td::actor::Actor {
|
||||||
virtual void update_peer_id(AdnlNodeIdFull id) = 0;
|
virtual void update_peer_id(AdnlNodeIdFull id) = 0;
|
||||||
virtual void update_addr_list(AdnlAddressList addr_list) = 0;
|
virtual void update_addr_list(AdnlAddressList addr_list) = 0;
|
||||||
virtual void get_conn_ip_str(td::Promise<td::string> promise) = 0;
|
virtual void get_conn_ip_str(td::Promise<td::string> promise) = 0;
|
||||||
|
virtual void get_stats(bool all, td::Promise<tl_object_ptr<ton_api::adnl_stats_peerPair>> promise) = 0;
|
||||||
|
|
||||||
static td::actor::ActorOwn<AdnlPeerPair> create(td::actor::ActorId<AdnlNetworkManager> network_manager,
|
static td::actor::ActorOwn<AdnlPeerPair> create(td::actor::ActorId<AdnlNetworkManager> network_manager,
|
||||||
td::actor::ActorId<AdnlPeerTable> peer_table, td::uint32 local_mode,
|
td::actor::ActorId<AdnlPeerTable> peer_table, td::uint32 local_mode,
|
||||||
|
|
@ -71,7 +72,7 @@ class AdnlPeerPair : public td::actor::Actor {
|
||||||
class AdnlPeer : public td::actor::Actor {
|
class AdnlPeer : public td::actor::Actor {
|
||||||
public:
|
public:
|
||||||
virtual void receive_packet(AdnlNodeIdShort dst, td::uint32 dst_mode, td::actor::ActorId<AdnlLocalId> dst_actor,
|
virtual void receive_packet(AdnlNodeIdShort dst, td::uint32 dst_mode, td::actor::ActorId<AdnlLocalId> dst_actor,
|
||||||
AdnlPacket message) = 0;
|
AdnlPacket message, td::uint64 serialized_size) = 0;
|
||||||
virtual void send_messages(AdnlNodeIdShort src, td::uint32 src_mode, td::actor::ActorId<AdnlLocalId> src_actor,
|
virtual void send_messages(AdnlNodeIdShort src, td::uint32 src_mode, td::actor::ActorId<AdnlLocalId> src_actor,
|
||||||
std::vector<OutboundAdnlMessage> messages) = 0;
|
std::vector<OutboundAdnlMessage> messages) = 0;
|
||||||
virtual void send_query(AdnlNodeIdShort src, td::uint32 src_mode, td::actor::ActorId<AdnlLocalId> src_actor,
|
virtual void send_query(AdnlNodeIdShort src, td::uint32 src_mode, td::actor::ActorId<AdnlLocalId> src_actor,
|
||||||
|
|
@ -100,6 +101,7 @@ class AdnlPeer : public td::actor::Actor {
|
||||||
td::actor::ActorId<AdnlLocalId> local_actor, AdnlAddressList addr_list) = 0;
|
td::actor::ActorId<AdnlLocalId> local_actor, AdnlAddressList addr_list) = 0;
|
||||||
virtual void update_dht_node(td::actor::ActorId<dht::Dht> dht_node) = 0;
|
virtual void update_dht_node(td::actor::ActorId<dht::Dht> dht_node) = 0;
|
||||||
virtual void get_conn_ip_str(AdnlNodeIdShort l_id, td::Promise<td::string> promise) = 0;
|
virtual void get_conn_ip_str(AdnlNodeIdShort l_id, td::Promise<td::string> promise) = 0;
|
||||||
|
virtual void get_stats(bool all, td::Promise<std::vector<tl_object_ptr<ton_api::adnl_stats_peerPair>>> promise) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace adnl
|
} // namespace adnl
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
#include "adnl-peer.h"
|
#include "adnl-peer.h"
|
||||||
#include "adnl-peer-table.h"
|
#include "adnl-peer-table.h"
|
||||||
|
|
@ -66,12 +67,12 @@ class AdnlPeerPairImpl : public AdnlPeerPair {
|
||||||
|
|
||||||
void discover();
|
void discover();
|
||||||
|
|
||||||
void receive_packet_from_channel(AdnlChannelIdShort id, AdnlPacket packet) override;
|
void receive_packet_from_channel(AdnlChannelIdShort id, AdnlPacket packet, td::uint64 serialized_size) override;
|
||||||
void receive_packet_checked(AdnlPacket packet) override;
|
void receive_packet_checked(AdnlPacket packet) override;
|
||||||
void receive_packet(AdnlPacket packet) override;
|
void receive_packet(AdnlPacket packet, td::uint64 serialized_size) override;
|
||||||
void deliver_message(AdnlMessage message);
|
void deliver_message(AdnlMessage message);
|
||||||
|
|
||||||
void send_messages_in(std::vector<OutboundAdnlMessage> messages, bool allow_postpone);
|
void send_messages_from_queue();
|
||||||
void send_messages(std::vector<OutboundAdnlMessage> messages) override;
|
void send_messages(std::vector<OutboundAdnlMessage> messages) override;
|
||||||
void send_packet_continue(AdnlPacket packet, td::actor::ActorId<AdnlNetworkConnection> conn, bool via_channel);
|
void send_packet_continue(AdnlPacket packet, td::actor::ActorId<AdnlNetworkConnection> conn, bool via_channel);
|
||||||
void send_query(std::string name, td::Promise<td::BufferSlice> promise, td::Timestamp timeout, td::BufferSlice data,
|
void send_query(std::string name, td::Promise<td::BufferSlice> promise, td::Timestamp timeout, td::BufferSlice data,
|
||||||
|
|
@ -89,6 +90,7 @@ class AdnlPeerPairImpl : public AdnlPeerPair {
|
||||||
void update_peer_id(AdnlNodeIdFull id) override;
|
void update_peer_id(AdnlNodeIdFull id) override;
|
||||||
|
|
||||||
void get_conn_ip_str(td::Promise<td::string> promise) override;
|
void get_conn_ip_str(td::Promise<td::string> promise) override;
|
||||||
|
void get_stats(bool all, td::Promise<tl_object_ptr<ton_api::adnl_stats_peerPair>> promise) override;
|
||||||
|
|
||||||
void got_data_from_db(td::Result<AdnlDbItem> R);
|
void got_data_from_db(td::Result<AdnlDbItem> R);
|
||||||
void got_data_from_static_nodes(td::Result<AdnlNode> R);
|
void got_data_from_static_nodes(td::Result<AdnlNode> R);
|
||||||
|
|
@ -122,8 +124,9 @@ class AdnlPeerPairImpl : public AdnlPeerPair {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void respond_with_nop();
|
||||||
void reinit(td::int32 date);
|
void reinit(td::int32 date);
|
||||||
td::Result<std::pair<td::actor::ActorId<AdnlNetworkConnection>, bool>> get_conn(bool direct_only);
|
td::Result<std::pair<td::actor::ActorId<AdnlNetworkConnection>, bool>> get_conn();
|
||||||
void create_channel(pubkeys::Ed25519 pub, td::uint32 date);
|
void create_channel(pubkeys::Ed25519 pub, td::uint32 date);
|
||||||
|
|
||||||
bool received_packet(td::uint64 seqno) const {
|
bool received_packet(td::uint64 seqno) const {
|
||||||
|
|
@ -182,11 +185,11 @@ class AdnlPeerPairImpl : public AdnlPeerPair {
|
||||||
Conn() {
|
Conn() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ready() {
|
bool ready() const {
|
||||||
return !conn.empty() && conn.get_actor_unsafe().is_active();
|
return !conn.empty() && conn.get_actor_unsafe().is_active();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_direct() {
|
bool is_direct() const {
|
||||||
return addr->is_public();
|
return addr->is_public();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -194,7 +197,14 @@ class AdnlPeerPairImpl : public AdnlPeerPair {
|
||||||
td::actor::ActorId<Adnl> adnl);
|
td::actor::ActorId<Adnl> adnl);
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<OutboundAdnlMessage> pending_messages_;
|
// Messages waiting for connection or for nochannel rate limiter
|
||||||
|
std::queue<std::pair<OutboundAdnlMessage, td::Timestamp>> out_messages_queue_;
|
||||||
|
td::uint64 out_messages_queue_total_size_ = 0;
|
||||||
|
RateLimiter nochannel_rate_limiter_ = RateLimiter(50, 0.5); // max 50, period = 0.5s
|
||||||
|
td::Timestamp retry_send_at_ = td::Timestamp::never();
|
||||||
|
bool disable_dht_query_ = false;
|
||||||
|
bool skip_init_packet_ = false;
|
||||||
|
double message_in_queue_ttl_ = 10.0;
|
||||||
|
|
||||||
td::actor::ActorId<AdnlNetworkManager> network_manager_;
|
td::actor::ActorId<AdnlNetworkManager> network_manager_;
|
||||||
td::actor::ActorId<AdnlPeerTable> peer_table_;
|
td::actor::ActorId<AdnlPeerTable> peer_table_;
|
||||||
|
|
@ -214,6 +224,7 @@ class AdnlPeerPairImpl : public AdnlPeerPair {
|
||||||
pubkeys::Ed25519 channel_pub_;
|
pubkeys::Ed25519 channel_pub_;
|
||||||
td::int32 channel_pk_date_;
|
td::int32 channel_pk_date_;
|
||||||
td::actor::ActorOwn<AdnlChannel> channel_;
|
td::actor::ActorOwn<AdnlChannel> channel_;
|
||||||
|
td::Timestamp respond_with_nop_after_;
|
||||||
|
|
||||||
td::uint64 in_seqno_ = 0;
|
td::uint64 in_seqno_ = 0;
|
||||||
td::uint64 out_seqno_ = 0;
|
td::uint64 out_seqno_ = 0;
|
||||||
|
|
@ -252,20 +263,34 @@ class AdnlPeerPairImpl : public AdnlPeerPair {
|
||||||
|
|
||||||
td::Timestamp next_dht_query_at_ = td::Timestamp::never();
|
td::Timestamp next_dht_query_at_ = td::Timestamp::never();
|
||||||
td::Timestamp next_db_update_at_ = td::Timestamp::never();
|
td::Timestamp next_db_update_at_ = td::Timestamp::never();
|
||||||
td::Timestamp retry_send_at_ = td::Timestamp::never();
|
|
||||||
|
|
||||||
td::Timestamp last_received_packet_ = td::Timestamp::never();
|
td::Timestamp last_received_packet_ = td::Timestamp::never();
|
||||||
td::Timestamp try_reinit_at_ = td::Timestamp::never();
|
td::Timestamp try_reinit_at_ = td::Timestamp::never();
|
||||||
|
td::Timestamp drop_addr_list_at_ = td::Timestamp::never();
|
||||||
|
|
||||||
bool has_reverse_addr_ = false;
|
bool has_reverse_addr_ = false;
|
||||||
td::Timestamp request_reverse_ping_after_ = td::Timestamp::now();
|
td::Timestamp request_reverse_ping_after_ = td::Timestamp::now();
|
||||||
bool request_reverse_ping_active_ = false;
|
bool request_reverse_ping_active_ = false;
|
||||||
|
|
||||||
|
struct PacketStats {
|
||||||
|
double ts_start = 0.0, ts_end = 0.0;
|
||||||
|
td::uint64 in_packets = 0, in_bytes = 0, in_packets_channel = 0, in_bytes_channel = 0;
|
||||||
|
td::uint64 out_packets = 0, out_bytes = 0, out_packets_channel = 0, out_bytes_channel = 0;
|
||||||
|
td::uint64 out_expired_messages = 0, out_expired_bytes = 0;
|
||||||
|
|
||||||
|
tl_object_ptr<ton_api::adnl_stats_packets> tl() const;
|
||||||
|
} packet_stats_cur_, packet_stats_prev_, packet_stats_total_;
|
||||||
|
double last_in_packet_ts_ = 0.0, last_out_packet_ts_ = 0.0;
|
||||||
|
double started_ts_ = td::Clocks::system();
|
||||||
|
void add_packet_stats(td::uint64 bytes, bool in, bool channel);
|
||||||
|
void add_expired_msg_stats(td::uint64 bytes);
|
||||||
|
void prepare_packet_stats();
|
||||||
};
|
};
|
||||||
|
|
||||||
class AdnlPeerImpl : public AdnlPeer {
|
class AdnlPeerImpl : public AdnlPeer {
|
||||||
public:
|
public:
|
||||||
void receive_packet(AdnlNodeIdShort dst, td::uint32 dst_mode, td::actor::ActorId<AdnlLocalId> dst_actor,
|
void receive_packet(AdnlNodeIdShort dst, td::uint32 dst_mode, td::actor::ActorId<AdnlLocalId> dst_actor,
|
||||||
AdnlPacket packet) override;
|
AdnlPacket packet, td::uint64 serialized_size) override;
|
||||||
void send_messages(AdnlNodeIdShort src, td::uint32 src_mode, td::actor::ActorId<AdnlLocalId> src_actor,
|
void send_messages(AdnlNodeIdShort src, td::uint32 src_mode, td::actor::ActorId<AdnlLocalId> src_actor,
|
||||||
std::vector<OutboundAdnlMessage> messages) override;
|
std::vector<OutboundAdnlMessage> messages) override;
|
||||||
void send_query(AdnlNodeIdShort src, td::uint32 src_mode, td::actor::ActorId<AdnlLocalId> src_actor, std::string name,
|
void send_query(AdnlNodeIdShort src, td::uint32 src_mode, td::actor::ActorId<AdnlLocalId> src_actor, std::string name,
|
||||||
|
|
@ -278,6 +303,7 @@ class AdnlPeerImpl : public AdnlPeer {
|
||||||
AdnlAddressList addr_list) override;
|
AdnlAddressList addr_list) override;
|
||||||
void update_dht_node(td::actor::ActorId<dht::Dht> dht_node) override;
|
void update_dht_node(td::actor::ActorId<dht::Dht> dht_node) override;
|
||||||
void get_conn_ip_str(AdnlNodeIdShort l_id, td::Promise<td::string> promise) override;
|
void get_conn_ip_str(AdnlNodeIdShort l_id, td::Promise<td::string> promise) override;
|
||||||
|
void get_stats(bool all, td::Promise<std::vector<tl_object_ptr<ton_api::adnl_stats_peerPair>>> promise) override;
|
||||||
//void check_signature(td::BufferSlice data, td::BufferSlice signature, td::Promise<td::Unit> promise) override;
|
//void check_signature(td::BufferSlice data, td::BufferSlice signature, td::Promise<td::Unit> promise) override;
|
||||||
|
|
||||||
AdnlPeerImpl(td::actor::ActorId<AdnlNetworkManager> network_manager, td::actor::ActorId<AdnlPeerTable> peer_table,
|
AdnlPeerImpl(td::actor::ActorId<AdnlNetworkManager> network_manager, td::actor::ActorId<AdnlPeerTable> peer_table,
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ namespace ton {
|
||||||
namespace adnl {
|
namespace adnl {
|
||||||
|
|
||||||
void AdnlQuery::alarm() {
|
void AdnlQuery::alarm() {
|
||||||
set_error(td::Status::Error(ErrorCode::timeout, "adnl query timeout"));
|
set_error(td::Status::Error(ErrorCode::timeout, PSTRING() << "timeout for adnl query " << name_));
|
||||||
}
|
}
|
||||||
void AdnlQuery::result(td::BufferSlice data) {
|
void AdnlQuery::result(td::BufferSlice data) {
|
||||||
promise_.set_value(std::move(data));
|
promise_.set_value(std::move(data));
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,8 @@ class Adnl : public AdnlSenderInterface {
|
||||||
virtual void add_id_ex(AdnlNodeIdFull id, AdnlAddressList addr_list, td::uint8 cat, td::uint32 mode) = 0;
|
virtual void add_id_ex(AdnlNodeIdFull id, AdnlAddressList addr_list, td::uint8 cat, td::uint32 mode) = 0;
|
||||||
virtual void del_id(AdnlNodeIdShort id, td::Promise<td::Unit> promise) = 0;
|
virtual void del_id(AdnlNodeIdShort id, td::Promise<td::Unit> promise) = 0;
|
||||||
|
|
||||||
|
virtual void check_id_exists(AdnlNodeIdShort id, td::Promise<bool> promise) = 0;
|
||||||
|
|
||||||
// subscribe to (some) messages(+queries) to this local id
|
// subscribe to (some) messages(+queries) to this local id
|
||||||
virtual void subscribe(AdnlNodeIdShort dst, std::string prefix, std::unique_ptr<Callback> callback) = 0;
|
virtual void subscribe(AdnlNodeIdShort dst, std::string prefix, std::unique_ptr<Callback> callback) = 0;
|
||||||
virtual void unsubscribe(AdnlNodeIdShort dst, std::string prefix) = 0;
|
virtual void unsubscribe(AdnlNodeIdShort dst, std::string prefix) = 0;
|
||||||
|
|
@ -119,6 +121,8 @@ class Adnl : public AdnlSenderInterface {
|
||||||
virtual void create_tunnel(AdnlNodeIdShort dst, td::uint32 size,
|
virtual void create_tunnel(AdnlNodeIdShort dst, td::uint32 size,
|
||||||
td::Promise<std::pair<td::actor::ActorOwn<AdnlTunnel>, AdnlAddress>> promise) = 0;
|
td::Promise<std::pair<td::actor::ActorOwn<AdnlTunnel>, AdnlAddress>> promise) = 0;
|
||||||
|
|
||||||
|
virtual void get_stats(bool all, td::Promise<tl_object_ptr<ton_api::adnl_stats>> promise) = 0;
|
||||||
|
|
||||||
static td::actor::ActorOwn<Adnl> create(std::string db, td::actor::ActorId<keyring::Keyring> keyring);
|
static td::actor::ActorOwn<Adnl> create(std::string db, td::actor::ActorId<keyring::Keyring> keyring);
|
||||||
|
|
||||||
static std::string int_to_bytestring(td::int32 id) {
|
static std::string int_to_bytestring(td::int32 id) {
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,40 @@ inline bool adnl_node_is_older(AdnlNode &a, AdnlNode &b) {
|
||||||
return a.addr_list().version() < b.addr_list().version();
|
return a.addr_list().version() < b.addr_list().version();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class RateLimiter {
|
||||||
|
public:
|
||||||
|
explicit RateLimiter(td::uint32 capacity, double period) : capacity_(capacity), period_(period), remaining_(capacity) {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool take() {
|
||||||
|
while (remaining_ < capacity_ && increment_at_.is_in_past()) {
|
||||||
|
++remaining_;
|
||||||
|
increment_at_ += period_;
|
||||||
|
}
|
||||||
|
if (remaining_) {
|
||||||
|
--remaining_;
|
||||||
|
if (increment_at_.is_in_past()) {
|
||||||
|
increment_at_ = td::Timestamp::in(period_);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
td::Timestamp ready_at() const {
|
||||||
|
if (remaining_) {
|
||||||
|
return td::Timestamp::now();
|
||||||
|
}
|
||||||
|
return increment_at_;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
td::uint32 capacity_;
|
||||||
|
double period_;
|
||||||
|
td::uint32 remaining_;
|
||||||
|
td::Timestamp increment_at_ = td::Timestamp::never();
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace adnl
|
} // namespace adnl
|
||||||
|
|
||||||
} // namespace ton
|
} // namespace ton
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,19 @@ while getopts 'a' flag; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
export CC=$(which clang-16)
|
||||||
|
export CXX=$(which clang++-16)
|
||||||
|
export CCACHE_DISABLE=1
|
||||||
|
|
||||||
if [ ! -d android-ndk-r25b ]; then
|
if [ ! -d android-ndk-r25b ]; then
|
||||||
rm android-ndk-r25b-linux.zip
|
rm android-ndk-r25b-linux.zip
|
||||||
|
echo "Downloading https://dl.google.com/android/repository/android-ndk-r25b-linux.zip"
|
||||||
wget -q https://dl.google.com/android/repository/android-ndk-r25b-linux.zip
|
wget -q https://dl.google.com/android/repository/android-ndk-r25b-linux.zip
|
||||||
unzip -q android-ndk-r25b-linux.zip
|
unzip -q android-ndk-r25b-linux.zip
|
||||||
test $? -eq 0 || { echo "Can't unzip android-ndk-r25b-linux.zip"; exit 1; }
|
test $? -eq 0 || { echo "Can't unzip android-ndk-r25b-linux.zip"; exit 1; }
|
||||||
echo Android NDK extracted
|
echo "Android NDK extracted"
|
||||||
else
|
else
|
||||||
echo Using extracted Android NDK
|
echo "Using extracted Android NDK"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export JAVA_AWT_LIBRARY=NotNeeded
|
export JAVA_AWT_LIBRARY=NotNeeded
|
||||||
|
|
|
||||||
3
assembly/appimage/AppRun
Normal file
3
assembly/appimage/AppRun
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
export LD_LIBRARY_PATH="${APPDIR}/usr/lib:${LD_LIBRARY_PATH}"
|
||||||
|
exec "$(dirname $0)"/usr/bin/app "$@"
|
||||||
50
assembly/appimage/create-appimages.sh
Normal file
50
assembly/appimage/create-appimages.sh
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ ! -d "artifacts" ]; then
|
||||||
|
echo "No artifacts found."
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
# x86_64 or aarch64
|
||||||
|
ARCH=$1
|
||||||
|
|
||||||
|
rm -rf appimages
|
||||||
|
|
||||||
|
mkdir -p appimages/artifacts
|
||||||
|
|
||||||
|
wget -nc https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-$ARCH.AppImage
|
||||||
|
chmod +x ./appimagetool-$ARCH.AppImage
|
||||||
|
|
||||||
|
cd appimages
|
||||||
|
for file in ../artifacts/*; do
|
||||||
|
if [[ -f "$file" && "$file" != *.so ]]; then
|
||||||
|
appName=$(basename "$file")
|
||||||
|
echo $appName
|
||||||
|
# prepare AppDir
|
||||||
|
mkdir -p $appName.AppDir/usr/{bin,lib}
|
||||||
|
cp ../AppRun $appName.AppDir/AppRun
|
||||||
|
sed -i "s/app/$appName/g" $appName.AppDir/AppRun
|
||||||
|
chmod +x ./$appName.AppDir/AppRun
|
||||||
|
printf '[Desktop Entry]\nName='$appName'\nExec='$appName'\nIcon='$appName'\nType=Application\nCategories=Utility;\n' > $appName.AppDir/$appName.desktop
|
||||||
|
cp ../ton.png $appName.AppDir/$appName.png
|
||||||
|
cp $file $appName.AppDir/usr/bin/
|
||||||
|
cp ../build/openssl_3/libcrypto.so.3 \
|
||||||
|
/lib/$ARCH-linux-gnu/libatomic.so.1 \
|
||||||
|
/lib/$ARCH-linux-gnu/libsodium.so.23 \
|
||||||
|
/lib/$ARCH-linux-gnu/libz.so.1 \
|
||||||
|
/lib/$ARCH-linux-gnu/liblz4.so.1 \
|
||||||
|
/lib/$ARCH-linux-gnu/libmicrohttpd.so.12 \
|
||||||
|
/lib/$ARCH-linux-gnu/libreadline.so.8 \
|
||||||
|
/lib/$ARCH-linux-gnu/libstdc++.so.6 \
|
||||||
|
$appName.AppDir/usr/lib/
|
||||||
|
|
||||||
|
chmod +x ./$appName.AppDir/usr/bin/$appName
|
||||||
|
# create AppImage
|
||||||
|
./../appimagetool-$ARCH.AppImage -l $appName.AppDir
|
||||||
|
mv $appName-$ARCH.AppImage artifacts/$appName
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
ls -larth artifacts
|
||||||
|
cp -r ../artifacts/{smartcont,lib} artifacts/
|
||||||
|
pwd
|
||||||
|
ls -larth artifacts
|
||||||
BIN
assembly/appimage/ton.png
Normal file
BIN
assembly/appimage/ton.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.4 KiB |
|
|
@ -1,236 +0,0 @@
|
||||||
pipeline {
|
|
||||||
agent none
|
|
||||||
stages {
|
|
||||||
stage('Run Builds') {
|
|
||||||
parallel {
|
|
||||||
stage('Ubuntu 20.04 x86-64 (shared)') {
|
|
||||||
agent {
|
|
||||||
label 'Ubuntu_x86-64'
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
timeout(time: 90, unit: 'MINUTES') {
|
|
||||||
sh '''
|
|
||||||
cp assembly/native/build-ubuntu-shared.sh .
|
|
||||||
chmod +x build-ubuntu-shared.sh
|
|
||||||
./build-ubuntu-shared.sh -t -a
|
|
||||||
'''
|
|
||||||
sh '''
|
|
||||||
cd artifacts
|
|
||||||
zip -9r ton-x86_64-linux-shared ./*
|
|
||||||
'''
|
|
||||||
archiveArtifacts artifacts: 'artifacts/ton-x86_64-linux-shared.zip'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Ubuntu 20.04 x86-64 (portable)') {
|
|
||||||
agent {
|
|
||||||
label 'Ubuntu_x86-64'
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
timeout(time: 90, unit: 'MINUTES') {
|
|
||||||
sh '''
|
|
||||||
cp assembly/nix/build-linux-x86-64-nix.sh .
|
|
||||||
chmod +x build-linux-x86-64-nix.sh
|
|
||||||
./build-linux-x86-64-nix.sh -t
|
|
||||||
'''
|
|
||||||
sh '''
|
|
||||||
cd artifacts
|
|
||||||
zip -9r ton-x86-64-linux-portable ./*
|
|
||||||
'''
|
|
||||||
archiveArtifacts artifacts: 'artifacts/ton-x86-64-linux-portable.zip'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Ubuntu 20.04 aarch64 (shared)') {
|
|
||||||
agent {
|
|
||||||
label 'Ubuntu_arm64'
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
timeout(time: 90, unit: 'MINUTES') {
|
|
||||||
sh '''
|
|
||||||
cp assembly/native/build-ubuntu-shared.sh .
|
|
||||||
chmod +x build-ubuntu-shared.sh
|
|
||||||
./build-ubuntu-shared.sh -t -a
|
|
||||||
'''
|
|
||||||
sh '''
|
|
||||||
cd artifacts
|
|
||||||
zip -9r ton-arm64-linux-shared ./*
|
|
||||||
'''
|
|
||||||
archiveArtifacts artifacts: 'artifacts/ton-arm64-linux-shared.zip'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Ubuntu 20.04 aarch64 (portable)') {
|
|
||||||
agent {
|
|
||||||
label 'Ubuntu_arm64'
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
timeout(time: 90, unit: 'MINUTES') {
|
|
||||||
sh '''
|
|
||||||
cp assembly/nix/build-linux-arm64-nix.sh .
|
|
||||||
chmod +x build-linux-arm64-nix.sh
|
|
||||||
./build-linux-arm64-nix.sh -t
|
|
||||||
'''
|
|
||||||
sh '''
|
|
||||||
cd artifacts
|
|
||||||
zip -9r ton-arm64-linux-portable ./*
|
|
||||||
'''
|
|
||||||
archiveArtifacts artifacts: 'artifacts/ton-arm64-linux-portable.zip'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('macOS 12.7 x86-64 (shared)') {
|
|
||||||
agent {
|
|
||||||
label 'macOS_12.7_x86-64'
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
timeout(time: 90, unit: 'MINUTES') {
|
|
||||||
sh '''
|
|
||||||
cp assembly/native/build-macos-shared.sh .
|
|
||||||
chmod +x build-macos-shared.sh
|
|
||||||
./build-macos-shared.sh -t -a
|
|
||||||
'''
|
|
||||||
sh '''
|
|
||||||
cd artifacts
|
|
||||||
zip -9r ton-x86-64-macos-shared ./*
|
|
||||||
'''
|
|
||||||
archiveArtifacts artifacts: 'artifacts/ton-x86-64-macos-shared.zip'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('macOS 12.7 x86-64 (portable)') {
|
|
||||||
agent {
|
|
||||||
label 'macOS_12.7_x86-64'
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
timeout(time: 90, unit: 'MINUTES') {
|
|
||||||
sh '''
|
|
||||||
cp assembly/nix/build-macos-nix.sh .
|
|
||||||
chmod +x build-macos-nix.sh
|
|
||||||
./build-macos-nix.sh -t
|
|
||||||
'''
|
|
||||||
sh '''
|
|
||||||
cd artifacts
|
|
||||||
zip -9r ton-x86-64-macos-portable ./*
|
|
||||||
'''
|
|
||||||
archiveArtifacts artifacts: 'artifacts/ton-x86-64-macos-portable.zip'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('macOS 12.6 aarch64 (shared)') {
|
|
||||||
agent {
|
|
||||||
label 'macOS_12.6-arm64-m1'
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
timeout(time: 90, unit: 'MINUTES') {
|
|
||||||
sh '''
|
|
||||||
cp assembly/native/build-macos-shared.sh .
|
|
||||||
chmod +x build-macos-shared.sh
|
|
||||||
./build-macos-shared.sh -t -a
|
|
||||||
'''
|
|
||||||
sh '''
|
|
||||||
cd artifacts
|
|
||||||
zip -9r ton-arm64-macos-m1-shared ./*
|
|
||||||
'''
|
|
||||||
archiveArtifacts artifacts: 'artifacts/ton-arm64-macos-m1-shared.zip'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('macOS 12.6 aarch64 (portable)') {
|
|
||||||
agent {
|
|
||||||
label 'macOS_12.6-arm64-m1'
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
timeout(time: 90, unit: 'MINUTES') {
|
|
||||||
sh '''
|
|
||||||
cp assembly/nix/build-macos-nix.sh .
|
|
||||||
chmod +x build-macos-nix.sh
|
|
||||||
./build-macos-nix.sh -t
|
|
||||||
'''
|
|
||||||
sh '''
|
|
||||||
cd artifacts
|
|
||||||
zip -9r ton-arm64-macos-portable ./*
|
|
||||||
'''
|
|
||||||
archiveArtifacts artifacts: 'artifacts/ton-arm64-macos-portable.zip'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('macOS 13.2 aarch64 (shared)') {
|
|
||||||
agent {
|
|
||||||
label 'macOS_13.2-arm64-m2'
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
timeout(time: 90, unit: 'MINUTES') {
|
|
||||||
sh '''
|
|
||||||
cp assembly/native/build-macos-shared.sh .
|
|
||||||
chmod +x build-macos-shared.sh
|
|
||||||
./build-macos-shared.sh -t -a
|
|
||||||
'''
|
|
||||||
sh '''
|
|
||||||
cd artifacts
|
|
||||||
zip -9r ton-arm64-macos-m2-shared ./*
|
|
||||||
'''
|
|
||||||
archiveArtifacts artifacts: 'artifacts/ton-arm64-macos-m2-shared.zip'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Windows Server 2022 x86-64') {
|
|
||||||
agent {
|
|
||||||
label 'Windows_x86-64'
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
timeout(time: 90, unit: 'MINUTES') {
|
|
||||||
bat '''
|
|
||||||
copy assembly\\native\\build-windows.bat .
|
|
||||||
build-windows.bat
|
|
||||||
'''
|
|
||||||
bat '''
|
|
||||||
cd artifacts
|
|
||||||
zip -9r ton-x86-64-windows ./*
|
|
||||||
'''
|
|
||||||
archiveArtifacts artifacts: 'artifacts/ton-x86-64-windows.zip'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Android Tonlib') {
|
|
||||||
agent {
|
|
||||||
label 'Ubuntu_x86-64'
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
timeout(time: 90, unit: 'MINUTES') {
|
|
||||||
sh '''
|
|
||||||
cp assembly/android/build-android-tonlib.sh .
|
|
||||||
chmod +x build-android-tonlib.sh
|
|
||||||
./build-android-tonlib.sh -a
|
|
||||||
'''
|
|
||||||
sh '''
|
|
||||||
cd artifacts/tonlib-android-jni
|
|
||||||
zip -9r ton-android-tonlib ./*
|
|
||||||
'''
|
|
||||||
archiveArtifacts artifacts: 'artifacts/tonlib-android-jni/ton-android-tonlib.zip'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('WASM fift func emulator') {
|
|
||||||
agent {
|
|
||||||
label 'Ubuntu_x86-64'
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
timeout(time: 90, unit: 'MINUTES') {
|
|
||||||
sh '''
|
|
||||||
cd assembly/wasm
|
|
||||||
chmod +x fift-func-wasm-build-ubuntu.sh
|
|
||||||
./fift-func-wasm-build-ubuntu.sh -a
|
|
||||||
'''
|
|
||||||
sh '''
|
|
||||||
cd artifacts
|
|
||||||
zip -9r ton-wasm-binaries ./*
|
|
||||||
'''
|
|
||||||
archiveArtifacts artifacts: 'artifacts/ton-wasm-binaries.zip'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -24,7 +24,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export NONINTERACTIVE=1
|
export NONINTERACTIVE=1
|
||||||
brew install ninja pkg-config automake libtool autoconf
|
brew install ninja pkg-config automake libtool autoconf texinfo
|
||||||
brew install llvm@16
|
brew install llvm@16
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -37,19 +37,19 @@ else
|
||||||
fi
|
fi
|
||||||
export CCACHE_DISABLE=1
|
export CCACHE_DISABLE=1
|
||||||
|
|
||||||
if [ ! -d "secp256k1" ]; then
|
if [ ! -d "lz4" ]; then
|
||||||
git clone https://github.com/bitcoin-core/secp256k1.git
|
git clone https://github.com/lz4/lz4.git
|
||||||
cd secp256k1
|
cd lz4
|
||||||
secp256k1Path=`pwd`
|
lz4Path=`pwd`
|
||||||
git checkout v0.3.2
|
git checkout v1.9.4
|
||||||
./autogen.sh
|
|
||||||
./configure --enable-module-recovery --enable-static --disable-tests --disable-benchmark --with-pic
|
|
||||||
make -j12
|
make -j12
|
||||||
test $? -eq 0 || { echo "Can't compile secp256k1"; exit 1; }
|
test $? -eq 0 || { echo "Can't compile lz4"; exit 1; }
|
||||||
cd ..
|
cd ..
|
||||||
|
# ./lib/liblz4.a
|
||||||
|
# ./lib
|
||||||
else
|
else
|
||||||
secp256k1Path=$(pwd)/secp256k1
|
lz4Path=$(pwd)/lz4
|
||||||
echo "Using compiled secp256k1"
|
echo "Using compiled lz4"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d "libsodium" ]; then
|
if [ ! -d "libsodium" ]; then
|
||||||
|
|
@ -73,7 +73,7 @@ if [ ! -d "openssl_3" ]; then
|
||||||
cd openssl_3
|
cd openssl_3
|
||||||
opensslPath=`pwd`
|
opensslPath=`pwd`
|
||||||
git checkout openssl-3.1.4
|
git checkout openssl-3.1.4
|
||||||
./config -static
|
./config
|
||||||
make build_libs -j12
|
make build_libs -j12
|
||||||
test $? -eq 0 || { echo "Can't compile openssl_3"; exit 1; }
|
test $? -eq 0 || { echo "Can't compile openssl_3"; exit 1; }
|
||||||
cd ..
|
cd ..
|
||||||
|
|
@ -120,67 +120,48 @@ cmake -GNinja .. \
|
||||||
-DZLIB_FOUND=1 \
|
-DZLIB_FOUND=1 \
|
||||||
-DZLIB_INCLUDE_DIR=$zlibPath \
|
-DZLIB_INCLUDE_DIR=$zlibPath \
|
||||||
-DZLIB_LIBRARIES=$zlibPath/libz.a \
|
-DZLIB_LIBRARIES=$zlibPath/libz.a \
|
||||||
-DSECP256K1_FOUND=1 \
|
|
||||||
-DSECP256K1_INCLUDE_DIR=$secp256k1Path/include \
|
|
||||||
-DSECP256K1_LIBRARY=$secp256k1Path/.libs/libsecp256k1.a \
|
|
||||||
-DSODIUM_FOUND=1 \
|
-DSODIUM_FOUND=1 \
|
||||||
-DSODIUM_INCLUDE_DIR=$sodiumPath/src/libsodium/include \
|
-DSODIUM_INCLUDE_DIR=$sodiumPath/src/libsodium/include \
|
||||||
-DSODIUM_LIBRARY_RELEASE=$sodiumPath/src/libsodium/.libs/libsodium.a \
|
-DSODIUM_LIBRARY_RELEASE=$sodiumPath/src/libsodium/.libs/libsodium.a \
|
||||||
-DMHD_FOUND=1 \
|
-DMHD_FOUND=1 \
|
||||||
-DMHD_INCLUDE_DIR=$libmicrohttpdPath/src/include \
|
-DMHD_INCLUDE_DIR=$libmicrohttpdPath/src/include \
|
||||||
-DMHD_LIBRARY=$libmicrohttpdPath/src/microhttpd/.libs/libmicrohttpd.a
|
-DMHD_LIBRARY=$libmicrohttpdPath/src/microhttpd/.libs/libmicrohttpd.a \
|
||||||
|
-DLZ4_FOUND=1 \
|
||||||
|
-DLZ4_INCLUDE_DIRS=$lz4Path/lib \
|
||||||
|
-DLZ4_LIBRARIES=$lz4Path/lib/liblz4.a
|
||||||
|
|
||||||
|
|
||||||
test $? -eq 0 || { echo "Can't configure ton"; exit 1; }
|
test $? -eq 0 || { echo "Can't configure ton"; exit 1; }
|
||||||
|
|
||||||
if [ "$with_tests" = true ]; then
|
if [ "$with_tests" = true ]; then
|
||||||
ninja storage-daemon storage-daemon-cli blockchain-explorer \
|
ninja storage-daemon storage-daemon-cli blockchain-explorer \
|
||||||
tonlib tonlibjson tonlib-cli validator-engine func fift \
|
tonlib tonlibjson tonlib-cli validator-engine func tolk fift \
|
||||||
lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server \
|
lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server \
|
||||||
http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork tlbc emulator \
|
http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork tlbc emulator \
|
||||||
test-ed25519 test-ed25519-crypto test-bigint test-vm test-fift test-cells test-smartcont \
|
test-ed25519 test-ed25519-crypto test-bigint test-vm test-fift test-cells test-smartcont \
|
||||||
test-net test-tdactor test-tdutils test-tonlib-offline test-adnl test-dht test-rldp \
|
test-net test-tdactor test-tdutils test-tonlib-offline test-adnl test-dht test-rldp \
|
||||||
test-rldp2 test-catchain test-fec test-tddb test-db test-validator-session-state
|
test-rldp2 test-catchain test-fec test-tddb test-db test-validator-session-state test-emulator proxy-liteserver
|
||||||
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
|
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
|
||||||
else
|
else
|
||||||
ninja storage-daemon storage-daemon-cli blockchain-explorer \
|
ninja storage-daemon storage-daemon-cli blockchain-explorer \
|
||||||
tonlib tonlibjson tonlib-cli validator-engine func fift \
|
tonlib tonlibjson tonlib-cli validator-engine func tolk fift \
|
||||||
lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server \
|
lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server \
|
||||||
http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork tlbc emulator
|
http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork tlbc emulator proxy-liteserver
|
||||||
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
|
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
strip storage/storage-daemon/storage-daemon
|
|
||||||
strip storage/storage-daemon/storage-daemon-cli
|
|
||||||
strip blockchain-explorer/blockchain-explorer
|
|
||||||
strip crypto/fift
|
|
||||||
strip crypto/func
|
|
||||||
strip crypto/create-state
|
|
||||||
strip crypto/tlbc
|
|
||||||
strip validator-engine-console/validator-engine-console
|
|
||||||
strip tonlib/tonlib-cli
|
|
||||||
strip http/http-proxy
|
|
||||||
strip rldp-http-proxy/rldp-http-proxy
|
|
||||||
strip dht-server/dht-server
|
|
||||||
strip lite-client/lite-client
|
|
||||||
strip validator-engine/validator-engine
|
|
||||||
strip utils/generate-random-id
|
|
||||||
strip utils/json2tlo
|
|
||||||
strip adnl/adnl-proxy
|
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
if [ "$with_artifacts" = true ]; then
|
if [ "$with_artifacts" = true ]; then
|
||||||
echo Creating artifacts...
|
echo Creating artifacts...
|
||||||
rm -rf artifacts
|
rm -rf artifacts
|
||||||
mkdir artifacts
|
mkdir artifacts
|
||||||
cp crypto/fift/lib artifacts/
|
|
||||||
cp -R crypto/smartcont/ artifacts/
|
|
||||||
cp build/storage/storage-daemon/storage-daemon artifacts/
|
cp build/storage/storage-daemon/storage-daemon artifacts/
|
||||||
cp build/storage/storage-daemon/storage-daemon-cli artifacts/
|
cp build/storage/storage-daemon/storage-daemon-cli artifacts/
|
||||||
cp build/blockchain-explorer/blockchain-explorer artifacts/
|
cp build/blockchain-explorer/blockchain-explorer artifacts/
|
||||||
cp build/crypto/fift artifacts/
|
cp build/crypto/fift artifacts/
|
||||||
cp build/crypto/func artifacts/
|
cp build/crypto/func artifacts/
|
||||||
|
cp build/tolk/tolk artifacts/
|
||||||
cp build/crypto/create-state artifacts/
|
cp build/crypto/create-state artifacts/
|
||||||
cp build/crypto/tlbc artifacts/
|
cp build/crypto/tlbc artifacts/
|
||||||
cp build/validator-engine-console/validator-engine-console artifacts/
|
cp build/validator-engine-console/validator-engine-console artifacts/
|
||||||
|
|
@ -193,11 +174,12 @@ if [ "$with_artifacts" = true ]; then
|
||||||
cp build/validator-engine/validator-engine artifacts/
|
cp build/validator-engine/validator-engine artifacts/
|
||||||
cp build/utils/generate-random-id artifacts/
|
cp build/utils/generate-random-id artifacts/
|
||||||
cp build/utils/json2tlo artifacts/
|
cp build/utils/json2tlo artifacts/
|
||||||
|
cp build/utils/proxy-liteserver artifacts/
|
||||||
cp build/adnl/adnl-proxy artifacts/
|
cp build/adnl/adnl-proxy artifacts/
|
||||||
cp build/emulator/libemulator.dylib artifacts/
|
cp build/emulator/libemulator.dylib artifacts/
|
||||||
chmod +x artifacts/*
|
|
||||||
rsync -r crypto/smartcont artifacts/
|
rsync -r crypto/smartcont artifacts/
|
||||||
rsync -r crypto/fift/lib artifacts/
|
rsync -r crypto/fift/lib artifacts/
|
||||||
|
chmod -R +x artifacts/*
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$with_tests" = true ]; then
|
if [ "$with_tests" = true ]; then
|
||||||
|
|
|
||||||
|
|
@ -36,19 +36,17 @@ else
|
||||||
fi
|
fi
|
||||||
export CCACHE_DISABLE=1
|
export CCACHE_DISABLE=1
|
||||||
|
|
||||||
if [ ! -d "secp256k1" ]; then
|
if [ ! -d "lz4" ]; then
|
||||||
git clone https://github.com/bitcoin-core/secp256k1.git
|
git clone https://github.com/lz4/lz4
|
||||||
cd secp256k1
|
cd lz4
|
||||||
secp256k1Path=`pwd`
|
lz4Path=`pwd`
|
||||||
git checkout v0.3.2
|
git checkout v1.9.4
|
||||||
./autogen.sh
|
|
||||||
./configure --enable-module-recovery --enable-static --disable-tests --disable-benchmark
|
|
||||||
make -j12
|
make -j12
|
||||||
test $? -eq 0 || { echo "Can't compile secp256k1"; exit 1; }
|
test $? -eq 0 || { echo "Can't compile lz4"; exit 1; }
|
||||||
cd ..
|
cd ..
|
||||||
else
|
else
|
||||||
secp256k1Path=$(pwd)/secp256k1
|
lz4Path=$(pwd)/lz4
|
||||||
echo "Using compiled secp256k1"
|
echo "Using compiled lz4"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
brew unlink openssl@1.1
|
brew unlink openssl@1.1
|
||||||
|
|
@ -57,48 +55,29 @@ brew unlink openssl@3 && brew link --overwrite openssl@3
|
||||||
|
|
||||||
cmake -GNinja -DCMAKE_BUILD_TYPE=Release .. \
|
cmake -GNinja -DCMAKE_BUILD_TYPE=Release .. \
|
||||||
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
|
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
|
||||||
-DSECP256K1_FOUND=1 \
|
-DLZ4_FOUND=1 \
|
||||||
-DSECP256K1_INCLUDE_DIR=$secp256k1Path/include \
|
-DLZ4_LIBRARIES=$lz4Path/lib/liblz4.a \
|
||||||
-DSECP256K1_LIBRARY=$secp256k1Path/.libs/libsecp256k1.a
|
-DLZ4_INCLUDE_DIRS=$lz4Path/lib
|
||||||
|
|
||||||
test $? -eq 0 || { echo "Can't configure ton"; exit 1; }
|
test $? -eq 0 || { echo "Can't configure ton"; exit 1; }
|
||||||
|
|
||||||
if [ "$with_tests" = true ]; then
|
if [ "$with_tests" = true ]; then
|
||||||
ninja storage-daemon storage-daemon-cli blockchain-explorer \
|
ninja storage-daemon storage-daemon-cli blockchain-explorer \
|
||||||
tonlib tonlibjson tonlib-cli validator-engine func fift \
|
tonlib tonlibjson tonlib-cli validator-engine func tolk fift \
|
||||||
lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server \
|
lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server \
|
||||||
http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork tlbc emulator \
|
http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork tlbc emulator \
|
||||||
test-ed25519 test-ed25519-crypto test-bigint test-vm test-fift test-cells test-smartcont \
|
test-ed25519 test-ed25519-crypto test-bigint test-vm test-fift test-cells test-smartcont \
|
||||||
test-net test-tdactor test-tdutils test-tonlib-offline test-adnl test-dht test-rldp \
|
test-net test-tdactor test-tdutils test-tonlib-offline test-adnl test-dht test-rldp \
|
||||||
test-rldp2 test-catchain test-fec test-tddb test-db test-validator-session-state
|
test-rldp2 test-catchain test-fec test-tddb test-db test-validator-session-state test-emulator proxy-liteserver
|
||||||
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
|
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
|
||||||
else
|
else
|
||||||
ninja storage-daemon storage-daemon-cli blockchain-explorer \
|
ninja storage-daemon storage-daemon-cli blockchain-explorer \
|
||||||
tonlib tonlibjson tonlib-cli validator-engine func fift \
|
tonlib tonlibjson tonlib-cli validator-engine func tolk fift \
|
||||||
lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server \
|
lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server \
|
||||||
http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork tlbc emulator
|
http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork tlbc emulator proxy-liteserver
|
||||||
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
|
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
strip storage/storage-daemon/storage-daemon
|
|
||||||
strip storage/storage-daemon/storage-daemon-cli
|
|
||||||
strip blockchain-explorer/blockchain-explorer
|
|
||||||
strip crypto/fift
|
|
||||||
strip crypto/func
|
|
||||||
strip crypto/create-state
|
|
||||||
strip crypto/tlbc
|
|
||||||
strip validator-engine-console/validator-engine-console
|
|
||||||
strip tonlib/tonlib-cli
|
|
||||||
strip http/http-proxy
|
|
||||||
strip rldp-http-proxy/rldp-http-proxy
|
|
||||||
strip dht-server/dht-server
|
|
||||||
strip lite-client/lite-client
|
|
||||||
strip validator-engine/validator-engine
|
|
||||||
strip utils/generate-random-id
|
|
||||||
strip utils/json2tlo
|
|
||||||
strip adnl/adnl-proxy
|
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
if [ "$with_artifacts" = true ]; then
|
if [ "$with_artifacts" = true ]; then
|
||||||
|
|
@ -110,6 +89,7 @@ if [ "$with_artifacts" = true ]; then
|
||||||
cp build/blockchain-explorer/blockchain-explorer artifacts/
|
cp build/blockchain-explorer/blockchain-explorer artifacts/
|
||||||
cp build/crypto/fift artifacts/
|
cp build/crypto/fift artifacts/
|
||||||
cp build/crypto/func artifacts/
|
cp build/crypto/func artifacts/
|
||||||
|
cp build/tolk/tolk artifacts/
|
||||||
cp build/crypto/create-state artifacts/
|
cp build/crypto/create-state artifacts/
|
||||||
cp build/crypto/tlbc artifacts/
|
cp build/crypto/tlbc artifacts/
|
||||||
cp build/validator-engine-console/validator-engine-console artifacts/
|
cp build/validator-engine-console/validator-engine-console artifacts/
|
||||||
|
|
@ -122,11 +102,12 @@ if [ "$with_artifacts" = true ]; then
|
||||||
cp build/validator-engine/validator-engine artifacts/
|
cp build/validator-engine/validator-engine artifacts/
|
||||||
cp build/utils/generate-random-id artifacts/
|
cp build/utils/generate-random-id artifacts/
|
||||||
cp build/utils/json2tlo artifacts/
|
cp build/utils/json2tlo artifacts/
|
||||||
|
cp build/utils/proxy-liteserver artifacts/
|
||||||
cp build/adnl/adnl-proxy artifacts/
|
cp build/adnl/adnl-proxy artifacts/
|
||||||
cp build/emulator/libemulator.dylib artifacts/
|
cp build/emulator/libemulator.dylib artifacts/
|
||||||
chmod +x artifacts/*
|
cp -R crypto/smartcont artifacts/
|
||||||
rsync -r crypto/smartcont artifacts/
|
cp -R crypto/fift/lib artifacts/
|
||||||
rsync -r crypto/fift/lib artifacts/
|
chmod -R +x artifacts/*
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$with_tests" = true ]; then
|
if [ "$with_tests" = true ]; then
|
||||||
|
|
|
||||||
109
assembly/native/build-ubuntu-appimages.sh
Normal file
109
assembly/native/build-ubuntu-appimages.sh
Normal file
|
|
@ -0,0 +1,109 @@
|
||||||
|
#/bin/bash
|
||||||
|
|
||||||
|
with_tests=false
|
||||||
|
with_artifacts=false
|
||||||
|
|
||||||
|
|
||||||
|
while getopts 'ta' flag; do
|
||||||
|
case "${flag}" in
|
||||||
|
t) with_tests=true ;;
|
||||||
|
a) with_artifacts=true ;;
|
||||||
|
*) break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "build" ]; then
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
else
|
||||||
|
cd build
|
||||||
|
rm -rf .ninja* CMakeCache.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
export CC=$(which clang-16)
|
||||||
|
export CXX=$(which clang++-16)
|
||||||
|
export CCACHE_DISABLE=1
|
||||||
|
|
||||||
|
if [ ! -d "openssl_3" ]; then
|
||||||
|
git clone https://github.com/openssl/openssl openssl_3
|
||||||
|
cd openssl_3
|
||||||
|
opensslPath=`pwd`
|
||||||
|
git checkout openssl-3.1.4
|
||||||
|
./config
|
||||||
|
make build_libs -j12
|
||||||
|
test $? -eq 0 || { echo "Can't compile openssl_3"; exit 1; }
|
||||||
|
cd ..
|
||||||
|
else
|
||||||
|
opensslPath=$(pwd)/openssl_3
|
||||||
|
echo "Using compiled openssl_3"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cmake -GNinja .. \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DPORTABLE=1 \
|
||||||
|
-DOPENSSL_ROOT_DIR=$opensslPath \
|
||||||
|
-DOPENSSL_INCLUDE_DIR=$opensslPath/include \
|
||||||
|
-DOPENSSL_CRYPTO_LIBRARY=$opensslPath/libcrypto.so
|
||||||
|
|
||||||
|
|
||||||
|
test $? -eq 0 || { echo "Can't configure ton"; exit 1; }
|
||||||
|
|
||||||
|
if [ "$with_tests" = true ]; then
|
||||||
|
ninja storage-daemon storage-daemon-cli fift func tolk tonlib tonlibjson tonlib-cli \
|
||||||
|
validator-engine lite-client pow-miner validator-engine-console blockchain-explorer \
|
||||||
|
generate-random-id json2tlo dht-server http-proxy rldp-http-proxy \
|
||||||
|
adnl-proxy create-state emulator test-ed25519 test-ed25519-crypto test-bigint \
|
||||||
|
test-vm test-fift test-cells test-smartcont test-net test-tdactor test-tdutils \
|
||||||
|
test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain \
|
||||||
|
test-fec test-tddb test-db test-validator-session-state test-emulator proxy-liteserver
|
||||||
|
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
|
||||||
|
else
|
||||||
|
ninja storage-daemon storage-daemon-cli fift func tolk tonlib tonlibjson tonlib-cli \
|
||||||
|
validator-engine lite-client pow-miner validator-engine-console blockchain-explorer \
|
||||||
|
generate-random-id json2tlo dht-server http-proxy rldp-http-proxy \
|
||||||
|
adnl-proxy create-state emulator proxy-liteserver
|
||||||
|
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
|
||||||
|
fi
|
||||||
|
|
||||||
|
# simple binaries' test
|
||||||
|
./storage/storage-daemon/storage-daemon -V || exit 1
|
||||||
|
./validator-engine/validator-engine -V || exit 1
|
||||||
|
./lite-client/lite-client -V || exit 1
|
||||||
|
./crypto/fift -V || exit 1
|
||||||
|
|
||||||
|
echo validator-engine
|
||||||
|
ldd ./validator-engine/validator-engine || exit 1
|
||||||
|
ldd ./validator-engine-console/validator-engine-console || exit 1
|
||||||
|
ldd ./crypto/fift || exit 1
|
||||||
|
echo blockchain-explorer
|
||||||
|
ldd ./blockchain-explorer/blockchain-explorer || exit 1
|
||||||
|
echo libtonlibjson.so
|
||||||
|
ldd ./tonlib/libtonlibjson.so.0.5 || exit 1
|
||||||
|
echo libemulator.so
|
||||||
|
ldd ./emulator/libemulator.so || exit 1
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
if [ "$with_artifacts" = true ]; then
|
||||||
|
rm -rf artifacts
|
||||||
|
mkdir artifacts
|
||||||
|
mv build/tonlib/libtonlibjson.so.0.5 build/tonlib/libtonlibjson.so
|
||||||
|
cp build/storage/storage-daemon/storage-daemon build/storage/storage-daemon/storage-daemon-cli \
|
||||||
|
build/crypto/fift build/crypto/tlbc build/crypto/func build/tolk/tolk build/crypto/create-state build/blockchain-explorer/blockchain-explorer \
|
||||||
|
build/validator-engine-console/validator-engine-console build/tonlib/tonlib-cli build/utils/proxy-liteserver \
|
||||||
|
build/tonlib/libtonlibjson.so build/http/http-proxy build/rldp-http-proxy/rldp-http-proxy \
|
||||||
|
build/dht-server/dht-server build/lite-client/lite-client build/validator-engine/validator-engine \
|
||||||
|
build/utils/generate-random-id build/utils/json2tlo build/adnl/adnl-proxy build/emulator/libemulator.so \
|
||||||
|
artifacts
|
||||||
|
test $? -eq 0 || { echo "Can't copy final binaries"; exit 1; }
|
||||||
|
cp -R crypto/smartcont artifacts
|
||||||
|
cp -R crypto/fift/lib artifacts
|
||||||
|
chmod -R +x artifacts/*
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$with_tests" = true ]; then
|
||||||
|
cd build
|
||||||
|
# ctest --output-on-failure -E "test-catchain|test-actors|test-smartcont|test-adnl|test-validator-session-state|test-dht|test-rldp"
|
||||||
|
ctest --output-on-failure --timeout 1800
|
||||||
|
fi
|
||||||
132
assembly/native/build-ubuntu-portable-libs.sh
Normal file
132
assembly/native/build-ubuntu-portable-libs.sh
Normal file
|
|
@ -0,0 +1,132 @@
|
||||||
|
#/bin/bash
|
||||||
|
|
||||||
|
#sudo apt-get update
|
||||||
|
#sudo apt-get install -y build-essential git cmake ninja-build automake libtool texinfo autoconf libc++-dev libc++abi-dev
|
||||||
|
|
||||||
|
with_artifacts=false
|
||||||
|
|
||||||
|
while getopts 'ta' flag; do
|
||||||
|
case "${flag}" in
|
||||||
|
a) with_artifacts=true ;;
|
||||||
|
*) break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "build" ]; then
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
else
|
||||||
|
cd build
|
||||||
|
rm -rf .ninja* CMakeCache.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
export CC=$(which clang)
|
||||||
|
export CXX=$(which clang++)
|
||||||
|
export CCACHE_DISABLE=1
|
||||||
|
|
||||||
|
if [ ! -d "lz4" ]; then
|
||||||
|
git clone https://github.com/lz4/lz4.git
|
||||||
|
cd lz4
|
||||||
|
lz4Path=`pwd`
|
||||||
|
git checkout v1.9.4
|
||||||
|
CFLAGS="-fPIC" make -j12
|
||||||
|
test $? -eq 0 || { echo "Can't compile lz4"; exit 1; }
|
||||||
|
cd ..
|
||||||
|
# ./lib/liblz4.a
|
||||||
|
# ./lib
|
||||||
|
else
|
||||||
|
lz4Path=$(pwd)/lz4
|
||||||
|
echo "Using compiled lz4"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "libsodium" ]; then
|
||||||
|
export LIBSODIUM_FULL_BUILD=1
|
||||||
|
git clone https://github.com/jedisct1/libsodium.git
|
||||||
|
cd libsodium
|
||||||
|
sodiumPath=`pwd`
|
||||||
|
git checkout 1.0.18
|
||||||
|
./autogen.sh
|
||||||
|
./configure --with-pic --enable-static
|
||||||
|
make -j12
|
||||||
|
test $? -eq 0 || { echo "Can't compile libsodium"; exit 1; }
|
||||||
|
cd ..
|
||||||
|
else
|
||||||
|
sodiumPath=$(pwd)/libsodium
|
||||||
|
echo "Using compiled libsodium"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "openssl_3" ]; then
|
||||||
|
git clone https://github.com/openssl/openssl openssl_3
|
||||||
|
cd openssl_3
|
||||||
|
opensslPath=`pwd`
|
||||||
|
git checkout openssl-3.1.4
|
||||||
|
./config
|
||||||
|
make build_libs -j12
|
||||||
|
test $? -eq 0 || { echo "Can't compile openssl_3"; exit 1; }
|
||||||
|
cd ..
|
||||||
|
else
|
||||||
|
opensslPath=$(pwd)/openssl_3
|
||||||
|
echo "Using compiled openssl_3"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "zlib" ]; then
|
||||||
|
git clone https://github.com/madler/zlib.git
|
||||||
|
cd zlib
|
||||||
|
zlibPath=`pwd`
|
||||||
|
./configure --static
|
||||||
|
make -j12
|
||||||
|
test $? -eq 0 || { echo "Can't compile zlib"; exit 1; }
|
||||||
|
cd ..
|
||||||
|
else
|
||||||
|
zlibPath=$(pwd)/zlib
|
||||||
|
echo "Using compiled zlib"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "libmicrohttpd" ]; then
|
||||||
|
git clone https://git.gnunet.org/libmicrohttpd.git
|
||||||
|
cd libmicrohttpd
|
||||||
|
libmicrohttpdPath=`pwd`
|
||||||
|
./autogen.sh
|
||||||
|
./configure --enable-static --disable-tests --disable-benchmark --disable-shared --disable-https --with-pic
|
||||||
|
make -j12
|
||||||
|
test $? -eq 0 || { echo "Can't compile libmicrohttpd"; exit 1; }
|
||||||
|
cd ..
|
||||||
|
else
|
||||||
|
libmicrohttpdPath=$(pwd)/libmicrohttpd
|
||||||
|
echo "Using compiled libmicrohttpd"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cmake -GNinja .. \
|
||||||
|
-DPORTABLE=1 \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DOPENSSL_FOUND=1 \
|
||||||
|
-DOPENSSL_INCLUDE_DIR=$opensslPath/include \
|
||||||
|
-DOPENSSL_CRYPTO_LIBRARY=$opensslPath/libcrypto.a \
|
||||||
|
-DZLIB_FOUND=1 \
|
||||||
|
-DZLIB_INCLUDE_DIR=$zlibPath \
|
||||||
|
-DZLIB_LIBRARIES=$zlibPath/libz.a \
|
||||||
|
-DSODIUM_FOUND=1 \
|
||||||
|
-DSODIUM_INCLUDE_DIR=$sodiumPath/src/libsodium/include \
|
||||||
|
-DSODIUM_LIBRARY_RELEASE=$sodiumPath/src/libsodium/.libs/libsodium.a \
|
||||||
|
-DMHD_FOUND=1 \
|
||||||
|
-DMHD_INCLUDE_DIR=$libmicrohttpdPath/src/include \
|
||||||
|
-DMHD_LIBRARY=$libmicrohttpdPath/src/microhttpd/.libs/libmicrohttpd.a \
|
||||||
|
-DLZ4_FOUND=1 \
|
||||||
|
-DLZ4_INCLUDE_DIRS=$lz4Path/lib \
|
||||||
|
-DLZ4_LIBRARIES=$lz4Path/lib/liblz4.a
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
test $? -eq 0 || { echo "Can't configure ton"; exit 1; }
|
||||||
|
|
||||||
|
ninja tonlibjson emulator
|
||||||
|
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
mkdir artifacts
|
||||||
|
mv build/tonlib/libtonlibjson.so.0.5 build/tonlib/libtonlibjson.so
|
||||||
|
cp build/tonlib/libtonlibjson.so \
|
||||||
|
build/emulator/libemulator.so \
|
||||||
|
artifacts
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#/bin/bash
|
#/bin/bash
|
||||||
|
|
||||||
#sudo apt-get update
|
#sudo apt-get update
|
||||||
#sudo apt-get install -y build-essential git cmake ninja-build automake libtool texinfo autoconf
|
#sudo apt-get install -y build-essential git cmake ninja-build automake libtool texinfo autoconf libc++-dev libc++abi-dev
|
||||||
|
|
||||||
with_tests=false
|
with_tests=false
|
||||||
with_artifacts=false
|
with_artifacts=false
|
||||||
|
|
@ -24,26 +24,23 @@ else
|
||||||
rm -rf .ninja* CMakeCache.txt
|
rm -rf .ninja* CMakeCache.txt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export CC=$(which clang-16)
|
export CC=$(which clang)
|
||||||
export CXX=$(which clang++-16)
|
export CXX=$(which clang++)
|
||||||
export CCACHE_DISABLE=1
|
export CCACHE_DISABLE=1
|
||||||
|
|
||||||
|
if [ ! -d "lz4" ]; then
|
||||||
if [ ! -d "secp256k1" ]; then
|
git clone https://github.com/lz4/lz4.git
|
||||||
git clone https://github.com/bitcoin-core/secp256k1.git
|
cd lz4
|
||||||
cd secp256k1
|
lz4Path=`pwd`
|
||||||
secp256k1Path=`pwd`
|
git checkout v1.9.4
|
||||||
git checkout v0.3.2
|
CFLAGS="-fPIC" make -j12
|
||||||
./autogen.sh
|
test $? -eq 0 || { echo "Can't compile lz4"; exit 1; }
|
||||||
./configure --enable-module-recovery --enable-static --disable-tests --disable-benchmark --with-pic
|
|
||||||
make -j12
|
|
||||||
test $? -eq 0 || { echo "Can't compile secp256k1"; exit 1; }
|
|
||||||
cd ..
|
cd ..
|
||||||
# ./.libs/libsecp256k1.a
|
# ./lib/liblz4.a
|
||||||
# ./include
|
# ./lib
|
||||||
else
|
else
|
||||||
secp256k1Path=$(pwd)/secp256k1
|
lz4Path=$(pwd)/lz4
|
||||||
echo "Using compiled secp256k1"
|
echo "Using compiled lz4"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d "libsodium" ]; then
|
if [ ! -d "libsodium" ]; then
|
||||||
|
|
@ -67,7 +64,7 @@ if [ ! -d "openssl_3" ]; then
|
||||||
cd openssl_3
|
cd openssl_3
|
||||||
opensslPath=`pwd`
|
opensslPath=`pwd`
|
||||||
git checkout openssl-3.1.4
|
git checkout openssl-3.1.4
|
||||||
./config -static
|
./config
|
||||||
make build_libs -j12
|
make build_libs -j12
|
||||||
test $? -eq 0 || { echo "Can't compile openssl_3"; exit 1; }
|
test $? -eq 0 || { echo "Can't compile openssl_3"; exit 1; }
|
||||||
cd ..
|
cd ..
|
||||||
|
|
@ -112,58 +109,37 @@ cmake -GNinja .. \
|
||||||
-DZLIB_FOUND=1 \
|
-DZLIB_FOUND=1 \
|
||||||
-DZLIB_INCLUDE_DIR=$zlibPath \
|
-DZLIB_INCLUDE_DIR=$zlibPath \
|
||||||
-DZLIB_LIBRARIES=$zlibPath/libz.a \
|
-DZLIB_LIBRARIES=$zlibPath/libz.a \
|
||||||
-DSECP256K1_FOUND=1 \
|
|
||||||
-DSECP256K1_INCLUDE_DIR=$secp256k1Path/include \
|
|
||||||
-DSECP256K1_LIBRARY=$secp256k1Path/.libs/libsecp256k1.a \
|
|
||||||
-DSODIUM_FOUND=1 \
|
-DSODIUM_FOUND=1 \
|
||||||
-DSODIUM_INCLUDE_DIR=$sodiumPath/src/libsodium/include \
|
-DSODIUM_INCLUDE_DIR=$sodiumPath/src/libsodium/include \
|
||||||
-DSODIUM_LIBRARY_RELEASE=$sodiumPath/src/libsodium/.libs/libsodium.a \
|
-DSODIUM_LIBRARY_RELEASE=$sodiumPath/src/libsodium/.libs/libsodium.a \
|
||||||
-DMHD_FOUND=1 \
|
-DMHD_FOUND=1 \
|
||||||
-DMHD_INCLUDE_DIR=$libmicrohttpdPath/src/include \
|
-DMHD_INCLUDE_DIR=$libmicrohttpdPath/src/include \
|
||||||
-DMHD_LIBRARY=$libmicrohttpdPath/src/microhttpd/.libs/libmicrohttpd.a
|
-DMHD_LIBRARY=$libmicrohttpdPath/src/microhttpd/.libs/libmicrohttpd.a \
|
||||||
|
-DLZ4_FOUND=1 \
|
||||||
|
-DLZ4_INCLUDE_DIRS=$lz4Path/lib \
|
||||||
|
-DLZ4_LIBRARIES=$lz4Path/lib/liblz4.a
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
test $? -eq 0 || { echo "Can't configure ton"; exit 1; }
|
test $? -eq 0 || { echo "Can't configure ton"; exit 1; }
|
||||||
|
|
||||||
if [ "$with_tests" = true ]; then
|
if [ "$with_tests" = true ]; then
|
||||||
ninja storage-daemon storage-daemon-cli fift func tonlib tonlibjson tonlib-cli \
|
ninja storage-daemon storage-daemon-cli fift func tolk tonlib tonlibjson tonlib-cli \
|
||||||
validator-engine lite-client pow-miner validator-engine-console blockchain-explorer \
|
validator-engine lite-client pow-miner validator-engine-console blockchain-explorer \
|
||||||
generate-random-id json2tlo dht-server http-proxy rldp-http-proxy \
|
generate-random-id json2tlo dht-server http-proxy rldp-http-proxy \
|
||||||
adnl-proxy create-state emulator test-ed25519 test-ed25519-crypto test-bigint \
|
adnl-proxy create-state emulator test-ed25519 test-ed25519-crypto test-bigint \
|
||||||
test-vm test-fift test-cells test-smartcont test-net test-tdactor test-tdutils \
|
test-vm test-fift test-cells test-smartcont test-net test-tdactor test-tdutils \
|
||||||
test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain \
|
test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain \
|
||||||
test-fec test-tddb test-db test-validator-session-state
|
test-fec test-tddb test-db test-validator-session-state test-emulator proxy-liteserver
|
||||||
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
|
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
|
||||||
else
|
else
|
||||||
ninja storage-daemon storage-daemon-cli fift func tonlib tonlibjson tonlib-cli \
|
ninja storage-daemon storage-daemon-cli fift func tolk tonlib tonlibjson tonlib-cli \
|
||||||
validator-engine lite-client pow-miner validator-engine-console blockchain-explorer \
|
validator-engine lite-client pow-miner validator-engine-console blockchain-explorer \
|
||||||
generate-random-id json2tlo dht-server http-proxy rldp-http-proxy \
|
generate-random-id json2tlo dht-server http-proxy rldp-http-proxy \
|
||||||
adnl-proxy create-state emulator
|
adnl-proxy create-state emulator proxy-liteserver
|
||||||
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
|
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
strip -g storage/storage-daemon/storage-daemon \
|
|
||||||
storage/storage-daemon/storage-daemon-cli \
|
|
||||||
blockchain-explorer/blockchain-explorer \
|
|
||||||
crypto/fift \
|
|
||||||
crypto/tlbc \
|
|
||||||
crypto/func \
|
|
||||||
crypto/create-state \
|
|
||||||
validator-engine-console/validator-engine-console \
|
|
||||||
tonlib/tonlib-cli \
|
|
||||||
tonlib/libtonlibjson.so.0.5 \
|
|
||||||
http/http-proxy \
|
|
||||||
rldp-http-proxy/rldp-http-proxy \
|
|
||||||
dht-server/dht-server \
|
|
||||||
lite-client/lite-client \
|
|
||||||
validator-engine/validator-engine \
|
|
||||||
utils/generate-random-id \
|
|
||||||
utils/json2tlo \
|
|
||||||
adnl/adnl-proxy \
|
|
||||||
emulator/libemulator.*
|
|
||||||
|
|
||||||
test $? -eq 0 || { echo "Can't strip final binaries"; exit 1; }
|
|
||||||
|
|
||||||
# simple binaries' test
|
# simple binaries' test
|
||||||
./storage/storage-daemon/storage-daemon -V || exit 1
|
./storage/storage-daemon/storage-daemon -V || exit 1
|
||||||
./validator-engine/validator-engine -V || exit 1
|
./validator-engine/validator-engine -V || exit 1
|
||||||
|
|
@ -175,20 +151,18 @@ cd ..
|
||||||
if [ "$with_artifacts" = true ]; then
|
if [ "$with_artifacts" = true ]; then
|
||||||
rm -rf artifacts
|
rm -rf artifacts
|
||||||
mkdir artifacts
|
mkdir artifacts
|
||||||
cp crypto/fift/lib artifacts/
|
|
||||||
cp -R crypto/smartcont/ artifacts/
|
|
||||||
mv build/tonlib/libtonlibjson.so.0.5 build/tonlib/libtonlibjson.so
|
mv build/tonlib/libtonlibjson.so.0.5 build/tonlib/libtonlibjson.so
|
||||||
cp build/storage/storage-daemon/storage-daemon build/storage/storage-daemon/storage-daemon-cli \
|
cp build/storage/storage-daemon/storage-daemon build/storage/storage-daemon/storage-daemon-cli \
|
||||||
build/crypto/fift build/crypto/tlbc build/crypto/func build/crypto/create-state build/blockchain-explorer/blockchain-explorer \
|
build/crypto/fift build/crypto/tlbc build/crypto/func build/tolk/tolk build/crypto/create-state build/blockchain-explorer/blockchain-explorer \
|
||||||
build/validator-engine-console/validator-engine-console build/tonlib/tonlib-cli \
|
build/validator-engine-console/validator-engine-console build/tonlib/tonlib-cli build/utils/proxy-liteserver \
|
||||||
build/tonlib/libtonlibjson.so build/http/http-proxy build/rldp-http-proxy/rldp-http-proxy \
|
build/tonlib/libtonlibjson.so build/http/http-proxy build/rldp-http-proxy/rldp-http-proxy \
|
||||||
build/dht-server/dht-server build/lite-client/lite-client build/validator-engine/validator-engine \
|
build/dht-server/dht-server build/lite-client/lite-client build/validator-engine/validator-engine \
|
||||||
build/utils/generate-random-id build/utils/json2tlo build/adnl/adnl-proxy build/emulator/libemulator.so \
|
build/utils/generate-random-id build/utils/json2tlo build/adnl/adnl-proxy build/emulator/libemulator.so \
|
||||||
artifacts
|
artifacts
|
||||||
test $? -eq 0 || { echo "Can't copy final binaries"; exit 1; }
|
test $? -eq 0 || { echo "Can't copy final binaries"; exit 1; }
|
||||||
chmod +x artifacts/*
|
|
||||||
cp -R crypto/smartcont artifacts
|
cp -R crypto/smartcont artifacts
|
||||||
cp -R crypto/fift/lib artifacts
|
cp -R crypto/fift/lib artifacts
|
||||||
|
chmod -R +x artifacts/*
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$with_tests" = true ]; then
|
if [ "$with_tests" = true ]; then
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#/bin/bash
|
#/bin/bash
|
||||||
|
|
||||||
#sudo apt-get update
|
#sudo apt-get update
|
||||||
#sudo apt-get install -y build-essential git cmake ninja-build zlib1g-dev libsecp256k1-dev libmicrohttpd-dev libsodium-dev
|
#sudo apt-get install -y build-essential git cmake ninja-build zlib1g-dev libsecp256k1-dev libmicrohttpd-dev libsodium-dev liblz4-dev libjemalloc-dev
|
||||||
|
|
||||||
with_tests=false
|
with_tests=false
|
||||||
with_artifacts=false
|
with_artifacts=false
|
||||||
|
|
@ -42,7 +42,7 @@ else
|
||||||
echo "Using compiled openssl_3"
|
echo "Using compiled openssl_3"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cmake -GNinja .. \
|
cmake -GNinja -DTON_USE_JEMALLOC=ON .. \
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
-DOPENSSL_ROOT_DIR=$opensslPath \
|
-DOPENSSL_ROOT_DIR=$opensslPath \
|
||||||
-DOPENSSL_INCLUDE_DIR=$opensslPath/include \
|
-DOPENSSL_INCLUDE_DIR=$opensslPath/include \
|
||||||
|
|
@ -52,50 +52,30 @@ cmake -GNinja .. \
|
||||||
test $? -eq 0 || { echo "Can't configure ton"; exit 1; }
|
test $? -eq 0 || { echo "Can't configure ton"; exit 1; }
|
||||||
|
|
||||||
if [ "$with_tests" = true ]; then
|
if [ "$with_tests" = true ]; then
|
||||||
ninja storage-daemon storage-daemon-cli fift func tonlib tonlibjson tonlib-cli \
|
ninja storage-daemon storage-daemon-cli fift func tolk tonlib tonlibjson tonlib-cli \
|
||||||
validator-engine lite-client pow-miner validator-engine-console blockchain-explorer \
|
validator-engine lite-client pow-miner validator-engine-console blockchain-explorer \
|
||||||
generate-random-id json2tlo dht-server http-proxy rldp-http-proxy \
|
generate-random-id json2tlo dht-server http-proxy rldp-http-proxy \
|
||||||
adnl-proxy create-state emulator test-ed25519 test-ed25519-crypto test-bigint \
|
adnl-proxy create-state emulator test-ed25519 test-ed25519-crypto test-bigint \
|
||||||
test-vm test-fift test-cells test-smartcont test-net test-tdactor test-tdutils \
|
test-vm test-fift test-cells test-smartcont test-net test-tdactor test-tdutils \
|
||||||
test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain \
|
test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain \
|
||||||
test-fec test-tddb test-db test-validator-session-state
|
test-fec test-tddb test-db test-validator-session-state test-emulator proxy-liteserver
|
||||||
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
|
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
|
||||||
else
|
else
|
||||||
ninja storage-daemon storage-daemon-cli fift func tonlib tonlibjson tonlib-cli \
|
ninja storage-daemon storage-daemon-cli fift func tolk tonlib tonlibjson tonlib-cli \
|
||||||
validator-engine lite-client pow-miner validator-engine-console blockchain-explorer \
|
validator-engine lite-client pow-miner validator-engine-console blockchain-explorer \
|
||||||
generate-random-id json2tlo dht-server http-proxy rldp-http-proxy \
|
generate-random-id json2tlo dht-server http-proxy rldp-http-proxy \
|
||||||
adnl-proxy create-state emulator
|
adnl-proxy create-state emulator proxy-liteserver
|
||||||
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
|
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
strip -g storage/storage-daemon/storage-daemon \
|
|
||||||
storage/storage-daemon/storage-daemon-cli \
|
|
||||||
blockchain-explorer/blockchain-explorer \
|
|
||||||
crypto/fift \
|
|
||||||
crypto/tlbc \
|
|
||||||
crypto/func \
|
|
||||||
crypto/create-state \
|
|
||||||
validator-engine-console/validator-engine-console \
|
|
||||||
tonlib/tonlib-cli \
|
|
||||||
tonlib/libtonlibjson.so.0.5 \
|
|
||||||
http/http-proxy \
|
|
||||||
rldp-http-proxy/rldp-http-proxy \
|
|
||||||
dht-server/dht-server \
|
|
||||||
lite-client/lite-client \
|
|
||||||
validator-engine/validator-engine \
|
|
||||||
utils/generate-random-id \
|
|
||||||
utils/json2tlo \
|
|
||||||
adnl/adnl-proxy \
|
|
||||||
emulator/libemulator.*
|
|
||||||
|
|
||||||
test $? -eq 0 || { echo "Can't strip final binaries"; exit 1; }
|
|
||||||
|
|
||||||
# simple binaries' test
|
# simple binaries' test
|
||||||
./storage/storage-daemon/storage-daemon -V || exit 1
|
./storage/storage-daemon/storage-daemon -V || exit 1
|
||||||
./validator-engine/validator-engine -V || exit 1
|
./validator-engine/validator-engine -V || exit 1
|
||||||
./lite-client/lite-client -V || exit 1
|
./lite-client/lite-client -V || exit 1
|
||||||
./crypto/fift -V || exit 1
|
./crypto/fift -V || exit 1
|
||||||
|
|
||||||
|
ldd ./validator-engine/validator-engine || exit 1
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
if [ "$with_artifacts" = true ]; then
|
if [ "$with_artifacts" = true ]; then
|
||||||
|
|
@ -103,20 +83,20 @@ if [ "$with_artifacts" = true ]; then
|
||||||
mkdir artifacts
|
mkdir artifacts
|
||||||
mv build/tonlib/libtonlibjson.so.0.5 build/tonlib/libtonlibjson.so
|
mv build/tonlib/libtonlibjson.so.0.5 build/tonlib/libtonlibjson.so
|
||||||
cp build/storage/storage-daemon/storage-daemon build/storage/storage-daemon/storage-daemon-cli \
|
cp build/storage/storage-daemon/storage-daemon build/storage/storage-daemon/storage-daemon-cli \
|
||||||
build/crypto/fift build/crypto/tlbc build/crypto/func build/crypto/create-state build/blockchain-explorer/blockchain-explorer \
|
build/crypto/fift build/crypto/tlbc build/crypto/func build/tolk/tolk build/crypto/create-state build/blockchain-explorer/blockchain-explorer \
|
||||||
build/validator-engine-console/validator-engine-console build/tonlib/tonlib-cli \
|
build/validator-engine-console/validator-engine-console build/tonlib/tonlib-cli build/utils/proxy-liteserver \
|
||||||
build/tonlib/libtonlibjson.so build/http/http-proxy build/rldp-http-proxy/rldp-http-proxy \
|
build/tonlib/libtonlibjson.so build/http/http-proxy build/rldp-http-proxy/rldp-http-proxy \
|
||||||
build/dht-server/dht-server build/lite-client/lite-client build/validator-engine/validator-engine \
|
build/dht-server/dht-server build/lite-client/lite-client build/validator-engine/validator-engine \
|
||||||
build/utils/generate-random-id build/utils/json2tlo build/adnl/adnl-proxy build/emulator/libemulator.so \
|
build/utils/generate-random-id build/utils/json2tlo build/adnl/adnl-proxy build/emulator/libemulator.so \
|
||||||
artifacts
|
artifacts
|
||||||
test $? -eq 0 || { echo "Can't copy final binaries"; exit 1; }
|
test $? -eq 0 || { echo "Can't copy final binaries"; exit 1; }
|
||||||
chmod +x artifacts/*
|
|
||||||
cp -R crypto/smartcont artifacts
|
cp -R crypto/smartcont artifacts
|
||||||
cp -R crypto/fift/lib artifacts
|
cp -R crypto/fift/lib artifacts
|
||||||
|
chmod -R +x artifacts/*
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$with_tests" = true ]; then
|
if [ "$with_tests" = true ]; then
|
||||||
cd build
|
cd build
|
||||||
# ctest --output-on-failure -E "test-catchain|test-actors|test-smartcont|test-adnl|test-validator-session-state|test-dht|test-rldp"
|
# ctest --output-on-failure -E "test-catchain|test-actors|test-smartcont|test-adnl|test-validator-session-state|test-dht|test-rldp"
|
||||||
ctest --output-on-failure --timeout 1800
|
ctest --output-on-failure --timeout 1800
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
208
assembly/native/build-windows-2019.bat
Normal file
208
assembly/native/build-windows-2019.bat
Normal file
|
|
@ -0,0 +1,208 @@
|
||||||
|
REM execute this script inside elevated (Run as Administrator) console "x64 Native Tools Command Prompt for VS 2019"
|
||||||
|
|
||||||
|
echo off
|
||||||
|
|
||||||
|
echo Installing chocolatey windows package manager...
|
||||||
|
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
|
||||||
|
choco -?
|
||||||
|
IF %errorlevel% NEQ 0 (
|
||||||
|
echo Can't install chocolatey
|
||||||
|
exit /b %errorlevel%
|
||||||
|
)
|
||||||
|
|
||||||
|
choco feature enable -n allowEmptyChecksums
|
||||||
|
|
||||||
|
echo Installing pkgconfiglite...
|
||||||
|
choco install -y pkgconfiglite
|
||||||
|
IF %errorlevel% NEQ 0 (
|
||||||
|
echo Can't install pkgconfiglite
|
||||||
|
exit /b %errorlevel%
|
||||||
|
)
|
||||||
|
|
||||||
|
echo Installing ninja...
|
||||||
|
choco install -y ninja
|
||||||
|
IF %errorlevel% NEQ 0 (
|
||||||
|
echo Can't install ninja
|
||||||
|
exit /b %errorlevel%
|
||||||
|
)
|
||||||
|
|
||||||
|
echo Installing nasm...
|
||||||
|
choco install -y nasm
|
||||||
|
where nasm
|
||||||
|
SET PATH=%PATH%;C:\Program Files\NASM
|
||||||
|
IF %errorlevel% NEQ 0 (
|
||||||
|
echo Can't install nasm
|
||||||
|
exit /b %errorlevel%
|
||||||
|
)
|
||||||
|
|
||||||
|
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 (
|
||||||
|
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
|
||||||
|
cd ..\..\..\..
|
||||||
|
) else (
|
||||||
|
echo Using lz4...
|
||||||
|
)
|
||||||
|
|
||||||
|
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 libsodium...
|
||||||
|
)
|
||||||
|
|
||||||
|
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 openssl...
|
||||||
|
)
|
||||||
|
|
||||||
|
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 libmicrohttpd...
|
||||||
|
)
|
||||||
|
|
||||||
|
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=%third_libs%\lz4\lib ^
|
||||||
|
-DLZ4_LIBRARIES=%third_libs%\lz4\build\VS2017\liblz4\bin\x64_Release\liblz4_static.lib ^
|
||||||
|
-DMHD_FOUND=1 ^
|
||||||
|
-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=%third_libs%\zlib ^
|
||||||
|
-DZLIB_LIBRARIES=%third_libs%\zlib\contrib\vstudio\vc14\x64\ZlibStatReleaseWithoutAsm\zlibstat.lib ^
|
||||||
|
-DOPENSSL_FOUND=1 ^
|
||||||
|
-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%
|
||||||
|
)
|
||||||
|
|
||||||
|
IF "%1"=="-t" (
|
||||||
|
ninja storage-daemon storage-daemon-cli blockchain-explorer fift func tolk tonlib tonlibjson ^
|
||||||
|
tonlib-cli validator-engine lite-client pow-miner validator-engine-console generate-random-id ^
|
||||||
|
json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork emulator ^
|
||||||
|
test-ed25519 test-ed25519-crypto test-bigint test-vm test-fift test-cells test-smartcont test-net ^
|
||||||
|
test-tdactor test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain ^
|
||||||
|
test-fec test-tddb test-db test-validator-session-state test-emulator proxy-liteserver
|
||||||
|
IF %errorlevel% NEQ 0 (
|
||||||
|
echo Can't compile TON
|
||||||
|
exit /b %errorlevel%
|
||||||
|
)
|
||||||
|
) else (
|
||||||
|
ninja storage-daemon storage-daemon-cli blockchain-explorer fift func tolk tonlib tonlibjson ^
|
||||||
|
tonlib-cli validator-engine lite-client pow-miner validator-engine-console generate-random-id ^
|
||||||
|
json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork emulator proxy-liteserver
|
||||||
|
IF %errorlevel% NEQ 0 (
|
||||||
|
echo Can't compile TON
|
||||||
|
exit /b %errorlevel%
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
copy validator-engine\validator-engine.exe test
|
||||||
|
IF %errorlevel% NEQ 0 (
|
||||||
|
echo validator-engine.exe does not exist
|
||||||
|
exit /b %errorlevel%
|
||||||
|
)
|
||||||
|
|
||||||
|
IF "%1"=="-t" (
|
||||||
|
echo Running tests...
|
||||||
|
REM ctest -C Release --output-on-failure -E "test-catchain|test-actors|test-validator-session-state"
|
||||||
|
ctest -C Release --output-on-failure -E "test-bigint" --timeout 1800
|
||||||
|
IF %errorlevel% NEQ 0 (
|
||||||
|
echo Some tests failed
|
||||||
|
exit /b %errorlevel%
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
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 (
|
||||||
|
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
|
||||||
2
assembly/native/build-windows-github-2019.bat
Normal file
2
assembly/native/build-windows-github-2019.bat
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\%1\VC\Auxiliary\Build\vcvars64.bat"
|
||||||
|
call build-windows-2019.bat -t
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
call "C:\Program Files\Microsoft Visual Studio\2022\%1\VC\Auxiliary\Build\vcvars64.bat"
|
call "C:\Program Files\Microsoft Visual Studio\2022\%1\VC\Auxiliary\Build\vcvars64.bat"
|
||||||
call build-windows.bat -t
|
call build-windows.bat -t
|
||||||
|
|
|
||||||
|
|
@ -14,141 +14,149 @@ choco feature enable -n allowEmptyChecksums
|
||||||
|
|
||||||
echo Installing pkgconfiglite...
|
echo Installing pkgconfiglite...
|
||||||
choco install -y pkgconfiglite
|
choco install -y pkgconfiglite
|
||||||
IF errorlevel 1 (
|
IF %errorlevel% NEQ 0 (
|
||||||
echo Can't install pkgconfiglite
|
echo Can't install pkgconfiglite
|
||||||
exit /b %errorlevel%
|
exit /b %errorlevel%
|
||||||
)
|
)
|
||||||
|
|
||||||
echo Installing ninja...
|
echo Installing ninja...
|
||||||
choco install -y ninja
|
choco install -y ninja
|
||||||
IF errorlevel 1 (
|
IF %errorlevel% NEQ 0 (
|
||||||
echo Can't install ninja
|
echo Can't install ninja
|
||||||
exit /b %errorlevel%
|
exit /b %errorlevel%
|
||||||
)
|
)
|
||||||
|
|
||||||
|
echo Installing nasm...
|
||||||
|
choco install -y nasm
|
||||||
|
where nasm
|
||||||
|
SET PATH=%PATH%;C:\Program Files\NASM
|
||||||
|
IF %errorlevel% NEQ 0 (
|
||||||
|
echo Can't install nasm
|
||||||
|
exit /b %errorlevel%
|
||||||
|
)
|
||||||
|
|
||||||
|
mkdir third_libs
|
||||||
|
cd third_libs
|
||||||
|
|
||||||
|
set third_libs=%cd%
|
||||||
|
echo %third_libs%
|
||||||
|
|
||||||
if not exist "zlib" (
|
if not exist "zlib" (
|
||||||
git clone https://github.com/madler/zlib.git
|
git clone https://github.com/madler/zlib.git
|
||||||
cd zlib\contrib\vstudio\vc14
|
cd zlib
|
||||||
msbuild zlibstat.vcxproj /p:Configuration=ReleaseWithoutAsm /p:platform=x64 -p:PlatformToolset=v143
|
git checkout v1.3.1
|
||||||
|
cd contrib\vstudio\vc14
|
||||||
IF errorlevel 1 (
|
msbuild zlibstat.vcxproj /p:Configuration=ReleaseWithoutAsm /p:platform=x64 -p:PlatformToolset=v143
|
||||||
echo Can't install zlib
|
cd ..\..\..\..
|
||||||
exit /b %errorlevel%
|
|
||||||
)
|
|
||||||
cd ..\..\..\..
|
|
||||||
) else (
|
) else (
|
||||||
echo Using zlib...
|
echo Using zlib...
|
||||||
)
|
)
|
||||||
|
|
||||||
if not exist "secp256k1" (
|
if not exist "lz4" (
|
||||||
git clone https://github.com/libbitcoin/secp256k1.git
|
git clone https://github.com/lz4/lz4.git
|
||||||
cd secp256k1\builds\msvc\vs2017
|
cd lz4
|
||||||
msbuild /p:Configuration=StaticRelease -p:PlatformToolset=v143 -p:Platform=x64
|
git checkout v1.9.4
|
||||||
IF errorlevel 1 (
|
cd build\VS2022\liblz4
|
||||||
echo Can't install secp256k1
|
msbuild liblz4.vcxproj /p:Configuration=Release /p:platform=x64 -p:PlatformToolset=v143
|
||||||
exit /b %errorlevel%
|
cd ..\..\..\..
|
||||||
)
|
|
||||||
cd ..\..\..\..
|
|
||||||
) else (
|
) else (
|
||||||
echo Using secp256k1...
|
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 1 (
|
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 1 (
|
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 1 (
|
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 1 (
|
|
||||||
echo Can't download readline
|
|
||||||
exit /b %errorlevel%
|
|
||||||
)
|
|
||||||
unzip -q -d readline-5.0-1-lib readline-5.0-1-lib.zip
|
|
||||||
) else (
|
|
||||||
echo Using readline...
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
set root=%cd%
|
|
||||||
echo %root%
|
|
||||||
set SODIUM_DIR=%root%\libsodium
|
|
||||||
|
|
||||||
mkdir build
|
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 ^
|
||||||
-DSECP256K1_FOUND=1 ^
|
-DSODIUM_LIBRARY_RELEASE=%third_libs%\libsodium\Build\Release\x64\libsodium.lib ^
|
||||||
-DSECP256K1_INCLUDE_DIR=%root%\secp256k1\include ^
|
-DSODIUM_LIBRARY_DEBUG=%third_libs%\libsodium\Build\Release\x64\libsodium.lib ^
|
||||||
-DSECP256K1_LIBRARY=%root%\secp256k1\bin\x64\Release\v143\static\secp256k1.lib ^
|
-DSODIUM_INCLUDE_DIR=%third_libs%\libsodium\src\libsodium\include ^
|
||||||
|
-DLZ4_FOUND=1 ^
|
||||||
|
-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_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 ^
|
||||||
-DCMAKE_CXX_FLAGS="/DTD_WINDOWS=1 /EHsc /bigobj" ..
|
-DCMAKE_CXX_FLAGS="/DTD_WINDOWS=1 /EHsc /bigobj" ..
|
||||||
IF errorlevel 1 (
|
|
||||||
|
IF %errorlevel% NEQ 0 (
|
||||||
echo Can't configure TON
|
echo Can't configure TON
|
||||||
exit /b %errorlevel%
|
exit /b %errorlevel%
|
||||||
)
|
)
|
||||||
|
|
||||||
IF "%1"=="-t" (
|
IF "%1"=="-t" (
|
||||||
ninja storage-daemon storage-daemon-cli blockchain-explorer fift func tonlib tonlibjson ^
|
ninja storage-daemon storage-daemon-cli blockchain-explorer fift func tolk tonlib tonlibjson ^
|
||||||
tonlib-cli validator-engine lite-client pow-miner validator-engine-console generate-random-id ^
|
tonlib-cli validator-engine lite-client pow-miner validator-engine-console generate-random-id ^
|
||||||
json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork emulator ^
|
json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork emulator ^
|
||||||
test-ed25519 test-ed25519-crypto test-bigint test-vm test-fift test-cells test-smartcont test-net ^
|
test-ed25519 test-ed25519-crypto test-bigint test-vm test-fift test-cells test-smartcont test-net ^
|
||||||
test-tdactor test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain ^
|
test-tdactor test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain ^
|
||||||
test-fec test-tddb test-db test-validator-session-state
|
test-fec test-tddb test-db test-validator-session-state test-emulator proxy-liteserver
|
||||||
IF errorlevel 1 (
|
IF %errorlevel% NEQ 0 (
|
||||||
echo Can't compile TON
|
echo Can't compile TON
|
||||||
exit /b %errorlevel%
|
exit /b %errorlevel%
|
||||||
)
|
)
|
||||||
) else (
|
) else (
|
||||||
ninja storage-daemon storage-daemon-cli blockchain-explorer fift func tonlib tonlibjson ^
|
ninja storage-daemon storage-daemon-cli blockchain-explorer fift func tolk tonlib tonlibjson ^
|
||||||
tonlib-cli validator-engine lite-client pow-miner validator-engine-console generate-random-id ^
|
tonlib-cli validator-engine lite-client pow-miner validator-engine-console generate-random-id ^
|
||||||
json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork emulator
|
json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork emulator proxy-liteserver
|
||||||
IF errorlevel 1 (
|
IF %errorlevel% NEQ 0 (
|
||||||
echo Can't compile TON
|
echo Can't compile TON
|
||||||
exit /b %errorlevel%
|
exit /b %errorlevel%
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
copy validator-engine\validator-engine.exe test
|
copy validator-engine\validator-engine.exe test
|
||||||
IF errorlevel 1 (
|
IF %errorlevel% NEQ 0 (
|
||||||
echo validator-engine.exe does not exist
|
echo validator-engine.exe does not exist
|
||||||
exit /b %errorlevel%
|
exit /b %errorlevel%
|
||||||
)
|
)
|
||||||
|
|
@ -156,38 +164,45 @@ IF errorlevel 1 (
|
||||||
IF "%1"=="-t" (
|
IF "%1"=="-t" (
|
||||||
echo Running tests...
|
echo Running tests...
|
||||||
REM ctest -C Release --output-on-failure -E "test-catchain|test-actors|test-validator-session-state"
|
REM ctest -C Release --output-on-failure -E "test-catchain|test-actors|test-validator-session-state"
|
||||||
ctest -C Release --output-on-failure --timeout 1800
|
ctest -C Release --output-on-failure -E "test-bigint" --timeout 1800
|
||||||
IF errorlevel 1 (
|
IF %errorlevel% NEQ 0 (
|
||||||
echo Some tests failed
|
echo Some tests failed
|
||||||
exit /b %errorlevel%
|
exit /b %errorlevel%
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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\crypto\create-state.exe ^
|
build\tolk\tolk.exe ^
|
||||||
build\validator-engine-console\validator-engine-console.exe ^
|
build\crypto\create-state.exe ^
|
||||||
build\tonlib\tonlib-cli.exe ^
|
build\validator-engine-console\validator-engine-console.exe ^
|
||||||
build\tonlib\tonlibjson.dll ^
|
build\tonlib\tonlib-cli.exe ^
|
||||||
build\http\http-proxy.exe ^
|
build\tonlib\tonlibjson.dll ^
|
||||||
build\rldp-http-proxy\rldp-http-proxy.exe ^
|
build\http\http-proxy.exe ^
|
||||||
build\dht-server\dht-server.exe ^
|
build\rldp-http-proxy\rldp-http-proxy.exe ^
|
||||||
build\lite-client\lite-client.exe ^
|
build\dht-server\dht-server.exe ^
|
||||||
build\validator-engine\validator-engine.exe ^
|
build\lite-client\lite-client.exe ^
|
||||||
build\utils\generate-random-id.exe ^
|
build\validator-engine\validator-engine.exe ^
|
||||||
build\utils\json2tlo.exe ^
|
build\utils\generate-random-id.exe ^
|
||||||
build\adnl\adnl-proxy.exe ^
|
build\utils\json2tlo.exe ^
|
||||||
build\emulator\emulator.dll) do (strip -g %%I & copy %%I artifacts\)
|
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\smartcont artifacts\smartcont
|
||||||
xcopy /e /k /h /i crypto\fift\lib artifacts\lib
|
xcopy /e /k /h /i crypto\fift\lib artifacts\lib
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,6 @@ while getopts 't' flag; do
|
||||||
done
|
done
|
||||||
|
|
||||||
cp assembly/nix/linux-arm64* .
|
cp assembly/nix/linux-arm64* .
|
||||||
cp assembly/nix/microhttpd.nix .
|
|
||||||
cp assembly/nix/openssl.nix .
|
|
||||||
export NIX_PATH=nixpkgs=https://github.com/nixOS/nixpkgs/archive/23.05.tar.gz
|
export NIX_PATH=nixpkgs=https://github.com/nixOS/nixpkgs/archive/23.05.tar.gz
|
||||||
|
|
||||||
if [ "$with_tests" = true ]; then
|
if [ "$with_tests" = true ]; then
|
||||||
|
|
@ -24,12 +22,17 @@ if [ "$with_tests" = true ]; then
|
||||||
else
|
else
|
||||||
nix-build linux-arm64-static.nix
|
nix-build linux-arm64-static.nix
|
||||||
fi
|
fi
|
||||||
mkdir artifacts
|
|
||||||
|
mkdir -p artifacts/lib
|
||||||
cp ./result/bin/* artifacts/
|
cp ./result/bin/* artifacts/
|
||||||
|
test $? -eq 0 || { echo "No artifacts have been built..."; exit 1; }
|
||||||
chmod +x artifacts/*
|
chmod +x artifacts/*
|
||||||
rm -rf result
|
rm -rf result
|
||||||
|
|
||||||
nix-build linux-arm64-tonlib.nix
|
nix-build linux-arm64-tonlib.nix
|
||||||
|
|
||||||
cp ./result/lib/libtonlibjson.so.0.5 artifacts/libtonlibjson.so
|
cp ./result/lib/libtonlibjson.so.0.5 artifacts/libtonlibjson.so
|
||||||
cp ./result/lib/libemulator.so artifacts/
|
cp ./result/lib/libemulator.so artifacts/
|
||||||
cp -r crypto/fift/lib artifacts/
|
cp ./result/lib/fift/* artifacts/lib/
|
||||||
cp -r crypto/smartcont artifacts/
|
cp -r ./result/share/ton/smartcont artifacts/
|
||||||
|
chmod -R +x artifacts
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,6 @@ while getopts 't' flag; do
|
||||||
done
|
done
|
||||||
|
|
||||||
cp assembly/nix/linux-x86-64* .
|
cp assembly/nix/linux-x86-64* .
|
||||||
cp assembly/nix/microhttpd.nix .
|
|
||||||
cp assembly/nix/openssl.nix .
|
|
||||||
export NIX_PATH=nixpkgs=https://github.com/nixOS/nixpkgs/archive/23.05.tar.gz
|
export NIX_PATH=nixpkgs=https://github.com/nixOS/nixpkgs/archive/23.05.tar.gz
|
||||||
|
|
||||||
if [ "$with_tests" = true ]; then
|
if [ "$with_tests" = true ]; then
|
||||||
|
|
@ -25,12 +23,16 @@ else
|
||||||
nix-build linux-x86-64-static.nix
|
nix-build linux-x86-64-static.nix
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir artifacts
|
mkdir -p artifacts/lib
|
||||||
cp ./result/bin/* artifacts/
|
cp ./result/bin/* artifacts/
|
||||||
|
test $? -eq 0 || { echo "No artifacts have been built..."; exit 1; }
|
||||||
chmod +x artifacts/*
|
chmod +x artifacts/*
|
||||||
rm -rf result
|
rm -rf result
|
||||||
|
|
||||||
nix-build linux-x86-64-tonlib.nix
|
nix-build linux-x86-64-tonlib.nix
|
||||||
|
|
||||||
cp ./result/lib/libtonlibjson.so.0.5 artifacts/libtonlibjson.so
|
cp ./result/lib/libtonlibjson.so.0.5 artifacts/libtonlibjson.so
|
||||||
cp ./result/lib/libemulator.so artifacts/
|
cp ./result/lib/libemulator.so artifacts/
|
||||||
cp -r crypto/fift/lib artifacts/
|
cp ./result/lib/fift/* artifacts/lib/
|
||||||
cp -r crypto/smartcont artifacts/
|
cp -r ./result/share/ton/smartcont artifacts/
|
||||||
|
chmod -R +x artifacts
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,17 @@ if [ "$with_tests" = true ]; then
|
||||||
else
|
else
|
||||||
nix-build macos-static.nix
|
nix-build macos-static.nix
|
||||||
fi
|
fi
|
||||||
mkdir artifacts
|
|
||||||
|
mkdir -p artifacts/lib
|
||||||
cp ./result-bin/bin/* artifacts/
|
cp ./result-bin/bin/* artifacts/
|
||||||
|
test $? -eq 0 || { echo "No artifacts have been built..."; exit 1; }
|
||||||
chmod +x artifacts/*
|
chmod +x artifacts/*
|
||||||
rm -rf result-bin
|
rm -rf result-bin
|
||||||
|
|
||||||
nix-build macos-tonlib.nix
|
nix-build macos-tonlib.nix
|
||||||
|
|
||||||
cp ./result/lib/libtonlibjson.dylib artifacts/
|
cp ./result/lib/libtonlibjson.dylib artifacts/
|
||||||
cp ./result/lib/libemulator.dylib artifacts/
|
cp ./result/lib/libemulator.dylib artifacts/
|
||||||
cp -r crypto/fift/lib artifacts/
|
cp ./result/lib/fift/* artifacts/lib/
|
||||||
cp -r crypto/smartcont artifacts/
|
cp -r ./result/share/ton/smartcont artifacts/
|
||||||
|
chmod -R +x artifacts
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,23 @@
|
||||||
, testing ? false
|
, testing ? false
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
microhttpdmy = (import ./microhttpd.nix) {};
|
staticOptions = pkg: pkg.overrideAttrs(oldAttrs: {
|
||||||
|
dontDisableStatic = true;
|
||||||
|
enableSharedExecutables = false;
|
||||||
|
configureFlags = (oldAttrs.configureFlags or []) ++ [ "--without-shared" "--disable-shared" "--disable-tests" ];
|
||||||
|
});
|
||||||
|
|
||||||
|
secp256k1Static = (staticOptions pkgs.secp256k1);
|
||||||
|
libsodiumStatic = (staticOptions pkgs.libsodium);
|
||||||
|
jemallocStatic = (staticOptions pkgs.jemalloc);
|
||||||
|
|
||||||
|
microhttpdStatic = pkgs.libmicrohttpd.overrideAttrs(oldAttrs: {
|
||||||
|
dontDisableStatic = true;
|
||||||
|
enableSharedExecutables = false;
|
||||||
|
configureFlags = (oldAttrs.configureFlags or []) ++ [ "--enable-static" "--disable-tests" "--disable-benchmark" "--disable-shared" "--disable-https" "--with-pic" ];
|
||||||
|
});
|
||||||
|
|
||||||
in
|
in
|
||||||
with import microhttpdmy;
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
pname = "ton";
|
pname = "ton";
|
||||||
version = "dev-bin";
|
version = "dev-bin";
|
||||||
|
|
@ -16,31 +30,33 @@ stdenv.mkDerivation {
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
nativeBuildInputs = with pkgs;
|
nativeBuildInputs = with pkgs;
|
||||||
[
|
[ cmake ninja git pkg-config ];
|
||||||
cmake ninja git pkg-config
|
|
||||||
];
|
|
||||||
|
|
||||||
buildInputs = with pkgs;
|
buildInputs = with pkgs;
|
||||||
[
|
[
|
||||||
pkgsStatic.openssl microhttpdmy pkgsStatic.zlib pkgsStatic.libsodium.dev pkgsStatic.secp256k1 glibc.static
|
(openssl.override { static = true; }).dev
|
||||||
|
microhttpdStatic.dev
|
||||||
|
(zlib.override { shared = false; }).dev
|
||||||
|
(lz4.override { enableStatic = true; enableShared = false; }).dev
|
||||||
|
jemallocStatic
|
||||||
|
secp256k1Static
|
||||||
|
libsodiumStatic.dev
|
||||||
|
glibc.static
|
||||||
];
|
];
|
||||||
|
|
||||||
makeStatic = true;
|
|
||||||
doCheck = testing;
|
|
||||||
|
|
||||||
cmakeFlags = [
|
cmakeFlags = [
|
||||||
"-DTON_USE_ABSEIL=OFF"
|
"-DTON_USE_ABSEIL=OFF"
|
||||||
"-DNIX=ON"
|
"-DNIX=ON"
|
||||||
"-DBUILD_SHARED_LIBS=OFF"
|
"-DBUILD_SHARED_LIBS=OFF"
|
||||||
"-DCMAKE_LINK_SEARCH_START_STATIC=ON"
|
"-DCMAKE_LINK_SEARCH_START_STATIC=ON"
|
||||||
"-DCMAKE_LINK_SEARCH_END_STATIC=ON"
|
"-DCMAKE_LINK_SEARCH_END_STATIC=ON"
|
||||||
"-DMHD_FOUND=1"
|
"-DTON_USE_JEMALLOC=ON"
|
||||||
"-DMHD_INCLUDE_DIR=${microhttpdmy}/usr/local/include"
|
|
||||||
"-DMHD_LIBRARY=${microhttpdmy}/usr/local/lib/libmicrohttpd.a"
|
|
||||||
"-DCMAKE_CTEST_ARGUMENTS=--timeout;1800"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
makeStatic = true;
|
||||||
|
doCheck = testing;
|
||||||
|
|
||||||
LDFLAGS = [
|
LDFLAGS = [
|
||||||
"-static-libgcc" "-static-libstdc++" "-static"
|
"-static-libgcc" "-static-libstdc++" "-static"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,21 @@
|
||||||
, stdenv ? pkgs.stdenv
|
, stdenv ? pkgs.stdenv
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
microhttpdmy = (import ./microhttpd.nix) {};
|
staticOptions = pkg: pkg.overrideAttrs(oldAttrs: {
|
||||||
|
dontDisableStatic = true;
|
||||||
|
enableSharedExecutables = false;
|
||||||
|
configureFlags = (oldAttrs.configureFlags or []) ++ [ "--without-shared" "--disable-shared" "--disable-tests" ];
|
||||||
|
});
|
||||||
|
|
||||||
|
secp256k1Static = (staticOptions pkgs.secp256k1);
|
||||||
|
libsodiumStatic = (staticOptions pkgs.libsodium);
|
||||||
|
|
||||||
|
microhttpdStatic = pkgs.libmicrohttpd.overrideAttrs(oldAttrs: {
|
||||||
|
dontDisableStatic = true;
|
||||||
|
enableSharedExecutables = false;
|
||||||
|
configureFlags = (oldAttrs.configureFlags or []) ++ [ "--enable-static" "--disable-tests" "--disable-benchmark" "--disable-shared" "--disable-https" "--with-pic" ];
|
||||||
|
});
|
||||||
in
|
in
|
||||||
with import microhttpdmy;
|
|
||||||
pkgs.llvmPackages_16.stdenv.mkDerivation {
|
pkgs.llvmPackages_16.stdenv.mkDerivation {
|
||||||
pname = "ton";
|
pname = "ton";
|
||||||
version = "dev-lib";
|
version = "dev-lib";
|
||||||
|
|
@ -21,17 +33,22 @@ pkgs.llvmPackages_16.stdenv.mkDerivation {
|
||||||
|
|
||||||
buildInputs = with pkgs;
|
buildInputs = with pkgs;
|
||||||
[
|
[
|
||||||
pkgsStatic.openssl microhttpdmy pkgsStatic.zlib pkgsStatic.libsodium.dev pkgsStatic.secp256k1
|
(openssl.override { static = true; }).dev
|
||||||
|
microhttpdStatic.dev
|
||||||
|
(zlib.override { shared = false; }).dev
|
||||||
|
(lz4.override { enableStatic = true; enableShared = false; }).dev
|
||||||
|
secp256k1Static
|
||||||
|
libsodiumStatic.dev
|
||||||
];
|
];
|
||||||
|
|
||||||
dontAddStaticConfigureFlags = false;
|
dontAddStaticConfigureFlags = false;
|
||||||
|
doCheck = false;
|
||||||
|
doInstallCheck = false;
|
||||||
|
|
||||||
cmakeFlags = [
|
cmakeFlags = [
|
||||||
"-DTON_USE_ABSEIL=OFF"
|
"-DTON_USE_ABSEIL=ON"
|
||||||
"-DNIX=ON"
|
"-DNIX=ON"
|
||||||
"-DMHD_FOUND=1"
|
"-DTON_ONLY_TONLIB=ON"
|
||||||
"-DMHD_INCLUDE_DIR=${microhttpdmy}/usr/local/include"
|
|
||||||
"-DMHD_LIBRARY=${microhttpdmy}/usr/local/lib/libmicrohttpd.a"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
LDFLAGS = [
|
LDFLAGS = [
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,23 @@
|
||||||
, testing ? false
|
, testing ? false
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
microhttpdmy = (import ./microhttpd.nix) {};
|
staticOptions = pkg: pkg.overrideAttrs(oldAttrs: {
|
||||||
|
dontDisableStatic = true;
|
||||||
|
enableSharedExecutables = false;
|
||||||
|
configureFlags = (oldAttrs.configureFlags or []) ++ [ "--without-shared" "--disable-shared" "--disable-tests" ];
|
||||||
|
});
|
||||||
|
|
||||||
|
secp256k1Static = (staticOptions pkgs.secp256k1);
|
||||||
|
libsodiumStatic = (staticOptions pkgs.libsodium);
|
||||||
|
jemallocStatic = (staticOptions pkgs.jemalloc);
|
||||||
|
|
||||||
|
microhttpdStatic = pkgs.libmicrohttpd.overrideAttrs(oldAttrs: {
|
||||||
|
dontDisableStatic = true;
|
||||||
|
enableSharedExecutables = false;
|
||||||
|
configureFlags = (oldAttrs.configureFlags or []) ++ [ "--enable-static" "--disable-tests" "--disable-benchmark" "--disable-shared" "--disable-https" "--with-pic" ];
|
||||||
|
});
|
||||||
|
|
||||||
in
|
in
|
||||||
with import microhttpdmy;
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
pname = "ton";
|
pname = "ton";
|
||||||
version = "dev-bin";
|
version = "dev-bin";
|
||||||
|
|
@ -16,31 +30,33 @@ stdenv.mkDerivation {
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
nativeBuildInputs = with pkgs;
|
nativeBuildInputs = with pkgs;
|
||||||
[
|
[ cmake ninja git pkg-config ];
|
||||||
cmake ninja git pkg-config
|
|
||||||
];
|
|
||||||
|
|
||||||
buildInputs = with pkgs;
|
buildInputs = with pkgs;
|
||||||
[
|
[
|
||||||
pkgsStatic.openssl microhttpdmy pkgsStatic.zlib pkgsStatic.libsodium.dev pkgsStatic.secp256k1 glibc.static
|
(openssl.override { static = true; }).dev
|
||||||
|
microhttpdStatic.dev
|
||||||
|
(zlib.override { shared = false; }).dev
|
||||||
|
(lz4.override { enableStatic = true; enableShared = false; }).dev
|
||||||
|
jemallocStatic
|
||||||
|
secp256k1Static
|
||||||
|
libsodiumStatic.dev
|
||||||
|
glibc.static
|
||||||
];
|
];
|
||||||
|
|
||||||
makeStatic = true;
|
|
||||||
doCheck = testing;
|
|
||||||
|
|
||||||
cmakeFlags = [
|
cmakeFlags = [
|
||||||
"-DTON_USE_ABSEIL=OFF"
|
"-DTON_USE_ABSEIL=OFF"
|
||||||
"-DNIX=ON"
|
"-DNIX=ON"
|
||||||
"-DBUILD_SHARED_LIBS=OFF"
|
"-DBUILD_SHARED_LIBS=OFF"
|
||||||
"-DCMAKE_LINK_SEARCH_START_STATIC=ON"
|
"-DCMAKE_LINK_SEARCH_START_STATIC=ON"
|
||||||
"-DCMAKE_LINK_SEARCH_END_STATIC=ON"
|
"-DCMAKE_LINK_SEARCH_END_STATIC=ON"
|
||||||
"-DMHD_FOUND=1"
|
"-DTON_USE_JEMALLOC=ON"
|
||||||
"-DMHD_INCLUDE_DIR=${microhttpdmy}/usr/local/include"
|
|
||||||
"-DMHD_LIBRARY=${microhttpdmy}/usr/local/lib/libmicrohttpd.a"
|
|
||||||
"-DCMAKE_CTEST_ARGUMENTS=--timeout;1800"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
makeStatic = true;
|
||||||
|
doCheck = testing;
|
||||||
|
|
||||||
LDFLAGS = [
|
LDFLAGS = [
|
||||||
"-static-libgcc" "-static-libstdc++" "-static"
|
"-static-libgcc" "-static-libstdc++" "-fPIC"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,20 +7,35 @@
|
||||||
, stdenv ? pkgs.stdenv
|
, stdenv ? pkgs.stdenv
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
system = builtins.currentSystem;
|
system = builtins.currentSystem;
|
||||||
|
|
||||||
nixos1909 = (import (builtins.fetchTarball {
|
staticOptions = pkg: pkg.overrideAttrs(oldAttrs: {
|
||||||
url = "https://channels.nixos.org/nixos-19.09/nixexprs.tar.xz";
|
dontDisableStatic = true;
|
||||||
sha256 = "1vp1h2gkkrckp8dzkqnpcc6xx5lph5d2z46sg2cwzccpr8ay58zy";
|
enableSharedExecutables = false;
|
||||||
}) { inherit system; });
|
configureFlags = (oldAttrs.configureFlags or []) ++ [ "--without-shared" "--disable-shared" "--disable-tests" ];
|
||||||
glibc227 = nixos1909.glibc // { pname = "glibc"; };
|
});
|
||||||
stdenv227 = let
|
|
||||||
cc = pkgs.wrapCCWith {
|
secp256k1Static = (staticOptions pkgs.secp256k1);
|
||||||
cc = nixos1909.buildPackages.gcc-unwrapped;
|
libsodiumStatic = (staticOptions pkgs.libsodium);
|
||||||
libc = glibc227;
|
|
||||||
bintools = pkgs.binutils.override { libc = glibc227; };
|
microhttpdStatic = pkgs.libmicrohttpd.overrideAttrs(oldAttrs: {
|
||||||
};
|
dontDisableStatic = true;
|
||||||
in (pkgs.overrideCC pkgs.stdenv cc);
|
enableSharedExecutables = false;
|
||||||
|
configureFlags = (oldAttrs.configureFlags or []) ++ [ "--enable-static" "--disable-tests" "--disable-benchmark" "--disable-shared" "--disable-https" "--with-pic" ];
|
||||||
|
});
|
||||||
|
|
||||||
|
nixos1909 = (import (builtins.fetchTarball {
|
||||||
|
url = "https://channels.nixos.org/nixos-19.09/nixexprs.tar.xz";
|
||||||
|
sha256 = "1vp1h2gkkrckp8dzkqnpcc6xx5lph5d2z46sg2cwzccpr8ay58zy";
|
||||||
|
}) { inherit system; });
|
||||||
|
glibc227 = nixos1909.glibc // { pname = "glibc"; };
|
||||||
|
stdenv227 = let
|
||||||
|
cc = pkgs.wrapCCWith {
|
||||||
|
cc = nixos1909.buildPackages.gcc-unwrapped;
|
||||||
|
libc = glibc227;
|
||||||
|
bintools = pkgs.binutils.override { libc = glibc227; };
|
||||||
|
};
|
||||||
|
in (pkgs.overrideCC pkgs.stdenv cc);
|
||||||
|
|
||||||
in
|
in
|
||||||
stdenv227.mkDerivation {
|
stdenv227.mkDerivation {
|
||||||
|
|
@ -34,14 +49,22 @@ stdenv227.mkDerivation {
|
||||||
|
|
||||||
buildInputs = with pkgs;
|
buildInputs = with pkgs;
|
||||||
[
|
[
|
||||||
pkgsStatic.openssl pkgsStatic.zlib pkgsStatic.libmicrohttpd.dev pkgsStatic.libsodium.dev pkgsStatic.secp256k1
|
(openssl.override { static = true; }).dev
|
||||||
|
microhttpdStatic.dev
|
||||||
|
(zlib.override { shared = false; }).dev
|
||||||
|
(lz4.override { enableStatic = true; enableShared = false; }).dev
|
||||||
|
secp256k1Static
|
||||||
|
libsodiumStatic.dev
|
||||||
];
|
];
|
||||||
|
|
||||||
dontAddStaticConfigureFlags = false;
|
dontAddStaticConfigureFlags = false;
|
||||||
|
doCheck = false;
|
||||||
|
doInstallCheck = false;
|
||||||
|
|
||||||
cmakeFlags = [
|
cmakeFlags = [
|
||||||
"-DTON_USE_ABSEIL=OFF"
|
"-DTON_USE_ABSEIL=ON"
|
||||||
"-DNIX=ON"
|
"-DNIX=ON"
|
||||||
|
"-DTON_ONLY_TONLIB=ON"
|
||||||
];
|
];
|
||||||
|
|
||||||
LDFLAGS = [
|
LDFLAGS = [
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ pkgs.llvmPackages_14.stdenv.mkDerivation {
|
||||||
|
|
||||||
buildInputs = with pkgs;
|
buildInputs = with pkgs;
|
||||||
lib.forEach [
|
lib.forEach [
|
||||||
secp256k1 libsodium.dev libmicrohttpd.dev gmp.dev nettle.dev libtasn1.dev libidn2.dev libunistring.dev gettext (gnutls.override { withP11-kit = false; }).dev
|
secp256k1 libsodium.dev libmicrohttpd.dev gmp.dev nettle.dev libtasn1.dev libidn2.dev libunistring.dev gettext jemalloc (gnutls.override { withP11-kit = false; }).dev
|
||||||
]
|
]
|
||||||
(x: x.overrideAttrs(oldAttrs: rec { configureFlags = (oldAttrs.configureFlags or []) ++ [ "--enable-static" "--disable-shared" "--disable-tests" ]; dontDisableStatic = true; }))
|
(x: x.overrideAttrs(oldAttrs: rec { configureFlags = (oldAttrs.configureFlags or []) ++ [ "--enable-static" "--disable-shared" "--disable-tests" ]; dontDisableStatic = true; }))
|
||||||
++ [
|
++ [
|
||||||
|
|
@ -25,6 +25,7 @@ pkgs.llvmPackages_14.stdenv.mkDerivation {
|
||||||
(openssl.override { static = true; }).dev
|
(openssl.override { static = true; }).dev
|
||||||
(zlib.override { shared = false; }).dev
|
(zlib.override { shared = false; }).dev
|
||||||
(libiconv.override { enableStatic = true; enableShared = false; })
|
(libiconv.override { enableStatic = true; enableShared = false; })
|
||||||
|
(lz4.override { enableStatic = true; enableShared = false; }).dev
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -37,13 +38,13 @@ pkgs.llvmPackages_14.stdenv.mkDerivation {
|
||||||
cmakeFlags = [
|
cmakeFlags = [
|
||||||
"-DTON_USE_ABSEIL=OFF"
|
"-DTON_USE_ABSEIL=OFF"
|
||||||
"-DNIX=ON"
|
"-DNIX=ON"
|
||||||
|
"-DTON_USE_JEMALLOC=ON"
|
||||||
"-DCMAKE_CROSSCOMPILING=OFF"
|
"-DCMAKE_CROSSCOMPILING=OFF"
|
||||||
"-DCMAKE_LINK_SEARCH_START_STATIC=ON"
|
"-DCMAKE_LINK_SEARCH_START_STATIC=ON"
|
||||||
"-DCMAKE_LINK_SEARCH_END_STATIC=ON"
|
"-DCMAKE_LINK_SEARCH_END_STATIC=ON"
|
||||||
"-DBUILD_SHARED_LIBS=OFF"
|
"-DBUILD_SHARED_LIBS=OFF"
|
||||||
"-DCMAKE_CXX_FLAGS=-stdlib=libc++"
|
"-DCMAKE_CXX_FLAGS=-stdlib=libc++"
|
||||||
"-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=11.3"
|
"-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=11.3"
|
||||||
"-DCMAKE_CTEST_ARGUMENTS=--timeout;1800"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
LDFLAGS = [
|
LDFLAGS = [
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ pkgs.llvmPackages_14.stdenv.mkDerivation {
|
||||||
(openssl.override { static = true; }).dev
|
(openssl.override { static = true; }).dev
|
||||||
(zlib.override { shared = false; }).dev
|
(zlib.override { shared = false; }).dev
|
||||||
(libiconv.override { enableStatic = true; enableShared = false; })
|
(libiconv.override { enableStatic = true; enableShared = false; })
|
||||||
|
(lz4.override { enableStatic = true; enableShared = false; }).dev
|
||||||
];
|
];
|
||||||
|
|
||||||
dontAddStaticConfigureFlags = true;
|
dontAddStaticConfigureFlags = true;
|
||||||
|
|
@ -52,4 +53,4 @@ pkgs.llvmPackages_14.stdenv.mkDerivation {
|
||||||
install_name_tool -change "$(otool -L "$fn" | grep libc++abi.1 | cut -d' ' -f1 | xargs)" libc++abi.dylib "$fn"
|
install_name_tool -change "$(otool -L "$fn" | grep libc++abi.1 | cut -d' ' -f1 | xargs)" libc++abi.dylib "$fn"
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
{ pkgs ? import <nixpkgs> { system = builtins.currentSystem; }
|
|
||||||
, stdenv ? pkgs.stdenv
|
|
||||||
, fetchgit ? pkgs.fetchgit
|
|
||||||
}:
|
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
|
||||||
name = "microhttpdmy";
|
|
||||||
|
|
||||||
|
|
||||||
src = fetchgit {
|
|
||||||
url = "https://git.gnunet.org/libmicrohttpd.git";
|
|
||||||
rev = "refs/tags/v0.9.77";
|
|
||||||
sha256 = "sha256-x+nfB07PbZwBlFc6kZZFYiRpk0a3QN/ByHB+hC8na/o=";
|
|
||||||
};
|
|
||||||
|
|
||||||
nativeBuildInputs = with pkgs; [ automake libtool autoconf texinfo ];
|
|
||||||
|
|
||||||
buildInputs = with pkgs; [ ];
|
|
||||||
|
|
||||||
configurePhase = ''
|
|
||||||
./autogen.sh
|
|
||||||
./configure --enable-static --disable-tests --disable-benchmark --disable-shared --disable-https --with-pic
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
make install DESTDIR=$out
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
{ pkgs ? import <nixpkgs> { system = builtins.currentSystem; }
|
|
||||||
, stdenv ? pkgs.stdenv
|
|
||||||
, fetchFromGitHub ? pkgs.fetchFromGitHub
|
|
||||||
}:
|
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
|
||||||
name = "opensslmy";
|
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
|
||||||
owner = "openssl";
|
|
||||||
repo = "openssl";
|
|
||||||
rev = "refs/tags/openssl-3.1.4";
|
|
||||||
sha256 = "sha256-Vvf1wiNb4ikg1lIS9U137aodZ2JzM711tSWMJFYWtWI=";
|
|
||||||
};
|
|
||||||
|
|
||||||
nativeBuildInputs = with pkgs; [ perl ];
|
|
||||||
|
|
||||||
buildInputs = with pkgs; [ ];
|
|
||||||
|
|
||||||
postPatch = ''
|
|
||||||
patchShebangs Configure
|
|
||||||
'';
|
|
||||||
|
|
||||||
configurePhase = ''
|
|
||||||
./Configure no-shared
|
|
||||||
'';
|
|
||||||
installPhase = ''
|
|
||||||
make install DESTDIR=$out
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
# The script builds funcfift compiler to WASM
|
|
||||||
|
|
||||||
# Execute these prerequisites first
|
# Execute these prerequisites first
|
||||||
# sudo apt update
|
# sudo apt update
|
||||||
# sudo apt install -y build-essential git make cmake ninja-build clang libgflags-dev zlib1g-dev libssl-dev \
|
# sudo apt install -y build-essential git make cmake ninja-build clang libgflags-dev zlib1g-dev libssl-dev \
|
||||||
# libreadline-dev libmicrohttpd-dev pkg-config libgsl-dev python3 python3-dev python3-pip \
|
# libreadline-dev libmicrohttpd-dev pkg-config libgsl-dev python3 python3-dev python3-pip \
|
||||||
# nodejs libsecp256k1-dev libsodium-dev automake libtool
|
# nodejs libsodium-dev automake libtool libjemalloc-dev
|
||||||
|
|
||||||
# wget https://apt.llvm.org/llvm.sh
|
# wget https://apt.llvm.org/llvm.sh
|
||||||
# chmod +x llvm.sh
|
# chmod +x llvm.sh
|
||||||
# sudo ./llvm.sh 16 all
|
# sudo ./llvm.sh 16 all
|
||||||
|
|
||||||
with_artifacts=false
|
with_artifacts=false
|
||||||
|
scratch_new=false
|
||||||
|
|
||||||
while getopts 'a' flag; do
|
while getopts 'af' flag; do
|
||||||
case "${flag}" in
|
case "${flag}" in
|
||||||
a) with_artifacts=true ;;
|
a) with_artifacts=true ;;
|
||||||
|
f) scratch_new=true ;;
|
||||||
*) break
|
*) break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
@ -24,116 +24,141 @@ export CC=$(which clang-16)
|
||||||
export CXX=$(which clang++-16)
|
export CXX=$(which clang++-16)
|
||||||
export CCACHE_DISABLE=1
|
export CCACHE_DISABLE=1
|
||||||
|
|
||||||
cd ../..
|
|
||||||
rm -rf openssl zlib emsdk secp256k1 libsodium build
|
|
||||||
echo `pwd`
|
echo `pwd`
|
||||||
|
if [ "$scratch_new" = true ]; then
|
||||||
|
echo Compiling openssl zlib lz4 emsdk libsodium emsdk ton
|
||||||
|
rm -rf openssl zlib lz4 emsdk libsodium build openssl_em
|
||||||
|
fi
|
||||||
|
|
||||||
git clone https://github.com/openssl/openssl.git
|
|
||||||
cd openssl
|
|
||||||
git checkout checkout openssl-3.1.4
|
|
||||||
./config
|
|
||||||
make -j16
|
|
||||||
OPENSSL_DIR=`pwd`
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
git clone https://github.com/madler/zlib.git
|
if [ ! -d "openssl" ]; then
|
||||||
cd zlib
|
git clone https://github.com/openssl/openssl.git
|
||||||
ZLIB_DIR=`pwd`
|
cp -r openssl openssl_em
|
||||||
cd ..
|
cd openssl
|
||||||
|
git checkout openssl-3.1.4
|
||||||
|
./config
|
||||||
|
make -j16
|
||||||
|
OPENSSL_DIR=`pwd`
|
||||||
|
cd ..
|
||||||
|
else
|
||||||
|
OPENSSL_DIR=`pwd`/openssl
|
||||||
|
echo Using compiled openssl at $OPENSSL_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
git clone https://github.com/bitcoin-core/secp256k1.git
|
if [ ! -d "build" ]; then
|
||||||
cd secp256k1
|
mkdir build
|
||||||
./autogen.sh
|
cd build
|
||||||
SECP256K1_DIR=`pwd`
|
cmake -GNinja -DTON_USE_JEMALLOC=ON .. \
|
||||||
cd ..
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DOPENSSL_ROOT_DIR=$OPENSSL_DIR \
|
||||||
|
-DOPENSSL_INCLUDE_DIR=$OPENSSL_DIR/include \
|
||||||
|
-DOPENSSL_CRYPTO_LIBRARY=$OPENSSL_DIR/libcrypto.so
|
||||||
|
|
||||||
git clone https://github.com/jedisct1/libsodium --branch stable
|
test $? -eq 0 || { echo "Can't configure TON build"; exit 1; }
|
||||||
cd libsodium
|
ninja fift smc-envelope
|
||||||
SODIUM_DIR=`pwd`
|
test $? -eq 0 || { echo "Can't compile fift "; exit 1; }
|
||||||
cd ..
|
rm -rf * .ninja* CMakeCache.txt
|
||||||
|
cd ..
|
||||||
|
else
|
||||||
|
echo cleaning build...
|
||||||
|
rm -rf build/* build/.ninja* build/CMakeCache.txt
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir build
|
if [ ! -d "emsdk" ]; then
|
||||||
cd build
|
git clone https://github.com/emscripten-core/emsdk.git
|
||||||
cmake -GNinja -DCMAKE_BUILD_TYPE=Release \
|
echo
|
||||||
-DCMAKE_CXX_STANDARD=17 \
|
echo Using cloned emsdk
|
||||||
-DOPENSSL_FOUND=1 \
|
fi
|
||||||
-DOPENSSL_ROOT_DIR=$OPENSSL_DIR \
|
|
||||||
-DOPENSSL_INCLUDE_DIR=$OPENSSL_DIR/include \
|
|
||||||
-DOPENSSL_CRYPTO_LIBRARY=$OPENSSL_DIR/libcrypto.so \
|
|
||||||
-DOPENSSL_SSL_LIBRARY=$OPENSSL_DIR/libssl.so \
|
|
||||||
-DTON_USE_ABSEIL=OFF ..
|
|
||||||
|
|
||||||
test $? -eq 0 || { echo "Can't configure TON build"; exit 1; }
|
|
||||||
|
|
||||||
ninja fift smc-envelope
|
|
||||||
|
|
||||||
test $? -eq 0 || { echo "Can't compile fift "; exit 1; }
|
|
||||||
|
|
||||||
rm -rf *
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
git clone https://github.com/emscripten-core/emsdk.git
|
|
||||||
cd emsdk
|
cd emsdk
|
||||||
./emsdk install 3.1.19
|
./emsdk install 3.1.19
|
||||||
./emsdk activate 3.1.19
|
./emsdk activate 3.1.19
|
||||||
EMSDK_DIR=`pwd`
|
EMSDK_DIR=`pwd`
|
||||||
ls $EMSDK_DIR
|
|
||||||
|
|
||||||
. $EMSDK_DIR/emsdk_env.sh
|
. $EMSDK_DIR/emsdk_env.sh
|
||||||
export CC=$(which emcc)
|
export CC=$(which emcc)
|
||||||
export CXX=$(which em++)
|
export CXX=$(which em++)
|
||||||
export CCACHE_DISABLE=1
|
export CCACHE_DISABLE=1
|
||||||
|
|
||||||
cd ../openssl
|
cd ..
|
||||||
|
|
||||||
make clean
|
if [ ! -f "openssl_em/openssl_em" ]; then
|
||||||
emconfigure ./Configure linux-generic32 no-shared no-dso no-engine no-unit-test
|
cd openssl_em
|
||||||
sed -i 's/CROSS_COMPILE=.*/CROSS_COMPILE=/g' Makefile
|
emconfigure ./Configure linux-generic32 no-shared no-dso no-engine no-unit-test no-tests no-fuzz-afl no-fuzz-libfuzzer
|
||||||
sed -i 's/-ldl//g' Makefile
|
sed -i 's/CROSS_COMPILE=.*/CROSS_COMPILE=/g' Makefile
|
||||||
sed -i 's/-O3/-Os/g' Makefile
|
sed -i 's/-ldl//g' Makefile
|
||||||
emmake make depend
|
sed -i 's/-O3/-Os/g' Makefile
|
||||||
emmake make -j16
|
emmake make depend
|
||||||
test $? -eq 0 || { echo "Can't compile OpenSSL with emmake "; exit 1; }
|
emmake make -j16
|
||||||
|
test $? -eq 0 || { echo "Can't compile OpenSSL with emmake "; exit 1; }
|
||||||
|
OPENSSL_DIR=`pwd`
|
||||||
|
touch openssl_em
|
||||||
|
cd ..
|
||||||
|
else
|
||||||
|
OPENSSL_DIR=`pwd`/openssl_em
|
||||||
|
echo Using compiled with empscripten openssl at $OPENSSL_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
cd ../zlib
|
if [ ! -d "zlib" ]; then
|
||||||
|
git clone https://github.com/madler/zlib.git
|
||||||
|
cd zlib
|
||||||
|
git checkout v1.3.1
|
||||||
|
ZLIB_DIR=`pwd`
|
||||||
|
emconfigure ./configure --static
|
||||||
|
emmake make -j16
|
||||||
|
test $? -eq 0 || { echo "Can't compile zlib with emmake "; exit 1; }
|
||||||
|
cd ..
|
||||||
|
else
|
||||||
|
ZLIB_DIR=`pwd`/zlib
|
||||||
|
echo Using compiled zlib with emscripten at $ZLIB_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
emconfigure ./configure --static
|
if [ ! -d "lz4" ]; then
|
||||||
emmake make -j16
|
git clone https://github.com/lz4/lz4.git
|
||||||
test $? -eq 0 || { echo "Can't compile zlib with emmake "; exit 1; }
|
cd lz4
|
||||||
ZLIB_DIR=`pwd`
|
git checkout v1.9.4
|
||||||
|
LZ4_DIR=`pwd`
|
||||||
|
emmake make -j16
|
||||||
|
test $? -eq 0 || { echo "Can't compile lz4 with emmake "; exit 1; }
|
||||||
|
cd ..
|
||||||
|
else
|
||||||
|
LZ4_DIR=`pwd`/lz4
|
||||||
|
echo Using compiled lz4 with emscripten at $LZ4_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
cd ../secp256k1
|
if [ ! -d "libsodium" ]; then
|
||||||
|
git clone https://github.com/jedisct1/libsodium
|
||||||
|
cd libsodium
|
||||||
|
git checkout 1.0.18-RELEASE
|
||||||
|
SODIUM_DIR=`pwd`
|
||||||
|
emconfigure ./configure --disable-ssp
|
||||||
|
emmake make -j16
|
||||||
|
test $? -eq 0 || { echo "Can't compile libsodium with emmake "; exit 1; }
|
||||||
|
cd ..
|
||||||
|
else
|
||||||
|
SODIUM_DIR=`pwd`/libsodium
|
||||||
|
echo Using compiled libsodium with emscripten at $SODIUM_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
emconfigure ./configure --enable-module-recovery
|
cd build
|
||||||
emmake make -j16
|
|
||||||
test $? -eq 0 || { echo "Can't compile secp256k1 with emmake "; exit 1; }
|
|
||||||
|
|
||||||
cd ../libsodium
|
emcmake cmake -DUSE_EMSCRIPTEN=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
|
||||||
|
|
||||||
emconfigure ./configure --disable-ssp
|
|
||||||
emmake make -j16
|
|
||||||
test $? -eq 0 || { echo "Can't compile libsodium with emmake "; exit 1; }
|
|
||||||
|
|
||||||
cd ../build
|
|
||||||
|
|
||||||
emcmake cmake -DUSE_EMSCRIPTEN=ON -DCMAKE_BUILD_TYPE=Release \
|
|
||||||
-DZLIB_FOUND=1 \
|
-DZLIB_FOUND=1 \
|
||||||
-DZLIB_LIBRARIES=$ZLIB_DIR/libz.a \
|
-DZLIB_LIBRARIES=$ZLIB_DIR/libz.a \
|
||||||
-DZLIB_INCLUDE_DIR=$ZLIB_DIR \
|
-DZLIB_INCLUDE_DIR=$ZLIB_DIR \
|
||||||
|
-DLZ4_FOUND=1 \
|
||||||
|
-DLZ4_LIBRARIES=$LZ4_DIR/lib/liblz4.a \
|
||||||
|
-DLZ4_INCLUDE_DIRS=$LZ4_DIR/lib \
|
||||||
-DOPENSSL_FOUND=1 \
|
-DOPENSSL_FOUND=1 \
|
||||||
-DOPENSSL_ROOT_DIR=$OPENSSL_DIR \
|
|
||||||
-DOPENSSL_INCLUDE_DIR=$OPENSSL_DIR/include \
|
-DOPENSSL_INCLUDE_DIR=$OPENSSL_DIR/include \
|
||||||
-DOPENSSL_CRYPTO_LIBRARY=$OPENSSL_DIR/libcrypto.a \
|
-DOPENSSL_CRYPTO_LIBRARY=$OPENSSL_DIR/libcrypto.a \
|
||||||
-DOPENSSL_SSL_LIBRARY=$OPENSSL_DIR/libssl.a \
|
|
||||||
-DCMAKE_TOOLCHAIN_FILE=$EMSDK_DIR/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
|
-DCMAKE_TOOLCHAIN_FILE=$EMSDK_DIR/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
|
||||||
-DCMAKE_CXX_FLAGS="-sUSE_ZLIB=1" \
|
-DCMAKE_CXX_FLAGS="-sUSE_ZLIB=1" \
|
||||||
-DSECP256K1_FOUND=1 \
|
-DSODIUM_FOUND=1 \
|
||||||
-DSECP256K1_INCLUDE_DIR=$SECP256K1_DIR/include \
|
|
||||||
-DSECP256K1_LIBRARY=$SECP256K1_DIR/.libs/libsecp256k1.a \
|
|
||||||
-DSODIUM_INCLUDE_DIR=$SODIUM_DIR/src/libsodium/include \
|
-DSODIUM_INCLUDE_DIR=$SODIUM_DIR/src/libsodium/include \
|
||||||
|
-DSODIUM_USE_STATIC_LIBS=1 \
|
||||||
-DSODIUM_LIBRARY_RELEASE=$SODIUM_DIR/src/libsodium/.libs/libsodium.a \
|
-DSODIUM_LIBRARY_RELEASE=$SODIUM_DIR/src/libsodium/.libs/libsodium.a \
|
||||||
-DSODIUM_USE_STATIC_LIBS=ON ..
|
..
|
||||||
|
|
||||||
test $? -eq 0 || { echo "Can't configure TON with emmake "; exit 1; }
|
test $? -eq 0 || { echo "Can't configure TON with emmake "; exit 1; }
|
||||||
cp -R ../crypto/smartcont ../crypto/fift/lib crypto
|
cp -R ../crypto/smartcont ../crypto/fift/lib crypto
|
||||||
|
|
@ -155,5 +180,3 @@ if [ "$with_artifacts" = true ]; then
|
||||||
cp -R crypto/smartcont artifacts
|
cp -R crypto/smartcont artifacts
|
||||||
cp -R crypto/fift/lib artifacts
|
cp -R crypto/fift/lib artifacts
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
61
assembly/wasm/intrinsics.fc
Normal file
61
assembly/wasm/intrinsics.fc
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
#pragma allow-post-modification;
|
||||||
|
#pragma compute-asm-ltr;
|
||||||
|
|
||||||
|
(slice, slice) __tact_load_address(slice cs) inline {
|
||||||
|
slice raw = cs~load_msg_addr();
|
||||||
|
return (cs, raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
slice __gen_slice1 () asm """
|
||||||
|
B{b5ee9c72410101010005000006abcdefe1e98884} B>boc <s PUSHSLICE
|
||||||
|
""";
|
||||||
|
|
||||||
|
slice __gen_slice_slice_eb58904b617945cdf4f33042169c462cd36cf1772a2229f06171fd899e920b7f() asm """
|
||||||
|
B{b5ee9c724101010100030000011025086565} B>boc <s PUSHSLICE
|
||||||
|
""";
|
||||||
|
|
||||||
|
slice __gen_slice3 () asm """
|
||||||
|
B{b5ee9c724101010100030000017888c37a8e} B>boc <s PUSHSLICE
|
||||||
|
""";
|
||||||
|
|
||||||
|
slice __gen_slice_slice_6694a4a61b0dc7c7d5f63bbd394449f6921de7b2ad9cb() asm """
|
||||||
|
B{b5ee9c724101010100820000ffabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdab} B>boc <s PUSHSLICE
|
||||||
|
""";
|
||||||
|
|
||||||
|
slice __gen_slice_slice_80b26bab85f37e2bde3795993cdf7402cd42e68eff6187e8388083ce6cfe7c92() asm """
|
||||||
|
B{b5ee9c724101010100030000018a0adc2f9c} B>boc <s PUSHSLICE
|
||||||
|
""";
|
||||||
|
|
||||||
|
|
||||||
|
(slice,((slice, cell, int, int, slice, slice, int, int, int, int, slice, slice, slice, slice, slice, slice, slice, slice, slice, slice, slice))) IntrinsicsTester_load(slice sc_0) inline {
|
||||||
|
var v'c = sc_0~__tact_load_address();
|
||||||
|
var v'd = sc_0~load_ref();
|
||||||
|
var v'e = sc_0~load_int(257);
|
||||||
|
var v'f = sc_0~load_int(257);
|
||||||
|
slice sc_1 = sc_0~load_ref().begin_parse();
|
||||||
|
var v'g = sc_1~load_ref().begin_parse();
|
||||||
|
var v'h = sc_1~load_ref().begin_parse();
|
||||||
|
var v'i = sc_1~load_int(257);
|
||||||
|
var v'j = sc_1~load_int(257);
|
||||||
|
var v'k = sc_1~load_int(257);
|
||||||
|
slice sc_2 = sc_1~load_ref().begin_parse();
|
||||||
|
var v'l = sc_2~load_int(257);
|
||||||
|
var v'm = sc_2~load_ref().begin_parse();
|
||||||
|
var v'n = sc_2~load_ref().begin_parse();
|
||||||
|
var v'o = sc_2~load_ref().begin_parse();
|
||||||
|
slice sc_3 = sc_2~load_ref().begin_parse();
|
||||||
|
var v'p = sc_3~load_ref().begin_parse();
|
||||||
|
var v'q = sc_3~load_ref().begin_parse();
|
||||||
|
var v'r = sc_3~load_ref().begin_parse();
|
||||||
|
slice sc_4 = sc_3~load_ref().begin_parse();
|
||||||
|
var v's = sc_4~load_ref().begin_parse();
|
||||||
|
var v't = sc_4~load_ref().begin_parse();
|
||||||
|
var v'u = sc_4~load_ref().begin_parse();
|
||||||
|
slice sc_5 = sc_4~load_ref().begin_parse();
|
||||||
|
var v'w = sc_5~load_ref().begin_parse();
|
||||||
|
var v'v = sc_5~load_ref().begin_parse();
|
||||||
|
return (sc_0, (v'c, v'd, v'e, v'f, v'g, v'h, v'i, v'j, v'k, v'l, v'm, v'n, v'o, v'p, v'q, v'r, v's, v't, v'u, v'w, v'v));
|
||||||
|
}
|
||||||
|
|
||||||
|
() recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure { }
|
||||||
|
|
||||||
681
assembly/wasm/stdlib.fc
Normal file
681
assembly/wasm/stdlib.fc
Normal file
|
|
@ -0,0 +1,681 @@
|
||||||
|
;; Standard library for funC
|
||||||
|
;;
|
||||||
|
|
||||||
|
{-
|
||||||
|
This file is part of TON FunC Standard Library.
|
||||||
|
|
||||||
|
FunC Standard Library is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
FunC Standard Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
-}
|
||||||
|
|
||||||
|
{-
|
||||||
|
# Tuple manipulation primitives
|
||||||
|
The names and the types are mostly self-explaining.
|
||||||
|
See [polymorhism with forall](https://ton.org/docs/#/func/functions?id=polymorphism-with-forall)
|
||||||
|
for more info on the polymorphic functions.
|
||||||
|
|
||||||
|
Note that currently values of atomic type `tuple` can't be cast to composite tuple type (e.g. `[int, cell]`)
|
||||||
|
and vise versa.
|
||||||
|
-}
|
||||||
|
|
||||||
|
{-
|
||||||
|
# Lisp-style lists
|
||||||
|
|
||||||
|
Lists can be represented as nested 2-elements tuples.
|
||||||
|
Empty list is conventionally represented as TVM `null` value (it can be obtained by calling [null()]).
|
||||||
|
For example, tuple `(1, (2, (3, null)))` represents list `[1, 2, 3]`. Elements of a list can be of different types.
|
||||||
|
-}
|
||||||
|
|
||||||
|
;;; Adds an element to the beginning of lisp-style list.
|
||||||
|
forall X -> tuple cons(X head, tuple tail) asm "CONS";
|
||||||
|
|
||||||
|
;;; Extracts the head and the tail of lisp-style list.
|
||||||
|
forall X -> (X, tuple) uncons(tuple list) asm "UNCONS";
|
||||||
|
|
||||||
|
;;; Extracts the tail and the head of lisp-style list.
|
||||||
|
forall X -> (tuple, X) list_next(tuple list) asm(-> 1 0) "UNCONS";
|
||||||
|
|
||||||
|
;;; Returns the head of lisp-style list.
|
||||||
|
forall X -> X car(tuple list) asm "CAR";
|
||||||
|
|
||||||
|
;;; Returns the tail of lisp-style list.
|
||||||
|
tuple cdr(tuple list) asm "CDR";
|
||||||
|
|
||||||
|
;;; Creates tuple with zero elements.
|
||||||
|
tuple empty_tuple() asm "NIL";
|
||||||
|
|
||||||
|
;;; Appends a value `x` to a `Tuple t = (x1, ..., xn)`, but only if the resulting `Tuple t' = (x1, ..., xn, x)`
|
||||||
|
;;; is of length at most 255. Otherwise throws a type check exception.
|
||||||
|
forall X -> tuple tpush(tuple t, X value) asm "TPUSH";
|
||||||
|
forall X -> (tuple, ()) ~tpush(tuple t, X value) asm "TPUSH";
|
||||||
|
|
||||||
|
;;; Creates a tuple of length one with given argument as element.
|
||||||
|
forall X -> [X] single(X x) asm "SINGLE";
|
||||||
|
|
||||||
|
;;; Unpacks a tuple of length one
|
||||||
|
forall X -> X unsingle([X] t) asm "UNSINGLE";
|
||||||
|
|
||||||
|
;;; Creates a tuple of length two with given arguments as elements.
|
||||||
|
forall X, Y -> [X, Y] pair(X x, Y y) asm "PAIR";
|
||||||
|
|
||||||
|
;;; Unpacks a tuple of length two
|
||||||
|
forall X, Y -> (X, Y) unpair([X, Y] t) asm "UNPAIR";
|
||||||
|
|
||||||
|
;;; Creates a tuple of length three with given arguments as elements.
|
||||||
|
forall X, Y, Z -> [X, Y, Z] triple(X x, Y y, Z z) asm "TRIPLE";
|
||||||
|
|
||||||
|
;;; Unpacks a tuple of length three
|
||||||
|
forall X, Y, Z -> (X, Y, Z) untriple([X, Y, Z] t) asm "UNTRIPLE";
|
||||||
|
|
||||||
|
;;; Creates a tuple of length four with given arguments as elements.
|
||||||
|
forall X, Y, Z, W -> [X, Y, Z, W] tuple4(X x, Y y, Z z, W w) asm "4 TUPLE";
|
||||||
|
|
||||||
|
;;; Unpacks a tuple of length four
|
||||||
|
forall X, Y, Z, W -> (X, Y, Z, W) untuple4([X, Y, Z, W] t) asm "4 UNTUPLE";
|
||||||
|
|
||||||
|
;;; Returns the first element of a tuple (with unknown element types).
|
||||||
|
forall X -> X first(tuple t) asm "FIRST";
|
||||||
|
|
||||||
|
;;; Returns the second element of a tuple (with unknown element types).
|
||||||
|
forall X -> X second(tuple t) asm "SECOND";
|
||||||
|
|
||||||
|
;;; Returns the third element of a tuple (with unknown element types).
|
||||||
|
forall X -> X third(tuple t) asm "THIRD";
|
||||||
|
|
||||||
|
;;; Returns the fourth element of a tuple (with unknown element types).
|
||||||
|
forall X -> X fourth(tuple t) asm "3 INDEX";
|
||||||
|
|
||||||
|
;;; Returns the first element of a pair tuple.
|
||||||
|
forall X, Y -> X pair_first([X, Y] p) asm "FIRST";
|
||||||
|
|
||||||
|
;;; Returns the second element of a pair tuple.
|
||||||
|
forall X, Y -> Y pair_second([X, Y] p) asm "SECOND";
|
||||||
|
|
||||||
|
;;; Returns the first element of a triple tuple.
|
||||||
|
forall X, Y, Z -> X triple_first([X, Y, Z] p) asm "FIRST";
|
||||||
|
|
||||||
|
;;; Returns the second element of a triple tuple.
|
||||||
|
forall X, Y, Z -> Y triple_second([X, Y, Z] p) asm "SECOND";
|
||||||
|
|
||||||
|
;;; Returns the third element of a triple tuple.
|
||||||
|
forall X, Y, Z -> Z triple_third([X, Y, Z] p) asm "THIRD";
|
||||||
|
|
||||||
|
|
||||||
|
;;; Push null element (casted to given type)
|
||||||
|
;;; By the TVM type `Null` FunC represents absence of a value of some atomic type.
|
||||||
|
;;; So `null` can actually have any atomic type.
|
||||||
|
forall X -> X null() asm "PUSHNULL";
|
||||||
|
|
||||||
|
;;; Moves a variable [x] to the top of the stack
|
||||||
|
forall X -> (X, ()) ~impure_touch(X x) impure asm "NOP";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;;; Returns the current Unix time as an Integer
|
||||||
|
int now() asm "NOW";
|
||||||
|
|
||||||
|
;;; Returns the internal address of the current smart contract as a Slice with a `MsgAddressInt`.
|
||||||
|
;;; If necessary, it can be parsed further using primitives such as [parse_std_addr].
|
||||||
|
slice my_address() asm "MYADDR";
|
||||||
|
|
||||||
|
;;; Returns the balance of the smart contract as a tuple consisting of an int
|
||||||
|
;;; (balance in nanotoncoins) and a `cell`
|
||||||
|
;;; (a dictionary with 32-bit keys representing the balance of "extra currencies")
|
||||||
|
;;; at the start of Computation Phase.
|
||||||
|
;;; Note that RAW primitives such as [send_raw_message] do not update this field.
|
||||||
|
[int, cell] get_balance() asm "BALANCE";
|
||||||
|
|
||||||
|
;;; Returns the logical time of the current transaction.
|
||||||
|
int cur_lt() asm "LTIME";
|
||||||
|
|
||||||
|
;;; Returns the starting logical time of the current block.
|
||||||
|
int block_lt() asm "BLOCKLT";
|
||||||
|
|
||||||
|
;;; Computes the representation hash of a `cell` [c] and returns it as a 256-bit unsigned integer `x`.
|
||||||
|
;;; Useful for signing and checking signatures of arbitrary entities represented by a tree of cells.
|
||||||
|
int cell_hash(cell c) asm "HASHCU";
|
||||||
|
|
||||||
|
;;; Computes the hash of a `slice s` and returns it as a 256-bit unsigned integer `x`.
|
||||||
|
;;; The result is the same as if an ordinary cell containing only data and references from `s` had been created
|
||||||
|
;;; and its hash computed by [cell_hash].
|
||||||
|
int slice_hash(slice s) asm "HASHSU";
|
||||||
|
|
||||||
|
;;; Computes sha256 of the data bits of `slice` [s]. If the bit length of `s` is not divisible by eight,
|
||||||
|
;;; throws a cell underflow exception. The hash value is returned as a 256-bit unsigned integer `x`.
|
||||||
|
int string_hash(slice s) asm "SHA256U";
|
||||||
|
|
||||||
|
{-
|
||||||
|
# Signature checks
|
||||||
|
-}
|
||||||
|
|
||||||
|
;;; Checks the Ed25519-`signature` of a `hash` (a 256-bit unsigned integer, usually computed as the hash of some data)
|
||||||
|
;;; using [public_key] (also represented by a 256-bit unsigned integer).
|
||||||
|
;;; The signature must contain at least 512 data bits; only the first 512 bits are used.
|
||||||
|
;;; The result is `−1` if the signature is valid, `0` otherwise.
|
||||||
|
;;; Note that `CHKSIGNU` creates a 256-bit slice with the hash and calls `CHKSIGNS`.
|
||||||
|
;;; That is, if [hash] is computed as the hash of some data, these data are hashed twice,
|
||||||
|
;;; the second hashing occurring inside `CHKSIGNS`.
|
||||||
|
int check_signature(int hash, slice signature, int public_key) asm "CHKSIGNU";
|
||||||
|
|
||||||
|
;;; Checks whether [signature] is a valid Ed25519-signature of the data portion of `slice data` using `public_key`,
|
||||||
|
;;; similarly to [check_signature].
|
||||||
|
;;; If the bit length of [data] is not divisible by eight, throws a cell underflow exception.
|
||||||
|
;;; The verification of Ed25519 signatures is the standard one,
|
||||||
|
;;; with sha256 used to reduce [data] to the 256-bit number that is actually signed.
|
||||||
|
int check_data_signature(slice data, slice signature, int public_key) asm "CHKSIGNS";
|
||||||
|
|
||||||
|
{---
|
||||||
|
# Computation of boc size
|
||||||
|
The primitives below may be useful for computing storage fees of user-provided data.
|
||||||
|
-}
|
||||||
|
|
||||||
|
;;; Returns `(x, y, z, -1)` or `(null, null, null, 0)`.
|
||||||
|
;;; Recursively computes the count of distinct cells `x`, data bits `y`, and cell references `z`
|
||||||
|
;;; in the DAG rooted at `cell` [c], effectively returning the total storage used by this DAG taking into account
|
||||||
|
;;; the identification of equal cells.
|
||||||
|
;;; The values of `x`, `y`, and `z` are computed by a depth-first traversal of this DAG,
|
||||||
|
;;; with a hash table of visited cell hashes used to prevent visits of already-visited cells.
|
||||||
|
;;; The total count of visited cells `x` cannot exceed non-negative [max_cells];
|
||||||
|
;;; otherwise the computation is aborted before visiting the `(max_cells + 1)`-st cell and
|
||||||
|
;;; a zero flag is returned to indicate failure. If [c] is `null`, returns `x = y = z = 0`.
|
||||||
|
(int, int, int) compute_data_size(cell c, int max_cells) impure asm "CDATASIZE";
|
||||||
|
|
||||||
|
;;; Similar to [compute_data_size?], but accepting a `slice` [s] instead of a `cell`.
|
||||||
|
;;; The returned value of `x` does not take into account the cell that contains the `slice` [s] itself;
|
||||||
|
;;; however, the data bits and the cell references of [s] are accounted for in `y` and `z`.
|
||||||
|
(int, int, int) slice_compute_data_size(slice s, int max_cells) impure asm "SDATASIZE";
|
||||||
|
|
||||||
|
;;; A non-quiet version of [compute_data_size?] that throws a cell overflow exception (`8`) on failure.
|
||||||
|
(int, int, int, int) compute_data_size?(cell c, int max_cells) asm "CDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT";
|
||||||
|
|
||||||
|
;;; A non-quiet version of [slice_compute_data_size?] that throws a cell overflow exception (8) on failure.
|
||||||
|
(int, int, int, int) slice_compute_data_size?(cell c, int max_cells) asm "SDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT";
|
||||||
|
|
||||||
|
;;; Throws an exception with exit_code excno if cond is not 0 (commented since implemented in compilator)
|
||||||
|
;; () throw_if(int excno, int cond) impure asm "THROWARGIF";
|
||||||
|
|
||||||
|
{--
|
||||||
|
# Debug primitives
|
||||||
|
Only works for local TVM execution with debug level verbosity
|
||||||
|
-}
|
||||||
|
;;; Dumps the stack (at most the top 255 values) and shows the total stack depth.
|
||||||
|
() dump_stack() impure asm "DUMPSTK";
|
||||||
|
|
||||||
|
{-
|
||||||
|
# Persistent storage save and load
|
||||||
|
-}
|
||||||
|
|
||||||
|
;;; Returns the persistent contract storage cell. It can be parsed or modified with slice and builder primitives later.
|
||||||
|
cell get_data() asm "c4 PUSH";
|
||||||
|
|
||||||
|
;;; Sets `cell` [c] as persistent contract data. You can update persistent contract storage with this primitive.
|
||||||
|
() set_data(cell c) impure asm "c4 POP";
|
||||||
|
|
||||||
|
{-
|
||||||
|
# Continuation primitives
|
||||||
|
-}
|
||||||
|
;;; Usually `c3` has a continuation initialized by the whole code of the contract. It is used for function calls.
|
||||||
|
;;; The primitive returns the current value of `c3`.
|
||||||
|
cont get_c3() impure asm "c3 PUSH";
|
||||||
|
|
||||||
|
;;; Updates the current value of `c3`. Usually, it is used for updating smart contract code in run-time.
|
||||||
|
;;; Note that after execution of this primitive the current code
|
||||||
|
;;; (and the stack of recursive function calls) won't change,
|
||||||
|
;;; but any other function call will use a function from the new code.
|
||||||
|
() set_c3(cont c) impure asm "c3 POP";
|
||||||
|
|
||||||
|
;;; Transforms a `slice` [s] into a simple ordinary continuation `c`, with `c.code = s` and an empty stack and savelist.
|
||||||
|
cont bless(slice s) impure asm "BLESS";
|
||||||
|
|
||||||
|
{---
|
||||||
|
# Gas related primitives
|
||||||
|
-}
|
||||||
|
|
||||||
|
;;; Sets current gas limit `gl` to its maximal allowed value `gm`, and resets the gas credit `gc` to zero,
|
||||||
|
;;; decreasing the value of `gr` by `gc` in the process.
|
||||||
|
;;; In other words, the current smart contract agrees to buy some gas to finish the current transaction.
|
||||||
|
;;; This action is required to process external messages, which bring no value (hence no gas) with themselves.
|
||||||
|
;;;
|
||||||
|
;;; For more details check [accept_message effects](https://ton.org/docs/#/smart-contracts/accept).
|
||||||
|
() accept_message() impure asm "ACCEPT";
|
||||||
|
|
||||||
|
;;; Sets current gas limit `gl` to the minimum of limit and `gm`, and resets the gas credit `gc` to zero.
|
||||||
|
;;; If the gas consumed so far (including the present instruction) exceeds the resulting value of `gl`,
|
||||||
|
;;; an (unhandled) out of gas exception is thrown before setting new gas limits.
|
||||||
|
;;; Notice that [set_gas_limit] with an argument `limit ≥ 2^63 − 1` is equivalent to [accept_message].
|
||||||
|
() set_gas_limit(int limit) impure asm "SETGASLIMIT";
|
||||||
|
|
||||||
|
;;; Commits the current state of registers `c4` (“persistent data”) and `c5` (“actions”)
|
||||||
|
;;; so that the current execution is considered “successful” with the saved values even if an exception
|
||||||
|
;;; in Computation Phase is thrown later.
|
||||||
|
() commit() impure asm "COMMIT";
|
||||||
|
|
||||||
|
;;; Not implemented
|
||||||
|
;;; Computes the amount of gas that can be bought for `amount` nanoTONs,
|
||||||
|
;;; and sets `gl` accordingly in the same way as [set_gas_limit].
|
||||||
|
;;() buy_gas(int amount) impure asm "BUYGAS";
|
||||||
|
|
||||||
|
;;; Computes the minimum of two integers [x] and [y].
|
||||||
|
int min(int x, int y) asm "MIN";
|
||||||
|
|
||||||
|
;;; Computes the maximum of two integers [x] and [y].
|
||||||
|
int max(int x, int y) asm "MAX";
|
||||||
|
|
||||||
|
;;; Sorts two integers.
|
||||||
|
(int, int) minmax(int x, int y) asm "MINMAX";
|
||||||
|
|
||||||
|
;;; Computes the absolute value of an integer [x].
|
||||||
|
int abs(int x) asm "ABS";
|
||||||
|
|
||||||
|
{-
|
||||||
|
# Slice primitives
|
||||||
|
|
||||||
|
It is said that a primitive _loads_ some data,
|
||||||
|
if it returns the data and the remainder of the slice
|
||||||
|
(so it can also be used as [modifying method](https://ton.org/docs/#/func/statements?id=modifying-methods)).
|
||||||
|
|
||||||
|
It is said that a primitive _preloads_ some data, if it returns only the data
|
||||||
|
(it can be used as [non-modifying method](https://ton.org/docs/#/func/statements?id=non-modifying-methods)).
|
||||||
|
|
||||||
|
Unless otherwise stated, loading and preloading primitives read the data from a prefix of the slice.
|
||||||
|
-}
|
||||||
|
|
||||||
|
|
||||||
|
;;; Converts a `cell` [c] into a `slice`. Notice that [c] must be either an ordinary cell,
|
||||||
|
;;; or an exotic cell (see [TVM.pdf](https://ton-blockchain.github.io/docs/tvm.pdf), 3.1.2)
|
||||||
|
;;; which is automatically loaded to yield an ordinary cell `c'`, converted into a `slice` afterwards.
|
||||||
|
slice begin_parse(cell c) asm "CTOS";
|
||||||
|
|
||||||
|
;;; Checks if [s] is empty. If not, throws an exception.
|
||||||
|
() end_parse(slice s) impure asm "ENDS";
|
||||||
|
|
||||||
|
;;; Loads the first reference from the slice.
|
||||||
|
(slice, cell) load_ref(slice s) asm(-> 1 0) "LDREF";
|
||||||
|
|
||||||
|
;;; Preloads the first reference from the slice.
|
||||||
|
cell preload_ref(slice s) asm "PLDREF";
|
||||||
|
|
||||||
|
{- Functions below are commented because are implemented on compilator level for optimisation -}
|
||||||
|
|
||||||
|
;;; Loads a signed [len]-bit integer from a slice [s].
|
||||||
|
;; (slice, int) ~load_int(slice s, int len) asm(s len -> 1 0) "LDIX";
|
||||||
|
|
||||||
|
;;; Loads an unsigned [len]-bit integer from a slice [s].
|
||||||
|
;; (slice, int) ~load_uint(slice s, int len) asm( -> 1 0) "LDUX";
|
||||||
|
|
||||||
|
;;; Preloads a signed [len]-bit integer from a slice [s].
|
||||||
|
;; int preload_int(slice s, int len) asm "PLDIX";
|
||||||
|
|
||||||
|
;;; Preloads an unsigned [len]-bit integer from a slice [s].
|
||||||
|
;; int preload_uint(slice s, int len) asm "PLDUX";
|
||||||
|
|
||||||
|
;;; Loads the first `0 ≤ len ≤ 1023` bits from slice [s] into a separate `slice s''`.
|
||||||
|
;; (slice, slice) load_bits(slice s, int len) asm(s len -> 1 0) "LDSLICEX";
|
||||||
|
|
||||||
|
;;; Preloads the first `0 ≤ len ≤ 1023` bits from slice [s] into a separate `slice s''`.
|
||||||
|
;; slice preload_bits(slice s, int len) asm "PLDSLICEX";
|
||||||
|
|
||||||
|
;;; Loads serialized amount of TonCoins (any unsigned integer up to `2^120 - 1`).
|
||||||
|
(slice, int) load_grams(slice s) asm(-> 1 0) "LDGRAMS";
|
||||||
|
(slice, int) load_coins(slice s) asm(-> 1 0) "LDVARUINT16";
|
||||||
|
|
||||||
|
(slice, int) load_varint16(slice s) asm(-> 1 0) "LDVARINT16";
|
||||||
|
(slice, int) load_varint32(slice s) asm(-> 1 0) "LDVARINT32";
|
||||||
|
(slice, int) load_varuint16(slice s) asm(-> 1 0) "LDVARUINT16";
|
||||||
|
(slice, int) load_varuint32(slice s) asm(-> 1 0) "LDVARUINT32";
|
||||||
|
|
||||||
|
;;; Returns all but the first `0 ≤ len ≤ 1023` bits of `slice` [s].
|
||||||
|
slice skip_bits(slice s, int len) asm "SDSKIPFIRST";
|
||||||
|
(slice, ()) ~skip_bits(slice s, int len) asm "SDSKIPFIRST";
|
||||||
|
|
||||||
|
;;; Returns the first `0 ≤ len ≤ 1023` bits of `slice` [s].
|
||||||
|
slice first_bits(slice s, int len) asm "SDCUTFIRST";
|
||||||
|
|
||||||
|
;;; Returns all but the last `0 ≤ len ≤ 1023` bits of `slice` [s].
|
||||||
|
slice skip_last_bits(slice s, int len) asm "SDSKIPLAST";
|
||||||
|
(slice, ()) ~skip_last_bits(slice s, int len) asm "SDSKIPLAST";
|
||||||
|
|
||||||
|
;;; Returns the last `0 ≤ len ≤ 1023` bits of `slice` [s].
|
||||||
|
slice slice_last(slice s, int len) asm "SDCUTLAST";
|
||||||
|
|
||||||
|
;;; Loads a dictionary `D` (HashMapE) from `slice` [s].
|
||||||
|
;;; (returns `null` if `nothing` constructor is used).
|
||||||
|
(slice, cell) load_dict(slice s) asm(-> 1 0) "LDDICT";
|
||||||
|
|
||||||
|
;;; Preloads a dictionary `D` from `slice` [s].
|
||||||
|
cell preload_dict(slice s) asm "PLDDICT";
|
||||||
|
|
||||||
|
;;; Loads a dictionary as [load_dict], but returns only the remainder of the slice.
|
||||||
|
slice skip_dict(slice s) asm "SKIPDICT";
|
||||||
|
(slice, ()) ~skip_dict(slice s) asm "SKIPDICT";
|
||||||
|
|
||||||
|
;;; Loads (Maybe ^Cell) from `slice` [s].
|
||||||
|
;;; In other words loads 1 bit and if it is true
|
||||||
|
;;; loads first ref and return it with slice remainder
|
||||||
|
;;; otherwise returns `null` and slice remainder
|
||||||
|
(slice, cell) load_maybe_ref(slice s) asm(-> 1 0) "LDOPTREF";
|
||||||
|
|
||||||
|
;;; Preloads (Maybe ^Cell) from `slice` [s].
|
||||||
|
cell preload_maybe_ref(slice s) asm "PLDOPTREF";
|
||||||
|
|
||||||
|
|
||||||
|
;;; Returns the depth of `cell` [c].
|
||||||
|
;;; If [c] has no references, then return `0`;
|
||||||
|
;;; otherwise the returned value is one plus the maximum of depths of cells referred to from [c].
|
||||||
|
;;; If [c] is a `null` instead of a cell, returns zero.
|
||||||
|
int cell_depth(cell c) asm "CDEPTH";
|
||||||
|
|
||||||
|
|
||||||
|
{-
|
||||||
|
# Slice size primitives
|
||||||
|
-}
|
||||||
|
|
||||||
|
;;; Returns the number of references in `slice` [s].
|
||||||
|
int slice_refs(slice s) asm "SREFS";
|
||||||
|
|
||||||
|
;;; Returns the number of data bits in `slice` [s].
|
||||||
|
int slice_bits(slice s) asm "SBITS";
|
||||||
|
|
||||||
|
;;; Returns both the number of data bits and the number of references in `slice` [s].
|
||||||
|
(int, int) slice_bits_refs(slice s) asm "SBITREFS";
|
||||||
|
|
||||||
|
;;; Checks whether a `slice` [s] is empty (i.e., contains no bits of data and no cell references).
|
||||||
|
int slice_empty?(slice s) asm "SEMPTY";
|
||||||
|
|
||||||
|
;;; Checks whether `slice` [s] has no bits of data.
|
||||||
|
int slice_data_empty?(slice s) asm "SDEMPTY";
|
||||||
|
|
||||||
|
;;; Checks whether `slice` [s] has no references.
|
||||||
|
int slice_refs_empty?(slice s) asm "SREMPTY";
|
||||||
|
|
||||||
|
;;; Returns the depth of `slice` [s].
|
||||||
|
;;; If [s] has no references, then returns `0`;
|
||||||
|
;;; otherwise the returned value is one plus the maximum of depths of cells referred to from [s].
|
||||||
|
int slice_depth(slice s) asm "SDEPTH";
|
||||||
|
|
||||||
|
{-
|
||||||
|
# Builder size primitives
|
||||||
|
-}
|
||||||
|
|
||||||
|
;;; Returns the number of cell references already stored in `builder` [b]
|
||||||
|
int builder_refs(builder b) asm "BREFS";
|
||||||
|
|
||||||
|
;;; Returns the number of data bits already stored in `builder` [b].
|
||||||
|
int builder_bits(builder b) asm "BBITS";
|
||||||
|
|
||||||
|
;;; Returns the depth of `builder` [b].
|
||||||
|
;;; If no cell references are stored in [b], then returns 0;
|
||||||
|
;;; otherwise the returned value is one plus the maximum of depths of cells referred to from [b].
|
||||||
|
int builder_depth(builder b) asm "BDEPTH";
|
||||||
|
|
||||||
|
{-
|
||||||
|
# Builder primitives
|
||||||
|
It is said that a primitive _stores_ a value `x` into a builder `b`
|
||||||
|
if it returns a modified version of the builder `b'` with the value `x` stored at the end of it.
|
||||||
|
It can be used as [non-modifying method](https://ton.org/docs/#/func/statements?id=non-modifying-methods).
|
||||||
|
|
||||||
|
All the primitives below first check whether there is enough space in the `builder`,
|
||||||
|
and only then check the range of the value being serialized.
|
||||||
|
-}
|
||||||
|
|
||||||
|
;;; Creates a new empty `builder`.
|
||||||
|
builder begin_cell() asm "NEWC";
|
||||||
|
|
||||||
|
;;; Converts a `builder` into an ordinary `cell`.
|
||||||
|
cell end_cell(builder b) asm "ENDC";
|
||||||
|
|
||||||
|
;;; Stores a reference to `cell` [c] into `builder` [b].
|
||||||
|
builder store_ref(builder b, cell c) asm(c b) "STREF";
|
||||||
|
|
||||||
|
;;; Stores an unsigned [len]-bit integer `x` into `b` for `0 ≤ len ≤ 256`.
|
||||||
|
;; builder store_uint(builder b, int x, int len) asm(x b len) "STUX";
|
||||||
|
|
||||||
|
;;; Stores a signed [len]-bit integer `x` into `b` for` 0 ≤ len ≤ 257`.
|
||||||
|
;; builder store_int(builder b, int x, int len) asm(x b len) "STIX";
|
||||||
|
|
||||||
|
|
||||||
|
;;; Stores `slice` [s] into `builder` [b]
|
||||||
|
builder store_slice(builder b, slice s) asm "STSLICER";
|
||||||
|
|
||||||
|
;;; Stores (serializes) an integer [x] in the range `0..2^120 − 1` into `builder` [b].
|
||||||
|
;;; The serialization of [x] consists of a 4-bit unsigned big-endian integer `l`,
|
||||||
|
;;; which is the smallest integer `l ≥ 0`, such that `x < 2^8l`,
|
||||||
|
;;; followed by an `8l`-bit unsigned big-endian representation of [x].
|
||||||
|
;;; If [x] does not belong to the supported range, a range check exception is thrown.
|
||||||
|
;;;
|
||||||
|
;;; Store amounts of TonCoins to the builder as VarUInteger 16
|
||||||
|
builder store_grams(builder b, int x) asm "STGRAMS";
|
||||||
|
builder store_coins(builder b, int x) asm "STVARUINT16";
|
||||||
|
|
||||||
|
builder store_varint16(builder b, int x) asm "STVARINT16";
|
||||||
|
builder store_varint32(builder b, int x) asm "STVARINT32";
|
||||||
|
builder store_varuint16(builder b, int x) asm "STVARUINT16";
|
||||||
|
builder store_varuint32(builder b, int x) asm "STVARUINT32";
|
||||||
|
|
||||||
|
;;; Stores dictionary `D` represented by `cell` [c] or `null` into `builder` [b].
|
||||||
|
;;; In other words, stores a `1`-bit and a reference to [c] if [c] is not `null` and `0`-bit otherwise.
|
||||||
|
builder store_dict(builder b, cell c) asm(c b) "STDICT";
|
||||||
|
|
||||||
|
;;; Stores (Maybe ^Cell) to builder:
|
||||||
|
;;; if cell is null store 1 zero bit
|
||||||
|
;;; otherwise store 1 true bit and ref to cell
|
||||||
|
builder store_maybe_ref(builder b, cell c) asm(c b) "STOPTREF";
|
||||||
|
|
||||||
|
|
||||||
|
{-
|
||||||
|
# Address manipulation primitives
|
||||||
|
The address manipulation primitives listed below serialize and deserialize values according to the following TL-B scheme:
|
||||||
|
```TL-B
|
||||||
|
addr_none$00 = MsgAddressExt;
|
||||||
|
addr_extern$01 len:(## 8) external_address:(bits len)
|
||||||
|
= MsgAddressExt;
|
||||||
|
anycast_info$_ depth:(#<= 30) { depth >= 1 }
|
||||||
|
rewrite_pfx:(bits depth) = Anycast;
|
||||||
|
addr_std$10 anycast:(Maybe Anycast)
|
||||||
|
workchain_id:int8 address:bits256 = MsgAddressInt;
|
||||||
|
addr_var$11 anycast:(Maybe Anycast) addr_len:(## 9)
|
||||||
|
workchain_id:int32 address:(bits addr_len) = MsgAddressInt;
|
||||||
|
_ _:MsgAddressInt = MsgAddress;
|
||||||
|
_ _:MsgAddressExt = MsgAddress;
|
||||||
|
|
||||||
|
int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool
|
||||||
|
src:MsgAddress dest:MsgAddressInt
|
||||||
|
value:CurrencyCollection ihr_fee:Grams fwd_fee:Grams
|
||||||
|
created_lt:uint64 created_at:uint32 = CommonMsgInfoRelaxed;
|
||||||
|
ext_out_msg_info$11 src:MsgAddress dest:MsgAddressExt
|
||||||
|
created_lt:uint64 created_at:uint32 = CommonMsgInfoRelaxed;
|
||||||
|
```
|
||||||
|
A deserialized `MsgAddress` is represented by a tuple `t` as follows:
|
||||||
|
|
||||||
|
- `addr_none` is represented by `t = (0)`,
|
||||||
|
i.e., a tuple containing exactly one integer equal to zero.
|
||||||
|
- `addr_extern` is represented by `t = (1, s)`,
|
||||||
|
where slice `s` contains the field `external_address`. In other words, `
|
||||||
|
t` is a pair (a tuple consisting of two entries), containing an integer equal to one and slice `s`.
|
||||||
|
- `addr_std` is represented by `t = (2, u, x, s)`,
|
||||||
|
where `u` is either a `null` (if `anycast` is absent) or a slice `s'` containing `rewrite_pfx` (if anycast is present).
|
||||||
|
Next, integer `x` is the `workchain_id`, and slice `s` contains the address.
|
||||||
|
- `addr_var` is represented by `t = (3, u, x, s)`,
|
||||||
|
where `u`, `x`, and `s` have the same meaning as for `addr_std`.
|
||||||
|
-}
|
||||||
|
|
||||||
|
;;; Loads from slice [s] the only prefix that is a valid `MsgAddress`,
|
||||||
|
;;; and returns both this prefix `s'` and the remainder `s''` of [s] as slices.
|
||||||
|
(slice, slice) load_msg_addr(slice s) asm(-> 1 0) "LDMSGADDR";
|
||||||
|
|
||||||
|
;;; Decomposes slice [s] containing a valid `MsgAddress` into a `tuple t` with separate fields of this `MsgAddress`.
|
||||||
|
;;; If [s] is not a valid `MsgAddress`, a cell deserialization exception is thrown.
|
||||||
|
tuple parse_addr(slice s) asm "PARSEMSGADDR";
|
||||||
|
|
||||||
|
;;; Parses slice [s] containing a valid `MsgAddressInt` (usually a `msg_addr_std`),
|
||||||
|
;;; applies rewriting from the anycast (if present) to the same-length prefix of the address,
|
||||||
|
;;; and returns both the workchain and the 256-bit address as integers.
|
||||||
|
;;; If the address is not 256-bit, or if [s] is not a valid serialization of `MsgAddressInt`,
|
||||||
|
;;; throws a cell deserialization exception.
|
||||||
|
(int, int) parse_std_addr(slice s) asm "REWRITESTDADDR";
|
||||||
|
|
||||||
|
;;; A variant of [parse_std_addr] that returns the (rewritten) address as a slice [s],
|
||||||
|
;;; even if it is not exactly 256 bit long (represented by a `msg_addr_var`).
|
||||||
|
(int, slice) parse_var_addr(slice s) asm "REWRITEVARADDR";
|
||||||
|
|
||||||
|
{-
|
||||||
|
# Dictionary primitives
|
||||||
|
-}
|
||||||
|
|
||||||
|
|
||||||
|
;;; Sets the value associated with [key_len]-bit key signed index in dictionary [dict] to [value] (cell),
|
||||||
|
;;; and returns the resulting dictionary.
|
||||||
|
cell idict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETREF";
|
||||||
|
(cell, ()) ~idict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETREF";
|
||||||
|
|
||||||
|
;;; Sets the value associated with [key_len]-bit key unsigned index in dictionary [dict] to [value] (cell),
|
||||||
|
;;; and returns the resulting dictionary.
|
||||||
|
cell udict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETREF";
|
||||||
|
(cell, ()) ~udict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETREF";
|
||||||
|
|
||||||
|
cell idict_get_ref(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGETOPTREF";
|
||||||
|
(cell, int) idict_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGETREF" "NULLSWAPIFNOT";
|
||||||
|
(cell, int) udict_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUGETREF" "NULLSWAPIFNOT";
|
||||||
|
(cell, cell) idict_set_get_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETGETOPTREF";
|
||||||
|
(cell, cell) udict_set_get_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETGETOPTREF";
|
||||||
|
(cell, int) idict_delete?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDEL";
|
||||||
|
(cell, int) udict_delete?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDEL";
|
||||||
|
(slice, int) idict_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGET" "NULLSWAPIFNOT";
|
||||||
|
(slice, int) udict_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUGET" "NULLSWAPIFNOT";
|
||||||
|
(cell, slice, int) idict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT";
|
||||||
|
(cell, slice, int) udict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT";
|
||||||
|
(cell, (slice, int)) ~idict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT";
|
||||||
|
(cell, (slice, int)) ~udict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT";
|
||||||
|
(cell, cell, int) idict_delete_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDELGETREF" "NULLSWAPIFNOT";
|
||||||
|
(cell, cell, int) udict_delete_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDELGETREF" "NULLSWAPIFNOT";
|
||||||
|
(cell, (cell, int)) ~idict_delete_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDELGETREF" "NULLSWAPIFNOT";
|
||||||
|
(cell, (cell, int)) ~udict_delete_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDELGETREF" "NULLSWAPIFNOT";
|
||||||
|
cell udict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUSET";
|
||||||
|
(cell, ()) ~udict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUSET";
|
||||||
|
cell idict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTISET";
|
||||||
|
(cell, ()) ~idict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTISET";
|
||||||
|
cell dict_set(cell dict, int key_len, slice index, slice value) asm(value index dict key_len) "DICTSET";
|
||||||
|
(cell, ()) ~dict_set(cell dict, int key_len, slice index, slice value) asm(value index dict key_len) "DICTSET";
|
||||||
|
(cell, int) udict_add?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUADD";
|
||||||
|
(cell, int) udict_replace?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUREPLACE";
|
||||||
|
(cell, int) udict_replace_ref?(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUREPLACEREF";
|
||||||
|
(cell, slice, int) udict_replaceget?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUREPLACEGET" "NULLSWAPIFNOT";
|
||||||
|
(cell, cell, int) udict_replaceget_ref?(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUREPLACEGETREF" "NULLSWAPIFNOT";
|
||||||
|
(cell, (slice, int)) ~udict_replaceget?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUREPLACEGET" "NULLSWAPIFNOT";
|
||||||
|
(cell, (cell, int)) ~udict_replaceget_ref?(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUREPLACEGETREF" "NULLSWAPIFNOT";
|
||||||
|
(cell, int) idict_add?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTIADD";
|
||||||
|
(cell, int) idict_replace?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTIREPLACE";
|
||||||
|
(cell, int) idict_replace_ref?(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTIREPLACEREF";
|
||||||
|
(cell, slice, int) idict_replaceget?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTIREPLACEGET" "NULLSWAPIFNOT";
|
||||||
|
(cell, cell, int) idict_replaceget_ref?(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTIREPLACEGETREF" "NULLSWAPIFNOT";
|
||||||
|
(cell, (slice, int)) ~idict_replaceget?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTIREPLACEGET" "NULLSWAPIFNOT";
|
||||||
|
(cell, (cell, int)) ~idict_replaceget_ref?(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTIREPLACEGETREF" "NULLSWAPIFNOT";
|
||||||
|
cell udict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUSETB";
|
||||||
|
(cell, ()) ~udict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUSETB";
|
||||||
|
cell idict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTISETB";
|
||||||
|
(cell, ()) ~idict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTISETB";
|
||||||
|
cell dict_set_builder(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTSETB";
|
||||||
|
(cell, ()) ~dict_set_builder(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTSETB";
|
||||||
|
(cell, int) dict_replace_builder?(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTREPLACEB";
|
||||||
|
(cell, builder, int) dict_replaceget_builder?(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTREPLACEGETB" "NULLSWAPIFNOT";
|
||||||
|
(cell, slice, int) dict_replaceget?(cell dict, int key_len, slice index, slice value) asm(value index dict key_len) "DICTREPLACEGET" "NULLSWAPIFNOT";
|
||||||
|
(cell, (builder, int)) ~dict_replaceget_builder?(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTREPLACEGETB" "NULLSWAPIFNOT";
|
||||||
|
(cell, (slice, int)) ~dict_replaceget?(cell dict, int key_len, slice index, slice value) asm(value index dict key_len) "DICTREPLACEGET" "NULLSWAPIFNOT";
|
||||||
|
(cell, int) udict_add_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUADDB";
|
||||||
|
(cell, int) udict_replace_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUREPLACEB";
|
||||||
|
(cell, builder, int) udict_replaceget_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUREPLACEGETB" "NULLSWAPIFNOT";
|
||||||
|
(cell, (builder, int)) ~udict_replaceget_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUREPLACEGETB" "NULLSWAPIFNOT";
|
||||||
|
(cell, int) idict_add_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTIADDB";
|
||||||
|
(cell, int) idict_replace_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTIREPLACEB";
|
||||||
|
(cell, builder, int) idict_replaceget_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTIREPLACEGETB" "NULLSWAPIFNOT";
|
||||||
|
(cell, (builder, int)) ~idict_replaceget_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTIREPLACEGETB" "NULLSWAPIFNOT";
|
||||||
|
(cell, int, slice, int) udict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2";
|
||||||
|
(cell, (int, slice, int)) ~udict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2";
|
||||||
|
(cell, int, slice, int) idict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2";
|
||||||
|
(cell, (int, slice, int)) ~idict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2";
|
||||||
|
(cell, slice, slice, int) dict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2";
|
||||||
|
(cell, (slice, slice, int)) ~dict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2";
|
||||||
|
(cell, int, slice, int) udict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2";
|
||||||
|
(cell, (int, slice, int)) ~udict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2";
|
||||||
|
(cell, int, slice, int) idict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2";
|
||||||
|
(cell, (int, slice, int)) ~idict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2";
|
||||||
|
(cell, slice, slice, int) dict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2";
|
||||||
|
(cell, (slice, slice, int)) ~dict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2";
|
||||||
|
(int, slice, int) udict_get_min?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMIN" "NULLSWAPIFNOT2";
|
||||||
|
(int, slice, int) udict_get_max?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMAX" "NULLSWAPIFNOT2";
|
||||||
|
(int, cell, int) udict_get_min_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMINREF" "NULLSWAPIFNOT2";
|
||||||
|
(int, cell, int) udict_get_max_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMAXREF" "NULLSWAPIFNOT2";
|
||||||
|
(int, slice, int) idict_get_min?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMIN" "NULLSWAPIFNOT2";
|
||||||
|
(int, slice, int) idict_get_max?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMAX" "NULLSWAPIFNOT2";
|
||||||
|
(int, cell, int) idict_get_min_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMINREF" "NULLSWAPIFNOT2";
|
||||||
|
(int, cell, int) idict_get_max_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMAXREF" "NULLSWAPIFNOT2";
|
||||||
|
(int, slice, int) udict_get_next?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXT" "NULLSWAPIFNOT2";
|
||||||
|
(int, slice, int) udict_get_nexteq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXTEQ" "NULLSWAPIFNOT2";
|
||||||
|
(int, slice, int) udict_get_prev?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETPREV" "NULLSWAPIFNOT2";
|
||||||
|
(int, slice, int) udict_get_preveq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETPREVEQ" "NULLSWAPIFNOT2";
|
||||||
|
(int, slice, int) idict_get_next?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXT" "NULLSWAPIFNOT2";
|
||||||
|
(int, slice, int) idict_get_nexteq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXTEQ" "NULLSWAPIFNOT2";
|
||||||
|
(int, slice, int) idict_get_prev?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETPREV" "NULLSWAPIFNOT2";
|
||||||
|
(int, slice, int) idict_get_preveq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETPREVEQ" "NULLSWAPIFNOT2";
|
||||||
|
|
||||||
|
;;; Creates an empty dictionary, which is actually a null value. Equivalent to PUSHNULL
|
||||||
|
cell new_dict() asm "NEWDICT";
|
||||||
|
;;; Checks whether a dictionary is empty. Equivalent to cell_null?.
|
||||||
|
int dict_empty?(cell c) asm "DICTEMPTY";
|
||||||
|
|
||||||
|
|
||||||
|
{- Prefix dictionary primitives -}
|
||||||
|
(slice, slice, slice, int) pfxdict_get?(cell dict, int key_len, slice key) asm(key dict key_len) "PFXDICTGETQ" "NULLSWAPIFNOT2";
|
||||||
|
(cell, int) pfxdict_set?(cell dict, int key_len, slice key, slice value) asm(value key dict key_len) "PFXDICTSET";
|
||||||
|
(cell, int) pfxdict_delete?(cell dict, int key_len, slice key) asm(key dict key_len) "PFXDICTDEL";
|
||||||
|
|
||||||
|
;;; Returns the value of the global configuration parameter with integer index `i` as a `cell` or `null` value.
|
||||||
|
cell config_param(int x) asm "CONFIGOPTPARAM";
|
||||||
|
;;; Checks whether c is a null. Note, that FunC also has polymorphic null? built-in.
|
||||||
|
int cell_null?(cell c) asm "ISNULL";
|
||||||
|
|
||||||
|
;;; Creates an output action which would reserve exactly amount nanotoncoins (if mode = 0), at most amount nanotoncoins (if mode = 2), or all but amount nanotoncoins (if mode = 1 or mode = 3), from the remaining balance of the account. It is roughly equivalent to creating an outbound message carrying amount nanotoncoins (or b − amount nanotoncoins, where b is the remaining balance) to oneself, so that the subsequent output actions would not be able to spend more money than the remainder. Bit +2 in mode means that the external action does not fail if the specified amount cannot be reserved; instead, all remaining balance is reserved. Bit +8 in mode means `amount <- -amount` before performing any further actions. Bit +4 in mode means that amount is increased by the original balance of the current account (before the compute phase), including all extra currencies, before performing any other checks and actions. Currently, amount must be a non-negative integer, and mode must be in the range 0..15.
|
||||||
|
() raw_reserve(int amount, int mode) impure asm "RAWRESERVE";
|
||||||
|
;;; Similar to raw_reserve, but also accepts a dictionary extra_amount (represented by a cell or null) with extra currencies. In this way currencies other than TonCoin can be reserved.
|
||||||
|
() raw_reserve_extra(int amount, cell extra_amount, int mode) impure asm "RAWRESERVEX";
|
||||||
|
;;; Sends a raw message contained in msg, which should contain a correctly serialized object Message X, with the only exception that the source address is allowed to have dummy value addr_none (to be automatically replaced with the current smart contract address), and ihr_fee, fwd_fee, created_lt and created_at fields can have arbitrary values (to be rewritten with correct values during the action phase of the current transaction). Integer parameter mode contains the flags. Currently mode = 0 is used for ordinary messages; mode = 128 is used for messages that are to carry all the remaining balance of the current smart contract (instead of the value originally indicated in the message); mode = 64 is used for messages that carry all the remaining value of the inbound message in addition to the value initially indicated in the new message (if bit 0 is not set, the gas fees are deducted from this amount); mode' = mode + 1 means that the sender wants to pay transfer fees separately; mode' = mode + 2 means that any errors arising while processing this message during the action phase should be ignored. Finally, mode' = mode + 32 means that the current account must be destroyed if its resulting balance is zero. This flag is usually employed together with +128.
|
||||||
|
() send_raw_message(cell msg, int mode) impure asm "SENDRAWMSG";
|
||||||
|
;;; Creates an output action that would change this smart contract code to that given by cell new_code. Notice that this change will take effect only after the successful termination of the current run of the smart contract
|
||||||
|
() set_code(cell new_code) impure asm "SETCODE";
|
||||||
|
|
||||||
|
;;; Generates a new pseudo-random unsigned 256-bit integer x. The algorithm is as follows: if r is the old value of the random seed, considered as a 32-byte array (by constructing the big-endian representation of an unsigned 256-bit integer), then its sha512(r) is computed; the first 32 bytes of this hash are stored as the new value r' of the random seed, and the remaining 32 bytes are returned as the next random value x.
|
||||||
|
int random() impure asm "RANDU256";
|
||||||
|
;;; Generates a new pseudo-random integer z in the range 0..range−1 (or range..−1, if range < 0). More precisely, an unsigned random value x is generated as in random; then z := x * range / 2^256 is computed.
|
||||||
|
int rand(int range) impure asm "RAND";
|
||||||
|
;;; Returns the current random seed as an unsigned 256-bit Integer.
|
||||||
|
int get_seed() impure asm "RANDSEED";
|
||||||
|
;;; Sets the random seed to unsigned 256-bit seed.
|
||||||
|
() set_seed(int x) impure asm "SETRAND";
|
||||||
|
;;; Mixes unsigned 256-bit integer x into the random seed r by setting the random seed to sha256 of the concatenation of two 32-byte strings: the first with the big-endian representation of the old seed r, and the second with the big-endian representation of x.
|
||||||
|
() randomize(int x) impure asm "ADDRAND";
|
||||||
|
;;; Equivalent to randomize(cur_lt());.
|
||||||
|
() randomize_lt() impure asm "LTIME" "ADDRAND";
|
||||||
|
|
||||||
|
;;; Checks whether the data parts of two slices coinside
|
||||||
|
int equal_slices_bits(slice a, slice b) asm "SDEQ";
|
||||||
|
;;; Checks whether b is a null. Note, that FunC also has polymorphic null? built-in.
|
||||||
|
int builder_null?(builder b) asm "ISNULL";
|
||||||
|
;;; Concatenates two builders
|
||||||
|
builder store_builder(builder to, builder from) asm "STBR";
|
||||||
|
|
||||||
|
;; CUSTOM:
|
||||||
|
|
||||||
|
;; TVM UPGRADE 2023-07 https://docs.ton.org/learn/tvm-instructions/tvm-upgrade-2023-07
|
||||||
|
;; In mainnet since 20 Dec 2023 https://t.me/tonblockchain/226
|
||||||
|
|
||||||
|
;;; Retrieves code of smart-contract from c7
|
||||||
|
|
||||||
|
cell my_code() asm "MYCODE";
|
||||||
|
|
@ -16,26 +16,27 @@ add_executable(blockchain-explorer ${BLOCHAIN_EXPLORER_SOURCE})
|
||||||
if (NIX)
|
if (NIX)
|
||||||
if (MHD_FOUND)
|
if (MHD_FOUND)
|
||||||
target_include_directories(blockchain-explorer PUBLIC ${MHD_INCLUDE_DIR})
|
target_include_directories(blockchain-explorer PUBLIC ${MHD_INCLUDE_DIR})
|
||||||
target_link_libraries(blockchain-explorer tdutils tdactor adnllite tl_lite_api tl-lite-utils ton_crypto ton_block ${MHD_LIBRARY})
|
target_link_libraries(blockchain-explorer tdactor adnllite tl_lite_api tl-lite-utils ton_crypto ${MHD_LIBRARY})
|
||||||
else()
|
else()
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_check_modules(MHD libmicrohttpd)
|
pkg_check_modules(MHD libmicrohttpd)
|
||||||
target_include_directories(blockchain-explorer PUBLIC ${MHD_INCLUDE_DIR} ${MHD_STATIC_INCLUDE_DIRS})
|
target_include_directories(blockchain-explorer PUBLIC ${MHD_INCLUDE_DIR} ${MHD_STATIC_INCLUDE_DIRS})
|
||||||
target_link_libraries(blockchain-explorer tdutils tdactor adnllite tl_lite_api tl-lite-utils ton_crypto ton_block ${MHD_LIBRARIES} ${MHD_STATIC_LIBRARIES})
|
target_link_libraries(blockchain-explorer tdactor adnllite tl_lite_api tl-lite-utils ton_crypto ${MHD_LIBRARIES} ${MHD_STATIC_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
if (MHD_FOUND)
|
if (MHD_FOUND)
|
||||||
target_include_directories(blockchain-explorer PUBLIC ${MHD_INCLUDE_DIR})
|
target_include_directories(blockchain-explorer PUBLIC ${MHD_INCLUDE_DIR})
|
||||||
target_link_libraries(blockchain-explorer tdutils tdactor adnllite tl_lite_api tl-lite-utils ton_crypto ton_block ${MHD_LIBRARY})
|
target_link_libraries(blockchain-explorer tdactor adnllite tl_lite_api tl-lite-utils ton_crypto ${MHD_LIBRARY})
|
||||||
else()
|
else()
|
||||||
find_package(MHD)
|
find_package(MHD)
|
||||||
target_include_directories(blockchain-explorer PUBLIC ${MHD_INCLUDE_DIR})
|
target_include_directories(blockchain-explorer PUBLIC ${MHD_INCLUDE_DIR})
|
||||||
target_link_libraries(blockchain-explorer tdutils tdactor adnllite tl_lite_api tl-lite-utils ton_crypto ton_block ${MHD_LIBRARY})
|
target_link_libraries(blockchain-explorer tdactor adnllite tl_lite_api tl-lite-utils ton_crypto ${MHD_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(blockchain-explorer PUBLIC ${MHD_INCLUDE_DIR})
|
target_include_directories(blockchain-explorer PUBLIC ${MHD_INCLUDE_DIR})
|
||||||
target_link_libraries(blockchain-explorer tdutils tdactor adnllite tl_lite_api tl-lite-utils ton_crypto ton_block ${MHD_LIBRARY})
|
target_link_libraries(blockchain-explorer tdactor adnllite tl_lite_api tl-lite-utils ton_crypto ${MHD_LIBRARY})
|
||||||
|
target_link_libraries(blockchain-explorer lite-client-common)
|
||||||
|
|
||||||
install(TARGETS blockchain-explorer RUNTIME DESTINATION bin)
|
install(TARGETS blockchain-explorer RUNTIME DESTINATION bin)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -122,9 +122,8 @@ HttpAnswer& HttpAnswer::operator<<(MessageCell msg) {
|
||||||
abort("cannot unpack internal message");
|
abort("cannot unpack internal message");
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
td::RefInt256 value;
|
block::CurrencyCollection currency_collection;
|
||||||
td::Ref<vm::Cell> extra;
|
if (!currency_collection.unpack(info.value)) {
|
||||||
if (!block::unpack_CurrencyCollection(info.value, value, extra)) {
|
|
||||||
abort("cannot unpack message value");
|
abort("cannot unpack message value");
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
@ -133,7 +132,7 @@ HttpAnswer& HttpAnswer::operator<<(MessageCell msg) {
|
||||||
<< "<tr><th>destination</th><td>" << AddressCell{info.dest} << "</td></tr>\n"
|
<< "<tr><th>destination</th><td>" << AddressCell{info.dest} << "</td></tr>\n"
|
||||||
<< "<tr><th>lt</th><td>" << info.created_lt << "</td></tr>\n"
|
<< "<tr><th>lt</th><td>" << info.created_lt << "</td></tr>\n"
|
||||||
<< "<tr><th>time</th><td>" << info.created_at << " (" << time_to_human(info.created_at) << ")</td></tr>\n"
|
<< "<tr><th>time</th><td>" << info.created_at << " (" << time_to_human(info.created_at) << ")</td></tr>\n"
|
||||||
<< "<tr><th>value</th><td>" << value << "</td></tr>\n";
|
<< "<tr><th>value</th><td>" << currency_collection.to_str()<< "</td></tr>\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
@ -365,6 +364,7 @@ HttpAnswer& HttpAnswer::operator<<(AccountCell acc_c) {
|
||||||
ton::LogicalTime last_trans_lt = 0;
|
ton::LogicalTime last_trans_lt = 0;
|
||||||
ton::Bits256 last_trans_hash;
|
ton::Bits256 last_trans_hash;
|
||||||
last_trans_hash.set_zero();
|
last_trans_hash.set_zero();
|
||||||
|
block::CurrencyCollection balance = block::CurrencyCollection::zero();
|
||||||
try {
|
try {
|
||||||
auto state_root = vm::MerkleProof::virtualize(acc_c.q_roots[1], 1);
|
auto state_root = vm::MerkleProof::virtualize(acc_c.q_roots[1], 1);
|
||||||
if (state_root.is_null()) {
|
if (state_root.is_null()) {
|
||||||
|
|
@ -397,6 +397,20 @@ HttpAnswer& HttpAnswer::operator<<(AccountCell acc_c) {
|
||||||
}
|
}
|
||||||
last_trans_hash = acc_info.last_trans_hash;
|
last_trans_hash = acc_info.last_trans_hash;
|
||||||
last_trans_lt = acc_info.last_trans_lt;
|
last_trans_lt = acc_info.last_trans_lt;
|
||||||
|
block::gen::Account::Record_account acc;
|
||||||
|
block::gen::AccountStorage::Record storage_rec;
|
||||||
|
if (!tlb::unpack_cell(acc_c.root, acc)) {
|
||||||
|
abort("cannot unpack Account");
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
if (!tlb::csr_unpack(acc.storage, storage_rec)) {
|
||||||
|
abort("cannot unpack AccountStorage");
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
if (!balance.unpack(storage_rec.balance)) {
|
||||||
|
abort("cannot unpack account balance");
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
} else if (acc_c.root.not_null()) {
|
} else if (acc_c.root.not_null()) {
|
||||||
abort(PSTRING() << "account state proof shows that account state for " << acc_c.addr.workchain << ":"
|
abort(PSTRING() << "account state proof shows that account state for " << acc_c.addr.workchain << ":"
|
||||||
<< acc_c.addr.addr.to_hex() << " must be empty, but it is not");
|
<< acc_c.addr.addr.to_hex() << " must be empty, but it is not");
|
||||||
|
|
@ -434,6 +448,7 @@ HttpAnswer& HttpAnswer::operator<<(AccountCell acc_c) {
|
||||||
*this << "<tr><th>workchain</th><td>" << acc_c.addr.workchain << "</td></tr>";
|
*this << "<tr><th>workchain</th><td>" << acc_c.addr.workchain << "</td></tr>";
|
||||||
*this << "<tr><th>account hex</th><td>" << acc_c.addr.addr.to_hex() << "</td></tr>";
|
*this << "<tr><th>account hex</th><td>" << acc_c.addr.addr.to_hex() << "</td></tr>";
|
||||||
*this << "<tr><th>account</th><td>" << acc_c.addr.rserialize(true) << "</td></tr>";
|
*this << "<tr><th>account</th><td>" << acc_c.addr.rserialize(true) << "</td></tr>";
|
||||||
|
*this << "<tr><th>balance</th><td>" << balance.to_str() << "</td></tr>";
|
||||||
if (last_trans_lt > 0) {
|
if (last_trans_lt > 0) {
|
||||||
*this << "<tr><th>last transaction</th><td>"
|
*this << "<tr><th>last transaction</th><td>"
|
||||||
<< "<a href=\"" << TransactionLink{acc_c.addr, last_trans_lt, last_trans_hash} << "\">lt=" << last_trans_lt
|
<< "<a href=\"" << TransactionLink{acc_c.addr, last_trans_lt, last_trans_hash} << "\">lt=" << last_trans_lt
|
||||||
|
|
|
||||||
|
|
@ -50,32 +50,6 @@
|
||||||
#include "vm/vm.h"
|
#include "vm/vm.h"
|
||||||
#include "vm/cp0.h"
|
#include "vm/cp0.h"
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
td::Ref<vm::Tuple> prepare_vm_c7(ton::UnixTime now, ton::LogicalTime lt, td::Ref<vm::CellSlice> my_addr,
|
|
||||||
const block::CurrencyCollection &balance) {
|
|
||||||
td::BitArray<256> rand_seed;
|
|
||||||
td::RefInt256 rand_seed_int{true};
|
|
||||||
td::Random::secure_bytes(rand_seed.as_slice());
|
|
||||||
if (!rand_seed_int.unique_write().import_bits(rand_seed.cbits(), 256, false)) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
auto tuple = vm::make_tuple_ref(td::make_refint(0x076ef1ea), // [ magic:0x076ef1ea
|
|
||||||
td::make_refint(0), // actions:Integer
|
|
||||||
td::make_refint(0), // msgs_sent:Integer
|
|
||||||
td::make_refint(now), // unixtime:Integer
|
|
||||||
td::make_refint(lt), // block_lt:Integer
|
|
||||||
td::make_refint(lt), // trans_lt:Integer
|
|
||||||
std::move(rand_seed_int), // rand_seed:Integer
|
|
||||||
balance.as_vm_tuple(), // balance_remaining:[Integer (Maybe Cell)]
|
|
||||||
my_addr, // myself:MsgAddressInt
|
|
||||||
vm::StackEntry()); // global_config:(Maybe Cell) ] = SmartContractInfo;
|
|
||||||
LOG(DEBUG) << "SmartContractInfo initialized with " << vm::StackEntry(tuple).to_string();
|
|
||||||
return vm::make_tuple_ref(std::move(tuple));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
td::Result<ton::BlockIdExt> parse_block_id(std::map<std::string, std::string> &opts, bool allow_empty) {
|
td::Result<ton::BlockIdExt> parse_block_id(std::map<std::string, std::string> &opts, bool allow_empty) {
|
||||||
if (allow_empty) {
|
if (allow_empty) {
|
||||||
if (opts.count("workchain") == 0 && opts.count("shard") == 0 && opts.count("seqno") == 0) {
|
if (opts.count("workchain") == 0 && opts.count("shard") == 0 && opts.count("seqno") == 0) {
|
||||||
|
|
@ -1343,111 +1317,71 @@ void HttpQueryRunMethod::start_up_query() {
|
||||||
if (R.is_error()) {
|
if (R.is_error()) {
|
||||||
td::actor::send_closure(SelfId, &HttpQueryRunMethod::abort_query, R.move_as_error_prefix("litequery failed: "));
|
td::actor::send_closure(SelfId, &HttpQueryRunMethod::abort_query, R.move_as_error_prefix("litequery failed: "));
|
||||||
} else {
|
} else {
|
||||||
td::actor::send_closure(SelfId, &HttpQueryRunMethod::got_account, R.move_as_ok());
|
td::actor::send_closure(SelfId, &HttpQueryRunMethod::got_result, R.move_as_ok());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
auto a = ton::create_tl_object<ton::lite_api::liteServer_accountId>(addr_.workchain, addr_.addr);
|
auto a = ton::create_tl_object<ton::lite_api::liteServer_accountId>(addr_.workchain, addr_.addr);
|
||||||
auto query = ton::serialize_tl_object(ton::create_tl_object<ton::lite_api::liteServer_getAccountState>(
|
td::int64 method_id = (td::crc16(td::Slice{method_name_}) & 0xffff) | 0x10000;
|
||||||
ton::create_tl_lite_block_id(block_id_), std::move(a)),
|
|
||||||
true);
|
// serialize params
|
||||||
|
vm::CellBuilder cb;
|
||||||
|
td::Ref<vm::Cell> cell;
|
||||||
|
if (!(vm::Stack{params_}.serialize(cb) && cb.finalize_to(cell))) {
|
||||||
|
return abort_query(td::Status::Error("cannot serialize stack with get-method parameters"));
|
||||||
|
}
|
||||||
|
auto params_serialized = vm::std_boc_serialize(std::move(cell));
|
||||||
|
if (params_serialized.is_error()) {
|
||||||
|
return abort_query(params_serialized.move_as_error_prefix("cannot serialize stack with get-method parameters : "));
|
||||||
|
}
|
||||||
|
|
||||||
|
auto query = ton::serialize_tl_object(
|
||||||
|
ton::create_tl_object<ton::lite_api::liteServer_runSmcMethod>(
|
||||||
|
0x17, ton::create_tl_lite_block_id(block_id_), std::move(a), method_id, params_serialized.move_as_ok()),
|
||||||
|
true);
|
||||||
td::actor::send_closure(CoreActorInterface::instance_actor_id(), &CoreActorInterface::send_lite_query,
|
td::actor::send_closure(CoreActorInterface::instance_actor_id(), &CoreActorInterface::send_lite_query,
|
||||||
std::move(query), std::move(P));
|
std::move(query), std::move(P));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpQueryRunMethod::got_account(td::BufferSlice data) {
|
void HttpQueryRunMethod::got_result(td::BufferSlice data) {
|
||||||
auto F = ton::fetch_tl_object<ton::lite_api::liteServer_accountState>(std::move(data), true);
|
auto F = ton::fetch_tl_object<ton::lite_api::liteServer_runMethodResult>(std::move(data), true);
|
||||||
if (F.is_error()) {
|
if (F.is_error()) {
|
||||||
abort_query(F.move_as_error());
|
return abort_query(F.move_as_error());
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto f = F.move_as_ok();
|
auto f = F.move_as_ok();
|
||||||
data_ = std::move(f->state_);
|
auto page = [&]() -> std::string {
|
||||||
proof_ = std::move(f->proof_);
|
HttpAnswer A{"account", prefix_};
|
||||||
shard_proof_ = std::move(f->shard_proof_);
|
A.set_account_id(addr_);
|
||||||
block_id_ = ton::create_block_id(f->id_);
|
A.set_block_id(ton::create_block_id(f->id_));
|
||||||
res_block_id_ = ton::create_block_id(f->shardblk_);
|
if (f->exit_code_ != 0) {
|
||||||
|
A.abort(PSTRING() << "VM terminated with error code " << f->exit_code_);
|
||||||
finish_query();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HttpQueryRunMethod::finish_query() {
|
|
||||||
if (promise_) {
|
|
||||||
auto page = [&]() -> std::string {
|
|
||||||
HttpAnswer A{"account", prefix_};
|
|
||||||
A.set_account_id(addr_);
|
|
||||||
A.set_block_id(res_block_id_);
|
|
||||||
|
|
||||||
block::AccountState account_state;
|
|
||||||
account_state.blk = block_id_;
|
|
||||||
account_state.shard_blk = res_block_id_;
|
|
||||||
account_state.shard_proof = std::move(shard_proof_);
|
|
||||||
account_state.proof = std::move(proof_);
|
|
||||||
account_state.state = std::move(data_);
|
|
||||||
auto r_info = account_state.validate(block_id_, addr_);
|
|
||||||
if (r_info.is_error()) {
|
|
||||||
A.abort(r_info.move_as_error());
|
|
||||||
return A.finish();
|
|
||||||
}
|
|
||||||
auto info = r_info.move_as_ok();
|
|
||||||
if (info.root.is_null()) {
|
|
||||||
A.abort(PSTRING() << "account state of " << addr_ << " is empty (cannot run method `" << method_name_ << "`)");
|
|
||||||
return A.finish();
|
|
||||||
}
|
|
||||||
block::gen::Account::Record_account acc;
|
|
||||||
block::gen::AccountStorage::Record store;
|
|
||||||
block::CurrencyCollection balance;
|
|
||||||
if (!(tlb::unpack_cell(info.root, acc) && tlb::csr_unpack(acc.storage, store) &&
|
|
||||||
balance.validate_unpack(store.balance))) {
|
|
||||||
A.abort("error unpacking account state");
|
|
||||||
return A.finish();
|
|
||||||
}
|
|
||||||
int tag = block::gen::t_AccountState.get_tag(*store.state);
|
|
||||||
switch (tag) {
|
|
||||||
case block::gen::AccountState::account_uninit:
|
|
||||||
A.abort(PSTRING() << "account " << addr_ << " not initialized yet (cannot run any methods)");
|
|
||||||
return A.finish();
|
|
||||||
case block::gen::AccountState::account_frozen:
|
|
||||||
A.abort(PSTRING() << "account " << addr_ << " frozen (cannot run any methods)");
|
|
||||||
return A.finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
CHECK(store.state.write().fetch_ulong(1) == 1); // account_init$1 _:StateInit = AccountState;
|
|
||||||
block::gen::StateInit::Record state_init;
|
|
||||||
CHECK(tlb::csr_unpack(store.state, state_init));
|
|
||||||
auto code = state_init.code->prefetch_ref();
|
|
||||||
auto data = state_init.data->prefetch_ref();
|
|
||||||
auto stack = td::make_ref<vm::Stack>(std::move(params_));
|
|
||||||
td::int64 method_id = (td::crc16(td::Slice{method_name_}) & 0xffff) | 0x10000;
|
|
||||||
stack.write().push_smallint(method_id);
|
|
||||||
long long gas_limit = vm::GasLimits::infty;
|
|
||||||
// OstreamLogger ostream_logger(ctx.error_stream);
|
|
||||||
// auto log = create_vm_log(ctx.error_stream ? &ostream_logger : nullptr);
|
|
||||||
vm::GasLimits gas{gas_limit};
|
|
||||||
LOG(DEBUG) << "creating VM";
|
|
||||||
vm::VmState vm{code, std::move(stack), gas, 1, data, vm::VmLog()};
|
|
||||||
vm.set_c7(prepare_vm_c7(info.gen_utime, info.gen_lt, acc.addr, balance)); // tuple with SmartContractInfo
|
|
||||||
// vm.incr_stack_trace(1); // enable stack dump after each step
|
|
||||||
int exit_code = ~vm.run();
|
|
||||||
if (exit_code != 0) {
|
|
||||||
A.abort(PSTRING() << "VM terminated with error code " << exit_code);
|
|
||||||
return A.finish();
|
|
||||||
}
|
|
||||||
stack = vm.get_stack_ref();
|
|
||||||
{
|
|
||||||
std::ostringstream os;
|
|
||||||
os << "result: ";
|
|
||||||
stack->dump(os, 3);
|
|
||||||
|
|
||||||
A << HttpAnswer::CodeBlock{os.str()};
|
|
||||||
}
|
|
||||||
|
|
||||||
return A.finish();
|
return A.finish();
|
||||||
}();
|
}
|
||||||
auto R = MHD_create_response_from_buffer(page.length(), const_cast<char *>(page.c_str()), MHD_RESPMEM_MUST_COPY);
|
|
||||||
MHD_add_response_header(R, "Content-Type", "text/html");
|
std::ostringstream os;
|
||||||
promise_.set_value(std::move(R));
|
os << "result: ";
|
||||||
}
|
if (f->result_.empty()) {
|
||||||
|
os << "<none>";
|
||||||
|
} else {
|
||||||
|
auto r_cell = vm::std_boc_deserialize(f->result_);
|
||||||
|
if (r_cell.is_error()) {
|
||||||
|
A.abort(PSTRING() << "cannot deserialize VM result boc: " << r_cell.move_as_error());
|
||||||
|
return A.finish();
|
||||||
|
}
|
||||||
|
auto cs = vm::load_cell_slice(r_cell.move_as_ok());
|
||||||
|
td::Ref<vm::Stack> stack;
|
||||||
|
if (!(vm::Stack::deserialize_to(cs, stack, 0) && cs.empty_ext())) {
|
||||||
|
A.abort("VM result boc cannot be deserialized");
|
||||||
|
return A.finish();
|
||||||
|
}
|
||||||
|
stack->dump(os, 3);
|
||||||
|
}
|
||||||
|
A << HttpAnswer::CodeBlock{os.str()};
|
||||||
|
return A.finish();
|
||||||
|
}();
|
||||||
|
auto R = MHD_create_response_from_buffer(page.length(), const_cast<char *>(page.c_str()), MHD_RESPMEM_MUST_COPY);
|
||||||
|
MHD_add_response_header(R, "Content-Type", "text/html");
|
||||||
|
promise_.set_value(std::move(R));
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
HttpQueryStatus::HttpQueryStatus(std::string prefix, td::Promise<MHD_Response *> promise)
|
HttpQueryStatus::HttpQueryStatus(std::string prefix, td::Promise<MHD_Response *> promise)
|
||||||
|
|
@ -1498,7 +1432,7 @@ void HttpQueryStatus::finish_query() {
|
||||||
for (td::uint32 i = 0; i < results_.ips.size(); i++) {
|
for (td::uint32 i = 0; i < results_.ips.size(); i++) {
|
||||||
A << "<tr>";
|
A << "<tr>";
|
||||||
if (results_.ips[i].is_valid()) {
|
if (results_.ips[i].is_valid()) {
|
||||||
A << "<td>" << results_.ips[i] << "</td>";
|
A << "<td>" << results_.ips[i].get_ip_str() << ":" << results_.ips[i].get_port() << "</td>";
|
||||||
} else {
|
} else {
|
||||||
A << "<td>hidden</td>";
|
A << "<td>hidden</td>";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -311,22 +311,14 @@ class HttpQueryRunMethod : public HttpQueryCommon {
|
||||||
std::vector<vm::StackEntry> params, std::string prefix, td::Promise<MHD_Response *> promise);
|
std::vector<vm::StackEntry> params, std::string prefix, td::Promise<MHD_Response *> promise);
|
||||||
HttpQueryRunMethod(std::map<std::string, std::string> opts, std::string prefix, td::Promise<MHD_Response *> promise);
|
HttpQueryRunMethod(std::map<std::string, std::string> opts, std::string prefix, td::Promise<MHD_Response *> promise);
|
||||||
|
|
||||||
void finish_query();
|
|
||||||
|
|
||||||
void start_up_query() override;
|
void start_up_query() override;
|
||||||
void got_account(td::BufferSlice result);
|
void got_result(td::BufferSlice result);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ton::BlockIdExt block_id_;
|
ton::BlockIdExt block_id_;
|
||||||
block::StdAddress addr_;
|
block::StdAddress addr_;
|
||||||
|
|
||||||
std::string method_name_;
|
std::string method_name_;
|
||||||
std::vector<vm::StackEntry> params_;
|
std::vector<vm::StackEntry> params_;
|
||||||
|
|
||||||
td::BufferSlice data_;
|
|
||||||
td::BufferSlice proof_;
|
|
||||||
td::BufferSlice shard_proof_;
|
|
||||||
ton::BlockIdExt res_block_id_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class HttpQueryStatus : public HttpQueryCommon {
|
class HttpQueryStatus : public HttpQueryCommon {
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@
|
||||||
#include "auto/tl/lite_api.h"
|
#include "auto/tl/lite_api.h"
|
||||||
#include "ton/lite-tl.hpp"
|
#include "ton/lite-tl.hpp"
|
||||||
#include "tl-utils/lite-utils.hpp"
|
#include "tl-utils/lite-utils.hpp"
|
||||||
|
#include "lite-client/ext-client.h"
|
||||||
|
|
||||||
#include <microhttpd.h>
|
#include <microhttpd.h>
|
||||||
|
|
||||||
|
|
@ -127,7 +128,7 @@ class CoreActor : public CoreActorInterface {
|
||||||
private:
|
private:
|
||||||
std::string global_config_ = "ton-global.config";
|
std::string global_config_ = "ton-global.config";
|
||||||
|
|
||||||
std::vector<td::actor::ActorOwn<ton::adnl::AdnlExtClient>> clients_;
|
td::actor::ActorOwn<liteclient::ExtClient> client_;
|
||||||
|
|
||||||
td::uint32 http_port_ = 80;
|
td::uint32 http_port_ = 80;
|
||||||
MHD_Daemon* daemon_ = nullptr;
|
MHD_Daemon* daemon_ = nullptr;
|
||||||
|
|
@ -137,35 +138,29 @@ class CoreActor : public CoreActorInterface {
|
||||||
|
|
||||||
bool hide_ips_ = false;
|
bool hide_ips_ = false;
|
||||||
|
|
||||||
std::unique_ptr<ton::adnl::AdnlExtClient::Callback> make_callback(td::uint32 idx) {
|
td::unique_ptr<liteclient::ExtClient::Callback> make_callback() {
|
||||||
class Callback : public ton::adnl::AdnlExtClient::Callback {
|
class Callback : public liteclient::ExtClient::Callback {
|
||||||
public:
|
public:
|
||||||
void on_ready() override {
|
Callback(td::actor::ActorId<CoreActor> id) : id_(std::move(id)) {
|
||||||
td::actor::send_closure(id_, &CoreActor::conn_ready, idx_);
|
|
||||||
}
|
|
||||||
void on_stop_ready() override {
|
|
||||||
td::actor::send_closure(id_, &CoreActor::conn_closed, idx_);
|
|
||||||
}
|
|
||||||
Callback(td::actor::ActorId<CoreActor> id, td::uint32 idx) : id_(std::move(id)), idx_(idx) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
td::actor::ActorId<CoreActor> id_;
|
td::actor::ActorId<CoreActor> id_;
|
||||||
td::uint32 idx_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return std::make_unique<Callback>(actor_id(this), idx);
|
return td::make_unique<Callback>(actor_id(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<RemoteNodeStatus> new_result_;
|
std::shared_ptr<RemoteNodeStatus> new_result_;
|
||||||
td::int32 attempt_ = 0;
|
td::int32 attempt_ = 0;
|
||||||
td::int32 waiting_ = 0;
|
td::int32 waiting_ = 0;
|
||||||
|
|
||||||
std::vector<bool> ready_;
|
size_t n_servers_ = 0;
|
||||||
|
|
||||||
void run_queries();
|
void run_queries();
|
||||||
void got_result(td::uint32 idx, td::int32 attempt, td::Result<td::BufferSlice> data);
|
void got_servers_ready(td::int32 attempt, std::vector<bool> ready);
|
||||||
void send_query(td::uint32 idx);
|
void send_ping(td::uint32 idx);
|
||||||
|
void got_ping_result(td::uint32 idx, td::int32 attempt, td::Result<td::BufferSlice> data);
|
||||||
|
|
||||||
void add_result() {
|
void add_result() {
|
||||||
if (new_result_) {
|
if (new_result_) {
|
||||||
|
|
@ -196,12 +191,6 @@ class CoreActor : public CoreActorInterface {
|
||||||
static CoreActor* instance_;
|
static CoreActor* instance_;
|
||||||
td::actor::ActorId<CoreActor> self_id_;
|
td::actor::ActorId<CoreActor> self_id_;
|
||||||
|
|
||||||
void conn_ready(td::uint32 idx) {
|
|
||||||
ready_.at(idx) = true;
|
|
||||||
}
|
|
||||||
void conn_closed(td::uint32 idx) {
|
|
||||||
ready_.at(idx) = false;
|
|
||||||
}
|
|
||||||
void set_global_config(std::string str) {
|
void set_global_config(std::string str) {
|
||||||
global_config_ = str;
|
global_config_ = str;
|
||||||
}
|
}
|
||||||
|
|
@ -226,10 +215,7 @@ class CoreActor : public CoreActorInterface {
|
||||||
hide_ips_ = value;
|
hide_ips_ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_lite_query(td::uint32 idx, td::BufferSlice query, td::Promise<td::BufferSlice> promise);
|
void send_lite_query(td::BufferSlice query, td::Promise<td::BufferSlice> promise) override;
|
||||||
void send_lite_query(td::BufferSlice data, td::Promise<td::BufferSlice> promise) override {
|
|
||||||
return send_lite_query(0, std::move(data), std::move(promise));
|
|
||||||
}
|
|
||||||
void get_last_result(td::Promise<std::shared_ptr<RemoteNodeStatus>> promise) override {
|
void get_last_result(td::Promise<std::shared_ptr<RemoteNodeStatus>> promise) override {
|
||||||
}
|
}
|
||||||
void get_results(td::uint32 max, td::Promise<RemoteNodeStatusList> promise) override {
|
void get_results(td::uint32 max, td::Promise<RemoteNodeStatusList> promise) override {
|
||||||
|
|
@ -449,33 +435,27 @@ class CoreActor : public CoreActorInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
void run() {
|
void run() {
|
||||||
|
std::vector<liteclient::LiteServerConfig> servers;
|
||||||
if (remote_public_key_.empty()) {
|
if (remote_public_key_.empty()) {
|
||||||
auto G = td::read_file(global_config_).move_as_ok();
|
auto G = td::read_file(global_config_).move_as_ok();
|
||||||
auto gc_j = td::json_decode(G.as_slice()).move_as_ok();
|
auto gc_j = td::json_decode(G.as_slice()).move_as_ok();
|
||||||
ton::ton_api::liteclient_config_global gc;
|
ton::ton_api::liteclient_config_global gc;
|
||||||
ton::ton_api::from_json(gc, gc_j.get_object()).ensure();
|
ton::ton_api::from_json(gc, gc_j.get_object()).ensure();
|
||||||
|
auto r_servers = liteclient::LiteServerConfig::parse_global_config(gc);
|
||||||
CHECK(gc.liteservers_.size() > 0);
|
r_servers.ensure();
|
||||||
td::uint32 size = static_cast<td::uint32>(gc.liteservers_.size());
|
servers = r_servers.move_as_ok();
|
||||||
ready_.resize(size, false);
|
for (const auto& serv : servers) {
|
||||||
|
addrs_.push_back(serv.addr);
|
||||||
for (td::uint32 i = 0; i < size; i++) {
|
|
||||||
auto& cli = gc.liteservers_[i];
|
|
||||||
td::IPAddress addr;
|
|
||||||
addr.init_host_port(td::IPAddress::ipv4_to_str(cli->ip_), cli->port_).ensure();
|
|
||||||
addrs_.push_back(addr);
|
|
||||||
clients_.emplace_back(ton::adnl::AdnlExtClient::create(ton::adnl::AdnlNodeIdFull::create(cli->id_).move_as_ok(),
|
|
||||||
addr, make_callback(i)));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!remote_addr_.is_valid()) {
|
if (!remote_addr_.is_valid()) {
|
||||||
LOG(FATAL) << "remote addr not set";
|
LOG(FATAL) << "remote addr not set";
|
||||||
}
|
}
|
||||||
ready_.resize(1, false);
|
|
||||||
addrs_.push_back(remote_addr_);
|
addrs_.push_back(remote_addr_);
|
||||||
clients_.emplace_back(ton::adnl::AdnlExtClient::create(ton::adnl::AdnlNodeIdFull{remote_public_key_},
|
servers.push_back(liteclient::LiteServerConfig{ton::adnl::AdnlNodeIdFull{remote_public_key_}, remote_addr_});
|
||||||
remote_addr_, make_callback(0)));
|
|
||||||
}
|
}
|
||||||
|
n_servers_ = servers.size();
|
||||||
|
client_ = liteclient::ExtClient::create(std::move(servers), make_callback(), true);
|
||||||
daemon_ = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, static_cast<td::uint16>(http_port_), nullptr, nullptr,
|
daemon_ = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, static_cast<td::uint16>(http_port_), nullptr, nullptr,
|
||||||
&process_http_request, nullptr, MHD_OPTION_NOTIFY_COMPLETED, request_completed, nullptr,
|
&process_http_request, nullptr, MHD_OPTION_NOTIFY_COMPLETED, request_completed, nullptr,
|
||||||
MHD_OPTION_THREAD_POOL_SIZE, 16, MHD_OPTION_END);
|
MHD_OPTION_THREAD_POOL_SIZE, 16, MHD_OPTION_END);
|
||||||
|
|
@ -483,7 +463,46 @@ class CoreActor : public CoreActorInterface {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void CoreActor::got_result(td::uint32 idx, td::int32 attempt, td::Result<td::BufferSlice> R) {
|
void CoreActor::run_queries() {
|
||||||
|
waiting_ = 0;
|
||||||
|
new_result_ = std::make_shared<RemoteNodeStatus>(n_servers_, td::Timestamp::at_unix(attempt_ * 60));
|
||||||
|
td::actor::send_closure(client_, &liteclient::ExtClient::get_servers_status,
|
||||||
|
[SelfId = actor_id(this), attempt = attempt_](td::Result<std::vector<bool>> R) {
|
||||||
|
R.ensure();
|
||||||
|
td::actor::send_closure(SelfId, &CoreActor::got_servers_ready, attempt, R.move_as_ok());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoreActor::got_servers_ready(td::int32 attempt, std::vector<bool> ready) {
|
||||||
|
if (attempt != attempt_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CHECK(ready.size() == n_servers_);
|
||||||
|
for (td::uint32 i = 0; i < n_servers_; i++) {
|
||||||
|
if (ready[i]) {
|
||||||
|
send_ping(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CHECK(waiting_ >= 0);
|
||||||
|
if (waiting_ == 0) {
|
||||||
|
add_result();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoreActor::send_ping(td::uint32 idx) {
|
||||||
|
waiting_++;
|
||||||
|
auto query = ton::create_tl_object<ton::lite_api::liteServer_getMasterchainInfo>();
|
||||||
|
auto q = ton::create_tl_object<ton::lite_api::liteServer_query>(serialize_tl_object(query, true));
|
||||||
|
|
||||||
|
auto P =
|
||||||
|
td::PromiseCreator::lambda([SelfId = actor_id(this), idx, attempt = attempt_](td::Result<td::BufferSlice> R) {
|
||||||
|
td::actor::send_closure(SelfId, &CoreActor::got_ping_result, idx, attempt, std::move(R));
|
||||||
|
});
|
||||||
|
td::actor::send_closure(client_, &liteclient::ExtClient::send_query_to_server, "query", serialize_tl_object(q, true),
|
||||||
|
idx, td::Timestamp::in(10.0), std::move(P));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoreActor::got_ping_result(td::uint32 idx, td::int32 attempt, td::Result<td::BufferSlice> R) {
|
||||||
if (attempt != attempt_) {
|
if (attempt != attempt_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -524,39 +543,7 @@ void CoreActor::got_result(td::uint32 idx, td::int32 attempt, td::Result<td::Buf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoreActor::send_query(td::uint32 idx) {
|
void CoreActor::send_lite_query(td::BufferSlice query, td::Promise<td::BufferSlice> promise) {
|
||||||
if (!ready_[idx]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
waiting_++;
|
|
||||||
auto query = ton::create_tl_object<ton::lite_api::liteServer_getMasterchainInfo>();
|
|
||||||
auto q = ton::create_tl_object<ton::lite_api::liteServer_query>(serialize_tl_object(query, true));
|
|
||||||
|
|
||||||
auto P =
|
|
||||||
td::PromiseCreator::lambda([SelfId = actor_id(this), idx, attempt = attempt_](td::Result<td::BufferSlice> R) {
|
|
||||||
td::actor::send_closure(SelfId, &CoreActor::got_result, idx, attempt, std::move(R));
|
|
||||||
});
|
|
||||||
td::actor::send_closure(clients_[idx], &ton::adnl::AdnlExtClient::send_query, "query", serialize_tl_object(q, true),
|
|
||||||
td::Timestamp::in(10.0), std::move(P));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CoreActor::run_queries() {
|
|
||||||
waiting_ = 0;
|
|
||||||
new_result_ = std::make_shared<RemoteNodeStatus>(ready_.size(), td::Timestamp::at_unix(attempt_ * 60));
|
|
||||||
for (td::uint32 i = 0; i < ready_.size(); i++) {
|
|
||||||
send_query(i);
|
|
||||||
}
|
|
||||||
CHECK(waiting_ >= 0);
|
|
||||||
if (waiting_ == 0) {
|
|
||||||
add_result();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CoreActor::send_lite_query(td::uint32 idx, td::BufferSlice query, td::Promise<td::BufferSlice> promise) {
|
|
||||||
if (!ready_[idx]) {
|
|
||||||
promise.set_error(td::Status::Error(ton::ErrorCode::notready, "ext conn not ready"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto P = td::PromiseCreator::lambda([promise = std::move(promise)](td::Result<td::BufferSlice> R) mutable {
|
auto P = td::PromiseCreator::lambda([promise = std::move(promise)](td::Result<td::BufferSlice> R) mutable {
|
||||||
if (R.is_error()) {
|
if (R.is_error()) {
|
||||||
promise.set_error(R.move_as_error());
|
promise.set_error(R.move_as_error());
|
||||||
|
|
@ -574,7 +561,7 @@ void CoreActor::send_lite_query(td::uint32 idx, td::BufferSlice query, td::Promi
|
||||||
promise.set_value(std::move(B));
|
promise.set_value(std::move(B));
|
||||||
});
|
});
|
||||||
auto q = ton::create_tl_object<ton::lite_api::liteServer_query>(std::move(query));
|
auto q = ton::create_tl_object<ton::lite_api::liteServer_query>(std::move(query));
|
||||||
td::actor::send_closure(clients_[idx], &ton::adnl::AdnlExtClient::send_query, "query", serialize_tl_object(q, true),
|
td::actor::send_closure(client_, &liteclient::ExtClient::send_query, "query", serialize_tl_object(q, true),
|
||||||
td::Timestamp::in(10.0), std::move(P));
|
td::Timestamp::in(10.0), std::move(P));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,5 @@ target_include_directories(overlay PUBLIC
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/..
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/..
|
||||||
${OPENSSL_INCLUDE_DIR}
|
${OPENSSL_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
target_link_libraries(catchain PRIVATE tdutils tdactor adnl tl_api dht tdfec
|
target_link_libraries(catchain PRIVATE tdutils tdactor adnl tl_api dht tdfec overlay)
|
||||||
overlay)
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ class CatChainReceiverSource {
|
||||||
virtual td::BufferSlice fork_proof() const = 0;
|
virtual td::BufferSlice fork_proof() const = 0;
|
||||||
virtual bool fork_is_found() const = 0;
|
virtual bool fork_is_found() const = 0;
|
||||||
|
|
||||||
// One block can be sent to one node only a limited number of times to prevent DoS
|
// One block can be sent to one node in catchain.getDifference only a limited number of times to prevent DoS
|
||||||
virtual bool allow_send_block(CatChainBlockHash hash) = 0;
|
virtual bool allow_send_block(CatChainBlockHash hash) = 0;
|
||||||
|
|
||||||
static td::Result<std::unique_ptr<CatChainReceiverSource>> create(CatChainReceiver *chain, PublicKey pub_key,
|
static td::Result<std::unique_ptr<CatChainReceiverSource>> create(CatChainReceiver *chain, PublicKey pub_key,
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@
|
||||||
|
|
||||||
#include "catchain-receiver.hpp"
|
#include "catchain-receiver.hpp"
|
||||||
|
|
||||||
|
#include "td/utils/ThreadSafeCounter.h"
|
||||||
|
|
||||||
namespace ton {
|
namespace ton {
|
||||||
|
|
||||||
namespace catchain {
|
namespace catchain {
|
||||||
|
|
@ -368,6 +370,12 @@ void CatChainReceiverImpl::add_block(td::BufferSlice payload, std::vector<CatCha
|
||||||
}
|
}
|
||||||
|
|
||||||
int height = prev->height_ + 1;
|
int height = prev->height_ + 1;
|
||||||
|
auto max_block_height = get_max_block_height(opts_, sources_.size());
|
||||||
|
if (td::narrow_cast<td::uint64>(height) > max_block_height) {
|
||||||
|
VLOG(CATCHAIN_WARNING) << this << ": cannot create block: max height exceeded (" << max_block_height << ")";
|
||||||
|
active_send_ = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto block_data = create_tl_object<ton_api::catchain_block_data>(std::move(prev), std::move(deps_arr));
|
auto block_data = create_tl_object<ton_api::catchain_block_data>(std::move(prev), std::move(deps_arr));
|
||||||
auto block = create_tl_object<ton_api::catchain_block>(incarnation_, local_idx_, height, std::move(block_data),
|
auto block = create_tl_object<ton_api::catchain_block>(incarnation_, local_idx_, height, std::move(block_data),
|
||||||
td::BufferSlice());
|
td::BufferSlice());
|
||||||
|
|
@ -518,9 +526,12 @@ void CatChainReceiverImpl::start_up() {
|
||||||
for (td::uint32 i = 0; i < get_sources_cnt(); i++) {
|
for (td::uint32 i = 0; i < get_sources_cnt(); i++) {
|
||||||
root_keys.emplace(get_source(i)->get_hash(), OVERLAY_MAX_ALLOWED_PACKET_SIZE);
|
root_keys.emplace(get_source(i)->get_hash(), OVERLAY_MAX_ALLOWED_PACKET_SIZE);
|
||||||
}
|
}
|
||||||
td::actor::send_closure(overlay_manager_, &overlay::Overlays::create_private_overlay,
|
overlay::OverlayOptions overlay_options;
|
||||||
|
overlay_options.broadcast_speed_multiplier_ = opts_.broadcast_speed_multiplier;
|
||||||
|
td::actor::send_closure(overlay_manager_, &overlay::Overlays::create_private_overlay_ex,
|
||||||
get_source(local_idx_)->get_adnl_id(), overlay_full_id_.clone(), std::move(ids),
|
get_source(local_idx_)->get_adnl_id(), overlay_full_id_.clone(), std::move(ids),
|
||||||
make_callback(), overlay::OverlayPrivacyRules{0, 0, std::move(root_keys)});
|
make_callback(), overlay::OverlayPrivacyRules{0, 0, std::move(root_keys)},
|
||||||
|
R"({ "type": "catchain" })", std::move(overlay_options));
|
||||||
|
|
||||||
CHECK(root_block_);
|
CHECK(root_block_);
|
||||||
|
|
||||||
|
|
@ -678,6 +689,7 @@ void CatChainReceiverImpl::receive_query_from_overlay(adnl::AdnlNodeIdShort src,
|
||||||
promise.set_error(td::Status::Error(ErrorCode::notready, "db not read"));
|
promise.set_error(td::Status::Error(ErrorCode::notready, "db not read"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
TD_PERF_COUNTER(catchain_query_process);
|
||||||
td::PerfWarningTimer t{"catchain query process", 0.05};
|
td::PerfWarningTimer t{"catchain query process", 0.05};
|
||||||
auto F = fetch_tl_object<ton_api::Function>(data.clone(), true);
|
auto F = fetch_tl_object<ton_api::Function>(data.clone(), true);
|
||||||
if (F.is_error()) {
|
if (F.is_error()) {
|
||||||
|
|
@ -696,12 +708,8 @@ void CatChainReceiverImpl::process_query(adnl::AdnlNodeIdShort src, ton_api::cat
|
||||||
} else {
|
} else {
|
||||||
CatChainReceiverSource *S = get_source_by_adnl_id(src);
|
CatChainReceiverSource *S = get_source_by_adnl_id(src);
|
||||||
CHECK(S != nullptr);
|
CHECK(S != nullptr);
|
||||||
if (S->allow_send_block(it->second->get_hash())) {
|
promise.set_value(serialize_tl_object(create_tl_object<ton_api::catchain_blockResult>(it->second->export_tl()),
|
||||||
promise.set_value(serialize_tl_object(create_tl_object<ton_api::catchain_blockResult>(it->second->export_tl()),
|
true, it->second->get_payload().as_slice()));
|
||||||
true, it->second->get_payload().as_slice()));
|
|
||||||
} else {
|
|
||||||
promise.set_error(td::Status::Error("block was requested too many times"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,7 @@ class CatChain : public td::actor::Actor {
|
||||||
virtual void send_query_via(const PublicKeyHash &dst, std::string name, td::Promise<td::BufferSlice> promise,
|
virtual void send_query_via(const PublicKeyHash &dst, std::string name, td::Promise<td::BufferSlice> promise,
|
||||||
td::Timestamp timeout, td::BufferSlice query, td::uint64 max_answer_size,
|
td::Timestamp timeout, td::BufferSlice query, td::uint64 max_answer_size,
|
||||||
td::actor::ActorId<adnl::AdnlSenderInterface> via) = 0;
|
td::actor::ActorId<adnl::AdnlSenderInterface> via) = 0;
|
||||||
|
virtual void get_source_heights(td::Promise<std::vector<CatChainBlockHeight>> promise) = 0;
|
||||||
virtual void destroy() = 0;
|
virtual void destroy() = 0;
|
||||||
|
|
||||||
static td::actor::ActorOwn<CatChain> create(std::unique_ptr<Callback> callback, const CatChainOptions &opts,
|
static td::actor::ActorOwn<CatChain> create(std::unique_ptr<Callback> callback, const CatChainOptions &opts,
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,15 @@ class CatChainImpl : public CatChain {
|
||||||
td::actor::send_closure(receiver_, &CatChainReceiverInterface::send_custom_query_data_via, dst, name,
|
td::actor::send_closure(receiver_, &CatChainReceiverInterface::send_custom_query_data_via, dst, name,
|
||||||
std::move(promise), timeout, std::move(query), max_answer_size, via);
|
std::move(promise), timeout, std::move(query), max_answer_size, via);
|
||||||
}
|
}
|
||||||
|
void get_source_heights(td::Promise<std::vector<CatChainBlockHeight>> promise) override {
|
||||||
|
std::vector<CatChainBlockHeight> heights(top_source_blocks_.size(), 0);
|
||||||
|
for (size_t i = 0; i < top_source_blocks_.size(); ++i) {
|
||||||
|
if (top_source_blocks_[i]) {
|
||||||
|
heights[i] = top_source_blocks_[i]->height();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
promise.set_result(std::move(heights));
|
||||||
|
}
|
||||||
void destroy() override;
|
void destroy() override;
|
||||||
CatChainImpl(std::unique_ptr<Callback> callback, const CatChainOptions &opts,
|
CatChainImpl(std::unique_ptr<Callback> callback, const CatChainOptions &opts,
|
||||||
td::actor::ActorId<keyring::Keyring> keyring, td::actor::ActorId<adnl::Adnl> adnl,
|
td::actor::ActorId<keyring::Keyring> keyring, td::actor::ActorId<adnl::Adnl> adnl,
|
||||||
|
|
|
||||||
|
|
@ -49,4 +49,29 @@ template <typename T>
|
||||||
void delay_action(T promise, td::Timestamp timeout) {
|
void delay_action(T promise, td::Timestamp timeout) {
|
||||||
DelayedAction<T>::create(std::move(promise), timeout);
|
DelayedAction<T>::create(std::move(promise), timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename PromiseT, typename ValueT>
|
||||||
|
class AsyncApply : public td::actor::Actor {
|
||||||
|
public:
|
||||||
|
AsyncApply(PromiseT promise, ValueT value) : promise_(std::move(promise)), value_(std::move(value)){
|
||||||
|
}
|
||||||
|
|
||||||
|
void start_up() override {
|
||||||
|
promise_(std::move(value_));
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void create(td::Slice name, PromiseT promise, ValueT value ) {
|
||||||
|
td::actor::create_actor<AsyncApply>(PSLICE() << "async:" << name, std::move(promise), std::move(value)).release();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
PromiseT promise_;
|
||||||
|
ValueT value_;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class PromiseT, class ValueT>
|
||||||
|
void async_apply(td::Slice name, PromiseT &&promise, ValueT &&value) {
|
||||||
|
AsyncApply<PromiseT, ValueT>::create(name, std::forward<PromiseT>(promise), std::forward<ValueT>(value));
|
||||||
|
}
|
||||||
} // namespace ton
|
} // namespace ton
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,6 @@
|
||||||
namespace ton {
|
namespace ton {
|
||||||
|
|
||||||
// See doc/GlobalVersions.md
|
// See doc/GlobalVersions.md
|
||||||
const int SUPPORTED_VERSION = 5;
|
constexpr int SUPPORTED_VERSION = 10;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,7 @@ set(CREATE_HARDFORK_SOURCE
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(create-hardfork ${CREATE_HARDFORK_SOURCE})
|
add_executable(create-hardfork ${CREATE_HARDFORK_SOURCE})
|
||||||
target_link_libraries(create-hardfork overlay tdutils tdactor adnl tl_api dht
|
target_link_libraries(create-hardfork overlay tdutils tdactor adnl tl_api dht rldp catchain validatorsession full-node validator-hardfork ton_validator
|
||||||
rldp catchain validatorsession full-node validator-hardfork ton_validator
|
|
||||||
validator-hardfork fift-lib memprof git ${JEMALLOC_LIBRARIES})
|
validator-hardfork fift-lib memprof git ${JEMALLOC_LIBRARIES})
|
||||||
|
|
||||||
install(TARGETS create-hardfork RUNTIME DESTINATION bin)
|
install(TARGETS create-hardfork RUNTIME DESTINATION bin)
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ class HardforkCreator : public td::actor::Actor {
|
||||||
ton::validator::ValidatorManagerHardforkFactory::create(opts, shard_, shard_top_block_id_, db_root_);
|
ton::validator::ValidatorManagerHardforkFactory::create(opts, shard_, shard_top_block_id_, db_root_);
|
||||||
for (auto &msg : ext_msgs_) {
|
for (auto &msg : ext_msgs_) {
|
||||||
td::actor::send_closure(validator_manager_, &ton::validator::ValidatorManager::new_external_message,
|
td::actor::send_closure(validator_manager_, &ton::validator::ValidatorManager::new_external_message,
|
||||||
std::move(msg));
|
std::move(msg), 0);
|
||||||
}
|
}
|
||||||
for (auto &topmsg : top_shard_descrs_) {
|
for (auto &topmsg : top_shard_descrs_) {
|
||||||
td::actor::send_closure(validator_manager_, &ton::validator::ValidatorManager::new_shard_block, ton::BlockIdExt{},
|
td::actor::send_closure(validator_manager_, &ton::validator::ValidatorManager::new_shard_block, ton::BlockIdExt{},
|
||||||
|
|
@ -236,9 +236,8 @@ class HardforkCreator : public td::actor::Actor {
|
||||||
td::actor::send_closure(id_, &ton::validator::ValidatorManager::sync_complete,
|
td::actor::send_closure(id_, &ton::validator::ValidatorManager::sync_complete,
|
||||||
td::PromiseCreator::lambda([](td::Unit) {}));
|
td::PromiseCreator::lambda([](td::Unit) {}));
|
||||||
}
|
}
|
||||||
void add_shard(ton::ShardIdFull) override {
|
void on_new_masterchain_block(td::Ref<ton::validator::MasterchainState> state,
|
||||||
}
|
std::set<ton::ShardIdFull> shards_to_monitor) override {
|
||||||
void del_shard(ton::ShardIdFull) override {
|
|
||||||
}
|
}
|
||||||
void send_ihr_message(ton::AccountIdPrefixFull dst, td::BufferSlice data) override {
|
void send_ihr_message(ton::AccountIdPrefixFull dst, td::BufferSlice data) override {
|
||||||
}
|
}
|
||||||
|
|
@ -246,7 +245,10 @@ class HardforkCreator : public td::actor::Actor {
|
||||||
}
|
}
|
||||||
void send_shard_block_info(ton::BlockIdExt block_id, ton::CatchainSeqno cc_seqno, td::BufferSlice data) override {
|
void send_shard_block_info(ton::BlockIdExt block_id, ton::CatchainSeqno cc_seqno, td::BufferSlice data) override {
|
||||||
}
|
}
|
||||||
void send_broadcast(ton::BlockBroadcast broadcast) override {
|
void send_block_candidate(ton::BlockIdExt block_id, ton::CatchainSeqno cc_seqno, td::uint32 validator_set_hash,
|
||||||
|
td::BufferSlice data) override {
|
||||||
|
}
|
||||||
|
void send_broadcast(ton::BlockBroadcast broadcast, int mode) override {
|
||||||
}
|
}
|
||||||
void download_block(ton::BlockIdExt block_id, td::uint32 priority, td::Timestamp timeout,
|
void download_block(ton::BlockIdExt block_id, td::uint32 priority, td::Timestamp timeout,
|
||||||
td::Promise<ton::ReceivedBlock> promise) override {
|
td::Promise<ton::ReceivedBlock> promise) override {
|
||||||
|
|
@ -267,13 +269,19 @@ class HardforkCreator : public td::actor::Actor {
|
||||||
void get_next_key_blocks(ton::BlockIdExt block_id, td::Timestamp timeout,
|
void get_next_key_blocks(ton::BlockIdExt block_id, td::Timestamp timeout,
|
||||||
td::Promise<std::vector<ton::BlockIdExt>> promise) override {
|
td::Promise<std::vector<ton::BlockIdExt>> promise) override {
|
||||||
}
|
}
|
||||||
void download_archive(ton::BlockSeqno masterchain_seqno, std::string tmp_dir, td::Timestamp timeout,
|
void download_archive(ton::BlockSeqno masterchain_seqno, ton::ShardIdFull shard_prefix, std::string tmp_dir,
|
||||||
|
td::Timestamp timeout, td::Promise<std::string> promise) override {
|
||||||
td::Promise<std::string> promise) override {
|
}
|
||||||
|
void download_out_msg_queue_proof(
|
||||||
|
ton::ShardIdFull dst_shard, std::vector<ton::BlockIdExt> blocks, block::ImportedMsgQueueLimits limits,
|
||||||
|
td::Timestamp timeout, td::Promise<std::vector<td::Ref<ton::validator::OutMsgQueueProof>>> promise) override {
|
||||||
}
|
}
|
||||||
|
|
||||||
void new_key_block(ton::validator::BlockHandle handle) override {
|
void new_key_block(ton::validator::BlockHandle handle) override {
|
||||||
}
|
}
|
||||||
|
void send_validator_telemetry(ton::PublicKeyHash key,
|
||||||
|
ton::tl_object_ptr<ton::ton_api::validator_telemetry> telemetry) override {
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
td::actor::send_closure(validator_manager_, &ton::validator::ValidatorManagerInterface::install_callback,
|
td::actor::send_closure(validator_manager_, &ton::validator::ValidatorManagerInterface::install_callback,
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,7 @@ set(TON_DB_SOURCE
|
||||||
vm/db/CellHashTable.h
|
vm/db/CellHashTable.h
|
||||||
vm/db/CellStorage.h
|
vm/db/CellStorage.h
|
||||||
vm/db/TonDb.h
|
vm/db/TonDb.h
|
||||||
|
vm/db/InMemoryBagOfCellsDb.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(FIFT_SOURCE
|
set(FIFT_SOURCE
|
||||||
|
|
@ -213,6 +214,7 @@ set(BLOCK_SOURCE
|
||||||
block/mc-config.cpp
|
block/mc-config.cpp
|
||||||
block/output-queue-merger.cpp
|
block/output-queue-merger.cpp
|
||||||
block/transaction.cpp
|
block/transaction.cpp
|
||||||
|
block/precompiled-smc/PrecompiledSmartContract.cpp
|
||||||
${TLB_BLOCK_AUTO}
|
${TLB_BLOCK_AUTO}
|
||||||
|
|
||||||
block/block-binlog.h
|
block/block-binlog.h
|
||||||
|
|
@ -223,6 +225,8 @@ set(BLOCK_SOURCE
|
||||||
block/check-proof.h
|
block/check-proof.h
|
||||||
block/output-queue-merger.h
|
block/output-queue-merger.h
|
||||||
block/transaction.h
|
block/transaction.h
|
||||||
|
block/precompiled-smc/PrecompiledSmartContract.h
|
||||||
|
block/precompiled-smc/common.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SMC_ENVELOPE_SOURCE
|
set(SMC_ENVELOPE_SOURCE
|
||||||
|
|
@ -297,9 +301,8 @@ endif()
|
||||||
target_include_directories(ton_crypto_core SYSTEM PUBLIC $<BUILD_INTERFACE:${OPENSSL_INCLUDE_DIR}>)
|
target_include_directories(ton_crypto_core SYSTEM PUBLIC $<BUILD_INTERFACE:${OPENSSL_INCLUDE_DIR}>)
|
||||||
|
|
||||||
add_library(ton_crypto STATIC ${TON_CRYPTO_SOURCE})
|
add_library(ton_crypto STATIC ${TON_CRYPTO_SOURCE})
|
||||||
target_include_directories(ton_crypto PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
target_include_directories(ton_crypto PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
target_link_libraries(ton_crypto PUBLIC ${OPENSSL_CRYPTO_LIBRARY} ton_crypto_core ton_block)
|
||||||
target_link_libraries(ton_crypto PUBLIC ${OPENSSL_CRYPTO_LIBRARY} tdutils tddb_utils ton_crypto_core ton_block)
|
|
||||||
if (USE_EMSCRIPTEN)
|
if (USE_EMSCRIPTEN)
|
||||||
target_link_options(ton_crypto PRIVATE -fexceptions)
|
target_link_options(ton_crypto PRIVATE -fexceptions)
|
||||||
target_compile_options(ton_crypto PRIVATE -fexceptions)
|
target_compile_options(ton_crypto PRIVATE -fexceptions)
|
||||||
|
|
@ -315,20 +318,20 @@ endif()
|
||||||
target_include_directories(ton_crypto SYSTEM PUBLIC $<BUILD_INTERFACE:${OPENSSL_INCLUDE_DIR}>)
|
target_include_directories(ton_crypto SYSTEM PUBLIC $<BUILD_INTERFACE:${OPENSSL_INCLUDE_DIR}>)
|
||||||
|
|
||||||
add_dependencies(ton_crypto blst)
|
add_dependencies(ton_crypto blst)
|
||||||
|
add_dependencies(ton_crypto_core secp256k1)
|
||||||
|
|
||||||
target_include_directories(ton_crypto PRIVATE ${BLST_INCLUDE_DIR})
|
target_include_directories(ton_crypto PRIVATE ${BLST_INCLUDE_DIR})
|
||||||
target_link_libraries(ton_crypto PRIVATE ${BLST_LIB})
|
target_link_libraries(ton_crypto PRIVATE ${BLST_LIB})
|
||||||
|
|
||||||
if (NOT USE_EMSCRIPTEN)
|
target_include_directories(ton_crypto_core PUBLIC $<BUILD_INTERFACE:${SECP256K1_INCLUDE_DIR}>)
|
||||||
find_package(Secp256k1 REQUIRED)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
find_package(Sodium REQUIRED)
|
find_package(Sodium REQUIRED)
|
||||||
target_compile_definitions(ton_crypto PUBLIC SODIUM_STATIC)
|
target_compile_definitions(ton_crypto PUBLIC SODIUM_STATIC)
|
||||||
target_include_directories(ton_crypto_core PUBLIC $<BUILD_INTERFACE:${SECP256K1_INCLUDE_DIR}>)
|
target_link_libraries(ton_crypto_core PUBLIC ${SECP256K1_LIBRARY})
|
||||||
target_link_libraries(ton_crypto PUBLIC ${SECP256K1_LIBRARY})
|
target_link_libraries(ton_crypto PUBLIC ${SECP256K1_LIBRARY})
|
||||||
elseif (ANDROID OR EMSCRIPTEN)
|
elseif (EMSCRIPTEN)
|
||||||
target_include_directories(ton_crypto_core PUBLIC $<BUILD_INTERFACE:${SECP256K1_INCLUDE_DIR}>)
|
target_link_libraries(ton_crypto_core PUBLIC $<BUILD_INTERFACE:${SECP256K1_LIBRARY}>)
|
||||||
target_link_libraries(ton_crypto PUBLIC $<BUILD_INTERFACE:${SECP256K1_LIBRARY}>)
|
target_link_libraries(ton_crypto PUBLIC $<BUILD_INTERFACE:${SECP256K1_LIBRARY}>)
|
||||||
else()
|
else()
|
||||||
if (NOT SODIUM_FOUND)
|
if (NOT SODIUM_FOUND)
|
||||||
|
|
@ -337,7 +340,7 @@ else()
|
||||||
message(STATUS "Using Sodium ${SODIUM_LIBRARY_RELEASE}")
|
message(STATUS "Using Sodium ${SODIUM_LIBRARY_RELEASE}")
|
||||||
endif()
|
endif()
|
||||||
target_compile_definitions(ton_crypto PUBLIC SODIUM_STATIC)
|
target_compile_definitions(ton_crypto PUBLIC SODIUM_STATIC)
|
||||||
target_include_directories(ton_crypto_core PUBLIC $<BUILD_INTERFACE:${SECP256K1_INCLUDE_DIR}>)
|
target_link_libraries(ton_crypto_core PUBLIC ${SECP256K1_LIBRARY})
|
||||||
target_link_libraries(ton_crypto PUBLIC ${SECP256K1_LIBRARY})
|
target_link_libraries(ton_crypto PUBLIC ${SECP256K1_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
@ -355,7 +358,8 @@ target_link_libraries(test-ed25519-crypto PUBLIC ton_crypto)
|
||||||
|
|
||||||
add_library(fift-lib STATIC ${FIFT_SOURCE})
|
add_library(fift-lib STATIC ${FIFT_SOURCE})
|
||||||
target_include_directories(fift-lib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
target_include_directories(fift-lib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
||||||
target_link_libraries(fift-lib PUBLIC ton_crypto ton_db tdutils ton_block)
|
target_link_libraries(fift-lib PUBLIC ton_crypto)
|
||||||
|
|
||||||
if (USE_EMSCRIPTEN)
|
if (USE_EMSCRIPTEN)
|
||||||
target_link_options(fift-lib PRIVATE -fexceptions)
|
target_link_options(fift-lib PRIVATE -fexceptions)
|
||||||
target_compile_options(fift-lib PRIVATE -fexceptions)
|
target_compile_options(fift-lib PRIVATE -fexceptions)
|
||||||
|
|
@ -375,11 +379,15 @@ target_link_libraries(src_parser PUBLIC ton_crypto_core)
|
||||||
add_library(ton_block STATIC ${BLOCK_SOURCE})
|
add_library(ton_block STATIC ${BLOCK_SOURCE})
|
||||||
target_include_directories(ton_block PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
target_include_directories(ton_block PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/block> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/block> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||||
target_link_libraries(ton_block PUBLIC ton_crypto tdutils tdactor tl_api)
|
target_link_libraries(ton_block PUBLIC ton_crypto_core tdactor tl_api)
|
||||||
|
if (USE_EMSCRIPTEN)
|
||||||
|
target_link_options(ton_block PRIVATE -fexceptions)
|
||||||
|
target_compile_options(ton_block PRIVATE -fexceptions)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(func func/func-main.cpp ${FUNC_LIB_SOURCE})
|
add_executable(func func/func-main.cpp ${FUNC_LIB_SOURCE})
|
||||||
target_include_directories(func PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
target_include_directories(func PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
||||||
target_link_libraries(func PUBLIC ton_crypto src_parser git ton_block)
|
target_link_libraries(func PUBLIC ton_crypto src_parser git)
|
||||||
if (WINGETOPT_FOUND)
|
if (WINGETOPT_FOUND)
|
||||||
target_link_libraries_system(func wingetopt)
|
target_link_libraries_system(func wingetopt)
|
||||||
endif()
|
endif()
|
||||||
|
|
@ -401,29 +409,38 @@ if (USE_EMSCRIPTEN)
|
||||||
target_link_options(funcfiftlib PRIVATE -sALLOW_MEMORY_GROWTH=1)
|
target_link_options(funcfiftlib PRIVATE -sALLOW_MEMORY_GROWTH=1)
|
||||||
target_link_options(funcfiftlib PRIVATE -sALLOW_TABLE_GROWTH=1)
|
target_link_options(funcfiftlib PRIVATE -sALLOW_TABLE_GROWTH=1)
|
||||||
target_link_options(funcfiftlib PRIVATE --embed-file ${CMAKE_CURRENT_SOURCE_DIR}/fift/lib@/fiftlib)
|
target_link_options(funcfiftlib PRIVATE --embed-file ${CMAKE_CURRENT_SOURCE_DIR}/fift/lib@/fiftlib)
|
||||||
|
target_link_options(funcfiftlib PRIVATE --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/funcfiftlib/funcfiftlib-prejs.js)
|
||||||
target_link_options(funcfiftlib PRIVATE -fexceptions)
|
target_link_options(funcfiftlib PRIVATE -fexceptions)
|
||||||
target_compile_options(funcfiftlib PRIVATE -fexceptions -fno-stack-protector)
|
target_compile_options(funcfiftlib PRIVATE -fexceptions -fno-stack-protector)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(tlbc tl/tlbc.cpp)
|
add_executable(tlbc tl/tlbc.cpp)
|
||||||
target_include_directories(tlbc PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
target_include_directories(tlbc PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
||||||
target_link_libraries(tlbc PUBLIC ton_crypto_core src_parser)
|
target_link_libraries(tlbc PUBLIC src_parser)
|
||||||
if (WINGETOPT_FOUND)
|
if (WINGETOPT_FOUND)
|
||||||
target_link_libraries_system(tlbc wingetopt)
|
target_link_libraries_system(tlbc wingetopt)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(pow-miner-lib util/Miner.cpp util/Miner.h)
|
add_library(pow-miner-lib util/Miner.cpp util/Miner.h)
|
||||||
target_include_directories(pow-miner-lib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
target_include_directories(pow-miner-lib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
||||||
target_link_libraries(pow-miner-lib PUBLIC ton_crypto ton_block)
|
target_link_libraries(pow-miner-lib PUBLIC ton_crypto)
|
||||||
|
|
||||||
add_executable(pow-miner util/pow-miner.cpp)
|
add_executable(pow-miner util/pow-miner.cpp)
|
||||||
target_link_libraries(pow-miner PRIVATE ton_crypto ton_block pow-miner-lib git)
|
target_link_libraries(pow-miner PRIVATE ton_crypto pow-miner-lib git)
|
||||||
|
|
||||||
if (WINGETOPT_FOUND)
|
if (WINGETOPT_FOUND)
|
||||||
target_link_libraries_system(fift wingetopt)
|
target_link_libraries_system(fift wingetopt)
|
||||||
target_link_libraries_system(pow-miner wingetopt)
|
target_link_libraries_system(pow-miner wingetopt)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_executable(mintless-proof-generator util/mintless-proof-generator.cpp)
|
||||||
|
target_link_libraries(mintless-proof-generator PRIVATE ton_crypto git ${JEMALLOC_LIBRARIES})
|
||||||
|
|
||||||
|
if (JEMALLOC_FOUND)
|
||||||
|
target_include_directories(mintless-proof-generator PRIVATE ${JEMALLOC_INCLUDE_DIR})
|
||||||
|
target_compile_definitions(mintless-proof-generator PRIVATE -DTON_USE_JEMALLOC=1)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(TURN_OFF_LSAN cd .)
|
set(TURN_OFF_LSAN cd .)
|
||||||
if (TON_USE_ASAN AND NOT WIN32)
|
if (TON_USE_ASAN AND NOT WIN32)
|
||||||
set(TURN_OFF_LSAN export LSAN_OPTIONS=detect_leaks=0)
|
set(TURN_OFF_LSAN export LSAN_OPTIONS=detect_leaks=0)
|
||||||
|
|
@ -471,10 +488,17 @@ if (NOT CMAKE_CROSSCOMPILING OR USE_EMSCRIPTEN)
|
||||||
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_DEST_FIF}
|
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_DEST_FIF}
|
||||||
)
|
)
|
||||||
set(ARG_DEST_CPP "${ARG_DEST}.cpp")
|
set(ARG_DEST_CPP "${ARG_DEST}.cpp")
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
set(ARG_LIB_DIR "fift/lib@smartcont")
|
||||||
|
else()
|
||||||
|
set(ARG_LIB_DIR "fift/lib:smartcont")
|
||||||
|
endif()
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
COMMENT "Generate ${ARG_DEST_CPP}"
|
COMMENT "Generate ${ARG_DEST_CPP}"
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
COMMAND fift -Ifift/lib:smartcont -s asm-to-cpp.fif ${ARG_DEST_FIF} ${ARG_DEST_CPP} ${ARG_NAME}
|
COMMAND fift -I${ARG_LIB_DIR} -s asm-to-cpp.fif ${ARG_DEST_FIF} ${ARG_DEST_CPP} ${ARG_NAME}
|
||||||
MAIN_DEPENDENCY ${ARG_SOURCE}
|
MAIN_DEPENDENCY ${ARG_SOURCE}
|
||||||
DEPENDS fift ${ARG_DEST_FIF} smartcont/asm-to-cpp.fif fift/lib/Asm.fif
|
DEPENDS fift ${ARG_DEST_FIF} smartcont/asm-to-cpp.fif fift/lib/Asm.fif
|
||||||
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_DEST_CPP}
|
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_DEST_CPP}
|
||||||
|
|
@ -515,12 +539,12 @@ add_executable(create-state block/create-state.cpp)
|
||||||
target_include_directories(create-state PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
target_include_directories(create-state PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||||
if (INTERNAL_COMPILE)
|
if (INTERNAL_COMPILE)
|
||||||
target_link_libraries(create-state PUBLIC ton_crypto fift-lib ton_block tonlib git)
|
target_link_libraries(create-state PUBLIC ton_crypto fift-lib tonlib git)
|
||||||
else()
|
else()
|
||||||
if (TONLIB_COMPILE)
|
if (TONLIB_COMPILE)
|
||||||
target_link_libraries(create-state PUBLIC ton_crypto fift-lib ton_block tonlib git)
|
target_link_libraries(create-state PUBLIC ton_crypto fift-lib tonlib git)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(create-state PUBLIC ton_crypto fift-lib ton_block git)
|
target_link_libraries(create-state PUBLIC ton_crypto fift-lib git)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if (WINGETOPT_FOUND)
|
if (WINGETOPT_FOUND)
|
||||||
|
|
@ -530,7 +554,7 @@ endif()
|
||||||
add_executable(dump-block block/dump-block.cpp)
|
add_executable(dump-block block/dump-block.cpp)
|
||||||
target_include_directories(dump-block PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
target_include_directories(dump-block PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||||
target_link_libraries(dump-block PUBLIC ton_crypto fift-lib ton_block git)
|
target_link_libraries(dump-block PUBLIC ton_crypto fift-lib git)
|
||||||
if (WINGETOPT_FOUND)
|
if (WINGETOPT_FOUND)
|
||||||
target_link_libraries_system(dump-block wingetopt)
|
target_link_libraries_system(dump-block wingetopt)
|
||||||
endif()
|
endif()
|
||||||
|
|
@ -538,7 +562,7 @@ endif()
|
||||||
add_executable(adjust-block block/adjust-block.cpp)
|
add_executable(adjust-block block/adjust-block.cpp)
|
||||||
target_include_directories(adjust-block PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
target_include_directories(adjust-block PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||||
target_link_libraries(adjust-block PUBLIC ton_crypto fift-lib ton_block git)
|
target_link_libraries(adjust-block PUBLIC ton_crypto fift-lib git)
|
||||||
if (WINGETOPT_FOUND)
|
if (WINGETOPT_FOUND)
|
||||||
target_link_libraries_system(dump-block wingetopt)
|
target_link_libraries_system(dump-block wingetopt)
|
||||||
target_link_libraries_system(adjust-block wingetopt)
|
target_link_libraries_system(adjust-block wingetopt)
|
||||||
|
|
@ -547,7 +571,7 @@ endif()
|
||||||
add_executable(test-weight-distr block/test-weight-distr.cpp)
|
add_executable(test-weight-distr block/test-weight-distr.cpp)
|
||||||
target_include_directories(test-weight-distr PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
target_include_directories(test-weight-distr PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||||
target_link_libraries(test-weight-distr PUBLIC ton_crypto fift-lib ton_block git)
|
target_link_libraries(test-weight-distr PUBLIC ton_crypto fift-lib git)
|
||||||
if (WINGETOPT_FOUND)
|
if (WINGETOPT_FOUND)
|
||||||
target_link_libraries_system(test-weight-distr wingetopt)
|
target_link_libraries_system(test-weight-distr wingetopt)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -813,19 +813,45 @@ int IntermediateAddress::get_size(const vm::CellSlice& cs) const {
|
||||||
const IntermediateAddress t_IntermediateAddress;
|
const IntermediateAddress t_IntermediateAddress;
|
||||||
|
|
||||||
bool MsgEnvelope::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const {
|
bool MsgEnvelope::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const {
|
||||||
return cs.fetch_ulong(4) == 4 // msg_envelope#4
|
switch (get_tag(cs)) {
|
||||||
&& t_IntermediateAddress.validate_skip(ops, cs, weak) // cur_addr:IntermediateAddress
|
case 4:
|
||||||
&& t_IntermediateAddress.validate_skip(ops, cs, weak) // next_addr:IntermediateAddress
|
return cs.fetch_ulong(4) == 4 // msg_envelope#4
|
||||||
&& t_Grams.validate_skip(ops, cs, weak) // fwd_fee_remaining:Grams
|
&& t_IntermediateAddress.validate_skip(ops, cs, weak) // cur_addr:IntermediateAddress
|
||||||
&& t_Ref_Message.validate_skip(ops, cs, weak); // msg:^Message
|
&& t_IntermediateAddress.validate_skip(ops, cs, weak) // next_addr:IntermediateAddress
|
||||||
|
&& t_Grams.validate_skip(ops, cs, weak) // fwd_fee_remaining:Grams
|
||||||
|
&& t_Ref_Message.validate_skip(ops, cs, weak); // msg:^Message
|
||||||
|
case 5:
|
||||||
|
return cs.fetch_ulong(4) == 5 // msg_envelope_v2#5
|
||||||
|
&& t_IntermediateAddress.validate_skip(ops, cs, weak) // cur_addr:IntermediateAddress
|
||||||
|
&& t_IntermediateAddress.validate_skip(ops, cs, weak) // next_addr:IntermediateAddress
|
||||||
|
&& t_Grams.validate_skip(ops, cs, weak) // fwd_fee_remaining:Grams
|
||||||
|
&& t_Ref_Message.validate_skip(ops, cs, weak) // msg:^Message
|
||||||
|
&& Maybe<UInt>(64).validate_skip(ops, cs, weak) // emitted_lt:(Maybe uint64)
|
||||||
|
&& Maybe<gen::MsgMetadata>().validate_skip(ops, cs, weak); // metadata:(Maybe MsgMetadata)
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MsgEnvelope::skip(vm::CellSlice& cs) const {
|
bool MsgEnvelope::skip(vm::CellSlice& cs) const {
|
||||||
return cs.advance(4) // msg_envelope#4
|
switch (get_tag(cs)) {
|
||||||
&& t_IntermediateAddress.skip(cs) // cur_addr:IntermediateAddress
|
case 4:
|
||||||
&& t_IntermediateAddress.skip(cs) // next_addr:IntermediateAddress
|
return cs.advance(4) // msg_envelope#4
|
||||||
&& t_Grams.skip(cs) // fwd_fee_remaining:Grams
|
&& t_IntermediateAddress.skip(cs) // cur_addr:IntermediateAddress
|
||||||
&& t_Ref_Message.skip(cs); // msg:^Message
|
&& t_IntermediateAddress.skip(cs) // next_addr:IntermediateAddress
|
||||||
|
&& t_Grams.skip(cs) // fwd_fee_remaining:Grams
|
||||||
|
&& t_Ref_Message.skip(cs); // msg:^Message
|
||||||
|
case 5:
|
||||||
|
return cs.advance(4) // msg_envelope_v2#5
|
||||||
|
&& t_IntermediateAddress.skip(cs) // cur_addr:IntermediateAddress
|
||||||
|
&& t_IntermediateAddress.skip(cs) // next_addr:IntermediateAddress
|
||||||
|
&& t_Grams.skip(cs) // fwd_fee_remaining:Grams
|
||||||
|
&& t_Ref_Message.skip(cs) // msg:^Message
|
||||||
|
&& Maybe<UInt>(64).skip(cs) // emitted_lt:(Maybe uint64)
|
||||||
|
&& Maybe<gen::MsgMetadata>().skip(cs); // metadata:(Maybe MsgMetadata)
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MsgEnvelope::extract_fwd_fees_remaining(vm::CellSlice& cs) const {
|
bool MsgEnvelope::extract_fwd_fees_remaining(vm::CellSlice& cs) const {
|
||||||
|
|
@ -833,34 +859,101 @@ bool MsgEnvelope::extract_fwd_fees_remaining(vm::CellSlice& cs) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MsgEnvelope::unpack(vm::CellSlice& cs, MsgEnvelope::Record& data) const {
|
bool MsgEnvelope::unpack(vm::CellSlice& cs, MsgEnvelope::Record& data) const {
|
||||||
return cs.fetch_ulong(4) == 4 // msg_envelope#4
|
switch (get_tag(cs)) {
|
||||||
&& t_IntermediateAddress.fetch_to(cs, data.cur_addr) // cur_addr:IntermediateAddress
|
case 4:
|
||||||
&& t_IntermediateAddress.fetch_to(cs, data.next_addr) // next_addr:IntermediateAddress
|
return cs.fetch_ulong(4) == 4 // msg_envelope#4
|
||||||
&& t_Grams.fetch_to(cs, data.fwd_fee_remaining) // fwd_fee_remaining:Grams
|
&& t_IntermediateAddress.fetch_to(cs, data.cur_addr) // cur_addr:IntermediateAddress
|
||||||
&& cs.fetch_ref_to(data.msg); // msg:^Message
|
&& t_IntermediateAddress.fetch_to(cs, data.next_addr) // next_addr:IntermediateAddress
|
||||||
|
&& t_Grams.fetch_to(cs, data.fwd_fee_remaining) // fwd_fee_remaining:Grams
|
||||||
|
&& cs.fetch_ref_to(data.msg); // msg:^Message
|
||||||
|
case 5:
|
||||||
|
return cs.fetch_ulong(4) == 5 // msg_envelope_v2#5
|
||||||
|
&& t_IntermediateAddress.fetch_to(cs, data.cur_addr) // cur_addr:IntermediateAddress
|
||||||
|
&& t_IntermediateAddress.fetch_to(cs, data.next_addr) // next_addr:IntermediateAddress
|
||||||
|
&& t_Grams.fetch_to(cs, data.fwd_fee_remaining) // fwd_fee_remaining:Grams
|
||||||
|
&& cs.fetch_ref_to(data.msg) // msg:^Message
|
||||||
|
&& Maybe<UInt>(64).skip(cs) // emitted_lt:(Maybe uint64)
|
||||||
|
&& Maybe<gen::MsgMetadata>().skip(cs); // metadata:(Maybe MsgMetadata)
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MsgEnvelope::unpack(vm::CellSlice& cs, MsgEnvelope::Record_std& data) const {
|
bool MsgEnvelope::unpack(vm::CellSlice& cs, MsgEnvelope::Record_std& data) const {
|
||||||
return cs.fetch_ulong(4) == 4 // msg_envelope#4
|
data.emitted_lt = {};
|
||||||
&& t_IntermediateAddress.fetch_regular(cs, data.cur_addr) // cur_addr:IntermediateAddress
|
data.metadata = {};
|
||||||
&& t_IntermediateAddress.fetch_regular(cs, data.next_addr) // next_addr:IntermediateAddress
|
switch (get_tag(cs)) {
|
||||||
&& t_Grams.as_integer_skip_to(cs, data.fwd_fee_remaining) // fwd_fee_remaining:Grams
|
case 4:
|
||||||
&& cs.fetch_ref_to(data.msg); // msg:^Message
|
return cs.fetch_ulong(4) == 4 // msg_envelope#4
|
||||||
|
&& t_IntermediateAddress.fetch_regular(cs, data.cur_addr) // cur_addr:IntermediateAddress
|
||||||
|
&& t_IntermediateAddress.fetch_regular(cs, data.next_addr) // next_addr:IntermediateAddress
|
||||||
|
&& t_Grams.as_integer_skip_to(cs, data.fwd_fee_remaining) // fwd_fee_remaining:Grams
|
||||||
|
&& cs.fetch_ref_to(data.msg); // msg:^Message
|
||||||
|
case 5: {
|
||||||
|
bool with_metadata, with_emitted_lt;
|
||||||
|
return cs.fetch_ulong(4) == 5 // msg_envelope_v2#5
|
||||||
|
&& t_IntermediateAddress.fetch_regular(cs, data.cur_addr) // cur_addr:IntermediateAddress
|
||||||
|
&& t_IntermediateAddress.fetch_regular(cs, data.next_addr) // next_addr:IntermediateAddress
|
||||||
|
&& t_Grams.as_integer_skip_to(cs, data.fwd_fee_remaining) // fwd_fee_remaining:Grams
|
||||||
|
&& cs.fetch_ref_to(data.msg) // msg:^Message
|
||||||
|
&& cs.fetch_bool_to(with_emitted_lt) &&
|
||||||
|
(!with_emitted_lt || cs.fetch_uint_to(64, data.emitted_lt.value_force())) // emitted_lt:(Maybe uint64)
|
||||||
|
&& cs.fetch_bool_to(with_metadata) &&
|
||||||
|
(!with_metadata || data.metadata.value_force().unpack(cs)); // metadata:(Maybe MsgMetadata)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MsgEnvelope::unpack_std(vm::CellSlice& cs, int& cur_a, int& nhop_a, Ref<vm::Cell>& msg) const {
|
bool MsgEnvelope::pack(vm::CellBuilder& cb, const Record_std& data) const {
|
||||||
return cs.fetch_ulong(4) == 4 // msg_envelope#4
|
bool v2 = (bool)data.metadata || (bool)data.emitted_lt;
|
||||||
&& t_IntermediateAddress.fetch_regular(cs, cur_a) // cur_addr:IntermediateAddress
|
if (!(cb.store_long_bool(v2 ? 5 : 4, 4) && // msg_envelope#4 / msg_envelope_v2#5
|
||||||
&& t_IntermediateAddress.fetch_regular(cs, nhop_a) // next_addr:IntermediateAddress
|
cb.store_long_bool(data.cur_addr, 8) && // cur_addr:IntermediateAddress
|
||||||
&& cs.fetch_ref_to(msg);
|
cb.store_long_bool(data.next_addr, 8) && // next_addr:IntermediateAddress
|
||||||
|
t_Grams.store_integer_ref(cb, data.fwd_fee_remaining) && // fwd_fee_remaining:Grams
|
||||||
|
cb.store_ref_bool(data.msg))) { // msg:^Message
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (v2) {
|
||||||
|
if (!(cb.store_bool_bool((bool)data.emitted_lt) &&
|
||||||
|
(!data.emitted_lt || cb.store_long_bool(data.emitted_lt.value(), 64)))) { // emitted_lt:(Maybe uint64)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(cb.store_bool_bool((bool)data.metadata) &&
|
||||||
|
(!data.metadata || data.metadata.value().pack(cb)))) { // metadata:(Maybe MsgMetadata)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MsgEnvelope::get_created_lt(const vm::CellSlice& cs, unsigned long long& created_lt) const {
|
bool MsgEnvelope::pack_cell(td::Ref<vm::Cell>& cell, const Record_std& data) const {
|
||||||
|
vm::CellBuilder cb;
|
||||||
|
return pack(cb, data) && cb.finalize_to(cell);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MsgEnvelope::get_emitted_lt(const vm::CellSlice& cs, unsigned long long& emitted_lt) const {
|
||||||
|
// Emitted lt is emitted_lt from MsgEnvelope (if present), otherwise created_lt
|
||||||
if (!cs.size_refs()) {
|
if (!cs.size_refs()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (get_tag(cs) == 5) {
|
||||||
|
vm::CellSlice cs2 = cs;
|
||||||
|
// msg_envelope_v2#5 cur_addr:IntermediateAddress
|
||||||
|
// next_addr:IntermediateAddress fwd_fee_remaining:Grams
|
||||||
|
// msg:^(Message Any) emitted_lt:(Maybe uint64) ...
|
||||||
|
bool have_emitted_lt;
|
||||||
|
if (!(cs2.skip_first(4) && t_IntermediateAddress.skip(cs2) && t_IntermediateAddress.skip(cs2) &&
|
||||||
|
t_Grams.skip(cs2) && t_Ref_Message.skip(cs2) && cs2.fetch_bool_to(have_emitted_lt))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (have_emitted_lt) {
|
||||||
|
return cs2.fetch_ulong_bool(64, emitted_lt);
|
||||||
|
}
|
||||||
|
}
|
||||||
auto msg_cs = load_cell_slice(cs.prefetch_ref());
|
auto msg_cs = load_cell_slice(cs.prefetch_ref());
|
||||||
return t_Message.get_created_lt(msg_cs, created_lt);
|
return t_Message.get_created_lt(msg_cs, emitted_lt);
|
||||||
}
|
}
|
||||||
|
|
||||||
const MsgEnvelope t_MsgEnvelope;
|
const MsgEnvelope t_MsgEnvelope;
|
||||||
|
|
@ -1692,6 +1785,15 @@ bool InMsg::skip(vm::CellSlice& cs) const {
|
||||||
&& cs.advance(64) // transaction_id:uint64
|
&& cs.advance(64) // transaction_id:uint64
|
||||||
&& t_Grams.skip(cs) // fwd_fee:Grams
|
&& t_Grams.skip(cs) // fwd_fee:Grams
|
||||||
&& t_RefCell.skip(cs); // proof_delivered:^Cell
|
&& t_RefCell.skip(cs); // proof_delivered:^Cell
|
||||||
|
case msg_import_deferred_fin:
|
||||||
|
return cs.advance(5) // msg_import_deferred_fin$00100
|
||||||
|
&& t_Ref_MsgEnvelope.skip(cs) // in_msg:^MsgEnvelope
|
||||||
|
&& t_Ref_Transaction.skip(cs) // transaction:^Transaction
|
||||||
|
&& t_Grams.skip(cs); // fwd_fee:Grams
|
||||||
|
case msg_import_deferred_tr:
|
||||||
|
return cs.advance(5) // msg_import_deferred_tr$00101
|
||||||
|
&& t_Ref_MsgEnvelope.skip(cs) // in_msg:^MsgEnvelope
|
||||||
|
&& t_Ref_MsgEnvelope.skip(cs); // out_msg:^MsgEnvelope
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1734,12 +1836,22 @@ bool InMsg::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const {
|
||||||
&& cs.advance(64) // transaction_id:uint64
|
&& cs.advance(64) // transaction_id:uint64
|
||||||
&& t_Grams.validate_skip(ops, cs, weak) // fwd_fee:Grams
|
&& t_Grams.validate_skip(ops, cs, weak) // fwd_fee:Grams
|
||||||
&& t_RefCell.validate_skip(ops, cs, weak); // proof_delivered:^Cell
|
&& t_RefCell.validate_skip(ops, cs, weak); // proof_delivered:^Cell
|
||||||
|
case msg_import_deferred_fin:
|
||||||
|
return cs.advance(5) // msg_import_deferred_fin$00100
|
||||||
|
&& t_Ref_MsgEnvelope.validate_skip(ops, cs, weak) // in_msg:^MsgEnvelope
|
||||||
|
&& t_Ref_Transaction.validate_skip(ops, cs, weak) // transaction:^Transaction
|
||||||
|
&& t_Grams.validate_skip(ops, cs, weak); // fwd_fee:Grams
|
||||||
|
case msg_import_deferred_tr:
|
||||||
|
return cs.advance(5) // msg_import_deferred_tr$00101
|
||||||
|
&& t_Ref_MsgEnvelope.validate_skip(ops, cs, weak) // in_msg:^MsgEnvelope
|
||||||
|
&& t_Ref_MsgEnvelope.validate_skip(ops, cs, weak); // out_msg:^MsgEnvelope
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InMsg::get_import_fees(vm::CellBuilder& cb, vm::CellSlice& cs) const {
|
bool InMsg::get_import_fees(vm::CellBuilder& cb, vm::CellSlice& cs) const {
|
||||||
switch (get_tag(cs)) {
|
int tag = get_tag(cs);
|
||||||
|
switch (tag) {
|
||||||
case msg_import_ext: // inbound external message
|
case msg_import_ext: // inbound external message
|
||||||
return t_ImportFees.null_value(cb); // external messages have no value and no import fees
|
return t_ImportFees.null_value(cb); // external messages have no value and no import fees
|
||||||
case msg_import_ihr: // IHR-forwarded internal message to its final destination
|
case msg_import_ihr: // IHR-forwarded internal message to its final destination
|
||||||
|
|
@ -1765,8 +1877,9 @@ bool InMsg::get_import_fees(vm::CellBuilder& cb, vm::CellSlice& cs) const {
|
||||||
&& t_CurrencyCollection.null_value(cb); // value_imported := 0
|
&& t_CurrencyCollection.null_value(cb); // value_imported := 0
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case msg_import_fin: // internal message delivered to its final destination in this block
|
case msg_import_fin: // internal message delivered to its final destination in this block
|
||||||
if (cs.advance(3) && cs.size_refs() >= 2) {
|
case msg_import_deferred_fin: // internal message from DispatchQueue to its final destination in this block
|
||||||
|
if (cs.advance(tag == msg_import_fin ? 3 : 5) && cs.size_refs() >= 2) {
|
||||||
auto msg_env_cs = load_cell_slice(cs.fetch_ref());
|
auto msg_env_cs = load_cell_slice(cs.fetch_ref());
|
||||||
MsgEnvelope::Record in_msg;
|
MsgEnvelope::Record in_msg;
|
||||||
td::RefInt256 fwd_fee, fwd_fee_remaining, value_grams, ihr_fee;
|
td::RefInt256 fwd_fee, fwd_fee_remaining, value_grams, ihr_fee;
|
||||||
|
|
@ -1787,13 +1900,14 @@ bool InMsg::get_import_fees(vm::CellBuilder& cb, vm::CellSlice& cs) const {
|
||||||
msg_info.value.write()); // value_imported = msg.value + msg.ihr_fee + fwd_fee_remaining
|
msg_info.value.write()); // value_imported = msg.value + msg.ihr_fee + fwd_fee_remaining
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case msg_import_tr: // transit internal message
|
case msg_import_tr: // transit internal message
|
||||||
if (cs.advance(3) && cs.size_refs() >= 2) {
|
case msg_import_deferred_tr: // internal message from DispatchQueue to OutMsgQueue
|
||||||
|
if (cs.advance(tag == msg_import_tr ? 3 : 5) && cs.size_refs() >= 2) {
|
||||||
auto msg_env_cs = load_cell_slice(cs.fetch_ref());
|
auto msg_env_cs = load_cell_slice(cs.fetch_ref());
|
||||||
MsgEnvelope::Record in_msg;
|
MsgEnvelope::Record in_msg;
|
||||||
td::RefInt256 transit_fee, fwd_fee_remaining, value_grams, ihr_fee;
|
td::RefInt256 transit_fee = td::zero_refint(), fwd_fee_remaining, value_grams, ihr_fee;
|
||||||
if (!(t_MsgEnvelope.unpack(msg_env_cs, in_msg) && cs.fetch_ref().not_null() &&
|
if (!(t_MsgEnvelope.unpack(msg_env_cs, in_msg) && cs.fetch_ref().not_null() &&
|
||||||
t_Grams.as_integer_skip_to(cs, transit_fee) &&
|
(tag == msg_import_deferred_tr || t_Grams.as_integer_skip_to(cs, transit_fee)) &&
|
||||||
(fwd_fee_remaining = t_Grams.as_integer(in_msg.fwd_fee_remaining)).not_null() &&
|
(fwd_fee_remaining = t_Grams.as_integer(in_msg.fwd_fee_remaining)).not_null() &&
|
||||||
cmp(transit_fee, fwd_fee_remaining) <= 0)) {
|
cmp(transit_fee, fwd_fee_remaining) <= 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1871,6 +1985,14 @@ bool OutMsg::skip(vm::CellSlice& cs) const {
|
||||||
return cs.advance(3) // msg_export_tr_req$111
|
return cs.advance(3) // msg_export_tr_req$111
|
||||||
&& t_Ref_MsgEnvelope.skip(cs) // out_msg:^MsgEnvelope
|
&& t_Ref_MsgEnvelope.skip(cs) // out_msg:^MsgEnvelope
|
||||||
&& RefTo<InMsg>{}.skip(cs); // imported:^InMsg
|
&& RefTo<InMsg>{}.skip(cs); // imported:^InMsg
|
||||||
|
case msg_export_new_defer:
|
||||||
|
return cs.advance(5) // msg_export_new_defer$10100
|
||||||
|
&& t_Ref_MsgEnvelope.skip(cs) // out_msg:^MsgEnvelope
|
||||||
|
&& t_Ref_Transaction.skip(cs); // transaction:^Transaction
|
||||||
|
case msg_export_deferred_tr:
|
||||||
|
return cs.advance(5) // msg_export_deferred_tr$10101
|
||||||
|
&& t_Ref_MsgEnvelope.skip(cs) // out_msg:^MsgEnvelope
|
||||||
|
&& RefTo<InMsg>{}.skip(cs); // imported:^InMsg
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1910,12 +2032,21 @@ bool OutMsg::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const {
|
||||||
return cs.advance(3) // msg_export_tr_req$111
|
return cs.advance(3) // msg_export_tr_req$111
|
||||||
&& t_Ref_MsgEnvelope.validate_skip(ops, cs, weak) // out_msg:^MsgEnvelope
|
&& t_Ref_MsgEnvelope.validate_skip(ops, cs, weak) // out_msg:^MsgEnvelope
|
||||||
&& RefTo<InMsg>{}.validate_skip(ops, cs, weak); // imported:^InMsg
|
&& RefTo<InMsg>{}.validate_skip(ops, cs, weak); // imported:^InMsg
|
||||||
|
case msg_export_new_defer:
|
||||||
|
return cs.advance(5) // msg_export_new_defer$10100
|
||||||
|
&& t_Ref_MsgEnvelope.validate_skip(ops, cs, weak) // out_msg:^MsgEnvelope
|
||||||
|
&& t_Ref_Transaction.validate_skip(ops, cs, weak); // transaction:^Transaction
|
||||||
|
case msg_export_deferred_tr:
|
||||||
|
return cs.advance(5) // msg_export_deferred_tr$10101
|
||||||
|
&& t_Ref_MsgEnvelope.validate_skip(ops, cs, weak) // out_msg:^MsgEnvelope
|
||||||
|
&& RefTo<InMsg>{}.validate_skip(ops, cs, weak); // imported:^InMsg
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OutMsg::get_export_value(vm::CellBuilder& cb, vm::CellSlice& cs) const {
|
bool OutMsg::get_export_value(vm::CellBuilder& cb, vm::CellSlice& cs) const {
|
||||||
switch (get_tag(cs)) {
|
auto tag = get_tag(cs);
|
||||||
|
switch (tag) {
|
||||||
case msg_export_ext: // external outbound message carries no value
|
case msg_export_ext: // external outbound message carries no value
|
||||||
if (cs.have(3, 2)) {
|
if (cs.have(3, 2)) {
|
||||||
return t_CurrencyCollection.null_value(cb);
|
return t_CurrencyCollection.null_value(cb);
|
||||||
|
|
@ -1929,10 +2060,13 @@ bool OutMsg::get_export_value(vm::CellBuilder& cb, vm::CellSlice& cs) const {
|
||||||
return cs.have(4 + 63, 1) && t_CurrencyCollection.null_value(cb);
|
return cs.have(4 + 63, 1) && t_CurrencyCollection.null_value(cb);
|
||||||
case msg_export_deq_short: // dequeueing record for outbound message, no exported value
|
case msg_export_deq_short: // dequeueing record for outbound message, no exported value
|
||||||
return cs.have(4 + 256 + 32 + 64 + 64) && t_CurrencyCollection.null_value(cb);
|
return cs.have(4 + 256 + 32 + 64 + 64) && t_CurrencyCollection.null_value(cb);
|
||||||
case msg_export_new: // newly-generated outbound internal message, queued
|
case msg_export_new: // newly-generated outbound internal message, queued
|
||||||
case msg_export_tr: // transit internal message, queued
|
case msg_export_tr: // transit internal message, queued
|
||||||
case msg_export_tr_req: // transit internal message, re-queued from this shardchain
|
case msg_export_tr_req: // transit internal message, re-queued from this shardchain
|
||||||
if (cs.advance(3) && cs.size_refs() >= 2) {
|
case msg_export_new_defer: // newly-generated outbound internal message, deferred
|
||||||
|
case msg_export_deferred_tr: // internal message from DispatchQueue, queued
|
||||||
|
int tag_len = (tag == msg_export_new_defer || tag == msg_export_deferred_tr) ? 5 : 3;
|
||||||
|
if (cs.advance(tag_len) && cs.size_refs() >= 2) {
|
||||||
auto msg_env_cs = load_cell_slice(cs.fetch_ref());
|
auto msg_env_cs = load_cell_slice(cs.fetch_ref());
|
||||||
MsgEnvelope::Record out_msg;
|
MsgEnvelope::Record out_msg;
|
||||||
if (!(cs.fetch_ref().not_null() && t_MsgEnvelope.unpack(msg_env_cs, out_msg))) {
|
if (!(cs.fetch_ref().not_null() && t_MsgEnvelope.unpack(msg_env_cs, out_msg))) {
|
||||||
|
|
@ -1954,12 +2088,12 @@ bool OutMsg::get_export_value(vm::CellBuilder& cb, vm::CellSlice& cs) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OutMsg::get_created_lt(vm::CellSlice& cs, unsigned long long& created_lt) const {
|
bool OutMsg::get_emitted_lt(vm::CellSlice& cs, unsigned long long& emitted_lt) const {
|
||||||
switch (get_tag(cs)) {
|
switch (get_tag(cs)) {
|
||||||
case msg_export_ext:
|
case msg_export_ext:
|
||||||
if (cs.have(3, 1)) {
|
if (cs.have(3, 1)) {
|
||||||
auto msg_cs = load_cell_slice(cs.prefetch_ref());
|
auto msg_cs = load_cell_slice(cs.prefetch_ref());
|
||||||
return t_Message.get_created_lt(msg_cs, created_lt);
|
return t_Message.get_created_lt(msg_cs, emitted_lt);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1970,9 +2104,11 @@ bool OutMsg::get_created_lt(vm::CellSlice& cs, unsigned long long& created_lt) c
|
||||||
case msg_export_deq_short:
|
case msg_export_deq_short:
|
||||||
case msg_export_deq_imm:
|
case msg_export_deq_imm:
|
||||||
case msg_export_tr_req:
|
case msg_export_tr_req:
|
||||||
|
case msg_export_new_defer:
|
||||||
|
case msg_export_deferred_tr:
|
||||||
if (cs.have(3, 1)) {
|
if (cs.have(3, 1)) {
|
||||||
auto out_msg_cs = load_cell_slice(cs.prefetch_ref());
|
auto out_msg_cs = load_cell_slice(cs.prefetch_ref());
|
||||||
return t_MsgEnvelope.get_created_lt(out_msg_cs, created_lt);
|
return t_MsgEnvelope.get_emitted_lt(out_msg_cs, emitted_lt);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -2003,26 +2139,53 @@ bool Aug_OutMsgQueue::eval_empty(vm::CellBuilder& cb) const {
|
||||||
|
|
||||||
bool Aug_OutMsgQueue::eval_leaf(vm::CellBuilder& cb, vm::CellSlice& cs) const {
|
bool Aug_OutMsgQueue::eval_leaf(vm::CellBuilder& cb, vm::CellSlice& cs) const {
|
||||||
Ref<vm::Cell> msg_env;
|
Ref<vm::Cell> msg_env;
|
||||||
unsigned long long created_lt;
|
unsigned long long emitted_lt;
|
||||||
return cs.fetch_ref_to(msg_env) && t_MsgEnvelope.get_created_lt(load_cell_slice(std::move(msg_env)), created_lt) &&
|
return cs.fetch_ref_to(msg_env) && t_MsgEnvelope.get_emitted_lt(load_cell_slice(std::move(msg_env)), emitted_lt) &&
|
||||||
cb.store_ulong_rchk_bool(created_lt, 64);
|
cb.store_ulong_rchk_bool(emitted_lt, 64);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Aug_DispatchQueue::eval_fork(vm::CellBuilder& cb, vm::CellSlice& left_cs, vm::CellSlice& right_cs) const {
|
||||||
|
unsigned long long x, y;
|
||||||
|
return left_cs.fetch_ulong_bool(64, x) && right_cs.fetch_ulong_bool(64, y) &&
|
||||||
|
cb.store_ulong_rchk_bool(std::min(x, y), 64);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Aug_DispatchQueue::eval_empty(vm::CellBuilder& cb) const {
|
||||||
|
return cb.store_long_bool(0, 64);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Aug_DispatchQueue::eval_leaf(vm::CellBuilder& cb, vm::CellSlice& cs) const {
|
||||||
|
Ref<vm::Cell> messages_root;
|
||||||
|
if (!cs.fetch_maybe_ref(messages_root)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
vm::Dictionary messages{std::move(messages_root), 64};
|
||||||
|
td::BitArray<64> key_buffer;
|
||||||
|
td::uint64 key;
|
||||||
|
if (messages.get_minmax_key(key_buffer.bits(), 64).is_null()) {
|
||||||
|
key = (td::uint64)-1;
|
||||||
|
} else {
|
||||||
|
key = key_buffer.to_ulong();
|
||||||
|
}
|
||||||
|
return cb.store_long_bool(key, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Aug_OutMsgQueue aug_OutMsgQueue;
|
const Aug_OutMsgQueue aug_OutMsgQueue;
|
||||||
|
const Aug_DispatchQueue aug_DispatchQueue;
|
||||||
const OutMsgQueue t_OutMsgQueue;
|
const OutMsgQueue t_OutMsgQueue;
|
||||||
|
|
||||||
const ProcessedUpto t_ProcessedUpto;
|
const ProcessedUpto t_ProcessedUpto;
|
||||||
const HashmapE t_ProcessedInfo{96, t_ProcessedUpto};
|
const HashmapE t_ProcessedInfo{96, t_ProcessedUpto};
|
||||||
const HashmapE t_IhrPendingInfo{256, t_uint128};
|
const HashmapE t_IhrPendingInfo{256, t_uint128};
|
||||||
|
|
||||||
// _ out_queue:OutMsgQueue proc_info:ProcessedInfo = OutMsgQueueInfo;
|
// _ out_queue:OutMsgQueue proc_info:ProcessedInfo extra:(Maybe OutMsgQueueExtra) = OutMsgQueueInfo;
|
||||||
bool OutMsgQueueInfo::skip(vm::CellSlice& cs) const {
|
bool OutMsgQueueInfo::skip(vm::CellSlice& cs) const {
|
||||||
return t_OutMsgQueue.skip(cs) && t_ProcessedInfo.skip(cs) && t_IhrPendingInfo.skip(cs);
|
return t_OutMsgQueue.skip(cs) && t_ProcessedInfo.skip(cs) && Maybe<gen::OutMsgQueueExtra>().skip(cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OutMsgQueueInfo::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const {
|
bool OutMsgQueueInfo::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const {
|
||||||
return t_OutMsgQueue.validate_skip(ops, cs, weak) && t_ProcessedInfo.validate_skip(ops, cs, weak) &&
|
return t_OutMsgQueue.validate_skip(ops, cs, weak) && t_ProcessedInfo.validate_skip(ops, cs, weak) &&
|
||||||
t_IhrPendingInfo.validate_skip(ops, cs, weak);
|
Maybe<gen::OutMsgQueueExtra>().validate_skip(ops, cs, weak);
|
||||||
}
|
}
|
||||||
|
|
||||||
const OutMsgQueueInfo t_OutMsgQueueInfo;
|
const OutMsgQueueInfo t_OutMsgQueueInfo;
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
#include "td/utils/bits.h"
|
#include "td/utils/bits.h"
|
||||||
#include "td/utils/StringBuilder.h"
|
#include "td/utils/StringBuilder.h"
|
||||||
#include "ton/ton-types.h"
|
#include "ton/ton-types.h"
|
||||||
|
#include "block-auto.h"
|
||||||
|
|
||||||
namespace block {
|
namespace block {
|
||||||
|
|
||||||
|
|
@ -469,11 +470,17 @@ struct MsgEnvelope final : TLB_Complex {
|
||||||
int cur_addr, next_addr;
|
int cur_addr, next_addr;
|
||||||
td::RefInt256 fwd_fee_remaining;
|
td::RefInt256 fwd_fee_remaining;
|
||||||
Ref<vm::Cell> msg;
|
Ref<vm::Cell> msg;
|
||||||
|
td::optional<ton::LogicalTime> emitted_lt;
|
||||||
|
td::optional<MsgMetadata> metadata;
|
||||||
};
|
};
|
||||||
bool unpack(vm::CellSlice& cs, Record& data) const;
|
bool unpack(vm::CellSlice& cs, Record& data) const;
|
||||||
bool unpack(vm::CellSlice& cs, Record_std& data) const;
|
bool unpack(vm::CellSlice& cs, Record_std& data) const;
|
||||||
bool unpack_std(vm::CellSlice& cs, int& cur_a, int& nhop_a, Ref<vm::Cell>& msg) const;
|
bool pack(vm::CellBuilder& cb, const Record_std& data) const;
|
||||||
bool get_created_lt(const vm::CellSlice& cs, unsigned long long& created_lt) const;
|
bool pack_cell(td::Ref<vm::Cell>& cell, const Record_std& data) const;
|
||||||
|
bool get_emitted_lt(const vm::CellSlice& cs, unsigned long long& emitted_lt) const;
|
||||||
|
int get_tag(const vm::CellSlice& cs) const override {
|
||||||
|
return (int)cs.prefetch_ulong(4);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const MsgEnvelope t_MsgEnvelope;
|
extern const MsgEnvelope t_MsgEnvelope;
|
||||||
|
|
@ -801,12 +808,18 @@ struct InMsg final : TLB_Complex {
|
||||||
msg_import_fin = 4,
|
msg_import_fin = 4,
|
||||||
msg_import_tr = 5,
|
msg_import_tr = 5,
|
||||||
msg_discard_fin = 6,
|
msg_discard_fin = 6,
|
||||||
msg_discard_tr = 7
|
msg_discard_tr = 7,
|
||||||
|
msg_import_deferred_fin = 8,
|
||||||
|
msg_import_deferred_tr = 9
|
||||||
};
|
};
|
||||||
bool skip(vm::CellSlice& cs) const override;
|
bool skip(vm::CellSlice& cs) const override;
|
||||||
bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override;
|
bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override;
|
||||||
int get_tag(const vm::CellSlice& cs) const override {
|
int get_tag(const vm::CellSlice& cs) const override {
|
||||||
return (int)cs.prefetch_ulong(3);
|
int tag = (int)cs.prefetch_ulong(3);
|
||||||
|
if (tag != 1) {
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
return (int)cs.prefetch_ulong(5) - 0b00100 + 8;
|
||||||
}
|
}
|
||||||
bool get_import_fees(vm::CellBuilder& cb, vm::CellSlice& cs) const;
|
bool get_import_fees(vm::CellBuilder& cb, vm::CellSlice& cs) const;
|
||||||
};
|
};
|
||||||
|
|
@ -822,16 +835,24 @@ struct OutMsg final : TLB_Complex {
|
||||||
msg_export_deq_imm = 4,
|
msg_export_deq_imm = 4,
|
||||||
msg_export_deq = 12,
|
msg_export_deq = 12,
|
||||||
msg_export_deq_short = 13,
|
msg_export_deq_short = 13,
|
||||||
msg_export_tr_req = 7
|
msg_export_tr_req = 7,
|
||||||
|
msg_export_new_defer = 20, // 0b10100
|
||||||
|
msg_export_deferred_tr = 21 // 0b10101
|
||||||
};
|
};
|
||||||
bool skip(vm::CellSlice& cs) const override;
|
bool skip(vm::CellSlice& cs) const override;
|
||||||
bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override;
|
bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override;
|
||||||
int get_tag(const vm::CellSlice& cs) const override {
|
int get_tag(const vm::CellSlice& cs) const override {
|
||||||
int t = (int)cs.prefetch_ulong(3);
|
int t = (int)cs.prefetch_ulong(3);
|
||||||
return t != 6 ? t : (int)cs.prefetch_ulong(4);
|
if (t == 6) {
|
||||||
|
return (int)cs.prefetch_ulong(4);
|
||||||
|
}
|
||||||
|
if (t == 5) {
|
||||||
|
return (int)cs.prefetch_ulong(5);
|
||||||
|
}
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
bool get_export_value(vm::CellBuilder& cb, vm::CellSlice& cs) const;
|
bool get_export_value(vm::CellBuilder& cb, vm::CellSlice& cs) const;
|
||||||
bool get_created_lt(vm::CellSlice& cs, unsigned long long& created_lt) const;
|
bool get_emitted_lt(vm::CellSlice& cs, unsigned long long& emitted_lt) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const OutMsg t_OutMsg;
|
extern const OutMsg t_OutMsg;
|
||||||
|
|
@ -909,6 +930,16 @@ struct Aug_OutMsgQueue final : AugmentationCheckData {
|
||||||
|
|
||||||
extern const Aug_OutMsgQueue aug_OutMsgQueue;
|
extern const Aug_OutMsgQueue aug_OutMsgQueue;
|
||||||
|
|
||||||
|
struct Aug_DispatchQueue final : AugmentationCheckData {
|
||||||
|
Aug_DispatchQueue() : AugmentationCheckData(gen::t_AccountDispatchQueue, t_uint64) {
|
||||||
|
}
|
||||||
|
bool eval_fork(vm::CellBuilder& cb, vm::CellSlice& left_cs, vm::CellSlice& right_cs) const override;
|
||||||
|
bool eval_empty(vm::CellBuilder& cb) const override;
|
||||||
|
bool eval_leaf(vm::CellBuilder& cb, vm::CellSlice& cs) const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern const Aug_DispatchQueue aug_DispatchQueue;
|
||||||
|
|
||||||
struct OutMsgQueue final : TLB_Complex {
|
struct OutMsgQueue final : TLB_Complex {
|
||||||
HashmapAugE dict_type;
|
HashmapAugE dict_type;
|
||||||
OutMsgQueue() : dict_type(32 + 64 + 256, aug_OutMsgQueue){};
|
OutMsgQueue() : dict_type(32 + 64 + 256, aug_OutMsgQueue){};
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
#include "td/utils/tl_storers.h"
|
#include "td/utils/tl_storers.h"
|
||||||
#include "td/utils/misc.h"
|
#include "td/utils/misc.h"
|
||||||
#include "td/utils/Random.h"
|
#include "td/utils/Random.h"
|
||||||
|
#include "vm/fmt.hpp"
|
||||||
|
|
||||||
namespace block {
|
namespace block {
|
||||||
using namespace std::literals::string_literals;
|
using namespace std::literals::string_literals;
|
||||||
|
|
@ -359,7 +360,6 @@ MsgProcessedUptoCollection::MsgProcessedUptoCollection(ton::ShardIdFull _owner,
|
||||||
z.shard = key.get_uint(64);
|
z.shard = key.get_uint(64);
|
||||||
z.mc_seqno = (unsigned)((key + 64).get_uint(32));
|
z.mc_seqno = (unsigned)((key + 64).get_uint(32));
|
||||||
z.last_inmsg_lt = value.write().fetch_ulong(64);
|
z.last_inmsg_lt = value.write().fetch_ulong(64);
|
||||||
// std::cerr << "ProcessedUpto shard " << std::hex << z.shard << std::dec << std::endl;
|
|
||||||
return value.write().fetch_bits_to(z.last_inmsg_hash) && z.shard && ton::shard_contains(owner.shard, z.shard);
|
return value.write().fetch_bits_to(z.last_inmsg_hash) && z.shard && ton::shard_contains(owner.shard, z.shard);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -642,7 +642,11 @@ bool EnqueuedMsgDescr::unpack(vm::CellSlice& cs) {
|
||||||
}
|
}
|
||||||
cur_prefix_ = interpolate_addr(src_prefix_, dest_prefix_, env.cur_addr);
|
cur_prefix_ = interpolate_addr(src_prefix_, dest_prefix_, env.cur_addr);
|
||||||
next_prefix_ = interpolate_addr(src_prefix_, dest_prefix_, env.next_addr);
|
next_prefix_ = interpolate_addr(src_prefix_, dest_prefix_, env.next_addr);
|
||||||
lt_ = info.created_lt;
|
unsigned long long lt;
|
||||||
|
if (!tlb::t_MsgEnvelope.get_emitted_lt(vm::load_cell_slice(enq.out_msg), lt)) {
|
||||||
|
return invalidate();
|
||||||
|
}
|
||||||
|
lt_ = lt;
|
||||||
enqueued_lt_ = enq.enqueued_lt;
|
enqueued_lt_ = enq.enqueued_lt;
|
||||||
hash_ = env.msg->get_hash().bits();
|
hash_ = env.msg->get_hash().bits();
|
||||||
msg_ = std::move(env.msg);
|
msg_ = std::move(env.msg);
|
||||||
|
|
@ -655,6 +659,12 @@ bool EnqueuedMsgDescr::check_key(td::ConstBitPtr key) const {
|
||||||
hash_ == key + 96;
|
hash_ == key + 96;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ImportedMsgQueueLimits::deserialize(vm::CellSlice& cs) {
|
||||||
|
return cs.fetch_ulong(8) == 0xd3 // imported_msg_queue_limits#d3
|
||||||
|
&& cs.fetch_uint_to(32, max_bytes) // max_bytes:#
|
||||||
|
&& cs.fetch_uint_to(32, max_msgs); // max_msgs:#
|
||||||
|
}
|
||||||
|
|
||||||
bool ParamLimits::deserialize(vm::CellSlice& cs) {
|
bool ParamLimits::deserialize(vm::CellSlice& cs) {
|
||||||
return cs.fetch_ulong(8) == 0xc3 // param_limits#c3
|
return cs.fetch_ulong(8) == 0xc3 // param_limits#c3
|
||||||
&& cs.fetch_uint_to(32, limits_[0]) // underload:uint32
|
&& cs.fetch_uint_to(32, limits_[0]) // underload:uint32
|
||||||
|
|
@ -714,8 +724,8 @@ td::uint64 BlockLimitStatus::estimate_block_size(const vm::NewCellStorageStat::S
|
||||||
if (extra) {
|
if (extra) {
|
||||||
sum += *extra;
|
sum += *extra;
|
||||||
}
|
}
|
||||||
return 2000 + (sum.bits >> 3) + sum.cells * 12 + sum.internal_refs * 3 + sum.external_refs * 40 + accounts * 200 +
|
return 2000 + (sum.bits >> 3) + sum.cells * 12 + sum.internal_refs * 3 + sum.external_refs * 40 + transactions * 200 +
|
||||||
transactions * 200 + (extra ? 200 : 0) + extra_out_msgs * 300 + public_library_diff * 700;
|
(extra ? 200 : 0) + extra_out_msgs * 300 + public_library_diff * 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BlockLimitStatus::classify() const {
|
int BlockLimitStatus::classify() const {
|
||||||
|
|
@ -851,19 +861,29 @@ td::Status ShardState::unpack_out_msg_queue_info(Ref<vm::Cell> out_msg_queue_inf
|
||||||
out_msg_queue_ =
|
out_msg_queue_ =
|
||||||
std::make_unique<vm::AugmentedDictionary>(std::move(qinfo.out_queue), 352, block::tlb::aug_OutMsgQueue);
|
std::make_unique<vm::AugmentedDictionary>(std::move(qinfo.out_queue), 352, block::tlb::aug_OutMsgQueue);
|
||||||
if (verbosity >= 3 * 1) {
|
if (verbosity >= 3 * 1) {
|
||||||
LOG(DEBUG) << "unpacking ProcessedUpto of our previous block " << id_.to_str();
|
FLOG(DEBUG) {
|
||||||
block::gen::t_ProcessedInfo.print(std::cerr, qinfo.proc_info);
|
sb << "unpacking ProcessedUpto of our previous block " << id_.to_str();
|
||||||
|
block::gen::t_ProcessedInfo.print(sb, qinfo.proc_info);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
if (!block::gen::t_ProcessedInfo.validate_csr(1024, qinfo.proc_info)) {
|
if (!block::gen::t_ProcessedInfo.validate_csr(1024, qinfo.proc_info)) {
|
||||||
return td::Status::Error(
|
return td::Status::Error(
|
||||||
-666, "ProcessedInfo in the state of "s + id_.to_str() + " is invalid according to automated validity checks");
|
-666, "ProcessedInfo in the state of "s + id_.to_str() + " is invalid according to automated validity checks");
|
||||||
}
|
}
|
||||||
if (!block::gen::t_IhrPendingInfo.validate_csr(1024, qinfo.ihr_pending)) {
|
|
||||||
return td::Status::Error(
|
|
||||||
-666, "IhrPendingInfo in the state of "s + id_.to_str() + " is invalid according to automated validity checks");
|
|
||||||
}
|
|
||||||
processed_upto_ = block::MsgProcessedUptoCollection::unpack(ton::ShardIdFull(id_), std::move(qinfo.proc_info));
|
processed_upto_ = block::MsgProcessedUptoCollection::unpack(ton::ShardIdFull(id_), std::move(qinfo.proc_info));
|
||||||
ihr_pending_ = std::make_unique<vm::Dictionary>(std::move(qinfo.ihr_pending), 320);
|
ihr_pending_ = std::make_unique<vm::Dictionary>(320);
|
||||||
|
if (qinfo.extra.write().fetch_long(1)) {
|
||||||
|
block::gen::OutMsgQueueExtra::Record extra;
|
||||||
|
if (!block::tlb::csr_unpack(qinfo.extra, extra)) {
|
||||||
|
return td::Status::Error(-666, "cannot unpack OutMsgQueueExtre in the state of "s + id_.to_str());
|
||||||
|
}
|
||||||
|
dispatch_queue_ = std::make_unique<vm::AugmentedDictionary>(extra.dispatch_queue, 256, tlb::aug_DispatchQueue);
|
||||||
|
if (extra.out_queue_size.write().fetch_long(1)) {
|
||||||
|
out_msg_queue_size_ = extra.out_queue_size->prefetch_ulong(48);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dispatch_queue_ = std::make_unique<vm::AugmentedDictionary>(256, tlb::aug_DispatchQueue);
|
||||||
|
}
|
||||||
auto shard1 = id_.shard_full();
|
auto shard1 = id_.shard_full();
|
||||||
td::BitArray<64> pfx{(long long)shard1.shard};
|
td::BitArray<64> pfx{(long long)shard1.shard};
|
||||||
int pfx_len = shard_prefix_length(shard1);
|
int pfx_len = shard_prefix_length(shard1);
|
||||||
|
|
@ -994,6 +1014,17 @@ td::Status ShardState::merge_with(ShardState& sib) {
|
||||||
underload_history_ = overload_history_ = 0;
|
underload_history_ = overload_history_ = 0;
|
||||||
// 10. compute vert_seqno
|
// 10. compute vert_seqno
|
||||||
vert_seqno_ = std::max(vert_seqno_, sib.vert_seqno_);
|
vert_seqno_ = std::max(vert_seqno_, sib.vert_seqno_);
|
||||||
|
// 11. merge dispatch_queue (same as account dict)
|
||||||
|
if (!dispatch_queue_->combine_with(*sib.dispatch_queue_)) {
|
||||||
|
return td::Status::Error(-666, "cannot merge dispatch queues of the two ancestors");
|
||||||
|
}
|
||||||
|
sib.dispatch_queue_.reset();
|
||||||
|
// 11. merge out_msg_queue_size
|
||||||
|
if (out_msg_queue_size_ && sib.out_msg_queue_size_) {
|
||||||
|
out_msg_queue_size_.value() += sib.out_msg_queue_size_.value();
|
||||||
|
} else {
|
||||||
|
out_msg_queue_size_ = {};
|
||||||
|
}
|
||||||
// Anything else? add here
|
// Anything else? add here
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
|
|
@ -1009,8 +1040,8 @@ td::Status ShardState::merge_with(ShardState& sib) {
|
||||||
return td::Status::OK();
|
return td::Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
td::Result<std::unique_ptr<vm::AugmentedDictionary>> ShardState::compute_split_out_msg_queue(ton::ShardIdFull subshard,
|
td::Result<std::unique_ptr<vm::AugmentedDictionary>> ShardState::compute_split_out_msg_queue(
|
||||||
td::uint32* queue_size) {
|
ton::ShardIdFull subshard) {
|
||||||
auto shard = id_.shard_full();
|
auto shard = id_.shard_full();
|
||||||
if (!ton::shard_is_parent(shard, subshard)) {
|
if (!ton::shard_is_parent(shard, subshard)) {
|
||||||
return td::Status::Error(-666, "cannot split subshard "s + subshard.to_str() + " from state of " + id_.to_str() +
|
return td::Status::Error(-666, "cannot split subshard "s + subshard.to_str() + " from state of " + id_.to_str() +
|
||||||
|
|
@ -1018,7 +1049,7 @@ td::Result<std::unique_ptr<vm::AugmentedDictionary>> ShardState::compute_split_o
|
||||||
}
|
}
|
||||||
CHECK(out_msg_queue_);
|
CHECK(out_msg_queue_);
|
||||||
auto subqueue = std::make_unique<vm::AugmentedDictionary>(*out_msg_queue_);
|
auto subqueue = std::make_unique<vm::AugmentedDictionary>(*out_msg_queue_);
|
||||||
int res = block::filter_out_msg_queue(*subqueue, shard, subshard, queue_size);
|
int res = block::filter_out_msg_queue(*subqueue, shard, subshard);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
return td::Status::Error(-666, "error splitting OutMsgQueue of "s + id_.to_str());
|
return td::Status::Error(-666, "error splitting OutMsgQueue of "s + id_.to_str());
|
||||||
}
|
}
|
||||||
|
|
@ -1040,7 +1071,7 @@ td::Result<std::shared_ptr<block::MsgProcessedUptoCollection>> ShardState::compu
|
||||||
return std::move(sub_processed_upto);
|
return std::move(sub_processed_upto);
|
||||||
}
|
}
|
||||||
|
|
||||||
td::Status ShardState::split(ton::ShardIdFull subshard, td::uint32* queue_size) {
|
td::Status ShardState::split(ton::ShardIdFull subshard) {
|
||||||
if (!ton::shard_is_parent(id_.shard_full(), subshard)) {
|
if (!ton::shard_is_parent(id_.shard_full(), subshard)) {
|
||||||
return td::Status::Error(-666, "cannot split subshard "s + subshard.to_str() + " from state of " + id_.to_str() +
|
return td::Status::Error(-666, "cannot split subshard "s + subshard.to_str() + " from state of " + id_.to_str() +
|
||||||
" because it is not a parent");
|
" because it is not a parent");
|
||||||
|
|
@ -1058,10 +1089,12 @@ td::Status ShardState::split(ton::ShardIdFull subshard, td::uint32* queue_size)
|
||||||
auto shard1 = id_.shard_full();
|
auto shard1 = id_.shard_full();
|
||||||
CHECK(ton::shard_is_parent(shard1, subshard));
|
CHECK(ton::shard_is_parent(shard1, subshard));
|
||||||
CHECK(out_msg_queue_);
|
CHECK(out_msg_queue_);
|
||||||
int res1 = block::filter_out_msg_queue(*out_msg_queue_, shard1, subshard, queue_size);
|
td::uint64 queue_size;
|
||||||
|
int res1 = block::filter_out_msg_queue(*out_msg_queue_, shard1, subshard, &queue_size);
|
||||||
if (res1 < 0) {
|
if (res1 < 0) {
|
||||||
return td::Status::Error(-666, "error splitting OutMsgQueue of "s + id_.to_str());
|
return td::Status::Error(-666, "error splitting OutMsgQueue of "s + id_.to_str());
|
||||||
}
|
}
|
||||||
|
out_msg_queue_size_ = queue_size;
|
||||||
LOG(DEBUG) << "split counters: " << res1;
|
LOG(DEBUG) << "split counters: " << res1;
|
||||||
// 3. processed_upto
|
// 3. processed_upto
|
||||||
LOG(DEBUG) << "splitting ProcessedUpto";
|
LOG(DEBUG) << "splitting ProcessedUpto";
|
||||||
|
|
@ -1091,6 +1124,11 @@ td::Status ShardState::split(ton::ShardIdFull subshard, td::uint32* queue_size)
|
||||||
// NB: if total_fees_extra will be allowed to be non-empty, split it here too
|
// NB: if total_fees_extra will be allowed to be non-empty, split it here too
|
||||||
// 7. reset overload/underload history
|
// 7. reset overload/underload history
|
||||||
overload_history_ = underload_history_ = 0;
|
overload_history_ = underload_history_ = 0;
|
||||||
|
// 8. split dispatch_queue (same as account dict)
|
||||||
|
LOG(DEBUG) << "splitting dispatch_queue";
|
||||||
|
CHECK(dispatch_queue_);
|
||||||
|
CHECK(dispatch_queue_->cut_prefix_subdict(pfx.bits(), pfx_len));
|
||||||
|
CHECK(dispatch_queue_->has_common_prefix(pfx.bits(), pfx_len));
|
||||||
// 999. anything else?
|
// 999. anything else?
|
||||||
id_.id.shard = subshard.shard;
|
id_.id.shard = subshard.shard;
|
||||||
id_.file_hash.set_zero();
|
id_.file_hash.set_zero();
|
||||||
|
|
@ -1099,7 +1137,7 @@ td::Status ShardState::split(ton::ShardIdFull subshard, td::uint32* queue_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
int filter_out_msg_queue(vm::AugmentedDictionary& out_queue, ton::ShardIdFull old_shard, ton::ShardIdFull subshard,
|
int filter_out_msg_queue(vm::AugmentedDictionary& out_queue, ton::ShardIdFull old_shard, ton::ShardIdFull subshard,
|
||||||
td::uint32* queue_size) {
|
td::uint64* queue_size) {
|
||||||
if (queue_size) {
|
if (queue_size) {
|
||||||
*queue_size = 0;
|
*queue_size = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1282,6 +1320,65 @@ CurrencyCollection CurrencyCollection::operator-(td::RefInt256 other_grams) cons
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CurrencyCollection::clamp(const CurrencyCollection& other) {
|
||||||
|
if (!is_valid() || !other.is_valid()) {
|
||||||
|
return invalidate();
|
||||||
|
}
|
||||||
|
grams = std::min(grams, other.grams);
|
||||||
|
vm::Dictionary dict1{extra, 32}, dict2(other.extra, 32);
|
||||||
|
bool ok = dict1.check_for_each([&](td::Ref<vm::CellSlice> cs1, td::ConstBitPtr key, int n) {
|
||||||
|
CHECK(n == 32);
|
||||||
|
td::Ref<vm::CellSlice> cs2 = dict2.lookup(key, 32);
|
||||||
|
td::RefInt256 val1 = tlb::t_VarUIntegerPos_32.as_integer(cs1);
|
||||||
|
if (val1.is_null()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
td::RefInt256 val2 = cs2.is_null() ? td::zero_refint() : tlb::t_VarUIntegerPos_32.as_integer(cs2);
|
||||||
|
if (val2.is_null()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (val1 > val2) {
|
||||||
|
if (val2->sgn() == 0) {
|
||||||
|
dict1.lookup_delete(key, 32);
|
||||||
|
} else {
|
||||||
|
dict1.set(key, 32, cs2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
extra = dict1.get_root_cell();
|
||||||
|
return ok || invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CurrencyCollection::check_extra_currency_limit(td::uint32 max_currencies) const {
|
||||||
|
td::uint32 count = 0;
|
||||||
|
return vm::Dictionary{extra, 32}.check_for_each([&](td::Ref<vm::CellSlice>, td::ConstBitPtr, int) {
|
||||||
|
++count;
|
||||||
|
return count <= max_currencies;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CurrencyCollection::remove_zero_extra_currencies(Ref<vm::Cell>& root, td::uint32 max_currencies) {
|
||||||
|
td::uint32 count = 0;
|
||||||
|
vm::Dictionary dict{root, 32};
|
||||||
|
int res = dict.filter([&](const vm::CellSlice& cs, td::ConstBitPtr, int) -> int {
|
||||||
|
++count;
|
||||||
|
if (count > max_currencies) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
td::RefInt256 val = tlb::t_VarUInteger_32.as_integer(cs);
|
||||||
|
if (val.is_null()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return val->sgn() > 0;
|
||||||
|
});
|
||||||
|
if (res < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
root = dict.get_root_cell();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool CurrencyCollection::operator==(const CurrencyCollection& other) const {
|
bool CurrencyCollection::operator==(const CurrencyCollection& other) const {
|
||||||
return is_valid() && other.is_valid() && !td::cmp(grams, other.grams) &&
|
return is_valid() && other.is_valid() && !td::cmp(grams, other.grams) &&
|
||||||
(extra.not_null() == other.extra.not_null()) &&
|
(extra.not_null() == other.extra.not_null()) &&
|
||||||
|
|
@ -1390,7 +1487,7 @@ bool ValueFlow::store(vm::CellBuilder& cb) const {
|
||||||
&& exported.store(cb2) // exported:CurrencyCollection
|
&& exported.store(cb2) // exported:CurrencyCollection
|
||||||
&& cb.store_ref_bool(cb2.finalize()) // ]
|
&& cb.store_ref_bool(cb2.finalize()) // ]
|
||||||
&& fees_collected.store(cb) // fees_collected:CurrencyCollection
|
&& fees_collected.store(cb) // fees_collected:CurrencyCollection
|
||||||
&& (burned.is_zero() || burned.store(cb)) // fees_burned:CurrencyCollection
|
&& (burned.is_zero() || burned.store(cb)) // fees_burned:CurrencyCollection
|
||||||
&& fees_imported.store(cb2) // ^[ fees_imported:CurrencyCollection
|
&& fees_imported.store(cb2) // ^[ fees_imported:CurrencyCollection
|
||||||
&& recovered.store(cb2) // recovered:CurrencyCollection
|
&& recovered.store(cb2) // recovered:CurrencyCollection
|
||||||
&& created.store(cb2) // created:CurrencyCollection
|
&& created.store(cb2) // created:CurrencyCollection
|
||||||
|
|
@ -1419,8 +1516,7 @@ bool ValueFlow::fetch(vm::CellSlice& cs) {
|
||||||
from_prev_blk.validate_unpack(std::move(f2.r1.from_prev_blk)) &&
|
from_prev_blk.validate_unpack(std::move(f2.r1.from_prev_blk)) &&
|
||||||
to_next_blk.validate_unpack(std::move(f2.r1.to_next_blk)) &&
|
to_next_blk.validate_unpack(std::move(f2.r1.to_next_blk)) &&
|
||||||
imported.validate_unpack(std::move(f2.r1.imported)) && exported.validate_unpack(std::move(f2.r1.exported)) &&
|
imported.validate_unpack(std::move(f2.r1.imported)) && exported.validate_unpack(std::move(f2.r1.exported)) &&
|
||||||
fees_collected.validate_unpack(std::move(f2.fees_collected)) &&
|
fees_collected.validate_unpack(std::move(f2.fees_collected)) && burned.validate_unpack(std::move(f2.burned)) &&
|
||||||
burned.validate_unpack(std::move(f2.burned)) &&
|
|
||||||
fees_imported.validate_unpack(std::move(f2.r2.fees_imported)) &&
|
fees_imported.validate_unpack(std::move(f2.r2.fees_imported)) &&
|
||||||
recovered.validate_unpack(std::move(f2.r2.recovered)) && created.validate_unpack(std::move(f2.r2.created)) &&
|
recovered.validate_unpack(std::move(f2.r2.recovered)) && created.validate_unpack(std::move(f2.r2.created)) &&
|
||||||
minted.validate_unpack(std::move(f2.r2.minted))) {
|
minted.validate_unpack(std::move(f2.r2.minted))) {
|
||||||
|
|
@ -2305,4 +2401,132 @@ bool parse_block_id_ext(td::Slice str, ton::BlockIdExt& blkid) {
|
||||||
return parse_block_id_ext(str.begin(), str.end(), blkid);
|
return parse_block_id_ext(str.begin(), str.end(), blkid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool unpack_account_dispatch_queue(Ref<vm::CellSlice> csr, vm::Dictionary& dict, td::uint64& dict_size) {
|
||||||
|
if (csr.not_null()) {
|
||||||
|
block::gen::AccountDispatchQueue::Record rec;
|
||||||
|
if (!block::tlb::csr_unpack(std::move(csr), rec)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
dict = vm::Dictionary{rec.messages, 64};
|
||||||
|
dict_size = rec.count;
|
||||||
|
if (dict_size == 0 || dict.is_empty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dict = vm::Dictionary{64};
|
||||||
|
dict_size = 0;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<vm::CellSlice> pack_account_dispatch_queue(const vm::Dictionary& dict, td::uint64 dict_size) {
|
||||||
|
if (dict_size == 0) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
// _ messages:(HashmapE 64 EnqueuedMsg) count:uint48 = AccountDispatchQueue;
|
||||||
|
vm::CellBuilder cb;
|
||||||
|
CHECK(dict.append_dict_to_bool(cb));
|
||||||
|
cb.store_long(dict_size, 48);
|
||||||
|
return cb.as_cellslice_ref();
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<vm::CellSlice> get_dispatch_queue_min_lt_account(const vm::AugmentedDictionary& dispatch_queue,
|
||||||
|
ton::StdSmcAddress& addr) {
|
||||||
|
// TODO: This can be done more effectively
|
||||||
|
vm::AugmentedDictionary queue{dispatch_queue.get_root(), 256, tlb::aug_DispatchQueue};
|
||||||
|
if (queue.is_empty()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
auto root_extra = queue.get_root_extra();
|
||||||
|
if (root_extra.is_null()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
ton::LogicalTime min_lt = root_extra->prefetch_long(64);
|
||||||
|
while (true) {
|
||||||
|
td::Bits256 key;
|
||||||
|
int pfx_len = queue.get_common_prefix(key.bits(), 256);
|
||||||
|
if (pfx_len < 0) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
if (pfx_len == 256) {
|
||||||
|
addr = key;
|
||||||
|
return queue.lookup(key);
|
||||||
|
}
|
||||||
|
key[pfx_len] = false;
|
||||||
|
vm::AugmentedDictionary queue_cut{queue.get_root(), 256, tlb::aug_DispatchQueue};
|
||||||
|
if (!queue_cut.cut_prefix_subdict(key.bits(), pfx_len + 1)) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
root_extra = queue_cut.get_root_extra();
|
||||||
|
if (root_extra.is_null()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
ton::LogicalTime cut_min_lt = root_extra->prefetch_long(64);
|
||||||
|
if (cut_min_lt != min_lt) {
|
||||||
|
key[pfx_len] = true;
|
||||||
|
}
|
||||||
|
if (!queue.cut_prefix_subdict(key.bits(), pfx_len + 1)) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool remove_dispatch_queue_entry(vm::AugmentedDictionary& dispatch_queue, const ton::StdSmcAddress& addr,
|
||||||
|
ton::LogicalTime lt) {
|
||||||
|
auto account_dispatch_queue = dispatch_queue.lookup(addr);
|
||||||
|
if (account_dispatch_queue.is_null()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
vm::Dictionary dict{64};
|
||||||
|
td::uint64 dict_size;
|
||||||
|
if (!unpack_account_dispatch_queue(std::move(account_dispatch_queue), dict, dict_size)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
td::BitArray<64> key;
|
||||||
|
key.store_ulong(lt);
|
||||||
|
auto entry = dict.lookup_delete(key);
|
||||||
|
if (entry.is_null()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
--dict_size;
|
||||||
|
account_dispatch_queue = pack_account_dispatch_queue(dict, dict_size);
|
||||||
|
if (account_dispatch_queue.not_null()) {
|
||||||
|
dispatch_queue.set(addr, account_dispatch_queue);
|
||||||
|
} else {
|
||||||
|
dispatch_queue.lookup_delete(addr);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MsgMetadata::unpack(vm::CellSlice& cs) {
|
||||||
|
// msg_metadata#0 depth:uint32 initiator_addr:MsgAddressInt initiator_lt:uint64 = MsgMetadata;
|
||||||
|
int tag;
|
||||||
|
return cs.fetch_int_to(4, tag) && tag == 0 && cs.fetch_uint_to(32, depth) &&
|
||||||
|
cs.prefetch_ulong(3) == 0b100 && // std address, no anycast
|
||||||
|
tlb::t_MsgAddressInt.extract_std_address(cs, initiator_wc, initiator_addr) &&
|
||||||
|
cs.fetch_uint_to(64, initiator_lt);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MsgMetadata::pack(vm::CellBuilder& cb) const {
|
||||||
|
// msg_metadata#0 depth:uint32 initiator_addr:MsgAddressInt initiator_lt:uint64 = MsgMetadata;
|
||||||
|
return cb.store_long_bool(0, 4) && cb.store_long_bool(depth, 32) &&
|
||||||
|
tlb::t_MsgAddressInt.store_std_address(cb, initiator_wc, initiator_addr) &&
|
||||||
|
cb.store_long_bool(initiator_lt, 64);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string MsgMetadata::to_str() const {
|
||||||
|
return PSTRING() << "[ depth=" << depth << " init=" << initiator_wc << ":" << initiator_addr.to_hex() << ":"
|
||||||
|
<< initiator_lt << " ]";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MsgMetadata::operator==(const MsgMetadata& other) const {
|
||||||
|
return depth == other.depth && initiator_wc == other.initiator_wc && initiator_addr == other.initiator_addr &&
|
||||||
|
initiator_lt == other.initiator_lt;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MsgMetadata::operator!=(const MsgMetadata& other) const {
|
||||||
|
return !(*this == other);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace block
|
} // namespace block
|
||||||
|
|
|
||||||
|
|
@ -216,6 +216,16 @@ static inline std::ostream& operator<<(std::ostream& os, const MsgProcessedUptoC
|
||||||
return proc_coll.print(os);
|
return proc_coll.print(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ImportedMsgQueueLimits {
|
||||||
|
// Default values
|
||||||
|
td::uint32 max_bytes = 1 << 16;
|
||||||
|
td::uint32 max_msgs = 30;
|
||||||
|
bool deserialize(vm::CellSlice& cs);
|
||||||
|
ImportedMsgQueueLimits operator*(td::uint32 x) const {
|
||||||
|
return {max_bytes * x, max_msgs * x};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct ParamLimits {
|
struct ParamLimits {
|
||||||
enum { limits_cnt = 4 };
|
enum { limits_cnt = 4 };
|
||||||
enum { cl_underload = 0, cl_normal = 1, cl_soft = 2, cl_medium = 3, cl_hard = 4 };
|
enum { cl_underload = 0, cl_normal = 1, cl_soft = 2, cl_medium = 3, cl_hard = 4 };
|
||||||
|
|
@ -239,6 +249,12 @@ struct ParamLimits {
|
||||||
bool deserialize(vm::CellSlice& cs);
|
bool deserialize(vm::CellSlice& cs);
|
||||||
int classify(td::uint64 value) const;
|
int classify(td::uint64 value) const;
|
||||||
bool fits(unsigned cls, td::uint64 value) const;
|
bool fits(unsigned cls, td::uint64 value) const;
|
||||||
|
void multiply_by(double x) {
|
||||||
|
CHECK(x > 0.0);
|
||||||
|
for (td::uint32& y : limits_) {
|
||||||
|
y = (td::uint32)std::min<double>(y * x, 1e9);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::array<td::uint32, limits_cnt> limits_;
|
std::array<td::uint32, limits_cnt> limits_;
|
||||||
|
|
@ -374,6 +390,9 @@ struct CurrencyCollection {
|
||||||
CurrencyCollection operator-(const CurrencyCollection& other) const;
|
CurrencyCollection operator-(const CurrencyCollection& other) const;
|
||||||
CurrencyCollection operator-(CurrencyCollection&& other) const;
|
CurrencyCollection operator-(CurrencyCollection&& other) const;
|
||||||
CurrencyCollection operator-(td::RefInt256 other_grams) const;
|
CurrencyCollection operator-(td::RefInt256 other_grams) const;
|
||||||
|
bool clamp(const CurrencyCollection& other);
|
||||||
|
bool check_extra_currency_limit(td::uint32 max_currencies) const;
|
||||||
|
static bool remove_zero_extra_currencies(Ref<vm::Cell>& root, td::uint32 max_currencies);
|
||||||
bool store(vm::CellBuilder& cb) const;
|
bool store(vm::CellBuilder& cb) const;
|
||||||
bool store_or_zero(vm::CellBuilder& cb) const;
|
bool store_or_zero(vm::CellBuilder& cb) const;
|
||||||
bool fetch(vm::CellSlice& cs);
|
bool fetch(vm::CellSlice& cs);
|
||||||
|
|
@ -417,6 +436,8 @@ struct ShardState {
|
||||||
std::unique_ptr<vm::Dictionary> ihr_pending_;
|
std::unique_ptr<vm::Dictionary> ihr_pending_;
|
||||||
std::unique_ptr<vm::Dictionary> block_create_stats_;
|
std::unique_ptr<vm::Dictionary> block_create_stats_;
|
||||||
std::shared_ptr<block::MsgProcessedUptoCollection> processed_upto_;
|
std::shared_ptr<block::MsgProcessedUptoCollection> processed_upto_;
|
||||||
|
std::unique_ptr<vm::AugmentedDictionary> dispatch_queue_;
|
||||||
|
td::optional<td::uint64> out_msg_queue_size_;
|
||||||
|
|
||||||
bool is_valid() const {
|
bool is_valid() const {
|
||||||
return id_.is_valid();
|
return id_.is_valid();
|
||||||
|
|
@ -433,11 +454,10 @@ struct ShardState {
|
||||||
ton::BlockSeqno prev_mc_block_seqno, bool after_split, bool clear_history,
|
ton::BlockSeqno prev_mc_block_seqno, bool after_split, bool clear_history,
|
||||||
std::function<bool(ton::BlockSeqno)> for_each_mcseqno);
|
std::function<bool(ton::BlockSeqno)> for_each_mcseqno);
|
||||||
td::Status merge_with(ShardState& sib);
|
td::Status merge_with(ShardState& sib);
|
||||||
td::Result<std::unique_ptr<vm::AugmentedDictionary>> compute_split_out_msg_queue(ton::ShardIdFull subshard,
|
td::Result<std::unique_ptr<vm::AugmentedDictionary>> compute_split_out_msg_queue(ton::ShardIdFull subshard);
|
||||||
td::uint32* queue_size = nullptr);
|
|
||||||
td::Result<std::shared_ptr<block::MsgProcessedUptoCollection>> compute_split_processed_upto(
|
td::Result<std::shared_ptr<block::MsgProcessedUptoCollection>> compute_split_processed_upto(
|
||||||
ton::ShardIdFull subshard);
|
ton::ShardIdFull subshard);
|
||||||
td::Status split(ton::ShardIdFull subshard, td::uint32* queue_size = nullptr);
|
td::Status split(ton::ShardIdFull subshard);
|
||||||
td::Status unpack_out_msg_queue_info(Ref<vm::Cell> out_msg_queue_info);
|
td::Status unpack_out_msg_queue_info(Ref<vm::Cell> out_msg_queue_info);
|
||||||
bool clear_load_history() {
|
bool clear_load_history() {
|
||||||
overload_history_ = underload_history_ = 0;
|
overload_history_ = underload_history_ = 0;
|
||||||
|
|
@ -658,7 +678,7 @@ class MtCarloComputeShare {
|
||||||
};
|
};
|
||||||
|
|
||||||
int filter_out_msg_queue(vm::AugmentedDictionary& out_queue, ton::ShardIdFull old_shard, ton::ShardIdFull subshard,
|
int filter_out_msg_queue(vm::AugmentedDictionary& out_queue, ton::ShardIdFull old_shard, ton::ShardIdFull subshard,
|
||||||
td::uint32* queue_size = nullptr);
|
td::uint64* queue_size = nullptr);
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& os, const ShardId& shard_id);
|
std::ostream& operator<<(std::ostream& os, const ShardId& shard_id);
|
||||||
|
|
||||||
|
|
@ -749,4 +769,25 @@ bool parse_hex_hash(td::Slice str, td::Bits256& hash);
|
||||||
bool parse_block_id_ext(const char* str, const char* end, ton::BlockIdExt& blkid);
|
bool parse_block_id_ext(const char* str, const char* end, ton::BlockIdExt& blkid);
|
||||||
bool parse_block_id_ext(td::Slice str, ton::BlockIdExt& blkid);
|
bool parse_block_id_ext(td::Slice str, ton::BlockIdExt& blkid);
|
||||||
|
|
||||||
|
bool unpack_account_dispatch_queue(Ref<vm::CellSlice> csr, vm::Dictionary& dict, td::uint64& dict_size);
|
||||||
|
Ref<vm::CellSlice> pack_account_dispatch_queue(const vm::Dictionary& dict, td::uint64 dict_size);
|
||||||
|
Ref<vm::CellSlice> get_dispatch_queue_min_lt_account(const vm::AugmentedDictionary& dispatch_queue,
|
||||||
|
ton::StdSmcAddress& addr);
|
||||||
|
bool remove_dispatch_queue_entry(vm::AugmentedDictionary& dispatch_queue, const ton::StdSmcAddress& addr,
|
||||||
|
ton::LogicalTime lt);
|
||||||
|
|
||||||
|
struct MsgMetadata {
|
||||||
|
td::uint32 depth;
|
||||||
|
ton::WorkchainId initiator_wc;
|
||||||
|
ton::StdSmcAddress initiator_addr;
|
||||||
|
ton::LogicalTime initiator_lt;
|
||||||
|
|
||||||
|
bool unpack(vm::CellSlice& cs);
|
||||||
|
bool pack(vm::CellBuilder& cb) const;
|
||||||
|
std::string to_str() const;
|
||||||
|
|
||||||
|
bool operator==(const MsgMetadata& other) const;
|
||||||
|
bool operator!=(const MsgMetadata& other) const;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace block
|
} // namespace block
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,12 @@ interm_addr_ext$11 workchain_id:int32 addr_pfx:uint64
|
||||||
msg_envelope#4 cur_addr:IntermediateAddress
|
msg_envelope#4 cur_addr:IntermediateAddress
|
||||||
next_addr:IntermediateAddress fwd_fee_remaining:Grams
|
next_addr:IntermediateAddress fwd_fee_remaining:Grams
|
||||||
msg:^(Message Any) = MsgEnvelope;
|
msg:^(Message Any) = MsgEnvelope;
|
||||||
|
msg_metadata#0 depth:uint32 initiator_addr:MsgAddressInt initiator_lt:uint64 = MsgMetadata;
|
||||||
|
msg_envelope_v2#5 cur_addr:IntermediateAddress
|
||||||
|
next_addr:IntermediateAddress fwd_fee_remaining:Grams
|
||||||
|
msg:^(Message Any)
|
||||||
|
emitted_lt:(Maybe uint64)
|
||||||
|
metadata:(Maybe MsgMetadata) = MsgEnvelope;
|
||||||
//
|
//
|
||||||
msg_import_ext$000 msg:^(Message Any) transaction:^Transaction
|
msg_import_ext$000 msg:^(Message Any) transaction:^Transaction
|
||||||
= InMsg;
|
= InMsg;
|
||||||
|
|
@ -187,6 +193,9 @@ msg_discard_fin$110 in_msg:^MsgEnvelope transaction_id:uint64
|
||||||
fwd_fee:Grams = InMsg;
|
fwd_fee:Grams = InMsg;
|
||||||
msg_discard_tr$111 in_msg:^MsgEnvelope transaction_id:uint64
|
msg_discard_tr$111 in_msg:^MsgEnvelope transaction_id:uint64
|
||||||
fwd_fee:Grams proof_delivered:^Cell = InMsg;
|
fwd_fee:Grams proof_delivered:^Cell = InMsg;
|
||||||
|
msg_import_deferred_fin$00100 in_msg:^MsgEnvelope
|
||||||
|
transaction:^Transaction fwd_fee:Grams = InMsg;
|
||||||
|
msg_import_deferred_tr$00101 in_msg:^MsgEnvelope out_msg:^MsgEnvelope = InMsg;
|
||||||
//
|
//
|
||||||
import_fees$_ fees_collected:Grams
|
import_fees$_ fees_collected:Grams
|
||||||
value_imported:CurrencyCollection = ImportFees;
|
value_imported:CurrencyCollection = ImportFees;
|
||||||
|
|
@ -210,6 +219,10 @@ msg_export_tr_req$111 out_msg:^MsgEnvelope
|
||||||
imported:^InMsg = OutMsg;
|
imported:^InMsg = OutMsg;
|
||||||
msg_export_deq_imm$100 out_msg:^MsgEnvelope
|
msg_export_deq_imm$100 out_msg:^MsgEnvelope
|
||||||
reimport:^InMsg = OutMsg;
|
reimport:^InMsg = OutMsg;
|
||||||
|
msg_export_new_defer$10100 out_msg:^MsgEnvelope
|
||||||
|
transaction:^Transaction = OutMsg;
|
||||||
|
msg_export_deferred_tr$10101 out_msg:^MsgEnvelope
|
||||||
|
imported:^InMsg = OutMsg;
|
||||||
|
|
||||||
_ enqueued_lt:uint64 out_msg:^MsgEnvelope = EnqueuedMsg;
|
_ enqueued_lt:uint64 out_msg:^MsgEnvelope = EnqueuedMsg;
|
||||||
|
|
||||||
|
|
@ -224,8 +237,15 @@ _ (HashmapE 96 ProcessedUpto) = ProcessedInfo;
|
||||||
ihr_pending$_ import_lt:uint64 = IhrPendingSince;
|
ihr_pending$_ import_lt:uint64 = IhrPendingSince;
|
||||||
_ (HashmapE 320 IhrPendingSince) = IhrPendingInfo;
|
_ (HashmapE 320 IhrPendingSince) = IhrPendingInfo;
|
||||||
|
|
||||||
|
// key - created_lt
|
||||||
|
_ messages:(HashmapE 64 EnqueuedMsg) count:uint48 = AccountDispatchQueue;
|
||||||
|
// key - sender address, aug - min created_lt
|
||||||
|
_ (HashmapAugE 256 AccountDispatchQueue uint64) = DispatchQueue;
|
||||||
|
|
||||||
|
out_msg_queue_extra#0 dispatch_queue:DispatchQueue out_queue_size:(Maybe uint48) = OutMsgQueueExtra;
|
||||||
|
|
||||||
_ out_queue:OutMsgQueue proc_info:ProcessedInfo
|
_ out_queue:OutMsgQueue proc_info:ProcessedInfo
|
||||||
ihr_pending:IhrPendingInfo = OutMsgQueueInfo;
|
extra:(Maybe OutMsgQueueExtra) = OutMsgQueueInfo;
|
||||||
//
|
//
|
||||||
storage_used$_ cells:(VarUInteger 7) bits:(VarUInteger 7)
|
storage_used$_ cells:(VarUInteger 7) bits:(VarUInteger 7)
|
||||||
public_cells:(VarUInteger 7) = StorageUsed;
|
public_cells:(VarUInteger 7) = StorageUsed;
|
||||||
|
|
@ -276,7 +296,7 @@ transaction$0111 account_addr:bits256 lt:uint64
|
||||||
total_fees:CurrencyCollection state_update:^(HASH_UPDATE Account)
|
total_fees:CurrencyCollection state_update:^(HASH_UPDATE Account)
|
||||||
description:^TransactionDescr = Transaction;
|
description:^TransactionDescr = Transaction;
|
||||||
|
|
||||||
!merkle_update#02 {X:Type} old_hash:bits256 new_hash:bits256
|
!merkle_update#04 {X:Type} old_hash:bits256 new_hash:bits256 old_depth:uint16 new_depth:uint16
|
||||||
old:^X new:^X = MERKLE_UPDATE X;
|
old:^X new:^X = MERKLE_UPDATE X;
|
||||||
update_hashes#72 {X:Type} old_hash:bits256 new_hash:bits256
|
update_hashes#72 {X:Type} old_hash:bits256 new_hash:bits256
|
||||||
= HASH_UPDATE X;
|
= HASH_UPDATE X;
|
||||||
|
|
@ -646,15 +666,15 @@ wc_split_merge_timings#0
|
||||||
//workchain#a5 enabled_since:uint32 min_split:(## 8) max_split:(## 8)
|
//workchain#a5 enabled_since:uint32 min_split:(## 8) max_split:(## 8)
|
||||||
// { min_split <= max_split } { max_split <= 60 }
|
// { min_split <= max_split } { max_split <= 60 }
|
||||||
|
|
||||||
workchain#a6 enabled_since:uint32 actual_min_split:(## 8)
|
workchain#a6 enabled_since:uint32 monitor_min_split:(## 8)
|
||||||
min_split:(## 8) max_split:(## 8) { actual_min_split <= min_split }
|
min_split:(## 8) max_split:(## 8) { monitor_min_split <= min_split }
|
||||||
basic:(## 1) active:Bool accept_msgs:Bool flags:(## 13) { flags = 0 }
|
basic:(## 1) active:Bool accept_msgs:Bool flags:(## 13) { flags = 0 }
|
||||||
zerostate_root_hash:bits256 zerostate_file_hash:bits256
|
zerostate_root_hash:bits256 zerostate_file_hash:bits256
|
||||||
version:uint32 format:(WorkchainFormat basic)
|
version:uint32 format:(WorkchainFormat basic)
|
||||||
= WorkchainDescr;
|
= WorkchainDescr;
|
||||||
|
|
||||||
workchain_v2#a7 enabled_since:uint32 actual_min_split:(## 8)
|
workchain_v2#a7 enabled_since:uint32 monitor_min_split:(## 8)
|
||||||
min_split:(## 8) max_split:(## 8) { actual_min_split <= min_split }
|
min_split:(## 8) max_split:(## 8) { monitor_min_split <= min_split }
|
||||||
basic:(## 1) active:Bool accept_msgs:Bool flags:(## 13) { flags = 0 }
|
basic:(## 1) active:Bool accept_msgs:Bool flags:(## 13) { flags = 0 }
|
||||||
zerostate_root_hash:bits256 zerostate_file_hash:bits256
|
zerostate_root_hash:bits256 zerostate_file_hash:bits256
|
||||||
version:uint32 format:(WorkchainFormat basic)
|
version:uint32 format:(WorkchainFormat basic)
|
||||||
|
|
@ -781,20 +801,24 @@ size_limits_config#01 max_msg_bits:uint32 max_msg_cells:uint32 max_library_cells
|
||||||
max_ext_msg_size:uint32 max_ext_msg_depth:uint16 = SizeLimitsConfig;
|
max_ext_msg_size:uint32 max_ext_msg_depth:uint16 = SizeLimitsConfig;
|
||||||
size_limits_config_v2#02 max_msg_bits:uint32 max_msg_cells:uint32 max_library_cells:uint32 max_vm_data_depth:uint16
|
size_limits_config_v2#02 max_msg_bits:uint32 max_msg_cells:uint32 max_library_cells:uint32 max_vm_data_depth:uint16
|
||||||
max_ext_msg_size:uint32 max_ext_msg_depth:uint16 max_acc_state_cells:uint32 max_acc_state_bits:uint32
|
max_ext_msg_size:uint32 max_ext_msg_depth:uint16 max_acc_state_cells:uint32 max_acc_state_bits:uint32
|
||||||
max_acc_public_libraries:uint32 = SizeLimitsConfig;
|
max_acc_public_libraries:uint32 defer_out_queue_size_limit:uint32 max_msg_extra_currencies:uint32 = SizeLimitsConfig;
|
||||||
_ SizeLimitsConfig = ConfigParam 43;
|
_ SizeLimitsConfig = ConfigParam 43;
|
||||||
|
|
||||||
// key is [ wc:int32 addr:uint256 ]
|
// key is [ wc:int32 addr:uint256 ]
|
||||||
suspended_address_list#00 addresses:(HashmapE 288 Unit) suspended_until:uint32 = SuspendedAddressList;
|
suspended_address_list#00 addresses:(HashmapE 288 Unit) suspended_until:uint32 = SuspendedAddressList;
|
||||||
_ SuspendedAddressList = ConfigParam 44;
|
_ SuspendedAddressList = ConfigParam 44;
|
||||||
|
|
||||||
|
precompiled_smc#b0 gas_usage:uint64 = PrecompiledSmc;
|
||||||
|
precompiled_contracts_config#c0 list:(HashmapE 256 PrecompiledSmc) = PrecompiledContractsConfig;
|
||||||
|
_ PrecompiledContractsConfig = ConfigParam 45;
|
||||||
|
|
||||||
oracle_bridge_params#_ bridge_address:bits256 oracle_mutlisig_address:bits256 oracles:(HashmapE 256 uint256) external_chain_address:bits256 = OracleBridgeParams;
|
oracle_bridge_params#_ bridge_address:bits256 oracle_mutlisig_address:bits256 oracles:(HashmapE 256 uint256) external_chain_address:bits256 = OracleBridgeParams;
|
||||||
_ OracleBridgeParams = ConfigParam 71; // Ethereum bridge
|
_ OracleBridgeParams = ConfigParam 71; // Ethereum bridge
|
||||||
_ OracleBridgeParams = ConfigParam 72; // Binance Smart Chain bridge
|
_ OracleBridgeParams = ConfigParam 72; // Binance Smart Chain bridge
|
||||||
_ OracleBridgeParams = ConfigParam 73; // Polygon bridge
|
_ OracleBridgeParams = ConfigParam 73; // Polygon bridge
|
||||||
|
|
||||||
// Note that chains in which bridge, minter and jetton-wallet operate are fixated
|
// Note that chains in which bridge, minter and jetton-wallet operate are fixated
|
||||||
jetton_bridge_prices#_ bridge_burn_fee:Coins bridge_mint_fee:Coins
|
jetton_bridge_prices#_ bridge_burn_fee:Coins bridge_mint_fee:Coins
|
||||||
wallet_min_tons_for_storage:Coins
|
wallet_min_tons_for_storage:Coins
|
||||||
wallet_gas_consumption:Coins
|
wallet_gas_consumption:Coins
|
||||||
minter_min_tons_for_storage:Coins
|
minter_min_tons_for_storage:Coins
|
||||||
|
|
|
||||||
|
|
@ -426,7 +426,7 @@ bool store_validator_list_hash(vm::CellBuilder& cb) {
|
||||||
LOG_CHECK(vset) << "unpacked validator set is empty";
|
LOG_CHECK(vset) << "unpacked validator set is empty";
|
||||||
auto ccvc = block::Config::unpack_catchain_validators_config(config_dict.lookup_ref(td::BitArray<32>{28}));
|
auto ccvc = block::Config::unpack_catchain_validators_config(config_dict.lookup_ref(td::BitArray<32>{28}));
|
||||||
ton::ShardIdFull shard{ton::masterchainId};
|
ton::ShardIdFull shard{ton::masterchainId};
|
||||||
auto nodes = block::Config::do_compute_validator_set(ccvc, shard, *vset, now, 0);
|
auto nodes = block::Config::do_compute_validator_set(ccvc, shard, *vset, 0);
|
||||||
LOG_CHECK(!nodes.empty()) << "validator node list in unpacked validator set is empty";
|
LOG_CHECK(!nodes.empty()) << "validator node list in unpacked validator set is empty";
|
||||||
auto vset_hash = block::compute_validator_set_hash(0, shard, std::move(nodes));
|
auto vset_hash = block::compute_validator_set_hash(0, shard, std::move(nodes));
|
||||||
LOG(DEBUG) << "initial validator set hash is " << vset_hash;
|
LOG(DEBUG) << "initial validator set hash is " << vset_hash;
|
||||||
|
|
@ -814,11 +814,16 @@ void usage(const char* progname) {
|
||||||
void parse_include_path_set(std::string include_path_set, std::vector<std::string>& res) {
|
void parse_include_path_set(std::string include_path_set, std::vector<std::string>& res) {
|
||||||
td::Parser parser(include_path_set);
|
td::Parser parser(include_path_set);
|
||||||
while (!parser.empty()) {
|
while (!parser.empty()) {
|
||||||
auto path = parser.read_till_nofail(':');
|
#if TD_WINDOWS
|
||||||
|
auto path_separator = '@';
|
||||||
|
#else
|
||||||
|
auto path_separator = ':';
|
||||||
|
#endif
|
||||||
|
auto path = parser.read_till_nofail(path_separator);
|
||||||
if (!path.empty()) {
|
if (!path.empty()) {
|
||||||
res.push_back(path.str());
|
res.push_back(path.str());
|
||||||
}
|
}
|
||||||
parser.skip_nofail(':');
|
parser.skip_nofail(path_separator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -163,8 +163,11 @@ td::Status ConfigInfo::unpack() {
|
||||||
}
|
}
|
||||||
gen::McStateExtra::Record extra_info;
|
gen::McStateExtra::Record extra_info;
|
||||||
if (!tlb::unpack_cell(state_extra_root_, extra_info)) {
|
if (!tlb::unpack_cell(state_extra_root_, extra_info)) {
|
||||||
vm::load_cell_slice(state_extra_root_).print_rec(std::cerr);
|
FLOG(WARNING) {
|
||||||
block::gen::t_McStateExtra.print_ref(std::cerr, state_extra_root_);
|
sb << "state extra information is invalid: ";
|
||||||
|
vm::load_cell_slice(state_extra_root_).print_rec(sb);
|
||||||
|
block::gen::t_McStateExtra.print_ref(sb, state_extra_root_);
|
||||||
|
};
|
||||||
return td::Status::Error("state extra information is invalid");
|
return td::Status::Error("state extra information is invalid");
|
||||||
}
|
}
|
||||||
gen::ValidatorInfo::Record validator_info;
|
gen::ValidatorInfo::Record validator_info;
|
||||||
|
|
@ -320,7 +323,7 @@ ton::ValidatorSessionConfig Config::get_consensus_config() const {
|
||||||
c.max_block_size = r.max_block_bytes;
|
c.max_block_size = r.max_block_bytes;
|
||||||
c.max_collated_data_size = r.max_collated_bytes;
|
c.max_collated_data_size = r.max_collated_bytes;
|
||||||
};
|
};
|
||||||
auto set_v2 = [&] (auto& r) {
|
auto set_v2 = [&](auto& r) {
|
||||||
set_v1(r);
|
set_v1(r);
|
||||||
c.new_catchain_ids = r.new_catchain_ids;
|
c.new_catchain_ids = r.new_catchain_ids;
|
||||||
};
|
};
|
||||||
|
|
@ -621,12 +624,14 @@ td::Result<std::vector<StoragePrices>> Config::get_storage_prices() const {
|
||||||
}
|
}
|
||||||
vm::Dictionary dict{std::move(cell), 32};
|
vm::Dictionary dict{std::move(cell), 32};
|
||||||
if (!dict.check_for_each([&res](Ref<vm::CellSlice> cs_ref, td::ConstBitPtr key, int n) -> bool {
|
if (!dict.check_for_each([&res](Ref<vm::CellSlice> cs_ref, td::ConstBitPtr key, int n) -> bool {
|
||||||
block::gen::StoragePrices::Record data;
|
auto r_prices = do_get_one_storage_prices(*cs_ref);
|
||||||
if (!tlb::csr_unpack(std::move(cs_ref), data) || data.utime_since != key.get_uint(n)) {
|
if (r_prices.is_error()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
res.push_back(r_prices.move_as_ok());
|
||||||
|
if (res.back().valid_since != key.get_uint(n)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
res.emplace_back(data.utime_since, data.bit_price_ps, data.cell_price_ps, data.mc_bit_price_ps,
|
|
||||||
data.mc_cell_price_ps);
|
|
||||||
return true;
|
return true;
|
||||||
})) {
|
})) {
|
||||||
return td::Status::Error("invalid storage prices dictionary in configuration parameter 18");
|
return td::Status::Error("invalid storage prices dictionary in configuration parameter 18");
|
||||||
|
|
@ -634,16 +639,25 @@ td::Result<std::vector<StoragePrices>> Config::get_storage_prices() const {
|
||||||
return std::move(res);
|
return std::move(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
td::Result<GasLimitsPrices> Config::do_get_gas_limits_prices(td::Ref<vm::Cell> cell, int id) {
|
td::Result<StoragePrices> Config::do_get_one_storage_prices(vm::CellSlice cs) {
|
||||||
|
block::gen::StoragePrices::Record data;
|
||||||
|
if (!tlb::unpack(cs, data)) {
|
||||||
|
return td::Status::Error("invalid storage prices dictionary in configuration parameter 18");
|
||||||
|
}
|
||||||
|
return StoragePrices{data.utime_since, data.bit_price_ps, data.cell_price_ps, data.mc_bit_price_ps,
|
||||||
|
data.mc_cell_price_ps};
|
||||||
|
}
|
||||||
|
|
||||||
|
td::Result<GasLimitsPrices> Config::do_get_gas_limits_prices(vm::CellSlice cs, int id) {
|
||||||
GasLimitsPrices res;
|
GasLimitsPrices res;
|
||||||
auto cs = vm::load_cell_slice(cell);
|
vm::CellSlice cs0 = cs;
|
||||||
block::gen::GasLimitsPrices::Record_gas_flat_pfx flat;
|
block::gen::GasLimitsPrices::Record_gas_flat_pfx flat;
|
||||||
if (tlb::unpack(cs, flat)) {
|
if (tlb::unpack(cs, flat)) {
|
||||||
cs = *flat.other;
|
cs = *flat.other;
|
||||||
res.flat_gas_limit = flat.flat_gas_limit;
|
res.flat_gas_limit = flat.flat_gas_limit;
|
||||||
res.flat_gas_price = flat.flat_gas_price;
|
res.flat_gas_price = flat.flat_gas_price;
|
||||||
} else {
|
} else {
|
||||||
cs = vm::load_cell_slice(cell);
|
cs = cs0;
|
||||||
}
|
}
|
||||||
auto f = [&](const auto& r, td::uint64 spec_limit) {
|
auto f = [&](const auto& r, td::uint64 spec_limit) {
|
||||||
res.gas_limit = r.gas_limit;
|
res.gas_limit = r.gas_limit;
|
||||||
|
|
@ -654,7 +668,6 @@ td::Result<GasLimitsPrices> Config::do_get_gas_limits_prices(td::Ref<vm::Cell> c
|
||||||
res.delete_due_limit = r.delete_due_limit;
|
res.delete_due_limit = r.delete_due_limit;
|
||||||
};
|
};
|
||||||
block::gen::GasLimitsPrices::Record_gas_prices_ext rec;
|
block::gen::GasLimitsPrices::Record_gas_prices_ext rec;
|
||||||
vm::CellSlice cs0 = cs;
|
|
||||||
if (tlb::unpack(cs, rec)) {
|
if (tlb::unpack(cs, rec)) {
|
||||||
f(rec, rec.special_gas_limit);
|
f(rec, rec.special_gas_limit);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -689,7 +702,7 @@ td::Result<GasLimitsPrices> Config::get_gas_limits_prices(bool is_masterchain) c
|
||||||
if (cell.is_null()) {
|
if (cell.is_null()) {
|
||||||
return td::Status::Error(PSLICE() << "configuration parameter " << id << " with gas prices is absent");
|
return td::Status::Error(PSLICE() << "configuration parameter " << id << " with gas prices is absent");
|
||||||
}
|
}
|
||||||
return do_get_gas_limits_prices(std::move(cell), id);
|
return do_get_gas_limits_prices(vm::load_cell_slice(cell), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
td::Result<MsgPrices> Config::get_msg_prices(bool is_masterchain) const {
|
td::Result<MsgPrices> Config::get_msg_prices(bool is_masterchain) const {
|
||||||
|
|
@ -698,7 +711,10 @@ td::Result<MsgPrices> Config::get_msg_prices(bool is_masterchain) const {
|
||||||
if (cell.is_null()) {
|
if (cell.is_null()) {
|
||||||
return td::Status::Error(PSLICE() << "configuration parameter " << id << " with msg prices is absent");
|
return td::Status::Error(PSLICE() << "configuration parameter " << id << " with msg prices is absent");
|
||||||
}
|
}
|
||||||
auto cs = vm::load_cell_slice(std::move(cell));
|
return do_get_msg_prices(vm::load_cell_slice(cell), id);
|
||||||
|
}
|
||||||
|
|
||||||
|
td::Result<MsgPrices> Config::do_get_msg_prices(vm::CellSlice cs, int id) {
|
||||||
block::gen::MsgForwardPrices::Record rec;
|
block::gen::MsgForwardPrices::Record rec;
|
||||||
if (!tlb::unpack(cs, rec)) {
|
if (!tlb::unpack(cs, rec)) {
|
||||||
return td::Status::Error(PSLICE() << "configuration parameter " << id
|
return td::Status::Error(PSLICE() << "configuration parameter " << id
|
||||||
|
|
@ -1054,7 +1070,6 @@ Ref<McShardHash> ShardConfig::get_shard_hash(ton::ShardIdFull id, bool exact) co
|
||||||
ton::ShardIdFull true_id;
|
ton::ShardIdFull true_id;
|
||||||
vm::CellSlice cs;
|
vm::CellSlice cs;
|
||||||
if (get_shard_hash_raw(cs, id, true_id, exact)) {
|
if (get_shard_hash_raw(cs, id, true_id, exact)) {
|
||||||
// block::gen::t_ShardDescr.print(std::cerr, vm::CellSlice{cs});
|
|
||||||
return McShardHash::unpack(cs, true_id);
|
return McShardHash::unpack(cs, true_id);
|
||||||
} else {
|
} else {
|
||||||
return {};
|
return {};
|
||||||
|
|
@ -1624,8 +1639,10 @@ bool ShardConfig::set_shard_info(ton::ShardIdFull shard, Ref<vm::Cell> value) {
|
||||||
if (!gen::t_BinTree_ShardDescr.validate_ref(1024, value)) {
|
if (!gen::t_BinTree_ShardDescr.validate_ref(1024, value)) {
|
||||||
LOG(ERROR) << "attempting to store an invalid (BinTree ShardDescr) at shard configuration position "
|
LOG(ERROR) << "attempting to store an invalid (BinTree ShardDescr) at shard configuration position "
|
||||||
<< shard.to_str();
|
<< shard.to_str();
|
||||||
gen::t_BinTree_ShardDescr.print_ref(std::cerr, value);
|
FLOG(WARNING) {
|
||||||
vm::load_cell_slice(value).print_rec(std::cerr);
|
gen::t_BinTree_ShardDescr.print_ref(sb, value);
|
||||||
|
vm::load_cell_slice(value).print_rec(sb);
|
||||||
|
};
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto root = shard_hashes_dict_->lookup_ref(td::BitArray<32>{shard.workchain});
|
auto root = shard_hashes_dict_->lookup_ref(td::BitArray<32>{shard.workchain});
|
||||||
|
|
@ -1733,7 +1750,7 @@ ton::CatchainSeqno ConfigInfo::get_shard_cc_seqno(ton::ShardIdFull shard) const
|
||||||
|
|
||||||
std::vector<ton::ValidatorDescr> Config::compute_validator_set(ton::ShardIdFull shard, const block::ValidatorSet& vset,
|
std::vector<ton::ValidatorDescr> Config::compute_validator_set(ton::ShardIdFull shard, const block::ValidatorSet& vset,
|
||||||
ton::UnixTime time, ton::CatchainSeqno cc_seqno) const {
|
ton::UnixTime time, ton::CatchainSeqno cc_seqno) const {
|
||||||
return do_compute_validator_set(get_catchain_validators_config(), shard, vset, time, cc_seqno);
|
return do_compute_validator_set(get_catchain_validators_config(), shard, vset, cc_seqno);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ton::ValidatorDescr> Config::compute_validator_set(ton::ShardIdFull shard, ton::UnixTime time,
|
std::vector<ton::ValidatorDescr> Config::compute_validator_set(ton::ShardIdFull shard, ton::UnixTime time,
|
||||||
|
|
@ -1760,7 +1777,7 @@ std::vector<ton::ValidatorDescr> ConfigInfo::compute_validator_set_cc(ton::Shard
|
||||||
if (cc_seqno_delta) {
|
if (cc_seqno_delta) {
|
||||||
cc_seqno = *cc_seqno_delta += cc_seqno;
|
cc_seqno = *cc_seqno_delta += cc_seqno;
|
||||||
}
|
}
|
||||||
return do_compute_validator_set(get_catchain_validators_config(), shard, vset, time, cc_seqno);
|
return do_compute_validator_set(get_catchain_validators_config(), shard, vset, cc_seqno);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ton::ValidatorDescr> ConfigInfo::compute_validator_set_cc(ton::ShardIdFull shard, ton::UnixTime time,
|
std::vector<ton::ValidatorDescr> ConfigInfo::compute_validator_set_cc(ton::ShardIdFull shard, ton::UnixTime time,
|
||||||
|
|
@ -1843,9 +1860,8 @@ int ValidatorSet::lookup_public_key(td::ConstBitPtr pubkey) const {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ton::ValidatorDescr> Config::do_compute_validator_set(const block::CatchainValidatorsConfig& ccv_conf,
|
std::vector<ton::ValidatorDescr> Config::do_compute_validator_set(const CatchainValidatorsConfig& ccv_conf,
|
||||||
ton::ShardIdFull shard,
|
ton::ShardIdFull shard, const ValidatorSet& vset,
|
||||||
const block::ValidatorSet& vset, ton::UnixTime time,
|
|
||||||
ton::CatchainSeqno cc_seqno) {
|
ton::CatchainSeqno cc_seqno) {
|
||||||
// LOG(DEBUG) << "in Config::do_compute_validator_set() for " << shard.to_str() << " ; cc_seqno=" << cc_seqno;
|
// LOG(DEBUG) << "in Config::do_compute_validator_set() for " << shard.to_str() << " ; cc_seqno=" << cc_seqno;
|
||||||
std::vector<ton::ValidatorDescr> nodes;
|
std::vector<ton::ValidatorDescr> nodes;
|
||||||
|
|
@ -1917,10 +1933,17 @@ std::vector<ton::ValidatorDescr> Config::compute_total_validator_set(int next) c
|
||||||
}
|
}
|
||||||
|
|
||||||
td::Result<SizeLimitsConfig> Config::get_size_limits_config() const {
|
td::Result<SizeLimitsConfig> Config::get_size_limits_config() const {
|
||||||
SizeLimitsConfig limits;
|
|
||||||
td::Ref<vm::Cell> param = get_config_param(43);
|
td::Ref<vm::Cell> param = get_config_param(43);
|
||||||
if (param.is_null()) {
|
if (param.is_null()) {
|
||||||
return limits;
|
return do_get_size_limits_config({});
|
||||||
|
}
|
||||||
|
return do_get_size_limits_config(vm::load_cell_slice_ref(param));
|
||||||
|
}
|
||||||
|
|
||||||
|
td::Result<SizeLimitsConfig> Config::do_get_size_limits_config(td::Ref<vm::CellSlice> cs) {
|
||||||
|
SizeLimitsConfig limits;
|
||||||
|
if (cs.is_null()) {
|
||||||
|
return limits; // default values
|
||||||
}
|
}
|
||||||
auto unpack_v1 = [&](auto& rec) {
|
auto unpack_v1 = [&](auto& rec) {
|
||||||
limits.max_msg_bits = rec.max_msg_bits;
|
limits.max_msg_bits = rec.max_msg_bits;
|
||||||
|
|
@ -1936,12 +1959,14 @@ td::Result<SizeLimitsConfig> Config::get_size_limits_config() const {
|
||||||
limits.max_acc_state_bits = rec.max_acc_state_bits;
|
limits.max_acc_state_bits = rec.max_acc_state_bits;
|
||||||
limits.max_acc_state_cells = rec.max_acc_state_cells;
|
limits.max_acc_state_cells = rec.max_acc_state_cells;
|
||||||
limits.max_acc_public_libraries = rec.max_acc_public_libraries;
|
limits.max_acc_public_libraries = rec.max_acc_public_libraries;
|
||||||
|
limits.defer_out_queue_size_limit = rec.defer_out_queue_size_limit;
|
||||||
|
limits.max_msg_extra_currencies = rec.max_msg_extra_currencies;
|
||||||
};
|
};
|
||||||
gen::SizeLimitsConfig::Record_size_limits_config rec_v1;
|
gen::SizeLimitsConfig::Record_size_limits_config rec_v1;
|
||||||
gen::SizeLimitsConfig::Record_size_limits_config_v2 rec_v2;
|
gen::SizeLimitsConfig::Record_size_limits_config_v2 rec_v2;
|
||||||
if (tlb::unpack_cell(param, rec_v1)) {
|
if (tlb::csr_unpack(cs, rec_v1)) {
|
||||||
unpack_v1(rec_v1);
|
unpack_v1(rec_v1);
|
||||||
} else if (tlb::unpack_cell(param, rec_v2)) {
|
} else if (tlb::csr_unpack(cs, rec_v2)) {
|
||||||
unpack_v2(rec_v2);
|
unpack_v2(rec_v2);
|
||||||
} else {
|
} else {
|
||||||
return td::Status::Error("configuration parameter 43 is invalid");
|
return td::Status::Error("configuration parameter 43 is invalid");
|
||||||
|
|
@ -1976,6 +2001,53 @@ BurningConfig Config::get_burning_config() const {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td::Ref<vm::Tuple> Config::get_unpacked_config_tuple(ton::UnixTime now) const {
|
||||||
|
auto get_param = [&](td::int32 idx) -> vm::StackEntry {
|
||||||
|
auto cell = get_config_param(idx);
|
||||||
|
if (cell.is_null()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return vm::load_cell_slice_ref(cell);
|
||||||
|
};
|
||||||
|
auto get_current_storage_prices = [&]() -> vm::StackEntry {
|
||||||
|
auto cell = get_config_param(18);
|
||||||
|
if (cell.is_null()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
vm::StackEntry res;
|
||||||
|
vm::Dictionary dict{std::move(cell), 32};
|
||||||
|
dict.check_for_each([&](Ref<vm::CellSlice> cs_ref, td::ConstBitPtr key, int n) -> bool {
|
||||||
|
auto utime_since = key.get_uint(n);
|
||||||
|
if (now >= utime_since) {
|
||||||
|
res = std::move(cs_ref);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
std::vector<vm::StackEntry> tuple;
|
||||||
|
tuple.push_back(get_current_storage_prices()); // storage_prices
|
||||||
|
tuple.push_back(get_param(19)); // global_id
|
||||||
|
tuple.push_back(get_param(20)); // config_mc_gas_prices
|
||||||
|
tuple.push_back(get_param(21)); // config_gas_prices
|
||||||
|
tuple.push_back(get_param(24)); // config_mc_fwd_prices
|
||||||
|
tuple.push_back(get_param(25)); // config_fwd_prices
|
||||||
|
tuple.push_back(get_param(43)); // size_limits_config
|
||||||
|
return td::make_cnt_ref<std::vector<vm::StackEntry>>(std::move(tuple));
|
||||||
|
}
|
||||||
|
|
||||||
|
PrecompiledContractsConfig Config::get_precompiled_contracts_config() const {
|
||||||
|
PrecompiledContractsConfig c;
|
||||||
|
td::Ref<vm::Cell> param = get_config_param(45);
|
||||||
|
gen::PrecompiledContractsConfig::Record rec;
|
||||||
|
if (param.is_null() || !tlb::unpack_cell(param, rec)) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
c.list = vm::Dictionary{rec.list->prefetch_ref(), 256};
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
td::Result<std::pair<ton::UnixTime, ton::UnixTime>> Config::unpack_validator_set_start_stop(Ref<vm::Cell> vset_root) {
|
td::Result<std::pair<ton::UnixTime, ton::UnixTime>> Config::unpack_validator_set_start_stop(Ref<vm::Cell> vset_root) {
|
||||||
if (vset_root.is_null()) {
|
if (vset_root.is_null()) {
|
||||||
return td::Status::Error("validator set absent");
|
return td::Status::Error("validator set absent");
|
||||||
|
|
@ -2007,7 +2079,7 @@ bool WorkchainInfo::unpack(ton::WorkchainId wc, vm::CellSlice& cs) {
|
||||||
}
|
}
|
||||||
auto unpack_v1 = [this](auto& info) {
|
auto unpack_v1 = [this](auto& info) {
|
||||||
enabled_since = info.enabled_since;
|
enabled_since = info.enabled_since;
|
||||||
actual_min_split = info.actual_min_split;
|
monitor_min_split = info.monitor_min_split;
|
||||||
min_split = info.min_split;
|
min_split = info.min_split;
|
||||||
max_split = info.max_split;
|
max_split = info.max_split;
|
||||||
basic = info.basic;
|
basic = info.basic;
|
||||||
|
|
@ -2225,39 +2297,71 @@ Ref<vm::Cell> ConfigInfo::lookup_library(td::ConstBitPtr root_hash) const {
|
||||||
td::Result<Ref<vm::Tuple>> ConfigInfo::get_prev_blocks_info() const {
|
td::Result<Ref<vm::Tuple>> ConfigInfo::get_prev_blocks_info() const {
|
||||||
// [ wc:Integer shard:Integer seqno:Integer root_hash:Integer file_hash:Integer] = BlockId;
|
// [ wc:Integer shard:Integer seqno:Integer root_hash:Integer file_hash:Integer] = BlockId;
|
||||||
// [ last_mc_blocks:[BlockId...]
|
// [ last_mc_blocks:[BlockId...]
|
||||||
// prev_key_block:BlockId ] : PrevBlocksInfo
|
// prev_key_block:BlockId
|
||||||
|
// last_mc_blocks_100[BlockId...] ] : PrevBlocksInfo
|
||||||
auto block_id_to_tuple = [](const ton::BlockIdExt& block_id) -> vm::Ref<vm::Tuple> {
|
auto block_id_to_tuple = [](const ton::BlockIdExt& block_id) -> vm::Ref<vm::Tuple> {
|
||||||
td::RefInt256 shard = td::make_refint(block_id.id.shard);
|
td::RefInt256 shard = td::make_refint(block_id.id.shard);
|
||||||
if (shard->sgn() < 0) {
|
if (shard->sgn() < 0) {
|
||||||
shard &= ((td::make_refint(1) << 64) - 1);
|
shard &= ((td::make_refint(1) << 64) - 1);
|
||||||
}
|
}
|
||||||
return vm::make_tuple_ref(
|
return vm::make_tuple_ref(td::make_refint(block_id.id.workchain), std::move(shard),
|
||||||
td::make_refint(block_id.id.workchain),
|
td::make_refint(block_id.id.seqno), td::bits_to_refint(block_id.root_hash.bits(), 256),
|
||||||
std::move(shard),
|
td::bits_to_refint(block_id.file_hash.bits(), 256));
|
||||||
td::make_refint(block_id.id.seqno),
|
|
||||||
td::bits_to_refint(block_id.root_hash.bits(), 256),
|
|
||||||
td::bits_to_refint(block_id.file_hash.bits(), 256));
|
|
||||||
};
|
};
|
||||||
std::vector<vm::StackEntry> last_mc_blocks;
|
std::vector<vm::StackEntry> tuple;
|
||||||
|
|
||||||
|
std::vector<vm::StackEntry> last_mc_blocks;
|
||||||
last_mc_blocks.push_back(block_id_to_tuple(block_id));
|
last_mc_blocks.push_back(block_id_to_tuple(block_id));
|
||||||
for (ton::BlockSeqno seqno = block_id.id.seqno; seqno > 0 && last_mc_blocks.size() < 16; ) {
|
for (ton::BlockSeqno seqno = block_id.id.seqno; seqno > 0 && last_mc_blocks.size() < 16;) {
|
||||||
--seqno;
|
--seqno;
|
||||||
ton::BlockIdExt block_id;
|
ton::BlockIdExt id;
|
||||||
if (!get_old_mc_block_id(seqno, block_id)) {
|
if (!get_old_mc_block_id(seqno, id)) {
|
||||||
return td::Status::Error("cannot fetch old mc block");
|
return td::Status::Error("cannot fetch old mc block");
|
||||||
}
|
}
|
||||||
last_mc_blocks.push_back(block_id_to_tuple(block_id));
|
last_mc_blocks.push_back(block_id_to_tuple(id));
|
||||||
}
|
}
|
||||||
|
tuple.push_back(td::make_cnt_ref<std::vector<vm::StackEntry>>(std::move(last_mc_blocks)));
|
||||||
|
|
||||||
ton::BlockIdExt last_key_block;
|
ton::BlockIdExt last_key_block;
|
||||||
ton::LogicalTime last_key_block_lt;
|
ton::LogicalTime last_key_block_lt;
|
||||||
if (!get_last_key_block(last_key_block, last_key_block_lt)) {
|
if (!get_last_key_block(last_key_block, last_key_block_lt)) {
|
||||||
return td::Status::Error("cannot fetch last key block");
|
return td::Status::Error("cannot fetch last key block");
|
||||||
}
|
}
|
||||||
return vm::make_tuple_ref(
|
tuple.push_back(block_id_to_tuple(last_key_block));
|
||||||
td::make_cnt_ref<std::vector<vm::StackEntry>>(std::move(last_mc_blocks)),
|
|
||||||
block_id_to_tuple(last_key_block));
|
if (get_global_version() >= 9) {
|
||||||
|
std::vector<vm::StackEntry> last_mc_blocks_100;
|
||||||
|
for (ton::BlockSeqno seqno = block_id.id.seqno / 100 * 100; last_mc_blocks_100.size() < 16;) {
|
||||||
|
ton::BlockIdExt id;
|
||||||
|
if (!get_old_mc_block_id(seqno, id)) {
|
||||||
|
return td::Status::Error("cannot fetch old mc block");
|
||||||
|
}
|
||||||
|
last_mc_blocks_100.push_back(block_id_to_tuple(id));
|
||||||
|
if (seqno < 100) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
seqno -= 100;
|
||||||
|
}
|
||||||
|
tuple.push_back(td::make_cnt_ref<std::vector<vm::StackEntry>>(std::move(last_mc_blocks_100)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return td::make_cnt_ref<std::vector<vm::StackEntry>>(std::move(tuple));
|
||||||
|
}
|
||||||
|
|
||||||
|
td::optional<PrecompiledContractsConfig::Contract> PrecompiledContractsConfig::get_contract(
|
||||||
|
td::Bits256 code_hash) const {
|
||||||
|
auto list_copy = list;
|
||||||
|
auto cs = list_copy.lookup(code_hash);
|
||||||
|
if (cs.is_null()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
gen::PrecompiledSmc::Record rec;
|
||||||
|
if (!tlb::csr_unpack(cs, rec)) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
Contract c;
|
||||||
|
c.gas_usage = rec.gas_usage;
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace block
|
} // namespace block
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,7 @@ struct McShardHash : public McShardHashI {
|
||||||
: blk_(blk), start_lt_(start_lt), end_lt_(end_lt) {
|
: blk_(blk), start_lt_(start_lt), end_lt_(end_lt) {
|
||||||
}
|
}
|
||||||
McShardHash(const McShardHash&) = default;
|
McShardHash(const McShardHash&) = default;
|
||||||
|
McShardHash& operator=(const McShardHash&) = default;
|
||||||
bool is_valid() const {
|
bool is_valid() const {
|
||||||
return blk_.is_valid();
|
return blk_.is_valid();
|
||||||
}
|
}
|
||||||
|
|
@ -350,7 +351,11 @@ struct GasLimitsPrices {
|
||||||
td::uint64 freeze_due_limit{0};
|
td::uint64 freeze_due_limit{0};
|
||||||
td::uint64 delete_due_limit{0};
|
td::uint64 delete_due_limit{0};
|
||||||
|
|
||||||
td::RefInt256 compute_gas_price(td::uint64 gas_used) const;
|
td::RefInt256 compute_gas_price(td::uint64 gas_used) const {
|
||||||
|
return gas_used <= flat_gas_limit
|
||||||
|
? td::make_refint(flat_gas_price)
|
||||||
|
: td::rshift(td::make_refint(gas_price) * (gas_used - flat_gas_limit), 16, 1) + flat_gas_price;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// msg_fwd_fees = (lump_price + ceil((bit_price * msg.bits + cell_price * msg.cells)/2^16)) nanograms
|
// msg_fwd_fees = (lump_price + ceil((bit_price * msg.bits + cell_price * msg.cells)/2^16)) nanograms
|
||||||
|
|
@ -365,6 +370,7 @@ struct MsgPrices {
|
||||||
td::uint32 first_frac;
|
td::uint32 first_frac;
|
||||||
td::uint32 next_frac;
|
td::uint32 next_frac;
|
||||||
td::uint64 compute_fwd_fees(td::uint64 cells, td::uint64 bits) const;
|
td::uint64 compute_fwd_fees(td::uint64 cells, td::uint64 bits) const;
|
||||||
|
td::RefInt256 compute_fwd_fees256(td::uint64 cells, td::uint64 bits) const;
|
||||||
std::pair<td::uint64, td::uint64> compute_fwd_ihr_fees(td::uint64 cells, td::uint64 bits,
|
std::pair<td::uint64, td::uint64> compute_fwd_ihr_fees(td::uint64 cells, td::uint64 bits,
|
||||||
bool ihr_disabled = false) const;
|
bool ihr_disabled = false) const;
|
||||||
MsgPrices() = default;
|
MsgPrices() = default;
|
||||||
|
|
@ -390,6 +396,8 @@ struct SizeLimitsConfig {
|
||||||
td::uint32 max_acc_state_cells = 1 << 16;
|
td::uint32 max_acc_state_cells = 1 << 16;
|
||||||
td::uint32 max_acc_state_bits = (1 << 16) * 1023;
|
td::uint32 max_acc_state_bits = (1 << 16) * 1023;
|
||||||
td::uint32 max_acc_public_libraries = 256;
|
td::uint32 max_acc_public_libraries = 256;
|
||||||
|
td::uint32 defer_out_queue_size_limit = 256;
|
||||||
|
td::uint32 max_msg_extra_currencies = 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CatchainValidatorsConfig {
|
struct CatchainValidatorsConfig {
|
||||||
|
|
@ -408,7 +416,7 @@ struct CatchainValidatorsConfig {
|
||||||
struct WorkchainInfo : public td::CntObject {
|
struct WorkchainInfo : public td::CntObject {
|
||||||
ton::WorkchainId workchain{ton::workchainInvalid};
|
ton::WorkchainId workchain{ton::workchainInvalid};
|
||||||
ton::UnixTime enabled_since;
|
ton::UnixTime enabled_since;
|
||||||
td::uint32 actual_min_split;
|
td::uint32 monitor_min_split;
|
||||||
td::uint32 min_split, max_split;
|
td::uint32 min_split, max_split;
|
||||||
bool basic;
|
bool basic;
|
||||||
bool active;
|
bool active;
|
||||||
|
|
@ -449,10 +457,11 @@ class ShardConfig {
|
||||||
ShardConfig() = default;
|
ShardConfig() = default;
|
||||||
ShardConfig(const ShardConfig& other);
|
ShardConfig(const ShardConfig& other);
|
||||||
ShardConfig(ShardConfig&& other) = default;
|
ShardConfig(ShardConfig&& other) = default;
|
||||||
ShardConfig(Ref<vm::Cell> shard_hashes, Ref<McShardHash> mc_shard_hash = {})
|
explicit ShardConfig(Ref<vm::Cell> shard_hashes, Ref<McShardHash> mc_shard_hash = {})
|
||||||
: shard_hashes_(std::move(shard_hashes)), mc_shard_hash_(std::move(mc_shard_hash)) {
|
: shard_hashes_(std::move(shard_hashes)), mc_shard_hash_(std::move(mc_shard_hash)) {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
ShardConfig& operator=(ShardConfig&& other) = default;
|
||||||
bool is_valid() const {
|
bool is_valid() const {
|
||||||
return valid_;
|
return valid_;
|
||||||
}
|
}
|
||||||
|
|
@ -521,6 +530,15 @@ struct BurningConfig {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct PrecompiledContractsConfig {
|
||||||
|
struct Contract {
|
||||||
|
td::uint64 gas_usage;
|
||||||
|
};
|
||||||
|
vm::Dictionary list{256};
|
||||||
|
|
||||||
|
td::optional<Contract> get_contract(td::Bits256 code_hash) const;
|
||||||
|
};
|
||||||
|
|
||||||
class Config {
|
class Config {
|
||||||
enum {
|
enum {
|
||||||
default_mc_catchain_lifetime = 200,
|
default_mc_catchain_lifetime = 200,
|
||||||
|
|
@ -530,7 +548,10 @@ class Config {
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum { needValidatorSet = 16, needSpecialSmc = 32, needWorkchainInfo = 256, needCapabilities = 512 };
|
static constexpr int needValidatorSet = 16;
|
||||||
|
static constexpr int needSpecialSmc = 32;
|
||||||
|
static constexpr int needWorkchainInfo = 256;
|
||||||
|
static constexpr int needCapabilities = 512;
|
||||||
int mode{0};
|
int mode{0};
|
||||||
ton::BlockIdExt block_id;
|
ton::BlockIdExt block_id;
|
||||||
|
|
||||||
|
|
@ -604,9 +625,11 @@ class Config {
|
||||||
bool is_special_smartcontract(const ton::StdSmcAddress& addr) const;
|
bool is_special_smartcontract(const ton::StdSmcAddress& addr) const;
|
||||||
static td::Result<std::unique_ptr<ValidatorSet>> unpack_validator_set(Ref<vm::Cell> valset_root);
|
static td::Result<std::unique_ptr<ValidatorSet>> unpack_validator_set(Ref<vm::Cell> valset_root);
|
||||||
td::Result<std::vector<StoragePrices>> get_storage_prices() const;
|
td::Result<std::vector<StoragePrices>> get_storage_prices() const;
|
||||||
|
static td::Result<StoragePrices> do_get_one_storage_prices(vm::CellSlice cs);
|
||||||
td::Result<GasLimitsPrices> get_gas_limits_prices(bool is_masterchain = false) const;
|
td::Result<GasLimitsPrices> get_gas_limits_prices(bool is_masterchain = false) const;
|
||||||
static td::Result<GasLimitsPrices> do_get_gas_limits_prices(td::Ref<vm::Cell> cell, int id);
|
static td::Result<GasLimitsPrices> do_get_gas_limits_prices(vm::CellSlice cs, int id);
|
||||||
td::Result<MsgPrices> get_msg_prices(bool is_masterchain = false) const;
|
td::Result<MsgPrices> get_msg_prices(bool is_masterchain = false) const;
|
||||||
|
static td::Result<MsgPrices> do_get_msg_prices(vm::CellSlice cs, int id);
|
||||||
static CatchainValidatorsConfig unpack_catchain_validators_config(Ref<vm::Cell> cell);
|
static CatchainValidatorsConfig unpack_catchain_validators_config(Ref<vm::Cell> cell);
|
||||||
CatchainValidatorsConfig get_catchain_validators_config() const;
|
CatchainValidatorsConfig get_catchain_validators_config() const;
|
||||||
td::Status visit_validator_params() const;
|
td::Status visit_validator_params() const;
|
||||||
|
|
@ -633,11 +656,13 @@ class Config {
|
||||||
ton::CatchainSeqno cc_seqno) const;
|
ton::CatchainSeqno cc_seqno) const;
|
||||||
std::vector<ton::ValidatorDescr> compute_total_validator_set(int next) const;
|
std::vector<ton::ValidatorDescr> compute_total_validator_set(int next) const;
|
||||||
td::Result<SizeLimitsConfig> get_size_limits_config() const;
|
td::Result<SizeLimitsConfig> get_size_limits_config() const;
|
||||||
|
static td::Result<SizeLimitsConfig> do_get_size_limits_config(td::Ref<vm::CellSlice> cs);
|
||||||
std::unique_ptr<vm::Dictionary> get_suspended_addresses(ton::UnixTime now) const;
|
std::unique_ptr<vm::Dictionary> get_suspended_addresses(ton::UnixTime now) const;
|
||||||
BurningConfig get_burning_config() const;
|
BurningConfig get_burning_config() const;
|
||||||
static std::vector<ton::ValidatorDescr> do_compute_validator_set(const block::CatchainValidatorsConfig& ccv_conf,
|
td::Ref<vm::Tuple> get_unpacked_config_tuple(ton::UnixTime now) const;
|
||||||
ton::ShardIdFull shard,
|
PrecompiledContractsConfig get_precompiled_contracts_config() const;
|
||||||
const block::ValidatorSet& vset, ton::UnixTime time,
|
static std::vector<ton::ValidatorDescr> do_compute_validator_set(const CatchainValidatorsConfig& ccv_conf,
|
||||||
|
ton::ShardIdFull shard, const ValidatorSet& vset,
|
||||||
ton::CatchainSeqno cc_seqno);
|
ton::CatchainSeqno cc_seqno);
|
||||||
|
|
||||||
static td::Result<std::unique_ptr<Config>> unpack_config(Ref<vm::Cell> config_root,
|
static td::Result<std::unique_ptr<Config>> unpack_config(Ref<vm::Cell> config_root,
|
||||||
|
|
@ -662,14 +687,12 @@ class Config {
|
||||||
|
|
||||||
class ConfigInfo : public Config, public ShardConfig {
|
class ConfigInfo : public Config, public ShardConfig {
|
||||||
public:
|
public:
|
||||||
enum {
|
static constexpr int needStateRoot = 1;
|
||||||
needStateRoot = 1,
|
static constexpr int needLibraries = 2;
|
||||||
needLibraries = 2,
|
static constexpr int needStateExtraRoot = 4;
|
||||||
needStateExtraRoot = 4,
|
static constexpr int needShardHashes = 8;
|
||||||
needShardHashes = 8,
|
static constexpr int needAccountsRoot = 64;
|
||||||
needAccountsRoot = 64,
|
static constexpr int needPrevBlocks = 128;
|
||||||
needPrevBlocks = 128
|
|
||||||
};
|
|
||||||
ton::BlockSeqno vert_seqno{~0U};
|
ton::BlockSeqno vert_seqno{~0U};
|
||||||
int global_id_{0};
|
int global_id_{0};
|
||||||
ton::UnixTime utime{0};
|
ton::UnixTime utime{0};
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue