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

Increase limit for t_Block.validate, simplify validating StateInit (#691)

Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
EmelyanenkoK 2023-05-03 14:18:18 +03:00 committed by GitHub
parent 24ed85b155
commit a78adf3062
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 63 additions and 10 deletions

View file

@ -635,14 +635,15 @@ bool Transaction::unpack_input_msg(bool ihr_delivered, const ActionPhaseConfig*
vm::CellBuilder cb;
if (!(cs.advance(2) && block::gen::t_StateInit.fetch_to(cs, state_init) &&
cb.append_cellslice_bool(std::move(state_init)) && cb.finalize_to(in_msg_state) &&
block::gen::t_StateInit.validate_ref(in_msg_state))) {
block::gen::t_StateInitWithLibs.validate_ref(in_msg_state))) {
LOG(DEBUG) << "cannot parse StateInit in inbound message";
return false;
}
break;
}
case 3: { // (just$1 (right$1 _:^StateInit ))
if (!(cs.advance(2) && cs.fetch_ref_to(in_msg_state) && block::gen::t_StateInit.validate_ref(in_msg_state))) {
if (!(cs.advance(2) && cs.fetch_ref_to(in_msg_state) &&
block::gen::t_StateInitWithLibs.validate_ref(in_msg_state))) {
LOG(DEBUG) << "cannot parse ^StateInit in inbound message";
return false;
}
@ -1534,6 +1535,10 @@ int Transaction::try_action_send_msg(const vm::CellSlice& cs0, ActionPhase& ap,
if (!tlb::type_unpack_cell(act_rec.out_msg, block::gen::t_MessageRelaxed_Any, msg)) {
return -1;
}
if (!block::tlb::validate_message_relaxed_libs(act_rec.out_msg)) {
LOG(DEBUG) << "outbound message has invalid libs in StateInit";
return -1;
}
if (redoing >= 1) {
if (msg.init->size_refs() >= 2) {
LOG(DEBUG) << "moving the StateInit of a suggested outbound message into a separate cell";