mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Merge branch 'testnet' into block-generation
This commit is contained in:
commit
8e85bfa6e6
26 changed files with 432 additions and 321 deletions
|
@ -373,10 +373,10 @@ add_library(src_parser ${PARSER_SOURCE})
|
|||
target_include_directories(src_parser PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
||||
target_link_libraries(src_parser PUBLIC ton_crypto_core)
|
||||
|
||||
add_library(ton_block ${BLOCK_SOURCE})
|
||||
add_library(ton_block STATIC ${BLOCK_SOURCE})
|
||||
target_include_directories(ton_block PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/block> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||
target_link_libraries(ton_block PUBLIC ton_crypto_core tdutils tdactor tl_api)
|
||||
target_link_libraries(ton_block PUBLIC ton_crypto tdutils tdactor tl_api)
|
||||
|
||||
add_executable(func func/func-main.cpp ${FUNC_LIB_SOURCE})
|
||||
target_include_directories(func PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
||||
|
|
|
@ -610,7 +610,7 @@ _ dns_root_addr:bits256 = ConfigParam 4; // root TON DNS resolver
|
|||
|
||||
burning_config#01
|
||||
blackhole_addr:(Maybe bits256)
|
||||
fee_burn_nom:# fee_burn_denom:# { fee_burn_nom <= fee_burn_denom } { fee_burn_denom >= 1 } = BurningConfig;
|
||||
fee_burn_num:# fee_burn_denom:# { fee_burn_num <= fee_burn_denom } { fee_burn_denom >= 1 } = BurningConfig;
|
||||
_ BurningConfig = ConfigParam 5;
|
||||
|
||||
_ mint_new_price:Grams mint_add_price:Grams = ConfigParam 6;
|
||||
|
|
|
@ -1963,7 +1963,7 @@ BurningConfig Config::get_burning_config() const {
|
|||
return {};
|
||||
}
|
||||
BurningConfig c;
|
||||
c.fee_burn_nom = rec.fee_burn_nom;
|
||||
c.fee_burn_num = rec.fee_burn_num;
|
||||
c.fee_burn_denom = rec.fee_burn_denom;
|
||||
vm::CellSlice& addr = rec.blackhole_addr.write();
|
||||
if (addr.fetch_long(1)) {
|
||||
|
|
|
@ -506,13 +506,13 @@ class ShardConfig {
|
|||
|
||||
struct BurningConfig {
|
||||
td::optional<td::Bits256> blackhole_addr;
|
||||
td::uint32 fee_burn_nom = 0, fee_burn_denom = 1;
|
||||
td::uint32 fee_burn_num = 0, fee_burn_denom = 1;
|
||||
|
||||
td::RefInt256 calculate_burned_fees(const td::RefInt256& x) const {
|
||||
if (x.is_null()) {
|
||||
return x;
|
||||
}
|
||||
return x * fee_burn_nom / td::make_refint(fee_burn_denom);
|
||||
return x * fee_burn_num / td::make_refint(fee_burn_denom);
|
||||
}
|
||||
|
||||
CurrencyCollection calculate_burned_fees(const CurrencyCollection& x) const {
|
||||
|
|
|
@ -596,7 +596,7 @@ long parse_bitstring_hex_literal(unsigned char* buff, std::size_t buff_size, con
|
|||
unsigned char* ptr = buff;
|
||||
const char* rptr = str;
|
||||
while (rptr < str_end) {
|
||||
int c = *rptr++;
|
||||
char c = *rptr++;
|
||||
if (c == ' ' || c == '\t') {
|
||||
continue;
|
||||
}
|
||||
|
@ -627,14 +627,14 @@ long parse_bitstring_hex_literal(unsigned char* buff, std::size_t buff_size, con
|
|||
if (cmpl && bits) {
|
||||
int t = (hex_digits_count & 1) ? (0x100 + *ptr) >> 4 : (0x100 + *--ptr);
|
||||
while (bits > 0) {
|
||||
if (t == 1) {
|
||||
t = 0x100 + *--ptr;
|
||||
}
|
||||
--bits;
|
||||
if (t & 1) {
|
||||
break;
|
||||
}
|
||||
t >>= 1;
|
||||
if (t == 1) {
|
||||
t = 0x100 + *--ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bits;
|
||||
|
|
|
@ -246,10 +246,10 @@ SmartContract::Answer run_smartcont(SmartContract::State state, td::Ref<vm::Stac
|
|||
LOG(DEBUG) << "VM accepted: " << res.accepted;
|
||||
LOG(DEBUG) << "VM success: " << res.success;
|
||||
}
|
||||
td::ConstBitPtr mlib = vm.get_missing_library();
|
||||
if (!mlib.is_null()) {
|
||||
LOG(DEBUG) << "Missing library: " << mlib.to_hex(256);
|
||||
res.missing_library = mlib;
|
||||
auto mlib = vm.get_missing_library();
|
||||
if (mlib) {
|
||||
LOG(DEBUG) << "Missing library: " << mlib.value().to_hex();
|
||||
res.missing_library = mlib.value();
|
||||
}
|
||||
if (res.success) {
|
||||
res.new_state.data = vm.get_c4();
|
||||
|
@ -257,7 +257,7 @@ SmartContract::Answer run_smartcont(SmartContract::State state, td::Ref<vm::Stac
|
|||
LOG(DEBUG) << "output actions:\n"
|
||||
<< block::gen::OutList{res.output_actions_count(res.actions)}.as_string_ref(res.actions);
|
||||
}
|
||||
LOG_IF(ERROR, gas_credit != 0 && (res.accepted && !res.success) && mlib.is_null())
|
||||
LOG_IF(ERROR, gas_credit != 0 && (res.accepted && !res.success) && !mlib)
|
||||
<< "Accepted but failed with code " << res.code << "\n"
|
||||
<< res.gas_used << "\n";
|
||||
return res;
|
||||
|
|
|
@ -49,7 +49,7 @@ class SmartContract : public td::CntObject {
|
|||
td::Ref<vm::Cell> actions;
|
||||
td::int32 code;
|
||||
td::int64 gas_used;
|
||||
td::ConstBitPtr missing_library{0};
|
||||
td::optional<td::Bits256> missing_library;
|
||||
std::string vm_log;
|
||||
static int output_actions_count(td::Ref<vm::Cell> list);
|
||||
};
|
||||
|
|
|
@ -55,20 +55,23 @@ td::Ref<vm::Cell> WalletInterface::create_int_message(const Gift &gift) {
|
|||
} else {
|
||||
cbi.store_zeroes(1);
|
||||
}
|
||||
cbi.store_zeroes(1);
|
||||
store_gift_message(cbi, gift);
|
||||
return cbi.finalize();
|
||||
}
|
||||
void WalletInterface::store_gift_message(vm::CellBuilder &cb, const Gift &gift) {
|
||||
if (gift.body.not_null()) {
|
||||
auto body = vm::load_cell_slice(gift.body);
|
||||
//TODO: handle error
|
||||
CHECK(cb.append_cellslice_bool(body));
|
||||
if (cb.can_extend_by(1 + body.size(), body.size_refs())) {
|
||||
CHECK(cb.store_zeroes_bool(1) && cb.append_cellslice_bool(body));
|
||||
} else {
|
||||
CHECK(cb.store_ones_bool(1) && cb.store_ref_bool(gift.body));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
cb.store_zeroes(1);
|
||||
if (gift.is_encrypted) {
|
||||
cb.store_long(1, 32);
|
||||
cb.store_long(0x2167da4b, 32);
|
||||
} else {
|
||||
cb.store_long(0, 32);
|
||||
}
|
||||
|
|
|
@ -73,6 +73,8 @@ class WalletInterface : public SmartContract {
|
|||
td::uint32 valid_until = std::numeric_limits<td::uint32>::max()) const;
|
||||
|
||||
static td::Ref<vm::Cell> create_int_message(const Gift &gift);
|
||||
|
||||
private:
|
||||
static void store_gift_message(vm::CellBuilder &cb, const Gift &gift);
|
||||
};
|
||||
|
||||
|
|
|
@ -142,28 +142,57 @@ td::Ref<vm::Cell> CellText::do_store(td::BitSlice slice) {
|
|||
}
|
||||
|
||||
template <class F>
|
||||
void CellText::for_each(F &&f, CellSlice cs) {
|
||||
td::Status CellText::for_each(F &&f, CellSlice cs) {
|
||||
if (!cs.have(8)) {
|
||||
return td::Status::Error("Cell underflow");
|
||||
}
|
||||
auto depth = cs.fetch_ulong(8);
|
||||
if (depth > max_chain_length) {
|
||||
return td::Status::Error("Too deep string");
|
||||
}
|
||||
|
||||
for (td::uint32 i = 0; i < depth; i++) {
|
||||
auto size = cs.fetch_ulong(8);
|
||||
f(cs.fetch_bits(td::narrow_cast<int>(size) * 8));
|
||||
if (!cs.have(8)) {
|
||||
return td::Status::Error("Cell underflow");
|
||||
}
|
||||
auto size = td::narrow_cast<int>(cs.fetch_ulong(8));
|
||||
if (!cs.have(size * 8)) {
|
||||
return td::Status::Error("Cell underflow");
|
||||
}
|
||||
TRY_STATUS(f(cs.fetch_bits(size * 8)));
|
||||
if (i + 1 < depth) {
|
||||
if (!cs.have_refs()) {
|
||||
return td::Status::Error("Cell underflow");
|
||||
}
|
||||
cs = vm::load_cell_slice(cs.prefetch_ref());
|
||||
}
|
||||
}
|
||||
return td::Status::OK();
|
||||
}
|
||||
|
||||
td::Result<td::string> CellText::load(CellSlice &cs) {
|
||||
unsigned int size = 0;
|
||||
for_each([&](auto slice) { size += slice.size(); }, cs);
|
||||
TRY_STATUS(for_each(
|
||||
[&](auto slice) {
|
||||
size += slice.size();
|
||||
if (size > max_bytes * 8) {
|
||||
return td::Status::Error("String is too long");
|
||||
}
|
||||
return td::Status::OK();
|
||||
},
|
||||
cs));
|
||||
if (size % 8 != 0) {
|
||||
return td::Status::Error("Size is not divisible by 8");
|
||||
}
|
||||
std::string res(size / 8, 0);
|
||||
|
||||
td::BitPtr to(td::MutableSlice(res).ubegin());
|
||||
for_each([&](auto slice) { to.concat(slice); }, cs);
|
||||
TRY_STATUS(for_each(
|
||||
[&](auto slice) {
|
||||
to.concat(slice);
|
||||
return td::Status::OK();
|
||||
},
|
||||
cs));
|
||||
CHECK(to.offs == (int)size);
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ class CellText {
|
|||
|
||||
private:
|
||||
template <class F>
|
||||
static void for_each(F &&f, CellSlice cs);
|
||||
static td::Status for_each(F &&f, CellSlice cs);
|
||||
static td::Ref<vm::Cell> do_store(td::BitSlice slice);
|
||||
};
|
||||
|
||||
|
|
|
@ -633,7 +633,7 @@ Ref<Cell> VmState::load_library(td::ConstBitPtr hash) {
|
|||
return lib;
|
||||
}
|
||||
}
|
||||
missing_library = hash;
|
||||
missing_library = td::Bits256{hash};
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "vm/log.h"
|
||||
#include "vm/continuation.h"
|
||||
#include "td/utils/HashSet.h"
|
||||
#include "td/utils/optional.h"
|
||||
|
||||
namespace vm {
|
||||
|
||||
|
@ -97,7 +98,7 @@ class VmState final : public VmStateInterface {
|
|||
td::HashSet<CellHash> loaded_cells;
|
||||
int stack_trace{0}, debug_off{0};
|
||||
bool chksig_always_succeed{false};
|
||||
td::ConstBitPtr missing_library{0};
|
||||
td::optional<td::Bits256> missing_library;
|
||||
td::uint16 max_data_depth = 512; // Default value
|
||||
int global_version{0};
|
||||
size_t chksgn_counter = 0;
|
||||
|
@ -128,25 +129,25 @@ class VmState final : public VmStateInterface {
|
|||
chksgn_gas_price = 4000,
|
||||
p256_chksgn_gas_price = 3500,
|
||||
|
||||
bls_verify_gas_price = 61300,
|
||||
bls_aggregate_base_gas_price = -2645,
|
||||
bls_aggregate_element_gas_price = 4355,
|
||||
bls_fast_aggregate_verify_base_gas_price = 58400,
|
||||
bls_fast_aggregate_verify_element_gas_price = 2990,
|
||||
bls_aggregate_verify_base_gas_price = 37275,
|
||||
bls_aggregate_verify_element_gas_price = 22290,
|
||||
bls_verify_gas_price = 61000,
|
||||
bls_aggregate_base_gas_price = -2650,
|
||||
bls_aggregate_element_gas_price = 4350,
|
||||
bls_fast_aggregate_verify_base_gas_price = 58000,
|
||||
bls_fast_aggregate_verify_element_gas_price = 3000,
|
||||
bls_aggregate_verify_base_gas_price = 38500,
|
||||
bls_aggregate_verify_element_gas_price = 22500,
|
||||
|
||||
bls_g1_add_sub_gas_price = 3925,
|
||||
bls_g1_neg_gas_price = 765,
|
||||
bls_g1_mul_gas_price = 5180,
|
||||
bls_map_to_g1_gas_price = 2330,
|
||||
bls_g1_in_group_gas_price = 2930,
|
||||
bls_g1_add_sub_gas_price = 3900,
|
||||
bls_g1_neg_gas_price = 750,
|
||||
bls_g1_mul_gas_price = 5200,
|
||||
bls_map_to_g1_gas_price = 2350,
|
||||
bls_g1_in_group_gas_price = 2950,
|
||||
|
||||
bls_g2_add_sub_gas_price = 6100,
|
||||
bls_g2_neg_gas_price = 1550,
|
||||
bls_g2_mul_gas_price = 10530,
|
||||
bls_map_to_g2_gas_price = 7970,
|
||||
bls_g2_in_group_gas_price = 4255,
|
||||
bls_g2_mul_gas_price = 10550,
|
||||
bls_map_to_g2_gas_price = 7950,
|
||||
bls_g2_in_group_gas_price = 4250,
|
||||
|
||||
// multiexp gas = base + n * coef1 + n/floor(max(log2(n), 4)) * coef2
|
||||
bls_g1_multiexp_base_gas_price = 11375,
|
||||
|
@ -157,7 +158,7 @@ class VmState final : public VmStateInterface {
|
|||
bls_g2_multiexp_coef2_gas_price = 22840,
|
||||
|
||||
bls_pairing_base_gas_price = 20000,
|
||||
bls_pairing_element_gas_price = 11770
|
||||
bls_pairing_element_gas_price = 11800
|
||||
};
|
||||
VmState();
|
||||
VmState(Ref<CellSlice> _code);
|
||||
|
@ -383,7 +384,7 @@ class VmState final : public VmStateInterface {
|
|||
Ref<OrdCont> ref_to_cont(Ref<Cell> cell) const {
|
||||
return td::make_ref<OrdCont>(load_cell_slice_ref(std::move(cell)), get_cp());
|
||||
}
|
||||
td::ConstBitPtr get_missing_library() const {
|
||||
td::optional<td::Bits256> get_missing_library() const {
|
||||
return missing_library;
|
||||
}
|
||||
void set_max_data_depth(td::uint16 depth) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue