mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
updated vm (breaking compatibility)
- updated vm - new actor scheduler - updated tonlib - updated DNS smartcontract
This commit is contained in:
parent
9e4816e7f6
commit
e27fb1e09c
100 changed files with 3692 additions and 1299 deletions
|
@ -150,7 +150,7 @@ bool Account::unpack_storage_info(vm::CellSlice& cs) {
|
|||
return false;
|
||||
}
|
||||
} else {
|
||||
due_payment = td::RefInt256{true, 0};
|
||||
due_payment = td::zero_refint();
|
||||
}
|
||||
unsigned long long u = 0;
|
||||
u |= storage_stat.cells = block::tlb::t_VarUInteger_7.as_uint(*used.cells);
|
||||
|
@ -369,7 +369,7 @@ bool Account::init_new(ton::UnixTime now) {
|
|||
now_ = now;
|
||||
last_paid = 0;
|
||||
storage_stat.clear();
|
||||
due_payment = td::RefInt256{true, 0};
|
||||
due_payment = td::zero_refint();
|
||||
balance.set_zero();
|
||||
if (my_addr_exact.is_null()) {
|
||||
vm::CellBuilder cb;
|
||||
|
@ -473,6 +473,9 @@ Transaction::Transaction(const Account& _account, int ttype, ton::LogicalTime re
|
|||
start_lt = std::max(req_start_lt, account.last_trans_end_lt_);
|
||||
end_lt = start_lt + 1;
|
||||
acc_status = (account.status == Account::acc_nonexist ? Account::acc_uninit : account.status);
|
||||
if (acc_status == Account::acc_frozen) {
|
||||
frozen_hash = account.state_hash;
|
||||
}
|
||||
}
|
||||
|
||||
bool Transaction::unpack_input_msg(bool ihr_delivered, const ActionPhaseConfig* cfg) {
|
||||
|
@ -504,7 +507,7 @@ bool Transaction::unpack_input_msg(bool ihr_delivered, const ActionPhaseConfig*
|
|||
if (ihr_delivered) {
|
||||
in_fwd_fee = std::move(ihr_fee);
|
||||
} else {
|
||||
in_fwd_fee = td::RefInt256{true, 0};
|
||||
in_fwd_fee = td::zero_refint();
|
||||
msg_balance_remaining += std::move(ihr_fee);
|
||||
}
|
||||
if (info.created_lt >= start_lt) {
|
||||
|
@ -544,7 +547,7 @@ bool Transaction::unpack_input_msg(bool ihr_delivered, const ActionPhaseConfig*
|
|||
LOG(DEBUG) << "computed fwd fees set to zero for special account";
|
||||
fees_c.first = fees_c.second = 0;
|
||||
}
|
||||
in_fwd_fee = td::RefInt256{true, fees_c.first};
|
||||
in_fwd_fee = td::make_refint(fees_c.first);
|
||||
if (balance.grams < in_fwd_fee) {
|
||||
LOG(DEBUG) << "cannot pay for importing this external message";
|
||||
return false;
|
||||
|
@ -616,19 +619,19 @@ bool Transaction::prepare_storage_phase(const StoragePhaseConfig& cfg, bool forc
|
|||
res->is_special = account.is_special;
|
||||
last_paid = res->last_paid_updated = (res->is_special ? 0 : now);
|
||||
if (to_pay.is_null() || sgn(to_pay) == 0) {
|
||||
res->fees_collected = res->fees_due = td::RefInt256{true, 0};
|
||||
res->fees_collected = res->fees_due = td::zero_refint();
|
||||
} else if (to_pay <= balance.grams) {
|
||||
res->fees_collected = to_pay;
|
||||
res->fees_due = td::RefInt256{true, 0};
|
||||
res->fees_due = td::zero_refint();
|
||||
balance -= std::move(to_pay);
|
||||
} else if (acc_status == Account::acc_frozen && !force_collect && to_pay + due_payment < cfg.delete_due_limit) {
|
||||
// do not collect fee
|
||||
res->last_paid_updated = (res->is_special ? 0 : account.last_paid);
|
||||
res->fees_collected = res->fees_due = td::RefInt256{true, 0};
|
||||
res->fees_collected = res->fees_due = td::zero_refint();
|
||||
} else {
|
||||
res->fees_collected = balance.grams;
|
||||
res->fees_due = std::move(to_pay) - std::move(balance.grams);
|
||||
balance.grams = td::RefInt256{true, 0};
|
||||
balance.grams = td::zero_refint();
|
||||
if (!res->is_special) {
|
||||
auto total_due = res->fees_due + due_payment;
|
||||
switch (acc_status) {
|
||||
|
@ -707,8 +710,8 @@ bool ComputePhaseConfig::parse_GasLimitsPrices_internal(Ref<vm::CellSlice> cs, t
|
|||
special_gas_limit = spec_limit;
|
||||
gas_credit = r.gas_credit;
|
||||
gas_price = r.gas_price;
|
||||
freeze_due_limit = td::RefInt256{true, r.freeze_due_limit};
|
||||
delete_due_limit = td::RefInt256{true, r.delete_due_limit};
|
||||
freeze_due_limit = td::make_refint(r.freeze_due_limit);
|
||||
delete_due_limit = td::make_refint(r.delete_due_limit);
|
||||
};
|
||||
block::gen::GasLimitsPrices::Record_gas_prices_ext rec;
|
||||
if (tlb::csr_unpack(cs, rec)) {
|
||||
|
@ -728,10 +731,10 @@ bool ComputePhaseConfig::parse_GasLimitsPrices_internal(Ref<vm::CellSlice> cs, t
|
|||
}
|
||||
|
||||
void ComputePhaseConfig::compute_threshold() {
|
||||
gas_price256 = td::RefInt256{true, gas_price};
|
||||
gas_price256 = td::make_refint(gas_price);
|
||||
if (gas_limit > flat_gas_limit) {
|
||||
max_gas_threshold =
|
||||
td::rshift(gas_price256 * (gas_limit - flat_gas_limit), 16, 1) + td::make_refint(flat_gas_price);
|
||||
td::rshift(gas_price256 * (gas_limit - flat_gas_limit), 16, 1) + td::make_bigint(flat_gas_price);
|
||||
} else {
|
||||
max_gas_threshold = td::make_refint(flat_gas_price);
|
||||
}
|
||||
|
@ -828,8 +831,8 @@ Ref<vm::Tuple> Transaction::prepare_vm_c7(const ComputePhaseConfig& cfg) const {
|
|||
}
|
||||
auto tuple = vm::make_tuple_ref(
|
||||
td::make_refint(0x076ef1ea), // [ magic:0x076ef1ea
|
||||
td::make_refint(0), // actions:Integer
|
||||
td::make_refint(0), // msgs_sent:Integer
|
||||
td::zero_refint(), // actions:Integer
|
||||
td::zero_refint(), // msgs_sent:Integer
|
||||
td::make_refint(now), // unixtime:Integer
|
||||
td::make_refint(account.block_lt), // block_lt:Integer
|
||||
td::make_refint(start_lt), // trans_lt:Integer
|
||||
|
@ -1012,7 +1015,7 @@ bool Transaction::prepare_compute_phase(const ComputePhaseConfig& cfg) {
|
|||
}
|
||||
if (cp.accepted) {
|
||||
if (account.is_special) {
|
||||
cp.gas_fees = td::RefInt256{true, 0};
|
||||
cp.gas_fees = td::zero_refint();
|
||||
} else {
|
||||
cp.gas_fees = cfg.compute_gas_price(cp.gas_used);
|
||||
total_fees += cp.gas_fees;
|
||||
|
@ -1040,8 +1043,8 @@ bool Transaction::prepare_action_phase(const ActionPhaseConfig& cfg) {
|
|||
ap.action_list_hash = list->get_hash().bits();
|
||||
ap.remaining_balance = balance;
|
||||
ap.end_lt = end_lt;
|
||||
ap.total_fwd_fees = td::RefInt256{true, 0};
|
||||
ap.total_action_fees = td::RefInt256{true, 0};
|
||||
ap.total_fwd_fees = td::zero_refint();
|
||||
ap.total_action_fees = td::zero_refint();
|
||||
ap.reserved_balance.set_zero();
|
||||
|
||||
int n = 0;
|
||||
|
@ -1429,7 +1432,7 @@ int Transaction::try_action_send_msg(const vm::CellSlice& cs0, ActionPhase& ap,
|
|||
info.ihr_disabled = true;
|
||||
info.bounce = false;
|
||||
info.bounced = false;
|
||||
fwd_fee = ihr_fee = td::RefInt256{true, 0};
|
||||
fwd_fee = ihr_fee = td::zero_refint();
|
||||
} else {
|
||||
// int_msg_info$0 constructor
|
||||
if (!tlb::csr_unpack(msg.info, info) || !block::tlb::t_CurrencyCollection.validate_csr(info.value)) {
|
||||
|
@ -1482,10 +1485,10 @@ int Transaction::try_action_send_msg(const vm::CellSlice& cs0, ActionPhase& ap,
|
|||
|
||||
// set fees to computed values
|
||||
if (fwd_fee->unsigned_fits_bits(63) && fwd_fee->to_long() < (long long)fees_c.first) {
|
||||
fwd_fee = td::RefInt256{true, fees_c.first};
|
||||
fwd_fee = td::make_refint(fees_c.first);
|
||||
}
|
||||
if (fees_c.second && ihr_fee->unsigned_fits_bits(63) && ihr_fee->to_long() < (long long)fees_c.second) {
|
||||
ihr_fee = td::RefInt256{true, fees_c.second};
|
||||
ihr_fee = td::make_refint(fees_c.second);
|
||||
}
|
||||
|
||||
Ref<vm::Cell> new_msg;
|
||||
|
@ -1502,7 +1505,7 @@ int Transaction::try_action_send_msg(const vm::CellSlice& cs0, ActionPhase& ap,
|
|||
}
|
||||
if (info.ihr_disabled) {
|
||||
// if IHR is disabled, IHR fees will be always zero
|
||||
ihr_fee = td::RefInt256{true, 0};
|
||||
ihr_fee = td::zero_refint();
|
||||
}
|
||||
// extract value to be carried by the message
|
||||
block::CurrencyCollection req;
|
||||
|
@ -1757,10 +1760,10 @@ bool Transaction::prepare_bounce_phase(const ActionPhaseConfig& cfg) {
|
|||
balance -= msg_balance;
|
||||
CHECK(balance.is_valid());
|
||||
// debit total forwarding fees from the message's balance, then split forwarding fees into our part and remaining part
|
||||
msg_balance -= td::RefInt256{true, bp.fwd_fees};
|
||||
msg_balance -= td::make_refint(bp.fwd_fees);
|
||||
bp.fwd_fees_collected = msg_prices.get_first_part(bp.fwd_fees);
|
||||
bp.fwd_fees -= bp.fwd_fees_collected;
|
||||
total_fees += td::RefInt256{true, bp.fwd_fees_collected};
|
||||
total_fees += td::make_refint(bp.fwd_fees_collected);
|
||||
// serialize outbound message
|
||||
info.created_lt = end_lt++;
|
||||
info.created_at = now;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue