Skip to content

Commit

Permalink
Tonlib patch (ton-blockchain#966)
Browse files Browse the repository at this point in the history
* Bugfix in tonlib

* Fix calling actors in RunEmulator
* Fix checking proofs in blocks.getTransactions and blocks.getShards

* tonlib-cli: Fix printing special cells

---------

Co-authored-by: SpyCheese <[email protected]>
  • Loading branch information
EmelyanenkoK and SpyCheese authored Apr 15, 2024
1 parent 190aa6b commit 25f61df
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
24 changes: 17 additions & 7 deletions tonlib/tonlib/TonlibClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1891,7 +1891,9 @@ class RunEmulator : public TonlibQueryActor {
if (stopped_) {
return;
}
get_block_id([self = this](td::Result<FullBlockId>&& block_id) { self->set_block_id(std::move(block_id)); });
get_block_id([SelfId = actor_id(this)](td::Result<FullBlockId>&& block_id) {
td::actor::send_closure(SelfId, &RunEmulator::set_block_id, std::move(block_id));
});
}

void set_block_id(td::Result<FullBlockId>&& block_id) {
Expand All @@ -1900,8 +1902,12 @@ class RunEmulator : public TonlibQueryActor {
} else {
block_id_ = block_id.move_as_ok();

get_mc_state_root([self = this](td::Result<td::Ref<vm::Cell>>&& mc_state_root) { self->set_mc_state_root(std::move(mc_state_root)); });
get_account_state([self = this](td::Result<td::unique_ptr<AccountState>>&& state) { self->set_account_state(std::move(state)); });
get_mc_state_root([SelfId = actor_id(this)](td::Result<td::Ref<vm::Cell>>&& mc_state_root) {
td::actor::send_closure(SelfId, &RunEmulator::set_mc_state_root, std::move(mc_state_root));
});
get_account_state([SelfId = actor_id(this)](td::Result<td::unique_ptr<AccountState>>&& state) {
td::actor::send_closure(SelfId, &RunEmulator::set_account_state, std::move(state));
});
check(get_transactions(0));

inc();
Expand All @@ -1923,7 +1929,9 @@ class RunEmulator : public TonlibQueryActor {
} else {
account_state_ = account_state.move_as_ok();
send_query(int_api::ScanAndLoadGlobalLibs{account_state_->get_raw_state()},
[self = this](td::Result<vm::Dictionary> R) { self->set_global_libraries(std::move(R)); });
[SelfId = actor_id(this)](td::Result<vm::Dictionary> R) {
td::actor::send_closure(SelfId, &RunEmulator::set_global_libraries, std::move(R));
});
}
}

Expand Down Expand Up @@ -5521,7 +5529,7 @@ td::Status TonlibClient::do_request(const tonlib_api::blocks_getShards& request,
}

block::ShardConfig sh_conf;
if (!sh_conf.unpack(mc_extra.shard_hashes)) {
if (!sh_conf.unpack(data_csr)) {
return td::Status::Error("cannot extract shard block list from shard configuration");
}
auto ids = sh_conf.get_shard_hash_ids(true);
Expand All @@ -5544,7 +5552,9 @@ td::Status TonlibClient::do_request(const tonlib_api::blocks_getShards& request,
return td::Status::OK();
}

td::Status check_lookup_block_proof(lite_api_ptr<ton::lite_api::liteServer_lookupBlockResult>& result, int mode, ton::BlockId blkid, ton::BlockIdExt client_mc_blkid, td::uint64 lt, td::uint32 utime);
td::Status check_lookup_block_proof(lite_api_ptr<ton::lite_api::liteServer_lookupBlockResult>& result, int mode,
ton::BlockId blkid, ton::BlockIdExt client_mc_blkid, td::uint64 lt,
td::uint32 utime);

td::Status TonlibClient::do_request(const tonlib_api::blocks_lookupBlock& request,
td::Promise<object_ptr<tonlib_api::ton_blockIdExt>>&& promise) {
Expand Down Expand Up @@ -5730,7 +5740,7 @@ auto to_tonlib_api(const ton::lite_api::liteServer_transactionId& txid)

td::Status check_block_transactions_proof(lite_api_ptr<ton::lite_api::liteServer_blockTransactions>& bTxes, int32_t mode,
ton::LogicalTime start_lt, td::Bits256 start_addr, td::Bits256 root_hash, int req_count) {
if (mode & ton::lite_api::liteServer_listBlockTransactions::WANT_PROOF_MASK == 0) {
if ((mode & ton::lite_api::liteServer_listBlockTransactions::WANT_PROOF_MASK) == 0) {
return td::Status::OK();
}
constexpr int max_answer_transactions = 256;
Expand Down
3 changes: 2 additions & 1 deletion tonlib/tonlib/tonlib-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,8 @@ class TonlibCli : public td::actor::Actor {
if (r_cell.is_error()) {
sb << "<INVALID_CELL>";
}
auto cs = vm::load_cell_slice(r_cell.move_as_ok());
bool spec = true;
auto cs = vm::load_cell_slice_special(r_cell.move_as_ok(), spec);
std::stringstream ss;
cs.print_rec(ss);
sb << ss.str();
Expand Down

0 comments on commit 25f61df

Please sign in to comment.