mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
emergency update
This commit is contained in:
parent
5d846e0aaf
commit
9f351fc29f
87 changed files with 2486 additions and 655 deletions
|
@ -1633,15 +1633,19 @@ bool valid_config_data(Ref<vm::Cell> cell, const td::BitArray<256>& addr, bool c
|
|||
bool config_params_present(vm::Dictionary& dict, Ref<vm::Cell> param_dict_root) {
|
||||
auto res = block::Config::unpack_param_dict(std::move(param_dict_root));
|
||||
if (res.is_error()) {
|
||||
LOG(ERROR)
|
||||
<< "invalid mandatory parameters dictionary while checking existence of all mandatory configuration parameters";
|
||||
return false;
|
||||
}
|
||||
for (int x : res.move_as_ok()) {
|
||||
// LOG(DEBUG) << "checking whether mandatory configuration parameter #" << x << " exists";
|
||||
if (!dict.int_key_exists(x)) {
|
||||
LOG(ERROR) << "configuration parameter #" << x
|
||||
<< " (declared as mandatory in configuration parameter #9) is missing";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// LOG(DEBUG) << "all mandatory configuration parameters present";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -414,7 +414,7 @@ block_info#9bc7a987 version:uint32
|
|||
after_split:(## 1)
|
||||
want_split:Bool want_merge:Bool
|
||||
key_block:Bool vert_seqno_incr:(## 1)
|
||||
flags:(## 8)
|
||||
flags:(## 8) { flags <= 1 }
|
||||
seq_no:# vert_seq_no:# { vert_seq_no >= vert_seqno_incr }
|
||||
{ prev_seq_no:# } { ~prev_seq_no + 1 = seq_no }
|
||||
shard:ShardIdent gen_utime:uint32
|
||||
|
@ -423,6 +423,7 @@ block_info#9bc7a987 version:uint32
|
|||
gen_catchain_seqno:uint32
|
||||
min_ref_mc_seqno:uint32
|
||||
prev_key_block_seqno:uint32
|
||||
gen_software:flags . 0?GlobalVersion
|
||||
master_ref:not_master?^BlkMasterInfo
|
||||
prev_ref:^(BlkPrevInfo after_merge)
|
||||
prev_vert_ref:vert_seqno_incr?^(BlkPrevInfo 0)
|
||||
|
|
|
@ -55,6 +55,8 @@
|
|||
#include "td/utils/port/path.h"
|
||||
#include "td/utils/port/signals.h"
|
||||
|
||||
#include "tonlib/keys/Mnemonic.h"
|
||||
|
||||
#include "block.h"
|
||||
#include "block-parse.h"
|
||||
#include "block-auto.h"
|
||||
|
@ -634,7 +636,25 @@ void interpret_sub_extra_currencies(vm::Stack& stack) {
|
|||
stack.push_bool(ok);
|
||||
}
|
||||
|
||||
void interpret_mnemonic_to_privkey(vm::Stack& stack, int mode) {
|
||||
td::SecureString str{td::Slice{stack.pop_string()}};
|
||||
auto res = tonlib::Mnemonic::create(std::move(str), td::SecureString());
|
||||
if (res.is_error()) {
|
||||
throw fift::IntError{res.move_as_error().to_string()};
|
||||
}
|
||||
auto privkey = res.move_as_ok().to_private_key();
|
||||
td::SecureString key;
|
||||
if (mode & 1) {
|
||||
auto pub = privkey.get_public_key();
|
||||
key = pub.move_as_ok().as_octet_string();
|
||||
} else {
|
||||
key = privkey.as_octet_string();
|
||||
}
|
||||
stack.push_bytes(key.as_slice());
|
||||
}
|
||||
|
||||
void init_words_custom(fift::Dictionary& d) {
|
||||
using namespace std::placeholders;
|
||||
d.def_stack_word("verb@ ", interpret_get_verbosity);
|
||||
d.def_stack_word("verb! ", interpret_set_verbosity);
|
||||
d.def_stack_word("wcid@ ", interpret_get_workchain);
|
||||
|
@ -651,6 +671,8 @@ void init_words_custom(fift::Dictionary& d) {
|
|||
d.def_stack_word("isWorkchainDescr? ", interpret_is_workchain_descr);
|
||||
d.def_stack_word("CC+? ", interpret_add_extra_currencies);
|
||||
d.def_stack_word("CC-? ", interpret_sub_extra_currencies);
|
||||
d.def_stack_word("mnemo>priv ", std::bind(interpret_mnemonic_to_privkey, _1, 0));
|
||||
d.def_stack_word("mnemo>pub ", std::bind(interpret_mnemonic_to_privkey, _1, 1));
|
||||
}
|
||||
|
||||
tlb::TypenameLookup tlb_dict;
|
||||
|
@ -738,7 +760,8 @@ void init_words_tlb(fift::Dictionary& d) {
|
|||
d.def_stack_word("(tlb-dump-str?) ", interpret_tlb_dump_to_str);
|
||||
d.def_stack_word("tlb-skip ", interpret_tlb_skip);
|
||||
d.def_stack_word("tlb-validate-skip ", interpret_tlb_validate_skip);
|
||||
d.def_stack_word("ExtraCurrencyCollection", std::bind(interpret_tlb_type_const, _1, &block::tlb::t_ExtraCurrencyCollection));
|
||||
d.def_stack_word("ExtraCurrencyCollection",
|
||||
std::bind(interpret_tlb_type_const, _1, &block::tlb::t_ExtraCurrencyCollection));
|
||||
}
|
||||
|
||||
void usage(const char* progname) {
|
||||
|
|
|
@ -1561,10 +1561,10 @@ int Transaction::try_action_send_msg(const vm::CellSlice& cs0, ActionPhase& ap,
|
|||
return skip_invalid ? 0 : 38; // not enough (extra) funds
|
||||
}
|
||||
if (ap.remaining_balance.extra.not_null() || req.extra.not_null()) {
|
||||
LOG(WARNING) << "subtracting extra currencies: "
|
||||
<< block::CurrencyCollection{0, ap.remaining_balance.extra}.to_str() << " minus "
|
||||
<< block::CurrencyCollection{0, req.extra}.to_str() << " equals "
|
||||
<< block::CurrencyCollection{0, new_extra}.to_str();
|
||||
LOG(DEBUG) << "subtracting extra currencies: "
|
||||
<< block::CurrencyCollection{0, ap.remaining_balance.extra}.to_str() << " minus "
|
||||
<< block::CurrencyCollection{0, req.extra}.to_str() << " equals "
|
||||
<< block::CurrencyCollection{0, new_extra}.to_str();
|
||||
}
|
||||
|
||||
auto fwd_fee_mine = msg_prices.get_first_part(fwd_fee);
|
||||
|
@ -1730,11 +1730,17 @@ bool Transaction::prepare_bounce_phase(const ActionPhaseConfig& cfg) {
|
|||
}
|
||||
bounce_phase = std::make_unique<BouncePhase>();
|
||||
BouncePhase& bp = *bounce_phase;
|
||||
block::gen::Message::Record msg;
|
||||
block::gen::CommonMsgInfo::Record_int_msg_info info;
|
||||
if (!tlb::unpack_cell_inexact(in_msg, info)) {
|
||||
auto cs = vm::load_cell_slice(in_msg);
|
||||
if (!(tlb::unpack(cs, info) && gen::t_Maybe_Either_StateInit_Ref_StateInit.skip(cs) && cs.have(1) &&
|
||||
cs.have_refs((int)cs.prefetch_ulong(1)))) {
|
||||
bounce_phase.reset();
|
||||
return false;
|
||||
}
|
||||
if (cs.fetch_ulong(1)) {
|
||||
cs = vm::load_cell_slice(cs.prefetch_ref());
|
||||
}
|
||||
info.ihr_disabled = true;
|
||||
info.bounce = false;
|
||||
info.bounced = true;
|
||||
|
@ -1786,10 +1792,26 @@ bool Transaction::prepare_bounce_phase(const ActionPhaseConfig& cfg) {
|
|||
&& block::tlb::t_Grams.store_long(cb, bp.fwd_fees) // fwd_fee:Grams
|
||||
&& cb.store_long_bool(info.created_lt, 64) // created_lt:uint64
|
||||
&& cb.store_long_bool(info.created_at, 32) // created_at:uint32
|
||||
&& cb.store_long_bool(0, 2) // init:(Maybe ...) state:(Either ..)
|
||||
&& cb.finalize_to(bp.out_msg));
|
||||
&& cb.store_bool_bool(false)); // init:(Maybe ...)
|
||||
if (cfg.bounce_msg_body) {
|
||||
int body_bits = std::min((int)cs.size(), cfg.bounce_msg_body);
|
||||
if (cb.remaining_bits() >= body_bits + 33u) {
|
||||
CHECK(cb.store_bool_bool(false) // body:(Either X ^X) -> left X
|
||||
&& cb.store_long_bool(-1, 32) // int = -1 ("message type")
|
||||
&& cb.append_bitslice(cs.prefetch_bits(body_bits))); // truncated message body
|
||||
} else {
|
||||
vm::CellBuilder cb2;
|
||||
CHECK(cb.store_bool_bool(true) // body:(Either X ^X) -> right ^X
|
||||
&& cb2.store_long_bool(-1, 32) // int = -1 ("message type")
|
||||
&& cb2.append_bitslice(cs.prefetch_bits(body_bits)) // truncated message body
|
||||
&& cb.store_builder_ref_bool(std::move(cb2))); // ^X
|
||||
}
|
||||
} else {
|
||||
CHECK(cb.store_bool_bool(false)); // body:(Either ..)
|
||||
}
|
||||
CHECK(cb.finalize_to(bp.out_msg));
|
||||
if (verbosity > 2) {
|
||||
std::cerr << "generated bounced message: ";
|
||||
LOG(INFO) << "generated bounced message: ";
|
||||
block::gen::t_Message_Any.print_ref(std::cerr, bp.out_msg);
|
||||
}
|
||||
out_msgs.push_back(bp.out_msg);
|
||||
|
|
|
@ -139,6 +139,7 @@ struct ComputePhaseConfig {
|
|||
|
||||
struct ActionPhaseConfig {
|
||||
int max_actions{255};
|
||||
int bounce_msg_body{0}; // usually 0 or 256 bits
|
||||
MsgPrices fwd_std;
|
||||
MsgPrices fwd_mc; // from/to masterchain
|
||||
const WorkchainSet* workchains{nullptr};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue