@@ -528,11 +528,11 @@ void OutMsgQueueImporter::alarm() {
528528 td::remove_if (it->second .pending_entries ,
529529 [](const std::shared_ptr<CacheEntry>& entry) { return entry->done || entry->promises .empty (); });
530530 if (it->second .timeout .is_in_past ()) {
531- if (it->second .pending_entries .empty ()) {
532- it = small_cache_.erase (it);
533- } else {
534- ++it;
535- }
531+ if (it->second .pending_entries .empty ()) {
532+ it = small_cache_.erase (it);
533+ } else {
534+ ++it;
535+ }
536536 } else {
537537 alarm_timestamp ().relax (it->second .timeout );
538538 ++it;
@@ -571,6 +571,33 @@ void BuildOutMsgQueueProof::abort_query(td::Status reason) {
571571}
572572
573573void BuildOutMsgQueueProof::start_up () {
574+ if (blocks_.size () > 16 ) {
575+ abort_query (td::Status::Error (" too many blocks" ));
576+ return ;
577+ }
578+ td::actor::send_closure (manager_, &ValidatorManagerInterface::get_top_masterchain_state,
579+ [SelfId = actor_id (this )](td::Result<Ref<MasterchainState>> R) {
580+ if (R.is_error ()) {
581+ td::actor::send_closure (SelfId, &BuildOutMsgQueueProof::abort_query,
582+ R.move_as_error_prefix (" failed to get masterchain state: " ));
583+ } else {
584+ td::actor::send_closure (SelfId, &BuildOutMsgQueueProof::got_masterchain_state,
585+ R.move_as_ok ());
586+ }
587+ });
588+ }
589+
590+ void BuildOutMsgQueueProof::got_masterchain_state (Ref<MasterchainState> mc_state) {
591+ auto config_limits = mc_state->get_imported_msg_queue_limits (dst_shard_.is_masterchain ());
592+ if ((td::uint64)config_limits.max_msgs * blocks_.size () < limits_.max_msgs ) {
593+ abort_query (td::Status::Error (" too big max_msgs" ));
594+ return ;
595+ }
596+ if ((td::uint64)config_limits.max_bytes * blocks_.size () < limits_.max_bytes ) {
597+ abort_query (td::Status::Error (" too big max_bytes" ));
598+ return ;
599+ }
600+
574601 for (size_t i = 0 ; i < blocks_.size (); ++i) {
575602 BlockIdExt id = blocks_[i].id ;
576603 ++pending;
0 commit comments