Skip to content

Commit 0c21ce2

Browse files
authored
Merge pull request #1139 from ton-blockchain/stable_testnet
Merge recent updates
2 parents 140320b + 97c57c3 commit 0c21ce2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+758
-205
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Docker Ubuntu 22.04 branch image
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches-ignore:
7+
- master
8+
9+
env:
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: ${{ github.repository }}
12+
13+
jobs:
14+
build-and-push:
15+
runs-on: ubuntu-22.04
16+
steps:
17+
- name: Check out repository
18+
uses: actions/checkout@v3
19+
with:
20+
submodules: 'recursive'
21+
22+
- name: Set up QEMU
23+
uses: docker/setup-qemu-action@v3
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
28+
- name: Login to GitHub Container Registry
29+
uses: docker/login-action@v3
30+
with:
31+
registry: ${{ env.REGISTRY }}
32+
username: ${{ github.repository_owner }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Get tag as branch name
36+
id: tag
37+
run: |
38+
echo "TAG=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
39+
40+
- name: Build and push
41+
id: docker_build
42+
uses: docker/build-push-action@v6
43+
with:
44+
platforms: linux/amd64
45+
push: true
46+
context: ./
47+
tags: |
48+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.TAG }}

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,18 @@ RUN apt-get update && \
2727
apt-get install -y wget curl libatomic1 openssl libsecp256k1-dev libsodium-dev libmicrohttpd-dev liblz4-dev libjemalloc-dev htop net-tools netcat iptraf-ng jq tcpdump pv plzip && \
2828
rm -rf /var/lib/apt/lists/*
2929

30-
RUN mkdir -p /var/ton-work/db /var/ton-work/scripts
30+
RUN mkdir -p /var/ton-work/db /var/ton-work/scripts /usr/share/ton/smartcont/ /usr/lib/fift/
3131

3232
COPY --from=builder /ton/build/storage/storage-daemon/storage-daemon /usr/local/bin/
3333
COPY --from=builder /ton/build/storage/storage-daemon/storage-daemon-cli /usr/local/bin/
3434
COPY --from=builder /ton/build/lite-client/lite-client /usr/local/bin/
3535
COPY --from=builder /ton/build/validator-engine/validator-engine /usr/local/bin/
3636
COPY --from=builder /ton/build/validator-engine-console/validator-engine-console /usr/local/bin/
3737
COPY --from=builder /ton/build/utils/generate-random-id /usr/local/bin/
38+
COPY --from=builder /ton/build/crypto/fift /usr/local/bin/
39+
COPY --from=builder /ton/build/crypto/func /usr/local/bin/
40+
COPY --from=builder /ton/crypto/smartcont/* /usr/share/ton/smartcont/
41+
COPY --from=builder /ton/crypto/fift/lib/* /usr/lib/fift/
3842

3943
WORKDIR /var/ton-work/db
4044
COPY ./docker/init.sh ./docker/control.template /var/ton-work/scripts/

adnl/adnl-peer.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,11 @@ void AdnlPeerPairImpl::send_messages_in(std::vector<OutboundAdnlMessage> message
269269
size_t ptr = 0;
270270
bool first = true;
271271
do {
272+
respond_with_nop_after_ = td::Timestamp::in(td::Random::fast(1.0, 2.0));
272273
bool try_reinit = try_reinit_at_ && try_reinit_at_.is_in_past();
274+
if (try_reinit) {
275+
try_reinit_at_ = td::Timestamp::in(td::Random::fast(0.5, 1.5));
276+
}
273277
bool via_channel = channel_ready_ && !try_reinit;
274278
size_t s = (via_channel ? channel_packet_header_max_size() : packet_header_max_size());
275279
if (first) {
@@ -504,12 +508,6 @@ void AdnlPeerPairImpl::create_channel(pubkeys::Ed25519 pub, td::uint32 date) {
504508

505509
void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageCreateChannel &message) {
506510
create_channel(message.key(), message.date());
507-
if (respond_to_channel_create_after_.is_in_past()) {
508-
respond_to_channel_create_after_ = td::Timestamp::in(td::Random::fast(1.0, 2.0));
509-
std::vector<OutboundAdnlMessage> messages;
510-
messages.emplace_back(adnlmessage::AdnlMessageNop{}, 0);
511-
send_messages(std::move(messages));
512-
}
513511
}
514512

515513
void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageConfirmChannel &message) {
@@ -526,6 +524,7 @@ void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageConfirmChan
526524
}
527525

528526
void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageCustom &message) {
527+
respond_with_nop();
529528
td::actor::send_closure(local_actor_, &AdnlLocalId::deliver, peer_id_short_, message.data());
530529
}
531530

@@ -538,6 +537,7 @@ void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageReinit &mes
538537
}
539538

540539
void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageQuery &message) {
540+
respond_with_nop();
541541
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this), query_id = message.query_id(),
542542
flags = static_cast<td::uint32>(0)](td::Result<td::BufferSlice> R) {
543543
if (R.is_error()) {
@@ -556,6 +556,7 @@ void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageQuery &mess
556556
}
557557

558558
void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageAnswer &message) {
559+
respond_with_nop();
559560
auto Q = out_queries_.find(message.query_id());
560561

561562
if (Q == out_queries_.end()) {
@@ -573,6 +574,7 @@ void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessageAnswer &mes
573574
}
574575

575576
void AdnlPeerPairImpl::process_message(const adnlmessage::AdnlMessagePart &message) {
577+
respond_with_nop();
576578
auto size = message.total_size();
577579
if (size > huge_packet_max_size()) {
578580
VLOG(ADNL_WARNING) << this << ": dropping too big huge message: size=" << size;
@@ -635,6 +637,14 @@ void AdnlPeerPairImpl::delete_query(AdnlQueryId id) {
635637
}
636638
}
637639

640+
void AdnlPeerPairImpl::respond_with_nop() {
641+
if (respond_with_nop_after_.is_in_past()) {
642+
std::vector<OutboundAdnlMessage> messages;
643+
messages.emplace_back(adnlmessage::AdnlMessageNop{}, 0);
644+
send_messages(std::move(messages));
645+
}
646+
}
647+
638648
void AdnlPeerPairImpl::reinit(td::int32 date) {
639649
if (reinit_date_ == 0) {
640650
reinit_date_ = date;

adnl/adnl-peer.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class AdnlPeerPairImpl : public AdnlPeerPair {
122122
}
123123

124124
private:
125+
void respond_with_nop();
125126
void reinit(td::int32 date);
126127
td::Result<std::pair<td::actor::ActorId<AdnlNetworkConnection>, bool>> get_conn(bool direct_only);
127128
void create_channel(pubkeys::Ed25519 pub, td::uint32 date);
@@ -214,7 +215,7 @@ class AdnlPeerPairImpl : public AdnlPeerPair {
214215
pubkeys::Ed25519 channel_pub_;
215216
td::int32 channel_pk_date_;
216217
td::actor::ActorOwn<AdnlChannel> channel_;
217-
td::Timestamp respond_to_channel_create_after_;
218+
td::Timestamp respond_with_nop_after_;
218219

219220
td::uint64 in_seqno_ = 0;
220221
td::uint64 out_seqno_ = 0;

assembly/wasm/fift-func-wasm-build-ubuntu.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ cd ..
8585
if [ ! -f "openssl/openssl_em" ]; then
8686
cd openssl
8787
make clean
88-
emconfigure ./Configure linux-generic32 no-shared no-dso no-engine no-unit-test
88+
emconfigure ./Configure linux-generic32 no-shared no-dso no-engine no-unit-test no-tests no-fuzz-afl no-fuzz-libfuzzer
8989
sed -i 's/CROSS_COMPILE=.*/CROSS_COMPILE=/g' Makefile
9090
sed -i 's/-ldl//g' Makefile
9191
sed -i 's/-O3/-Os/g' Makefile

catchain/catchain-receiver-source.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class CatChainReceiverSource {
6161
virtual td::BufferSlice fork_proof() const = 0;
6262
virtual bool fork_is_found() const = 0;
6363

64-
// One block can be sent to one node only a limited number of times to prevent DoS
64+
// One block can be sent to one node in catchain.getDifference only a limited number of times to prevent DoS
6565
virtual bool allow_send_block(CatChainBlockHash hash) = 0;
6666

6767
static td::Result<std::unique_ptr<CatChainReceiverSource>> create(CatChainReceiver *chain, PublicKey pub_key,

catchain/catchain-receiver.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -697,12 +697,8 @@ void CatChainReceiverImpl::process_query(adnl::AdnlNodeIdShort src, ton_api::cat
697697
} else {
698698
CatChainReceiverSource *S = get_source_by_adnl_id(src);
699699
CHECK(S != nullptr);
700-
if (S->allow_send_block(it->second->get_hash())) {
701-
promise.set_value(serialize_tl_object(create_tl_object<ton_api::catchain_blockResult>(it->second->export_tl()),
702-
true, it->second->get_payload().as_slice()));
703-
} else {
704-
promise.set_error(td::Status::Error("block was requested too many times"));
705-
}
700+
promise.set_value(serialize_tl_object(create_tl_object<ton_api::catchain_blockResult>(it->second->export_tl()),
701+
true, it->second->get_payload().as_slice()));
706702
}
707703
}
708704

catchain/catchain.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class CatChain : public td::actor::Actor {
9696
virtual void send_query_via(const PublicKeyHash &dst, std::string name, td::Promise<td::BufferSlice> promise,
9797
td::Timestamp timeout, td::BufferSlice query, td::uint64 max_answer_size,
9898
td::actor::ActorId<adnl::AdnlSenderInterface> via) = 0;
99+
virtual void get_source_heights(td::Promise<std::vector<CatChainBlockHeight>> promise) = 0;
99100
virtual void destroy() = 0;
100101

101102
static td::actor::ActorOwn<CatChain> create(std::unique_ptr<Callback> callback, const CatChainOptions &opts,

catchain/catchain.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ class CatChainImpl : public CatChain {
115115
td::actor::send_closure(receiver_, &CatChainReceiverInterface::send_custom_query_data_via, dst, name,
116116
std::move(promise), timeout, std::move(query), max_answer_size, via);
117117
}
118+
void get_source_heights(td::Promise<std::vector<CatChainBlockHeight>> promise) override {
119+
std::vector<CatChainBlockHeight> heights(top_source_blocks_.size(), 0);
120+
for (size_t i = 0; i < top_source_blocks_.size(); ++i) {
121+
if (top_source_blocks_[i]) {
122+
heights[i] = top_source_blocks_[i]->height();
123+
}
124+
}
125+
promise.set_result(std::move(heights));
126+
}
118127
void destroy() override;
119128
CatChainImpl(std::unique_ptr<Callback> callback, const CatChainOptions &opts,
120129
td::actor::ActorId<keyring::Keyring> keyring, td::actor::ActorId<adnl::Adnl> adnl,

crypto/vm/bls.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,13 @@ bool aggregate_verify(const std::vector<std::pair<P1, td::BufferSlice>> &pubs_ms
9393
return false;
9494
}
9595
std::unique_ptr<blst::Pairing> pairing = std::make_unique<blst::Pairing>(true, DST);
96+
blst::P2_Affine p2_zero;
9697
for (const auto &p : pubs_msgs) {
9798
blst::P1_Affine p1(p.first.data(), P1_SIZE);
9899
if (!p1.in_group() || p1.is_inf()) {
99100
return false;
100101
}
101-
pairing->aggregate(&p1, nullptr, (const td::uint8 *)p.second.data(), p.second.size());
102+
pairing->aggregate(&p1, &p2_zero, (const td::uint8 *)p.second.data(), p.second.size());
102103
}
103104
pairing->commit();
104105
blst::P2_Affine p2(sig.data(), P2_SIZE);

0 commit comments

Comments
 (0)