mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
GETEXTRABALANCE instruction, changes in reserve
This commit is contained in:
parent
cf50b4b5da
commit
2b182186de
7 changed files with 143 additions and 14 deletions
|
@ -103,6 +103,8 @@ class VmState final : public VmStateInterface {
|
|||
td::uint16 max_data_depth = 512; // Default value
|
||||
int global_version{0};
|
||||
size_t chksgn_counter = 0;
|
||||
size_t get_extra_balance_counter = 0;
|
||||
long long free_gas_consumed = 0;
|
||||
std::unique_ptr<ParentVmState> parent = nullptr;
|
||||
|
||||
public:
|
||||
|
@ -161,7 +163,10 @@ class VmState final : public VmStateInterface {
|
|||
bls_g2_multiexp_coef2_gas_price = 22840,
|
||||
|
||||
bls_pairing_base_gas_price = 20000,
|
||||
bls_pairing_element_gas_price = 11800
|
||||
bls_pairing_element_gas_price = 11800,
|
||||
|
||||
get_extra_balance_cheap_count = 5,
|
||||
get_extra_balance_cheap_max_gas_price = 200
|
||||
};
|
||||
VmState();
|
||||
VmState(Ref<CellSlice> _code, int global_version, Ref<Stack> _stack, const GasLimits& _gas, int flags = 0, Ref<Cell> _data = {},
|
||||
|
@ -214,6 +219,9 @@ class VmState final : public VmStateInterface {
|
|||
consume_stack_gas((unsigned)stk->depth());
|
||||
}
|
||||
}
|
||||
void consume_free_gas(long long amount) {
|
||||
free_gas_consumed += amount;
|
||||
}
|
||||
GasLimits get_gas_limits() const {
|
||||
return gas;
|
||||
}
|
||||
|
@ -226,6 +234,7 @@ class VmState final : public VmStateInterface {
|
|||
Ref<Cell> load_library(
|
||||
td::ConstBitPtr hash) override; // may throw a dictionary exception; returns nullptr if library is not found
|
||||
void register_cell_load(const CellHash& cell_hash) override;
|
||||
bool register_cell_load_free(const CellHash& cell_hash);
|
||||
void register_cell_create() override;
|
||||
bool init_cp(int new_cp);
|
||||
bool set_cp(int new_cp);
|
||||
|
@ -420,9 +429,15 @@ class VmState final : public VmStateInterface {
|
|||
++chksgn_counter;
|
||||
if (chksgn_counter > chksgn_free_count) {
|
||||
consume_gas(chksgn_gas_price);
|
||||
} else {
|
||||
consume_free_gas(chksgn_gas_price);
|
||||
}
|
||||
}
|
||||
}
|
||||
bool register_get_extra_balance_call() {
|
||||
++get_extra_balance_counter;
|
||||
return get_extra_balance_counter <= get_extra_balance_cheap_count;
|
||||
}
|
||||
|
||||
private:
|
||||
void init_cregs(bool same_c3 = false, bool push_0 = true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue