1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

Fix returning config from LS, add extra c7 elements in getmethods (#713)

Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
EmelyanenkoK 2023-05-27 21:22:31 +03:00 committed by GitHub
parent 049ed0c737
commit 6b941dcceb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 111 additions and 32 deletions

View file

@ -62,7 +62,8 @@ void LastConfig::with_last_block(td::Result<LastBlockState> r_last_block) {
}
auto last_block = r_last_block.move_as_ok();
client_.send_query(ton::lite_api::liteServer_getConfigAll(0, create_tl_lite_block_id(last_block.last_block_id)),
client_.send_query(ton::lite_api::liteServer_getConfigAll(block::ConfigInfo::needPrevBlocks,
create_tl_lite_block_id(last_block.last_block_id)),
[this](auto r_config) { this->on_config(std::move(r_config)); });
}
@ -92,7 +93,7 @@ td::Status LastConfig::process_config_proof(ton::ton_api::object_ptr<ton::lite_a
}
TRY_RESULT(state, block::check_extract_state_proof(blkid, raw_config->state_proof_.as_slice(),
raw_config->config_proof_.as_slice()));
TRY_RESULT(config, block::Config::extract_from_state(std::move(state), 0));
TRY_RESULT(config, block::ConfigInfo::extract_config(std::move(state), block::ConfigInfo::needPrevBlocks));
for (auto i : params_) {
VLOG(last_config) << "ConfigParam(" << i << ") = ";
@ -109,6 +110,7 @@ td::Status LastConfig::process_config_proof(ton::ton_api::object_ptr<ton::lite_a
VLOG(last_config) << os.str();
}
}
TRY_RESULT_ASSIGN(state_.prev_blocks_info, config->get_prev_blocks_info());
state_.config.reset(config.release());
return td::Status::OK();
}

View file

@ -30,6 +30,7 @@
namespace tonlib {
struct LastConfigState {
std::shared_ptr<const block::Config> config;
td::Ref<vm::Tuple> prev_blocks_info;
};
td::StringBuilder& operator<<(td::StringBuilder& sb, const LastConfigState& state);

View file

@ -890,8 +890,10 @@ class Query {
}
return res;
}
td::Result<std::pair<Fee, std::vector<Fee>>> estimate_fees(bool ignore_chksig, std::shared_ptr<const block::Config>& cfg, vm::Dictionary& libraries) {
td::Result<std::pair<Fee, std::vector<Fee>>> estimate_fees(bool ignore_chksig, const LastConfigState& state,
vm::Dictionary& libraries) {
// gas fees
const auto& cfg = state.config;
bool is_masterchain = raw_.source->get_address().workchain == ton::masterchainId;
TRY_RESULT(gas_limits_prices, cfg->get_gas_limits_prices(is_masterchain));
TRY_RESULT(storage_prices, cfg->get_storage_prices());
@ -919,7 +921,9 @@ class Query {
.set_now(raw_.source->get_sync_time())
.set_ignore_chksig(ignore_chksig)
.set_address(raw_.source->get_address())
.set_config(cfg).set_libraries(libraries));
.set_config(cfg)
.set_prev_blocks_info(state.prev_blocks_info)
.set_libraries(libraries));
td::int64 fwd_fee = 0;
if (res.success) {
LOG(DEBUG) << "output actions:\n"
@ -4109,7 +4113,7 @@ void TonlibClient::query_estimate_fees(td::int64 id, bool ignore_chksig, td::Res
return;
}
TRY_RESULT_PROMISE(promise, state, std::move(r_state));
TRY_RESULT_PROMISE_PREFIX(promise, fees, TRY_VM(it->second->estimate_fees(ignore_chksig, state.config, libraries)),
TRY_RESULT_PROMISE_PREFIX(promise, fees, TRY_VM(it->second->estimate_fees(ignore_chksig, state, libraries)),
TonlibError::Internal());
promise.set_value(tonlib_api::make_object<tonlib_api::query_fees>(
fees.first.to_tonlib_api(), td::transform(fees.second, [](auto& x) { return x.to_tonlib_api(); })));
@ -4474,6 +4478,7 @@ td::Status TonlibClient::do_request(const tonlib_api::smc_runGetMethod& request,
](td::Result<LastConfigState> r_state) mutable {
TRY_RESULT_PROMISE(promise, state, std::move(r_state));
args.set_config(state.config);
args.set_prev_blocks_info(state.prev_blocks_info);
auto code = smc->get_state().code;
if (code.not_null()) {