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

updated vm

- updated func/fift
- additional checks in block validator
- docs
- tunnel prototype in ADNL
This commit is contained in:
ton 2020-03-11 14:19:31 +04:00
parent ba76f1404e
commit 54c7a4dcc3
50 changed files with 972 additions and 300 deletions

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP
Copyright 2017-2020 Telegram Systems LLP
*/
#pragma once
#include "interfaces/validator-manager.h"
@ -124,6 +124,7 @@ class Collator final : public td::actor::Actor {
Ref<vm::Cell> state_update; // Merkle update from prev_state_root to state_root
std::shared_ptr<vm::CellUsageTree> state_usage_tree_; // used to construct Merkle update
Ref<vm::CellSlice> new_config_params_;
Ref<vm::Cell> old_mparams_;
ton::LogicalTime prev_state_lt_;
ton::LogicalTime shards_max_end_lt_{0};
ton::UnixTime prev_state_utime_;

View file

@ -1457,6 +1457,7 @@ bool Collator::init_lt() {
}
bool Collator::fetch_config_params() {
old_mparams_ = config_->get_config_param(9);
{
auto res = config_->get_storage_prices();
if (res.is_error()) {
@ -2968,7 +2969,7 @@ bool Collator::create_mc_state_extra() {
auto cfg_smc_config = cfg_res.move_as_ok();
CHECK(cfg_smc_config.not_null());
vm::Dictionary cfg_dict{cfg_smc_config, 32};
if (!block::valid_config_data(cfg_smc_config, config_addr, true, true)) {
if (!block::valid_config_data(cfg_smc_config, config_addr, true, true, old_mparams_)) {
block::gen::t_Hashmap_32_Ref_Cell.print_ref(std::cerr, cfg_smc_config);
return fatal_error("configuration smart contract "s + config_addr.to_hex() +
" contains an invalid configuration in its data");
@ -3241,7 +3242,7 @@ bool Collator::try_fetch_new_config(const ton::StdSmcAddress& cfg_addr, Ref<vm::
return false;
}
auto cfg = cfg_res.move_as_ok();
if (!block::valid_config_data(cfg, cfg_addr, true)) {
if (!block::valid_config_data(cfg, cfg_addr, true, false, old_mparams_)) {
LOG(ERROR) << "new configuration smart contract " << cfg_addr.to_hex()
<< " contains a new configuration which is invalid, ignoring";
return false;

View file

@ -728,6 +728,7 @@ bool ValidateQuery::try_unpack_mc_state() {
// almost the same as in Collator
bool ValidateQuery::fetch_config_params() {
old_mparams_ = config_->get_config_param(9);
{
auto res = config_->get_storage_prices();
if (res.is_error()) {
@ -4804,7 +4805,7 @@ bool ValidateQuery::check_config_update(Ref<vm::CellSlice> old_conf_params, Ref<
Ref<vm::Cell> old_cfg_root, new_cfg_root;
CHECK(block::gen::t_ConfigParams.unpack_cons1(old_conf_params.write(), old_cfg_addr, old_cfg_root) &&
block::gen::t_ConfigParams.unpack_cons1(new_conf_params.write(), new_cfg_addr, new_cfg_root));
if (!block::valid_config_data(new_cfg_root, new_cfg_addr, true)) {
if (!block::valid_config_data(new_cfg_root, new_cfg_addr, true, false, old_mparams_)) {
return reject_query(
"new configuration parameters failed to pass per-parameter automated validity checks, or one of mandatory "
"configuration parameters is missing");
@ -4829,7 +4830,7 @@ bool ValidateQuery::check_config_update(Ref<vm::CellSlice> old_conf_params, Ref<
"the new configuration is different from that stored in the persistent data of the (new) configuration smart contract "s +
old_cfg_addr.to_hex());
}
if (!block::valid_config_data(ocfg_root, old_cfg_addr, true, true)) {
if (!block::valid_config_data(ocfg_root, old_cfg_addr, true, true, old_mparams_)) {
return reject_query("configuration extracted from (old) configuration smart contract "s + old_cfg_addr.to_hex() +
" failed to pass per-parameted validity checks, or one of mandatory parameters is missing");
}
@ -4883,7 +4884,7 @@ bool ValidateQuery::check_config_update(Ref<vm::CellSlice> old_conf_params, Ref<
return true;
}
auto wcfg_root = wcfg_res.move_as_ok();
if (!block::valid_config_data(wcfg_root, want_cfg_addr, true)) {
if (!block::valid_config_data(wcfg_root, want_cfg_addr, true, false, old_mparams_)) {
LOG(WARNING)
<< "switching of configuration smart contract did not happen because the configuration extracted from "
"suggested new configuration smart contract "

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP
Copyright 2017-2020 Telegram Systems LLP
*/
#pragma once
@ -169,6 +169,7 @@ class ValidateQuery : public td::actor::Actor {
std::unique_ptr<block::ShardConfig> new_shard_conf_; // from shard_hashes_ in mc blocks
Ref<block::WorkchainInfo> wc_info_;
std::unique_ptr<vm::AugmentedDictionary> fees_import_dict_;
Ref<vm::Cell> old_mparams_;
bool accept_msgs_{true};
ton::BlockSeqno min_shard_ref_mc_seqno_{~0U};