diff --git a/validator/impl/collator-impl.h b/validator/impl/collator-impl.h index 3572109d..9d73746b 100644 --- a/validator/impl/collator-impl.h +++ b/validator/impl/collator-impl.h @@ -224,7 +224,7 @@ class Collator final : public td::actor::Actor { std::unique_ptr block_candidate; - std::unique_ptr dispatch_queue_; + std::unique_ptr dispatch_queue_, old_dispatch_queue_; std::map sender_generated_messages_count_; unsigned dispatch_queue_ops_{0}; std::map last_dispatch_queue_emitted_lt_; diff --git a/validator/impl/collator.cpp b/validator/impl/collator.cpp index bc8e0ef5..e9e286c9 100644 --- a/validator/impl/collator.cpp +++ b/validator/impl/collator.cpp @@ -1215,6 +1215,7 @@ bool Collator::import_shard_state_data(block::ShardState& ss) { processed_upto_ = std::move(ss.processed_upto_); ihr_pending = std::move(ss.ihr_pending_); dispatch_queue_ = std::move(ss.dispatch_queue_); + old_dispatch_queue_ = std::make_unique(*dispatch_queue_); block_create_stats_ = std::move(ss.block_create_stats_); if (ss.out_msg_queue_size_) { have_out_msg_queue_size_in_state_ = true; @@ -5708,6 +5709,11 @@ Ref Collator::collate_shard_block_descr_set() { return cell; } +/** + * Visits certain cells in out msg queue and dispatch queue to add them to the proof + * + * @returns True on success, Falise if error occurred + */ bool Collator::prepare_msg_queue_proof() { auto res = old_out_msg_queue_->scan_diff( *out_msg_queue_, @@ -5732,7 +5738,32 @@ bool Collator::prepare_msg_queue_proof() { } return true; }, - 3); + 2); + if (!res) { + return false; + } + res = old_dispatch_queue_->scan_diff( + *dispatch_queue_, + [this](td::ConstBitPtr, int, Ref old_value, Ref new_value) { + if (old_value.not_null()) { + old_value = old_dispatch_queue_->extract_value(std::move(old_value)); + vm::Dictionary dispatch_dict{64}; + td::uint64 dispatch_dict_size; + CHECK(block::unpack_account_dispatch_queue(old_value, dispatch_dict, dispatch_dict_size)); + td::BitArray<64> max_lt; + CHECK(dispatch_dict.get_minmax_key(max_lt, true).not_null()); + } + if (new_value.not_null()) { + new_value = dispatch_queue_->extract_value(std::move(new_value)); + vm::Dictionary dispatch_dict{64}; + td::uint64 dispatch_dict_size; + CHECK(block::unpack_account_dispatch_queue(new_value, dispatch_dict, dispatch_dict_size)); + td::BitArray<64> min_lt; + CHECK(dispatch_dict.get_minmax_key(min_lt, false).not_null()); + } + return true; + }, + 2); return res; } diff --git a/validator/impl/validate-query.cpp b/validator/impl/validate-query.cpp index b38d2f37..2d1e95a5 100644 --- a/validator/impl/validate-query.cpp +++ b/validator/impl/validate-query.cpp @@ -2923,7 +2923,7 @@ bool ValidateQuery::precheck_account_updates() { CHECK(key_len == 256); return precheck_one_account_update(key, std::move(old_val_extra), std::move(new_val_extra)); }, - 3 /* check augmentation of changed nodes */)) { + 2 /* check augmentation of changed nodes in the new dict */)) { return reject_query("invalid ShardAccounts dictionary in the new state"); } } catch (vm::VmError& err) { @@ -3372,7 +3372,7 @@ bool ValidateQuery::precheck_message_queue_update() { CHECK(key_len == 352); return precheck_one_message_queue_update(key, std::move(old_val_extra), std::move(new_val_extra)); }, - 3 /* check augmentation of changed nodes */)) { + 2 /* check augmentation of changed nodes in the new dict */)) { return reject_query("invalid OutMsgQueue dictionary in the new state"); } } catch (vm::VmError& err) { @@ -3533,7 +3533,7 @@ bool ValidateQuery::unpack_dispatch_queue_update() { return check_account_dispatch_queue_update(key, ps_.dispatch_queue_->extract_value(std::move(old_val_extra)), ns_.dispatch_queue_->extract_value(std::move(new_val_extra))); }, - 3 /* check augmentation of changed nodes */); + 2 /* check augmentation of changed nodes in the new dict */); if (!res) { return reject_query("invalid DispatchQueue dictionary in the new state"); }