1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-02-12 11:12:16 +00:00

Fix prepare_vm_c7 (#958)

Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
EmelyanenkoK 2024-04-08 14:29:54 +03:00 committed by GitHub
parent b8111d8b5b
commit a2bd695b89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 12 deletions

View file

@ -1321,7 +1321,7 @@ Ref<vm::Tuple> Transaction::prepare_vm_c7(const ComputePhaseConfig& cfg) const {
vm::StackEntry::maybe(cfg.global_config) // global_config:(Maybe Cell) ] = SmartContractInfo;
};
if (cfg.global_version >= 4) {
tuple.push_back(new_code); // code:Cell
tuple.push_back(vm::StackEntry::maybe(new_code)); // code:Cell
if (msg_balance_remaining.is_valid()) {
tuple.push_back(msg_balance_remaining.as_vm_tuple()); // in_msg_value:[Integer (Maybe Cell)]
} else {
@ -1338,11 +1338,10 @@ Ref<vm::Tuple> Transaction::prepare_vm_c7(const ComputePhaseConfig& cfg) const {
// Inside validator, collator and liteserver checking external message contexts
// prev_blocks_info is always not null, since get_prev_blocks_info()
// may only return tuple or raise Error (See crypto/block/mc-config.cpp#2223)
tuple.push_back(cfg.prev_blocks_info.not_null() ? vm::StackEntry(cfg.prev_blocks_info) : vm::StackEntry());
tuple.push_back(vm::StackEntry::maybe(cfg.prev_blocks_info));
}
if (cfg.global_version >= 6) {
tuple.push_back(cfg.unpacked_config_tuple.not_null() ? vm::StackEntry(cfg.unpacked_config_tuple)
: vm::StackEntry()); // unpacked_config_tuple:[...]
tuple.push_back(vm::StackEntry::maybe(cfg.unpacked_config_tuple)); // unpacked_config_tuple:[...]
tuple.push_back(due_payment.not_null() ? due_payment : td::zero_refint()); // due_payment:Integer
tuple.push_back(compute_phase->precompiled_gas_usage
? vm::StackEntry(td::make_refint(compute_phase->precompiled_gas_usage.value()))

View file

@ -157,11 +157,11 @@ td::Ref<vm::Tuple> prepare_vm_c7(SmartContract::Args args, td::Ref<vm::Cell> cod
td::make_refint(0), //TODO: // trans_lt:Integer
std::move(rand_seed_int), // rand_seed:Integer
block::CurrencyCollection(args.balance).as_vm_tuple(), // balance_remaining:[Integer (Maybe Cell)]
vm::load_cell_slice_ref(address), // myself:MsgAddressInt
vm::StackEntry::maybe(config) //vm::StackEntry::maybe(td::Ref<vm::Cell>())
vm::load_cell_slice_ref(address), // myself:MsgAddressInt
vm::StackEntry::maybe(config) // vm::StackEntry::maybe(td::Ref<vm::Cell>())
};
if (args.config && args.config.value()->get_global_version() >= 4) {
tuple.push_back(code.not_null() ? code : vm::StackEntry{}); // code:Cell
tuple.push_back(vm::StackEntry::maybe(code)); // code:Cell
tuple.push_back(block::CurrencyCollection::zero().as_vm_tuple()); // in_msg_value:[Integer (Maybe Cell)]
tuple.push_back(td::zero_refint()); // storage_fees:Integer
@ -175,7 +175,10 @@ td::Ref<vm::Tuple> prepare_vm_c7(SmartContract::Args args, td::Ref<vm::Cell> cod
tuple.push_back(args.config.value()->get_unpacked_config_tuple(now)); // unpacked_config_tuple
tuple.push_back(td::zero_refint()); // due_payment
// precomiled_gas_usage:(Maybe Integer)
auto precompiled = args.config.value()->get_precompiled_contracts_config().get_contract(code->get_hash().bits());
td::optional<block::PrecompiledContractsConfig::Contract> precompiled;
if (code.not_null()) {
precompiled = args.config.value()->get_precompiled_contracts_config().get_contract(code->get_hash().bits());
}
tuple.push_back(precompiled ? td::make_refint(precompiled.value().gas_usage) : vm::StackEntry());
}
auto tuple_ref = td::make_cnt_ref<std::vector<vm::StackEntry>>(std::move(tuple));

View file

@ -1419,7 +1419,7 @@ static td::Ref<vm::Tuple> prepare_vm_c7(ton::UnixTime now, ton::LogicalTime lt,
config ? config->get_root_cell() : vm::StackEntry() // global_config:(Maybe Cell) ] = SmartContractInfo;
};
if (config && config->get_global_version() >= 4) {
tuple.push_back(my_code); // code:Cell
tuple.push_back(vm::StackEntry::maybe(my_code)); // code:Cell
tuple.push_back(block::CurrencyCollection::zero().as_vm_tuple()); // in_msg_value:[Integer (Maybe Cell)]
tuple.push_back(td::zero_refint()); // storage_fees:Integer
@ -1430,10 +1430,13 @@ static td::Ref<vm::Tuple> prepare_vm_c7(ton::UnixTime now, ton::LogicalTime lt,
tuple.push_back(info.is_ok() ? info.move_as_ok() : vm::StackEntry());
}
if (config && config->get_global_version() >= 6) {
tuple.push_back(config->get_unpacked_config_tuple(now)); // unpacked_config_tuple:[...]
tuple.push_back(due_payment); // due_payment:Integer
tuple.push_back(vm::StackEntry::maybe(config->get_unpacked_config_tuple(now))); // unpacked_config_tuple:[...]
tuple.push_back(due_payment); // due_payment:Integer
// precomiled_gas_usage:(Maybe Integer)
auto precompiled = config->get_precompiled_contracts_config().get_contract(my_code->get_hash().bits());
td::optional<block::PrecompiledContractsConfig::Contract> precompiled;
if (my_code.not_null()) {
precompiled = config->get_precompiled_contracts_config().get_contract(my_code->get_hash().bits());
}
tuple.push_back(precompiled ? td::make_refint(precompiled.value().gas_usage) : vm::StackEntry());
}
auto tuple_ref = td::make_cnt_ref<std::vector<vm::StackEntry>>(std::move(tuple));