mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
New extra currency behavior (#1539)
This commit is contained in:
parent
1b70e48327
commit
b3b2bd1c3c
17 changed files with 228 additions and 65 deletions
|
@ -109,14 +109,11 @@ class Collator final : public td::actor::Actor {
|
|||
return 2;
|
||||
}
|
||||
|
||||
static td::Result<std::unique_ptr<block::transaction::Transaction>>
|
||||
impl_create_ordinary_transaction(Ref<vm::Cell> msg_root,
|
||||
block::Account* acc,
|
||||
UnixTime utime, LogicalTime lt,
|
||||
block::StoragePhaseConfig* storage_phase_cfg,
|
||||
block::ComputePhaseConfig* compute_phase_cfg,
|
||||
block::ActionPhaseConfig* action_phase_cfg,
|
||||
bool external, LogicalTime after_lt);
|
||||
static td::Result<std::unique_ptr<block::transaction::Transaction>> impl_create_ordinary_transaction(
|
||||
Ref<vm::Cell> msg_root, block::Account* acc, UnixTime utime, LogicalTime lt,
|
||||
block::StoragePhaseConfig* storage_phase_cfg, block::ComputePhaseConfig* compute_phase_cfg,
|
||||
block::ActionPhaseConfig* action_phase_cfg, block::SerializeConfig* serialize_cfg, bool external,
|
||||
LogicalTime after_lt);
|
||||
|
||||
private:
|
||||
void start_up() override;
|
||||
|
@ -177,6 +174,7 @@ class Collator final : public td::actor::Actor {
|
|||
block::StoragePhaseConfig storage_phase_cfg_{&storage_prices_};
|
||||
block::ComputePhaseConfig compute_phase_cfg_;
|
||||
block::ActionPhaseConfig action_phase_cfg_;
|
||||
block::SerializeConfig serialize_cfg_;
|
||||
td::RefInt256 masterchain_create_fee_, basechain_create_fee_;
|
||||
std::unique_ptr<block::BlockLimits> block_limits_;
|
||||
std::unique_ptr<block::BlockLimitStatus> block_limit_status_;
|
||||
|
|
|
@ -1995,12 +1995,9 @@ bool Collator::init_lt() {
|
|||
* @returns True if the configuration parameters were successfully fetched and initialized, false otherwise.
|
||||
*/
|
||||
bool Collator::fetch_config_params() {
|
||||
auto res = block::FetchConfigParams::fetch_config_params(*config_,
|
||||
&old_mparams_, &storage_prices_, &storage_phase_cfg_,
|
||||
&rand_seed_, &compute_phase_cfg_, &action_phase_cfg_,
|
||||
&masterchain_create_fee_, &basechain_create_fee_,
|
||||
workchain(), now_
|
||||
);
|
||||
auto res = block::FetchConfigParams::fetch_config_params(
|
||||
*config_, &old_mparams_, &storage_prices_, &storage_phase_cfg_, &rand_seed_, &compute_phase_cfg_,
|
||||
&action_phase_cfg_, &serialize_cfg_, &masterchain_create_fee_, &basechain_create_fee_, workchain(), now_);
|
||||
if (res.is_error()) {
|
||||
return fatal_error(res.move_as_error());
|
||||
}
|
||||
|
@ -2750,7 +2747,7 @@ bool Collator::create_ticktock_transaction(const ton::StdSmcAddress& smc_addr, t
|
|||
return fatal_error(td::Status::Error(
|
||||
-666, std::string{"cannot create action phase of a new transaction for smart contract "} + smc_addr.to_hex()));
|
||||
}
|
||||
if (!trans->serialize()) {
|
||||
if (!trans->serialize(serialize_cfg_)) {
|
||||
return fatal_error(td::Status::Error(
|
||||
-666, std::string{"cannot serialize new transaction for smart contract "} + smc_addr.to_hex()));
|
||||
}
|
||||
|
@ -2834,7 +2831,7 @@ Ref<vm::Cell> Collator::create_ordinary_transaction(Ref<vm::Cell> msg_root,
|
|||
after_lt = std::max(after_lt, it->second);
|
||||
}
|
||||
auto res = impl_create_ordinary_transaction(msg_root, acc, now_, start_lt, &storage_phase_cfg_, &compute_phase_cfg_,
|
||||
&action_phase_cfg_, external, after_lt);
|
||||
&action_phase_cfg_, &serialize_cfg_, external, after_lt);
|
||||
if (res.is_error()) {
|
||||
auto error = res.move_as_error();
|
||||
if (error.code() == -701) {
|
||||
|
@ -2885,6 +2882,7 @@ Ref<vm::Cell> Collator::create_ordinary_transaction(Ref<vm::Cell> msg_root,
|
|||
* @param storage_phase_cfg The configuration for the storage phase of the transaction.
|
||||
* @param compute_phase_cfg The configuration for the compute phase of the transaction.
|
||||
* @param action_phase_cfg The configuration for the action phase of the transaction.
|
||||
* @param serialize_cfg The configuration for the serialization of the transaction.
|
||||
* @param external Flag indicating if the message is external.
|
||||
* @param after_lt The logical time after which the transaction should occur. Used only for external messages.
|
||||
*
|
||||
|
@ -2898,6 +2896,7 @@ td::Result<std::unique_ptr<block::transaction::Transaction>> Collator::impl_crea
|
|||
block::StoragePhaseConfig* storage_phase_cfg,
|
||||
block::ComputePhaseConfig* compute_phase_cfg,
|
||||
block::ActionPhaseConfig* action_phase_cfg,
|
||||
block::SerializeConfig* serialize_cfg,
|
||||
bool external, LogicalTime after_lt) {
|
||||
if (acc->last_trans_end_lt_ >= lt && acc->transactions.empty()) {
|
||||
return td::Status::Error(-669, PSTRING() << "last transaction time in the state of account " << acc->workchain
|
||||
|
@ -2965,7 +2964,7 @@ td::Result<std::unique_ptr<block::transaction::Transaction>> Collator::impl_crea
|
|||
return td::Status::Error(
|
||||
-669, "cannot create bounce phase of a new transaction for smart contract "s + acc->addr.to_hex());
|
||||
}
|
||||
if (!trans->serialize()) {
|
||||
if (!trans->serialize(*serialize_cfg)) {
|
||||
return td::Status::Error(-669, "cannot serialize new transaction for smart contract "s + acc->addr.to_hex());
|
||||
}
|
||||
return std::move(trans);
|
||||
|
|
|
@ -136,13 +136,12 @@ td::Status ExtMessageQ::run_message_on_account(ton::WorkchainId wc,
|
|||
td::BitArray<256> rand_seed_;
|
||||
block::ComputePhaseConfig compute_phase_cfg_;
|
||||
block::ActionPhaseConfig action_phase_cfg_;
|
||||
block::SerializeConfig serialize_config_;
|
||||
td::RefInt256 masterchain_create_fee, basechain_create_fee;
|
||||
|
||||
auto fetch_res = block::FetchConfigParams::fetch_config_params(*config, &old_mparams,
|
||||
&storage_prices_, &storage_phase_cfg_,
|
||||
&rand_seed_, &compute_phase_cfg_,
|
||||
&action_phase_cfg_, &masterchain_create_fee,
|
||||
&basechain_create_fee, wc, utime);
|
||||
auto fetch_res = block::FetchConfigParams::fetch_config_params(
|
||||
*config, &old_mparams, &storage_prices_, &storage_phase_cfg_, &rand_seed_, &compute_phase_cfg_,
|
||||
&action_phase_cfg_, &serialize_config_, &masterchain_create_fee, &basechain_create_fee, wc, utime);
|
||||
if(fetch_res.is_error()) {
|
||||
auto error = fetch_res.move_as_error();
|
||||
LOG(DEBUG) << "Cannot fetch config params: " << error.message();
|
||||
|
@ -152,10 +151,9 @@ td::Status ExtMessageQ::run_message_on_account(ton::WorkchainId wc,
|
|||
compute_phase_cfg_.with_vm_log = true;
|
||||
compute_phase_cfg_.stop_on_accept_message = true;
|
||||
|
||||
auto res = Collator::impl_create_ordinary_transaction(msg_root, acc, utime, lt,
|
||||
&storage_phase_cfg_, &compute_phase_cfg_,
|
||||
&action_phase_cfg_,
|
||||
true, lt);
|
||||
auto res =
|
||||
Collator::impl_create_ordinary_transaction(msg_root, acc, utime, lt, &storage_phase_cfg_, &compute_phase_cfg_,
|
||||
&action_phase_cfg_, &serialize_config_, true, lt);
|
||||
if(res.is_error()) {
|
||||
auto error = res.move_as_error();
|
||||
LOG(DEBUG) << "Cannot run message on account: " << error.message();
|
||||
|
|
|
@ -1004,6 +1004,10 @@ bool ValidateQuery::fetch_config_params() {
|
|||
action_phase_cfg_.disable_custom_fess = config_->get_global_version() >= 8;
|
||||
action_phase_cfg_.reserve_extra_enabled = config_->get_global_version() >= 9;
|
||||
action_phase_cfg_.mc_blackhole_addr = config_->get_burning_config().blackhole_addr;
|
||||
action_phase_cfg_.extra_currency_v2 = config_->get_global_version() >= 10;
|
||||
}
|
||||
{
|
||||
serialize_cfg_.extra_currency_v2 = config_->get_global_version() >= 10;
|
||||
}
|
||||
{
|
||||
// fetch block_grams_created
|
||||
|
@ -5608,7 +5612,7 @@ bool ValidateQuery::check_one_transaction(block::Account& account, ton::LogicalT
|
|||
return reject_query(PSTRING() << "cannot re-create bounce phase of transaction " << lt << " for smart contract "
|
||||
<< addr.to_hex());
|
||||
}
|
||||
if (!trs->serialize()) {
|
||||
if (!trs->serialize(serialize_cfg_)) {
|
||||
return reject_query(PSTRING() << "cannot re-create the serialization of transaction " << lt
|
||||
<< " for smart contract " << addr.to_hex());
|
||||
}
|
||||
|
|
|
@ -205,6 +205,7 @@ class ValidateQuery : public td::actor::Actor {
|
|||
block::StoragePhaseConfig storage_phase_cfg_{&storage_prices_};
|
||||
block::ComputePhaseConfig compute_phase_cfg_;
|
||||
block::ActionPhaseConfig action_phase_cfg_;
|
||||
block::SerializeConfig serialize_cfg_;
|
||||
td::RefInt256 masterchain_create_fee_, basechain_create_fee_;
|
||||
|
||||
std::vector<block::McShardDescr> neighbors_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue