mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Change recursion to loop in CellSlice
This commit is contained in:
parent
5baf3276a4
commit
bb5bc6178c
3 changed files with 38 additions and 41 deletions
|
@ -327,8 +327,7 @@ bool Account::unpack(Ref<vm::CellSlice> shard_account, Ref<vm::CellSlice> extra,
|
|||
block::gen::t_ShardAccount.print(std::cerr, *shard_account);
|
||||
}
|
||||
block::gen::ShardAccount::Record acc_info;
|
||||
if (!(block::gen::t_ShardAccount.validate_csr(shard_account) &&
|
||||
block::tlb::t_ShardAccount.validate_csr(shard_account) && tlb::unpack_exact(shard_account.write(), acc_info))) {
|
||||
if (!(block::tlb::t_ShardAccount.validate_csr(shard_account) && tlb::unpack_exact(shard_account.write(), acc_info))) {
|
||||
LOG(ERROR) << "account " << addr.to_hex() << " state is invalid";
|
||||
return false;
|
||||
}
|
||||
|
@ -2013,7 +2012,6 @@ bool Transaction::compute_state() {
|
|||
std::cerr << "new account state: ";
|
||||
block::gen::t_Account.print_ref(std::cerr, new_total_state);
|
||||
}
|
||||
CHECK(block::gen::t_Account.validate_ref(new_total_state));
|
||||
CHECK(block::tlb::t_Account.validate_ref(new_total_state));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1055,7 +1055,8 @@ std::ostream& operator<<(std::ostream& os, Ref<CellSlice> cs_ref) {
|
|||
|
||||
// If can_be_special is not null, then it is allowed to load special cell
|
||||
// Flag whether loaded cell is actually special will be stored into can_be_special
|
||||
VirtualCell::LoadedCell load_cell_slice_impl(const Ref<Cell>& cell, bool* can_be_special) {
|
||||
VirtualCell::LoadedCell load_cell_slice_impl(Ref<Cell> cell, bool* can_be_special) {
|
||||
while (true) {
|
||||
auto* vm_state_interface = VmStateInterface::get();
|
||||
if (vm_state_interface) {
|
||||
vm_state_interface->register_cell_load(cell->get_hash());
|
||||
|
@ -1080,8 +1081,9 @@ VirtualCell::LoadedCell load_cell_slice_impl(const Ref<Cell>& cell, bool* can_be
|
|||
DCHECK(cs.size() == Cell::hash_bits + 8);
|
||||
auto library_cell = vm_state_interface->load_library(cs.data_bits() + 8);
|
||||
if (library_cell.not_null()) {
|
||||
//TODO: fix infinity loop
|
||||
return load_cell_slice_impl(library_cell, nullptr);
|
||||
cell = library_cell;
|
||||
can_be_special = nullptr;
|
||||
continue;
|
||||
}
|
||||
throw VmError{Excno::cell_und, "failed to load library cell"};
|
||||
}
|
||||
|
@ -1094,6 +1096,7 @@ VirtualCell::LoadedCell load_cell_slice_impl(const Ref<Cell>& cell, bool* can_be
|
|||
}
|
||||
return loaded_cell;
|
||||
}
|
||||
}
|
||||
|
||||
CellSlice load_cell_slice(const Ref<Cell>& cell) {
|
||||
return CellSlice{load_cell_slice_impl(cell, nullptr)};
|
||||
|
|
|
@ -2313,10 +2313,6 @@ bool ValidateQuery::precheck_one_account_update(td::ConstBitPtr acc_id, Ref<vm::
|
|||
"AccountBlock for this account");
|
||||
}
|
||||
if (new_value.not_null()) {
|
||||
if (!block::gen::t_ShardAccount.validate_csr(10000, new_value)) {
|
||||
return reject_query("new state of account "s + acc_id.to_hex(256) +
|
||||
" failed to pass automated validity checks for ShardAccount");
|
||||
}
|
||||
if (!block::tlb::t_ShardAccount.validate_csr(10000, new_value)) {
|
||||
return reject_query("new state of account "s + acc_id.to_hex(256) +
|
||||
" failed to pass hand-written validity checks for ShardAccount");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue