Skip to content

Commit

Permalink
Add more required cells to the proof in collated data
Browse files Browse the repository at this point in the history
  • Loading branch information
SpyCheese committed Jan 7, 2025
1 parent 5ce9d0b commit e8e7883
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
2 changes: 1 addition & 1 deletion validator/impl/collator-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class Collator final : public td::actor::Actor {

std::unique_ptr<ton::BlockCandidate> block_candidate;

std::unique_ptr<vm::AugmentedDictionary> dispatch_queue_;
std::unique_ptr<vm::AugmentedDictionary> dispatch_queue_, old_dispatch_queue_;
std::map<StdSmcAddress, td::uint32> sender_generated_messages_count_;
unsigned dispatch_queue_ops_{0};
std::map<StdSmcAddress, LogicalTime> last_dispatch_queue_emitted_lt_;
Expand Down
33 changes: 32 additions & 1 deletion validator/impl/collator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<vm::AugmentedDictionary>(*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;
Expand Down Expand Up @@ -5708,6 +5709,11 @@ Ref<vm::Cell> 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_,
Expand All @@ -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<vm::CellSlice> old_value, Ref<vm::CellSlice> 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;
}

Expand Down
6 changes: 3 additions & 3 deletions validator/impl/validate-query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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");
}
Expand Down

0 comments on commit e8e7883

Please sign in to comment.