mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
updated submodules, bugfixes
- added new fift/func code for validator complaint creation - bugfixes in validator - updates in tonlib - new versions of rocksdb/abseil - hardfork support
This commit is contained in:
parent
16a4566091
commit
9f008b129f
129 changed files with 8438 additions and 879 deletions
|
@ -19,6 +19,7 @@
|
|||
#include "vm/cells/CellSlice.h"
|
||||
#include "vm/excno.hpp"
|
||||
#include "td/utils/bits.h"
|
||||
#include "td/utils/misc.h"
|
||||
|
||||
namespace vm {
|
||||
|
||||
|
@ -719,6 +720,10 @@ bool CellSlice::prefetch_bytes(unsigned char* buffer, unsigned bytes) const {
|
|||
}
|
||||
}
|
||||
|
||||
bool CellSlice::fetch_bytes(td::MutableSlice slice) {
|
||||
return fetch_bytes(slice.ubegin(), td::narrow_cast<unsigned>(slice.size()));
|
||||
}
|
||||
|
||||
bool CellSlice::fetch_bytes(unsigned char* buffer, unsigned bytes) {
|
||||
if (prefetch_bytes(buffer, bytes)) {
|
||||
advance(bytes * 8);
|
||||
|
@ -728,6 +733,10 @@ bool CellSlice::fetch_bytes(unsigned char* buffer, unsigned bytes) {
|
|||
}
|
||||
}
|
||||
|
||||
bool CellSlice::prefetch_bytes(td::MutableSlice slice) const {
|
||||
return prefetch_bytes(slice.ubegin(), td::narrow_cast<unsigned>(slice.size()));
|
||||
}
|
||||
|
||||
Ref<Cell> CellSlice::prefetch_ref(unsigned offset) const {
|
||||
if (offset < size_refs()) {
|
||||
auto ref_id = refs_st + offset;
|
||||
|
|
|
@ -218,7 +218,9 @@ class CellSlice : public td::CntObject {
|
|||
return prefetch_bits_to(buffer.bits(), n);
|
||||
}
|
||||
bool fetch_bytes(unsigned char* buffer, unsigned bytes);
|
||||
bool fetch_bytes(td::MutableSlice slice);
|
||||
bool prefetch_bytes(unsigned char* buffer, unsigned bytes) const;
|
||||
bool prefetch_bytes(td::MutableSlice slice) const;
|
||||
td::BitSlice as_bitslice() const {
|
||||
return prefetch_bits(size());
|
||||
}
|
||||
|
|
|
@ -148,6 +148,11 @@ class MerkleProofCombineFast {
|
|||
MerkleProofCombineFast(Ref<Cell> a, Ref<Cell> b) : a_(std::move(a)), b_(std::move(b)) {
|
||||
}
|
||||
td::Result<Ref<Cell>> run() {
|
||||
if (a_.is_null()) {
|
||||
return b_;
|
||||
} else if (b_.is_null()) {
|
||||
return a_;
|
||||
}
|
||||
TRY_RESULT_ASSIGN(a_, unpack_proof(a_));
|
||||
TRY_RESULT_ASSIGN(b_, unpack_proof(b_));
|
||||
TRY_RESULT(res, run_raw());
|
||||
|
@ -204,6 +209,11 @@ class MerkleProofCombine {
|
|||
MerkleProofCombine(Ref<Cell> a, Ref<Cell> b) : a_(std::move(a)), b_(std::move(b)) {
|
||||
}
|
||||
td::Result<Ref<Cell>> run() {
|
||||
if (a_.is_null()) {
|
||||
return b_;
|
||||
} else if (b_.is_null()) {
|
||||
return a_;
|
||||
}
|
||||
TRY_RESULT_ASSIGN(a_, unpack_proof(a_));
|
||||
TRY_RESULT_ASSIGN(b_, unpack_proof(b_));
|
||||
TRY_RESULT(res, run_raw());
|
||||
|
@ -323,6 +333,10 @@ Ref<Cell> MerkleProof::combine(Ref<Cell> a, Ref<Cell> b) {
|
|||
return res.move_as_ok();
|
||||
}
|
||||
|
||||
td::Result<Ref<Cell>> MerkleProof::combine_status(Ref<Cell> a, Ref<Cell> b) {
|
||||
return MerkleProofCombine(std::move(a), std::move(b)).run();
|
||||
}
|
||||
|
||||
Ref<Cell> MerkleProof::combine_fast(Ref<Cell> a, Ref<Cell> b) {
|
||||
auto res = MerkleProofCombineFast(std::move(a), std::move(b)).run();
|
||||
if (res.is_error()) {
|
||||
|
@ -331,6 +345,10 @@ Ref<Cell> MerkleProof::combine_fast(Ref<Cell> a, Ref<Cell> b) {
|
|||
return res.move_as_ok();
|
||||
}
|
||||
|
||||
td::Result<Ref<Cell>> MerkleProof::combine_fast_status(Ref<Cell> a, Ref<Cell> b) {
|
||||
return MerkleProofCombineFast(std::move(a), std::move(b)).run();
|
||||
}
|
||||
|
||||
Ref<Cell> MerkleProof::combine_raw(Ref<Cell> a, Ref<Cell> b) {
|
||||
auto res = MerkleProofCombine(std::move(a), std::move(b)).run_raw();
|
||||
if (res.is_error()) {
|
||||
|
|
|
@ -38,7 +38,9 @@ class MerkleProof {
|
|||
static Ref<Cell> virtualize(Ref<Cell> cell, int virtualization);
|
||||
|
||||
static Ref<Cell> combine(Ref<Cell> a, Ref<Cell> b);
|
||||
static td::Result<Ref<Cell>> combine_status(Ref<Cell> a, Ref<Cell> b);
|
||||
static Ref<Cell> combine_fast(Ref<Cell> a, Ref<Cell> b);
|
||||
static td::Result<Ref<Cell>> combine_fast_status(Ref<Cell> a, Ref<Cell> b);
|
||||
|
||||
// works with upwrapped proofs
|
||||
// works fine with cell of non-zero level, but this is not supported (yet?) in MerkeProof special cell
|
||||
|
|
|
@ -255,15 +255,15 @@ TonDbTransactionImpl::TonDbTransactionImpl(std::shared_ptr<KeyValue> kv) : kv_(s
|
|||
}
|
||||
|
||||
void TonDbTransactionImpl::begin() {
|
||||
kv_->begin_transaction();
|
||||
kv_->begin_write_batch();
|
||||
generation_++;
|
||||
}
|
||||
void TonDbTransactionImpl::commit() {
|
||||
kv_->commit_transaction();
|
||||
kv_->commit_write_batch();
|
||||
reader_.reset(kv_->snapshot().release());
|
||||
}
|
||||
void TonDbTransactionImpl::abort() {
|
||||
kv_->abort_transaction();
|
||||
kv_->abort_write_batch();
|
||||
}
|
||||
void TonDbTransactionImpl::clear_cache() {
|
||||
contracts_ = {};
|
||||
|
|
|
@ -77,6 +77,13 @@ class VmError {
|
|||
long long get_arg() const {
|
||||
return arg;
|
||||
}
|
||||
td::Status as_status() const {
|
||||
return td::Status::Error(td::Slice{get_msg()});
|
||||
}
|
||||
template <typename T>
|
||||
td::Status as_status(T pfx) const {
|
||||
return td::Status::Error(PSLICE() << pfx << get_msg());
|
||||
}
|
||||
};
|
||||
|
||||
struct VmNoGas {
|
||||
|
@ -90,6 +97,13 @@ struct VmNoGas {
|
|||
operator VmError() const {
|
||||
return VmError{Excno::out_of_gas, "out of gas"};
|
||||
}
|
||||
td::Status as_status() const {
|
||||
return td::Status::Error(td::Slice{get_msg()});
|
||||
}
|
||||
template <typename T>
|
||||
td::Status as_status(T pfx) const {
|
||||
return td::Status::Error(PSLICE() << pfx << get_msg());
|
||||
}
|
||||
};
|
||||
|
||||
struct VmVirtError {
|
||||
|
@ -106,6 +120,13 @@ struct VmVirtError {
|
|||
operator VmError() const {
|
||||
return VmError{Excno::virt_err, "prunned branch", virtualization};
|
||||
}
|
||||
td::Status as_status() const {
|
||||
return td::Status::Error(td::Slice{get_msg()});
|
||||
}
|
||||
template <typename T>
|
||||
td::Status as_status(T pfx) const {
|
||||
return td::Status::Error(PSLICE() << pfx << get_msg());
|
||||
}
|
||||
};
|
||||
|
||||
struct VmFatal {};
|
||||
|
@ -114,12 +135,12 @@ template <class F>
|
|||
auto try_f(F&& f) noexcept -> decltype(f()) {
|
||||
try {
|
||||
return f();
|
||||
} catch (vm::VmError error) {
|
||||
return td::Status::Error(PSLICE() << "Got a vm exception: " << error.get_msg());
|
||||
} catch (vm::VmVirtError error) {
|
||||
return td::Status::Error(PSLICE() << "Got a vm virtualization exception: " << error.get_msg());
|
||||
} catch (vm::VmNoGas error) {
|
||||
return td::Status::Error(PSLICE() << "Got a vm no gas exception: " << error.get_msg());
|
||||
} catch (vm::VmError& error) {
|
||||
return error.as_status("Got a vm exception: ");
|
||||
} catch (vm::VmVirtError& error) {
|
||||
return error.as_status("Got a vm virtualization exception: ");
|
||||
} catch (vm::VmNoGas& error) {
|
||||
return error.as_status("Got a vm no gas exception: ");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue