Skip to content

Commit

Permalink
fullnode: added getCapabilities query
Browse files Browse the repository at this point in the history
  • Loading branch information
ton committed Sep 24, 2019
1 parent a1e352d commit 07b26e2
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crypto/smartcont/testgiver.fif
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dest_addr 2dup bounce 7 + .Addr ." = " .addr

// create a message (NB: 01b00.., b = bounce)
<b b{01} s, bounce 1 i, b{000100} s, dest_addr addr,
amount Gram, 0 9 64 32 + + 1+ 1+ u, "GIFT" $, b>
amount Gram, 0 9 64 32 + + 1+ 1+ u, 0 32 u, "GIFT" $, b>
<b seqno 32 u, 1 8 u, swap ref, b>
dup ."enveloping message: " <s csr. cr
<b b{1000100} s, giver_addr addr, 0 Gram, b{00} s,
Expand Down
4 changes: 2 additions & 2 deletions crypto/smartcont/wallet.fif
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
."Creates a request to simple wallet created by new-wallet.fif, with private key loaded from file <filename-base>.pk "
."and address from <filename-base>.addr, and saves it into <savefile>.boc ('wallet-query.boc' by default)" cr 1 halt
} : usage
$# dup 4 < swap 5 > or ' usage if
def? $6 { @' $5 "-B" $= { @' $6 =: body-boc-file [forget] $6 def? $7 { @' $7 =: $5 [forget] $7 } { [forget] $5 } cond
@' $# 2- =: $# } if } if
$# dup 4 < swap 5 > or ' usage if

true constant bounce

Expand All @@ -22,7 +22,7 @@ file-base +".addr" load-address
."Source wallet address = " 2dup .addr cr 6 .Addr cr
file-base +".pk" load-keypair nip constant wallet_pk

def? body-boc-file { @' body-boc-file file>B B>boc } { <b "TEST" $, b> } cond
def? body-boc-file { @' body-boc-file file>B B>boc } { <b 0 32 u, "TEST" $, b> } cond
constant body-cell

."Transferring " amount .GR ."to account "
Expand Down
2 changes: 1 addition & 1 deletion dht/dht-remote-node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class DhtRemoteNode {
DhtRemoteNode(DhtNode node, td::uint32 max_missed_pings)
: node_(std::move(node)), max_missed_pings_(max_missed_pings) {
failed_from_ = td::Time::now_cached();
id_ = node.get_key();
id_ = node_.get_key();
}
static td::Result<std::unique_ptr<DhtRemoteNode>> create(DhtNode node, td::uint32 max_missed_pings);
DhtNode get_node() const {
Expand Down
1 change: 0 additions & 1 deletion dht/dht-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class DhtKey {
}
DhtKey(PublicKeyHash id, DhtKeyName namestr, td::uint32 idx)
: id_(std::move(id)), namestr_(std::move(namestr)), idx_(idx) {
CHECK(namestr.size() <= max_name_length());
}
static td::Result<DhtKey> create(tl_object_ptr<ton_api::dht_key> key);
td::Status check() const;
Expand Down
8 changes: 7 additions & 1 deletion tl/generate/scheme/ton_api.tl
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ tonNode.dataList data:(vector bytes) = tonNode.DataList;
tonNode.dataFull id:tonNode.blockIdExt proof:bytes block:bytes is_link:Bool = tonNode.DataFull;
tonNode.dataFullEmpty = tonNode.DataFull;

tonNode.capabilities version:int capabilities:long = tonNode.Capabilities;

tonNode.success = tonNode.Success;

---functions---

tonNode.getNextBlockDescription prev_block:tonNode.blockIdExt = tonNode.BlockDescription;
Expand All @@ -382,7 +386,9 @@ tonNode.downloadBlockProofs blocks:(vector tonNode.blockIdExt) = tonNode.DataLis
tonNode.downloadBlockProofLink block:tonNode.blockIdExt = tonNode.Data;
tonNode.downloadBlockProofLinks blocks:(vector tonNode.blockIdExt) = tonNode.DataList;

tonNode.slave.sendExtMessage message:tonNode.externalMessage = True;
tonNode.getCapabilities = tonNode.Capabilities;

tonNode.slave.sendExtMessage message:tonNode.externalMessage = tonNode.Success;

tonNode.query = Object;

Expand Down
Binary file modified tl/generate/scheme/ton_api.tlo
Binary file not shown.
8 changes: 6 additions & 2 deletions validator-engine/validator-engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1679,11 +1679,15 @@ void ValidatorEngine::try_add_validator_temp_key(ton::PublicKeyHash perm_key, to
return;
}

td::MultiPromise mp;
auto ig = mp.init_guard();
ig.add_promise(std::move(promise));

if (!validator_manager_.empty()) {
td::actor::send_closure(validator_manager_, &ton::validator::ValidatorManagerInterface::add_temp_key, temp_key,
std::move(promise));
ig.get_promise());
}
write_config(std::move(promise));
write_config(ig.get_promise());
}

void ValidatorEngine::try_add_validator_adnl_addr(ton::PublicKeyHash perm_key, ton::PublicKeyHash adnl_id,
Expand Down
18 changes: 18 additions & 0 deletions validator/full-node-master.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

#include "common/delay.h"

#include "auto/tl/lite_api.h"
#include "tl-utils/lite-utils.hpp"

namespace ton {

namespace validator {
Expand Down Expand Up @@ -301,6 +304,21 @@ void FullNodeMasterImpl::process_query(adnl::AdnlNodeIdShort src, ton_api::tonNo
masterchain_block_id, query.offset_, query.max_size_, std::move(P));
}

void FullNodeMasterImpl::process_query(adnl::AdnlNodeIdShort src, ton_api::tonNode_getCapabilities &query,
td::Promise<td::BufferSlice> promise) {
promise.set_value(create_serialize_tl_object<ton_api::tonNode_capabilities>(proto_version(), proto_capabilities()));
}

void FullNodeMasterImpl::process_query(adnl::AdnlNodeIdShort src, ton_api::tonNode_slave_sendExtMessage &query,
td::Promise<td::BufferSlice> promise) {
td::actor::send_closure(
validator_manager_, &ValidatorManagerInterface::run_ext_query,
create_serialize_tl_object<lite_api::liteServer_query>(
create_serialize_tl_object<lite_api::liteServer_sendMessage>(std::move(query.message_->data_))),
[&](td::Result<td::BufferSlice>) {});
promise.set_value(create_serialize_tl_object<ton_api::tonNode_success>());
}

void FullNodeMasterImpl::receive_query(adnl::AdnlNodeIdShort src, td::BufferSlice query,
td::Promise<td::BufferSlice> promise) {
auto BX = fetch_tl_prefix<ton_api::tonNode_query>(query, true);
Expand Down
10 changes: 10 additions & 0 deletions validator/full-node-master.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ namespace fullnode {

class FullNodeMasterImpl : public FullNodeMaster {
public:
static constexpr td::uint32 proto_version() {
return 1;
}
static constexpr td::uint64 proto_capabilities() {
return 0;
}
void start_up() override;

template <class T>
Expand Down Expand Up @@ -62,6 +68,10 @@ class FullNodeMasterImpl : public FullNodeMaster {
td::Promise<td::BufferSlice> promise);
void process_query(adnl::AdnlNodeIdShort src, ton_api::tonNode_downloadPersistentStateSlice &query,
td::Promise<td::BufferSlice> promise);
void process_query(adnl::AdnlNodeIdShort src, ton_api::tonNode_getCapabilities &query,
td::Promise<td::BufferSlice> promise);
void process_query(adnl::AdnlNodeIdShort src, ton_api::tonNode_slave_sendExtMessage &query,
td::Promise<td::BufferSlice> promise);
// void process_query(adnl::AdnlNodeIdShort src, ton_api::tonNode_prepareNextKeyBlockProof &query,
// td::Promise<td::BufferSlice> promise);
void receive_query(adnl::AdnlNodeIdShort src, td::BufferSlice query, td::Promise<td::BufferSlice> promise);
Expand Down
5 changes: 5 additions & 0 deletions validator/full-node-shard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,11 @@ void FullNodeShardImpl::process_query(adnl::AdnlNodeIdShort src, ton_api::tonNod
masterchain_block_id, query.offset_, query.max_size_, std::move(P));
}

void FullNodeShardImpl::process_query(adnl::AdnlNodeIdShort src, ton_api::tonNode_getCapabilities &query,
td::Promise<td::BufferSlice> promise) {
promise.set_value(create_serialize_tl_object<ton_api::tonNode_capabilities>(proto_version(), proto_capabilities()));
}

void FullNodeShardImpl::receive_query(adnl::AdnlNodeIdShort src, td::BufferSlice query,
td::Promise<td::BufferSlice> promise) {
auto B = fetch_tl_object<ton_api::Function>(std::move(query), true);
Expand Down
8 changes: 8 additions & 0 deletions validator/full-node-shard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ class FullNodeShardImpl : public FullNodeShard {
static constexpr td::uint32 download_next_priority() {
return 1;
}
static constexpr td::uint32 proto_version() {
return 1;
}
static constexpr td::uint64 proto_capabilities() {
return 0;
}

void create_overlay();
void update_adnl_id(adnl::AdnlNodeIdShort adnl_id, td::Promise<td::Unit> promise) override;
Expand Down Expand Up @@ -84,6 +90,8 @@ class FullNodeShardImpl : public FullNodeShard {
td::Promise<td::BufferSlice> promise);
void process_query(adnl::AdnlNodeIdShort src, ton_api::tonNode_downloadPersistentStateSlice &query,
td::Promise<td::BufferSlice> promise);
void process_query(adnl::AdnlNodeIdShort src, ton_api::tonNode_getCapabilities &query,
td::Promise<td::BufferSlice> promise);
// void process_query(adnl::AdnlNodeIdShort src, ton_api::tonNode_prepareNextKeyBlockProof &query,
// td::Promise<td::BufferSlice> promise);
void receive_query(adnl::AdnlNodeIdShort src, td::BufferSlice query, td::Promise<td::BufferSlice> promise);
Expand Down

0 comments on commit 07b26e2

Please sign in to comment.