1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00
This commit is contained in:
ton 2020-04-10 23:06:01 +04:00
parent 8be3fc99ed
commit be9c34c62d
699 changed files with 1171 additions and 978 deletions

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "adnl-db.hpp" #include "adnl-db.hpp"
#include "td/db/RocksDb.h" #include "td/db/RocksDb.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "adnl-ext-client.hpp" #include "adnl-ext-client.hpp"
#include "adnl-ext-client.h" #include "adnl-ext-client.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "adnl-ext-connection.hpp" #include "adnl-ext-connection.hpp"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "adnl-ext-server.hpp" #include "adnl-ext-server.hpp"
#include "keys/encryptor.h" #include "keys/encryptor.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "adnl/adnl-message.h" #include "adnl/adnl-message.h"
#include "auto/tl/ton_api.hpp" #include "auto/tl/ton_api.hpp"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "adnl-node.h" #include "adnl-node.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "adnl-packet.h" #include "adnl-packet.h"
#include "td/utils/Random.h" #include "td/utils/Random.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "adnl-query.h" #include "adnl-query.h"
#include "common/errorcode.h" #include "common/errorcode.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "adnl-static-nodes.h" #include "adnl-static-nodes.h"
#include "adnl-static-nodes.hpp" #include "adnl-static-nodes.hpp"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "adnl-test-loopback-implementation.h" #include "adnl-test-loopback-implementation.h"

View file

@ -23,7 +23,7 @@
exception statement from your version. If you delete this exception statement exception statement from your version. If you delete this exception statement
from all source files in the program, then also delete it here. from all source files in the program, then also delete it here.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "adnl/adnl-network-manager.h" #include "adnl/adnl-network-manager.h"
#include "adnl/adnl-peer-table.h" #include "adnl/adnl-peer-table.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "utils.hpp" #include "utils.hpp"
#include "tl/tl_object_store.h" #include "tl/tl_object_store.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -23,7 +23,7 @@
exception statement from your version. If you delete this exception statement exception statement from your version. If you delete this exception statement
from all source files in the program, then also delete it here. from all source files in the program, then also delete it here.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "catchain-block.hpp" #include "catchain-block.hpp"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include <set> #include <set>

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -55,13 +55,11 @@ class CatChainReceiverInterface : public td::actor::Actor {
virtual void destroy() = 0; virtual void destroy() = 0;
static td::actor::ActorOwn<CatChainReceiverInterface> create(std::unique_ptr<Callback> callback, CatChainOptions opts, static td::actor::ActorOwn<CatChainReceiverInterface> create(
td::actor::ActorId<keyring::Keyring> keyring, std::unique_ptr<Callback> callback, CatChainOptions opts, td::actor::ActorId<keyring::Keyring> keyring,
td::actor::ActorId<adnl::Adnl> adnl, td::actor::ActorId<adnl::Adnl> adnl, td::actor::ActorId<overlay::Overlays> overlay_manager,
td::actor::ActorId<overlay::Overlays> overlay_manager, std::vector<CatChainNode> ids, PublicKeyHash local_id, CatChainSessionId unique_hash, std::string db_root,
std::vector<CatChainNode> ids, PublicKeyHash local_id, std::string db_suffix, bool allow_unsafe_self_blocks_resync);
CatChainSessionId unique_hash, std::string db_root,
bool allow_unsafe_self_blocks_resync);
virtual ~CatChainReceiverInterface() = default; virtual ~CatChainReceiverInterface() = default;
}; };

View file

@ -430,7 +430,7 @@ CatChainReceiverImpl::CatChainReceiverImpl(std::unique_ptr<Callback> callback, C
td::actor::ActorId<adnl::Adnl> adnl, td::actor::ActorId<adnl::Adnl> adnl,
td::actor::ActorId<overlay::Overlays> overlay_manager, td::actor::ActorId<overlay::Overlays> overlay_manager,
std::vector<CatChainNode> ids, PublicKeyHash local_id, std::vector<CatChainNode> ids, PublicKeyHash local_id,
CatChainSessionId unique_hash, std::string db_root, CatChainSessionId unique_hash, std::string db_root, std::string db_suffix,
bool allow_unsafe_self_blocks_resync) bool allow_unsafe_self_blocks_resync)
: callback_(std::move(callback)) : callback_(std::move(callback))
, opts_(std::move(opts)) , opts_(std::move(opts))
@ -439,6 +439,7 @@ CatChainReceiverImpl::CatChainReceiverImpl(std::unique_ptr<Callback> callback, C
, overlay_manager_(overlay_manager) , overlay_manager_(overlay_manager)
, local_id_(local_id) , local_id_(local_id)
, db_root_(db_root) , db_root_(db_root)
, db_suffix_(db_suffix)
, allow_unsafe_self_blocks_resync_(allow_unsafe_self_blocks_resync) { , allow_unsafe_self_blocks_resync_(allow_unsafe_self_blocks_resync) {
std::vector<td::Bits256> short_ids; std::vector<td::Bits256> short_ids;
local_idx_ = static_cast<td::uint32>(ids.size()); local_idx_ = static_cast<td::uint32>(ids.size());
@ -491,7 +492,8 @@ void CatChainReceiverImpl::start_up() {
if (!opts_.debug_disable_db) { if (!opts_.debug_disable_db) {
std::shared_ptr<td::KeyValue> kv = std::make_shared<td::RocksDb>( std::shared_ptr<td::KeyValue> kv = std::make_shared<td::RocksDb>(
td::RocksDb::open(db_root_ + "/catchainreceiver-" + td::base64url_encode(as_slice(incarnation_))).move_as_ok()); td::RocksDb::open(db_root_ + "/catchainreceiver" + db_suffix_ + td::base64url_encode(as_slice(incarnation_)))
.move_as_ok());
db_ = DbType{std::move(kv)}; db_ = DbType{std::move(kv)};
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this)](td::Result<DbType::GetResult> R) { auto P = td::PromiseCreator::lambda([SelfId = actor_id(this)](td::Result<DbType::GetResult> R) {
@ -611,10 +613,10 @@ td::actor::ActorOwn<CatChainReceiverInterface> CatChainReceiverInterface::create
std::unique_ptr<Callback> callback, CatChainOptions opts, td::actor::ActorId<keyring::Keyring> keyring, std::unique_ptr<Callback> callback, CatChainOptions opts, td::actor::ActorId<keyring::Keyring> keyring,
td::actor::ActorId<adnl::Adnl> adnl, td::actor::ActorId<overlay::Overlays> overlay_manager, td::actor::ActorId<adnl::Adnl> adnl, td::actor::ActorId<overlay::Overlays> overlay_manager,
std::vector<CatChainNode> ids, PublicKeyHash local_id, CatChainSessionId unique_hash, std::string db_root, std::vector<CatChainNode> ids, PublicKeyHash local_id, CatChainSessionId unique_hash, std::string db_root,
bool allow_unsafe_self_blocks_resync) { std::string db_suffix, bool allow_unsafe_self_blocks_resync) {
auto A = td::actor::create_actor<CatChainReceiverImpl>("catchainreceiver", std::move(callback), std::move(opts), auto A = td::actor::create_actor<CatChainReceiverImpl>(
keyring, adnl, overlay_manager, std::move(ids), local_id, "catchainreceiver", std::move(callback), std::move(opts), keyring, adnl, overlay_manager, std::move(ids),
unique_hash, db_root, allow_unsafe_self_blocks_resync); local_id, unique_hash, db_root, db_suffix, allow_unsafe_self_blocks_resync);
return std::move(A); return std::move(A);
} }
@ -1058,7 +1060,7 @@ static void destroy_db(std::string name, td::uint32 attempt) {
} }
void CatChainReceiverImpl::destroy() { void CatChainReceiverImpl::destroy() {
auto name = db_root_ + "/catchainreceiver-" + td::base64url_encode(as_slice(incarnation_)); auto name = db_root_ + "/catchainreceiver" + db_suffix_ + td::base64url_encode(as_slice(incarnation_));
delay_action([name]() { destroy_db(name, 0); }, td::Timestamp::in(1.0)); delay_action([name]() { destroy_db(name, 0); }, td::Timestamp::in(1.0));
stop(); stop();
} }

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -144,7 +144,8 @@ class CatChainReceiverImpl : public CatChainReceiver {
CatChainReceiverImpl(std::unique_ptr<Callback> callback, CatChainOptions opts, CatChainReceiverImpl(std::unique_ptr<Callback> callback, CatChainOptions opts,
td::actor::ActorId<keyring::Keyring> keyring, td::actor::ActorId<adnl::Adnl> adnl, td::actor::ActorId<keyring::Keyring> keyring, td::actor::ActorId<adnl::Adnl> adnl,
td::actor::ActorId<overlay::Overlays>, std::vector<CatChainNode> ids, PublicKeyHash local_id, td::actor::ActorId<overlay::Overlays>, std::vector<CatChainNode> ids, PublicKeyHash local_id,
CatChainBlockHash unique_hash, std::string db_root, bool allow_unsafe_self_blocks_resync); CatChainBlockHash unique_hash, std::string db_root, std::string db_suffix,
bool allow_unsafe_self_blocks_resync);
private: private:
std::unique_ptr<overlay::Overlays::Callback> make_callback() { std::unique_ptr<overlay::Overlays::Callback> make_callback() {
@ -220,6 +221,7 @@ class CatChainReceiverImpl : public CatChainReceiver {
td::Timestamp next_rotate_; td::Timestamp next_rotate_;
std::string db_root_; std::string db_root_;
std::string db_suffix_;
using DbType = td::KeyValueAsync<CatChainBlockHash, td::BufferSlice>; using DbType = td::KeyValueAsync<CatChainBlockHash, td::BufferSlice>;
DbType db_; DbType db_;

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -223,8 +223,11 @@ CatChainImpl::CatChainImpl(std::unique_ptr<Callback> callback, CatChainOptions o
td::actor::ActorId<keyring::Keyring> keyring, td::actor::ActorId<adnl::Adnl> adnl, td::actor::ActorId<keyring::Keyring> keyring, td::actor::ActorId<adnl::Adnl> adnl,
td::actor::ActorId<overlay::Overlays> overlay_manager, std::vector<CatChainNode> ids, td::actor::ActorId<overlay::Overlays> overlay_manager, std::vector<CatChainNode> ids,
PublicKeyHash local_id, CatChainSessionId unique_hash, std::string db_root, PublicKeyHash local_id, CatChainSessionId unique_hash, std::string db_root,
bool allow_unsafe_self_blocks_resync) std::string db_suffix, bool allow_unsafe_self_blocks_resync)
: opts_(std::move(opts)), db_root_(db_root), allow_unsafe_self_blocks_resync_(allow_unsafe_self_blocks_resync) { : opts_(std::move(opts))
, db_root_(db_root)
, db_suffix_(db_suffix)
, allow_unsafe_self_blocks_resync_(allow_unsafe_self_blocks_resync) {
callback_ = std::move(callback); callback_ = std::move(callback);
sources_.resize(ids.size()); sources_.resize(ids.size());
unique_hash_ = unique_hash; unique_hash_ = unique_hash;
@ -281,9 +284,9 @@ void CatChainImpl::start_up() {
auto cb = std::make_unique<ChainCb>(actor_id(this)); auto cb = std::make_unique<ChainCb>(actor_id(this));
receiver_ = CatChainReceiverInterface::create(std::move(cb), opts_, args_->keyring, args_->adnl, receiver_ = CatChainReceiverInterface::create(
args_->overlay_manager, std::move(args_->ids), args_->local_id, std::move(cb), opts_, args_->keyring, args_->adnl, args_->overlay_manager, std::move(args_->ids), args_->local_id,
args_->unique_hash, db_root_, allow_unsafe_self_blocks_resync_); args_->unique_hash, db_root_, db_suffix_, allow_unsafe_self_blocks_resync_);
args_ = nullptr; args_ = nullptr;
//alarm_timestamp() = td::Timestamp::in(opts_.idle_timeout); //alarm_timestamp() = td::Timestamp::in(opts_.idle_timeout);
} }
@ -294,10 +297,10 @@ td::actor::ActorOwn<CatChain> CatChain::create(std::unique_ptr<Callback> callbac
td::actor::ActorId<overlay::Overlays> overlay_manager, td::actor::ActorId<overlay::Overlays> overlay_manager,
std::vector<CatChainNode> ids, PublicKeyHash local_id, std::vector<CatChainNode> ids, PublicKeyHash local_id,
CatChainSessionId unique_hash, std::string db_root, CatChainSessionId unique_hash, std::string db_root,
bool allow_unsafe_self_blocks_resync) { std::string db_suffix, bool allow_unsafe_self_blocks_resync) {
return td::actor::create_actor<CatChainImpl>("catchain", std::move(callback), std::move(opts), keyring, adnl, return td::actor::create_actor<CatChainImpl>("catchain", std::move(callback), std::move(opts), keyring, adnl,
overlay_manager, std::move(ids), local_id, unique_hash, db_root, overlay_manager, std::move(ids), local_id, unique_hash, db_root,
allow_unsafe_self_blocks_resync); db_suffix, allow_unsafe_self_blocks_resync);
} }
CatChainBlock *CatChainImpl::get_block(CatChainBlockHash hash) const { CatChainBlock *CatChainImpl::get_block(CatChainBlockHash hash) const {

View file

@ -102,7 +102,7 @@ class CatChain : public td::actor::Actor {
td::actor::ActorId<adnl::Adnl> adnl, td::actor::ActorId<adnl::Adnl> adnl,
td::actor::ActorId<overlay::Overlays> overlay_manager, td::actor::ActorId<overlay::Overlays> overlay_manager,
std::vector<CatChainNode> ids, PublicKeyHash local_id, std::vector<CatChainNode> ids, PublicKeyHash local_id,
CatChainSessionId unique_hash, std::string db_root, CatChainSessionId unique_hash, std::string db_root, std::string db_suffix,
bool allow_unsafe_self_blocks_resync); bool allow_unsafe_self_blocks_resync);
virtual ~CatChain() = default; virtual ~CatChain() = default;
}; };

View file

@ -51,6 +51,7 @@ class CatChainImpl : public CatChain {
bool receiver_started_ = false; bool receiver_started_ = false;
std::string db_root_; std::string db_root_;
std::string db_suffix_;
bool allow_unsafe_self_blocks_resync_; bool allow_unsafe_self_blocks_resync_;
void send_process(); void send_process();
@ -119,7 +120,7 @@ class CatChainImpl : public CatChain {
CatChainImpl(std::unique_ptr<Callback> callback, CatChainOptions opts, td::actor::ActorId<keyring::Keyring> keyring, CatChainImpl(std::unique_ptr<Callback> callback, CatChainOptions opts, td::actor::ActorId<keyring::Keyring> keyring,
td::actor::ActorId<adnl::Adnl> adnl, td::actor::ActorId<overlay::Overlays> overlay_manager, td::actor::ActorId<adnl::Adnl> adnl, td::actor::ActorId<overlay::Overlays> overlay_manager,
std::vector<CatChainNode> ids, PublicKeyHash local_id, CatChainSessionId unique_hash, std::vector<CatChainNode> ids, PublicKeyHash local_id, CatChainSessionId unique_hash,
std::string db_root, bool allow_unsafe_self_blocks_resync); std::string db_root, std::string db_suffix, bool allow_unsafe_self_blocks_resync);
void alarm() override; void alarm() override;
void start_up() override; void start_up() override;

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "errorlog.h" #include "errorlog.h"
#include "checksum.h" #include "checksum.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "crypto/block/Binlog.h" #include "crypto/block/Binlog.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -23,7 +23,7 @@
exception statement from your version. If you delete this exception statement exception statement from your version. If you delete this exception statement
from all source files in the program, then also delete it here. from all source files in the program, then also delete it here.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "block/block.h" #include "block/block.h"
#include "vm/boc.h" #include "vm/boc.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once
#include "td/utils/int_types.h" #include "td/utils/int_types.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once
#include <string> #include <string>

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "block-db.h" #include "block-db.h"
#include "block-db-impl.h" #include "block-db-impl.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once
#include "td/utils/int_types.h" #include "td/utils/int_types.h"

View file

@ -679,11 +679,22 @@ config_fwd_prices#_ MsgForwardPrices = ConfigParam 25;
catchain_config#c1 mc_catchain_lifetime:uint32 shard_catchain_lifetime:uint32 catchain_config#c1 mc_catchain_lifetime:uint32 shard_catchain_lifetime:uint32
shard_validators_lifetime:uint32 shard_validators_num:uint32 = CatchainConfig; shard_validators_lifetime:uint32 shard_validators_num:uint32 = CatchainConfig;
catchain_config_new#c2 flags:(## 7) { flags = 0 } shuffle_mc_validators:Bool
mc_catchain_lifetime:uint32 shard_catchain_lifetime:uint32
shard_validators_lifetime:uint32 shard_validators_num:uint32 = CatchainConfig;
consensus_config#d6 round_candidates:# { round_candidates >= 1 } consensus_config#d6 round_candidates:# { round_candidates >= 1 }
next_candidate_delay_ms:uint32 consensus_timeout_ms:uint32 next_candidate_delay_ms:uint32 consensus_timeout_ms:uint32
fast_attempts:uint32 attempt_duration:uint32 catchain_max_deps:uint32 fast_attempts:uint32 attempt_duration:uint32 catchain_max_deps:uint32
max_block_bytes:uint32 max_collated_bytes:uint32 = ConsensusConfig; max_block_bytes:uint32 max_collated_bytes:uint32 = ConsensusConfig;
consensus_config_new#d7 flags:(## 7) { flags = 0 } new_catchain_ids:Bool
round_candidates:(## 8) { round_candidates >= 1 }
next_candidate_delay_ms:uint32 consensus_timeout_ms:uint32
fast_attempts:uint32 attempt_duration:uint32 catchain_max_deps:uint32
max_block_bytes:uint32 max_collated_bytes:uint32 = ConsensusConfig;
_ CatchainConfig = ConfigParam 28; _ CatchainConfig = ConfigParam 28;
_ ConsensusConfig = ConfigParam 29; _ ConsensusConfig = ConfigParam 29;
@ -721,7 +732,7 @@ top_block_descr_set#4ac789f3 collection:(HashmapE 96 ^TopBlockDescr) = TopBlockD
// VALIDATOR MISBEHAVIOR COMPLAINTS // VALIDATOR MISBEHAVIOR COMPLAINTS
// //
no_blk_gen mc_blk_ref:ExtBlkRef from_utime:uint32 to_utime:uint32 state_proof:^Cell prod_proof:^Cell = ComplaintDescr; no_blk_gen mc_blk_ref:ExtBlkRef from_utime:uint32 to_utime:uint32 state_proof:^Cell prod_proof:^Cell = ComplaintDescr;
validator_complaint#ba validator_pubkey:uint256 description:^ComplaintDescr severity:uint8 reward_addr:uint256 paid:Grams suggested_fine:Grams suggested_fine_part:uint32 = ValidatorComplaint; validator_complaint#bc validator_pubkey:uint256 description:^ComplaintDescr created_at:uint32 severity:uint8 reward_addr:uint256 paid:Grams suggested_fine:Grams suggested_fine_part:uint32 = ValidatorComplaint;
complaint_status#2d complaint:^ValidatorComplaint voters:(HashmapE 16 True) vset_id:uint256 weight_remaining:int64 = ValidatorComplaintStatus; complaint_status#2d complaint:^ValidatorComplaint voters:(HashmapE 16 True) vset_id:uint256 weight_remaining:int64 = ValidatorComplaintStatus;
// //

View file

@ -310,8 +310,7 @@ td::Status Config::visit_validator_params() const {
ton::ValidatorSessionConfig Config::get_consensus_config() const { ton::ValidatorSessionConfig Config::get_consensus_config() const {
auto cc = get_config_param(29); auto cc = get_config_param(29);
ton::ValidatorSessionConfig c; ton::ValidatorSessionConfig c;
block::gen::ConsensusConfig::Record r; auto set = [&c](auto& r, bool new_cc_ids) {
if (cc.not_null() && tlb::unpack_cell(cc, r)) {
c.catchain_idle_timeout = r.consensus_timeout_ms * 0.001; c.catchain_idle_timeout = r.consensus_timeout_ms * 0.001;
c.catchain_max_deps = r.catchain_max_deps; c.catchain_max_deps = r.catchain_max_deps;
c.round_candidates = r.round_candidates; c.round_candidates = r.round_candidates;
@ -320,6 +319,13 @@ ton::ValidatorSessionConfig Config::get_consensus_config() const {
c.max_round_attempts = r.fast_attempts; c.max_round_attempts = r.fast_attempts;
c.max_block_size = r.max_block_bytes; c.max_block_size = r.max_block_bytes;
c.max_collated_data_size = r.max_collated_bytes; c.max_collated_data_size = r.max_collated_bytes;
c.new_catchain_ids = new_cc_ids;
return true;
};
if (cc.not_null()) {
block::gen::ConsensusConfig::Record_consensus_config_new r1;
block::gen::ConsensusConfig::Record_consensus_config r0;
(tlb::unpack_cell(cc, r1) && set(r1, r1.new_catchain_ids)) || (tlb::unpack_cell(cc, r0) && set(r0, false));
} }
return c; return c;
} }
@ -671,14 +677,20 @@ td::Result<MsgPrices> Config::get_msg_prices(bool is_masterchain) const {
} }
CatchainValidatorsConfig Config::unpack_catchain_validators_config(Ref<vm::Cell> cell) { CatchainValidatorsConfig Config::unpack_catchain_validators_config(Ref<vm::Cell> cell) {
block::gen::CatchainConfig::Record cfg; if (cell.not_null()) {
if (cell.is_null() || !tlb::unpack_cell(std::move(cell), cfg)) { block::gen::CatchainConfig::Record_catchain_config cfg;
return {default_mc_catchain_lifetime, default_shard_catchain_lifetime, default_shard_validators_lifetime, if (tlb::unpack_cell(cell, cfg)) {
default_shard_validators_num}; return {cfg.mc_catchain_lifetime, cfg.shard_catchain_lifetime, cfg.shard_validators_lifetime,
} else { cfg.shard_validators_num};
return {cfg.mc_catchain_lifetime, cfg.shard_catchain_lifetime, cfg.shard_validators_lifetime, }
cfg.shard_validators_num}; block::gen::CatchainConfig::Record_catchain_config_new cfg2;
if (tlb::unpack_cell(std::move(cell), cfg2)) {
return {cfg2.mc_catchain_lifetime, cfg2.shard_catchain_lifetime, cfg2.shard_validators_lifetime,
cfg2.shard_validators_num, cfg2.shuffle_mc_validators};
}
} }
return {default_mc_catchain_lifetime, default_shard_catchain_lifetime, default_shard_validators_lifetime,
default_shard_validators_num};
} }
CatchainValidatorsConfig Config::get_catchain_validators_config() const { CatchainValidatorsConfig Config::get_catchain_validators_config() const {
@ -1215,47 +1227,47 @@ std::vector<ton::BlockId> ShardConfig::get_shard_hash_ids(
std::vector<ton::BlockId> res; std::vector<ton::BlockId> res;
bool mcout = mc_shard_hash_.is_null() || !mc_shard_hash_->seqno(); // include masterchain as a shard if seqno > 0 bool mcout = mc_shard_hash_.is_null() || !mc_shard_hash_->seqno(); // include masterchain as a shard if seqno > 0
bool ok = shard_hashes_dict_->check_for_each( bool ok = shard_hashes_dict_->check_for_each(
[&res, &mcout, mc_shard_hash_ = mc_shard_hash_, &filter ](Ref<vm::CellSlice> cs_ref, td::ConstBitPtr key, int n) [&res, &mcout, mc_shard_hash_ = mc_shard_hash_, &filter](Ref<vm::CellSlice> cs_ref, td::ConstBitPtr key,
->bool { int n) -> bool {
int workchain = (int)key.get_int(n); int workchain = (int)key.get_int(n);
if (workchain >= 0 && !mcout) { if (workchain >= 0 && !mcout) {
if (filter(ton::ShardIdFull{ton::masterchainId}, true)) { if (filter(ton::ShardIdFull{ton::masterchainId}, true)) {
res.emplace_back(mc_shard_hash_->blk_.id); res.emplace_back(mc_shard_hash_->blk_.id);
} }
mcout = true; mcout = true;
} }
if (!cs_ref->have_refs()) { if (!cs_ref->have_refs()) {
return false;
}
std::stack<std::pair<Ref<vm::Cell>, unsigned long long>> stack;
stack.emplace(cs_ref->prefetch_ref(), ton::shardIdAll);
while (!stack.empty()) {
vm::CellSlice cs{vm::NoVmOrd(), std::move(stack.top().first)};
unsigned long long shard = stack.top().second;
stack.pop();
int t = (int)cs.fetch_ulong(1);
if (t < 0) {
return false;
}
if (!filter(ton::ShardIdFull{workchain, shard}, !t)) {
continue;
}
if (!t) {
if (!(cs.advance(4) && cs.have(32))) {
return false; return false;
} }
std::stack<std::pair<Ref<vm::Cell>, unsigned long long>> stack; res.emplace_back(workchain, shard, (int)cs.prefetch_ulong(32));
stack.emplace(cs_ref->prefetch_ref(), ton::shardIdAll); continue;
while (!stack.empty()) { }
vm::CellSlice cs{vm::NoVmOrd(), std::move(stack.top().first)}; unsigned long long delta = (td::lower_bit64(shard) >> 1);
unsigned long long shard = stack.top().second; if (!delta || cs.size_ext() != 0x20000) {
stack.pop(); return false;
int t = (int)cs.fetch_ulong(1); }
if (t < 0) { stack.emplace(cs.prefetch_ref(1), shard + delta);
return false; stack.emplace(cs.prefetch_ref(0), shard - delta);
} }
if (!filter(ton::ShardIdFull{workchain, shard}, !t)) { return true;
continue; },
}
if (!t) {
if (!(cs.advance(4) && cs.have(32))) {
return false;
}
res.emplace_back(workchain, shard, (int)cs.prefetch_ulong(32));
continue;
}
unsigned long long delta = (td::lower_bit64(shard) >> 1);
if (!delta || cs.size_ext() != 0x20000) {
return false;
}
stack.emplace(cs.prefetch_ref(1), shard + delta);
stack.emplace(cs.prefetch_ref(0), shard - delta);
}
return true;
},
true); true);
if (!ok) { if (!ok) {
return {}; return {};
@ -1611,8 +1623,8 @@ td::Result<std::vector<ton::StdSmcAddress>> Config::get_special_smartcontracts(b
return td::Status::Error(-666, "configuration loaded without fundamental smart contract list"); return td::Status::Error(-666, "configuration loaded without fundamental smart contract list");
} }
std::vector<ton::StdSmcAddress> res; std::vector<ton::StdSmcAddress> res;
if (!special_smc_dict->check_for_each([&res, &without_config, conf_addr = config_addr.bits() ]( if (!special_smc_dict->check_for_each([&res, &without_config, conf_addr = config_addr.bits()](
Ref<vm::CellSlice> cs_ref, td::ConstBitPtr key, int n) { Ref<vm::CellSlice> cs_ref, td::ConstBitPtr key, int n) {
if (cs_ref->size_ext() || n != 256) { if (cs_ref->size_ext() || n != 256) {
return false; return false;
} }
@ -1786,18 +1798,32 @@ std::vector<ton::ValidatorDescr> Config::do_compute_validator_set(const block::C
return {}; // no validators? return {}; // no validators?
} }
nodes.reserve(count); nodes.reserve(count);
ValidatorSetPRNG gen{shard, cc_seqno}; // use zero seed (might use a non-trivial seed from ccv_conf in the future)
if (is_mc) { if (is_mc) {
// simply take needed number of validators from the head of the list if (ccv_conf.shuffle_mc_val) {
// TODO: write a more clever validator list selection algorithm // shuffle mc validators from the head of the list
// (if we really need one for the masterchain) std::vector<unsigned> idx(count);
for (unsigned i = 0; i < count; i++) { CHECK(idx.size() == count);
const auto& v = vset.list[i]; for (unsigned i = 0; i < count; i++) {
nodes.emplace_back(v.pubkey, v.weight, v.adnl_addr); unsigned j = (unsigned)gen.next_ranged(i + 1); // number 0 .. i
CHECK(j <= i);
idx[i] = idx[j];
idx[j] = i;
}
for (unsigned i = 0; i < count; i++) {
const auto& v = vset.list[idx[i]];
nodes.emplace_back(v.pubkey, v.weight, v.adnl_addr);
}
} else {
// simply take needed number of validators from the head of the list
for (unsigned i = 0; i < count; i++) {
const auto& v = vset.list[i];
nodes.emplace_back(v.pubkey, v.weight, v.adnl_addr);
}
} }
return nodes; return nodes;
} }
// this is the "true" algorithm for generating shardchain validator subgroups // this is the "true" algorithm for generating shardchain validator subgroups
ValidatorSetPRNG gen{shard, cc_seqno}; // use zero seed (might use a non-trivial seed from ccv_conf in the future)
std::vector<std::pair<td::uint64, td::uint64>> holes; std::vector<std::pair<td::uint64, td::uint64>> holes;
holes.reserve(count); holes.reserve(count);
td::uint64 total_wt = vset.total_weight; td::uint64 total_wt = vset.total_weight;

View file

@ -50,7 +50,7 @@ struct ValidatorDescr {
: pubkey(_pubkey), weight(_weight), cum_weight(_cum_weight) { : pubkey(_pubkey), weight(_weight), cum_weight(_cum_weight) {
adnl_addr.set_zero(); adnl_addr.set_zero();
} }
bool operator<(td::uint64 wt_pos) const & { bool operator<(td::uint64 wt_pos) const& {
return cum_weight < wt_pos; return cum_weight < wt_pos;
} }
}; };
@ -372,11 +372,14 @@ struct MsgPrices {
struct CatchainValidatorsConfig { struct CatchainValidatorsConfig {
td::uint32 mc_cc_lifetime, shard_cc_lifetime, shard_val_lifetime, shard_val_num; td::uint32 mc_cc_lifetime, shard_cc_lifetime, shard_val_lifetime, shard_val_num;
CatchainValidatorsConfig(td::uint32 mc_cc_lt_, td::uint32 sh_cc_lt_, td::uint32 sh_val_lt_, td::uint32 sh_val_num_) bool shuffle_mc_val;
CatchainValidatorsConfig(td::uint32 mc_cc_lt_, td::uint32 sh_cc_lt_, td::uint32 sh_val_lt_, td::uint32 sh_val_num_,
bool shuffle_mc = false)
: mc_cc_lifetime(mc_cc_lt_) : mc_cc_lifetime(mc_cc_lt_)
, shard_cc_lifetime(sh_cc_lt_) , shard_cc_lifetime(sh_cc_lt_)
, shard_val_lifetime(sh_val_lt_) , shard_val_lifetime(sh_val_lt_)
, shard_val_num(sh_val_num_) { , shard_val_num(sh_val_num_)
, shuffle_mc_val(shuffle_mc) {
} }
}; };

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "output-queue-merger.h" #include "output-queue-merger.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once
#include "ton/ton-types.h" #include "ton/ton-types.h"

View file

@ -607,7 +607,7 @@ bool Transaction::unpack_input_msg(bool ihr_delivered, const ActionPhaseConfig*
return true; return true;
} }
bool Transaction::prepare_storage_phase(const StoragePhaseConfig& cfg, bool force_collect) { bool Transaction::prepare_storage_phase(const StoragePhaseConfig& cfg, bool force_collect, bool adjust_msg_value) {
if (now < account.last_paid) { if (now < account.last_paid) {
return false; return false;
} }
@ -657,6 +657,9 @@ bool Transaction::prepare_storage_phase(const StoragePhaseConfig& cfg, bool forc
} }
} }
} }
if (adjust_msg_value && msg_balance_remaining.grams > balance.grams) {
msg_balance_remaining.grams = balance.grams;
}
total_fees += res->fees_collected; total_fees += res->fees_collected;
storage_phase = std::move(res); storage_phase = std::move(res);
return true; return true;
@ -773,7 +776,7 @@ bool Transaction::compute_gas_limits(ComputePhase& cp, const ComputePhaseConfig&
} else { } else {
// originally use only gas bought using remaining message balance // originally use only gas bought using remaining message balance
// if the message is "accepted" by the smart contract, the gas limit will be set to gas_max // if the message is "accepted" by the smart contract, the gas limit will be set to gas_max
cp.gas_limit = cfg.gas_bought_for(msg_balance_remaining.grams); cp.gas_limit = std::min(cfg.gas_bought_for(msg_balance_remaining.grams), cp.gas_max);
if (!block::tlb::t_Message.is_internal(in_msg)) { if (!block::tlb::t_Message.is_internal(in_msg)) {
// external messages carry no balance, give them some credit to check whether they are accepted // external messages carry no balance, give them some credit to check whether they are accepted
cp.gas_credit = std::min(cfg.gas_credit, cp.gas_max); cp.gas_credit = std::min(cfg.gas_credit, cp.gas_max);

View file

@ -65,10 +65,10 @@ struct NewOutMsg {
NewOutMsg(ton::LogicalTime _lt, Ref<vm::Cell> _msg, Ref<vm::Cell> _trans) NewOutMsg(ton::LogicalTime _lt, Ref<vm::Cell> _msg, Ref<vm::Cell> _trans)
: lt(_lt), msg(std::move(_msg)), trans(std::move(_trans)) { : lt(_lt), msg(std::move(_msg)), trans(std::move(_trans)) {
} }
bool operator<(const NewOutMsg& other) const & { bool operator<(const NewOutMsg& other) const& {
return lt < other.lt || (lt == other.lt && msg->get_hash() < other.msg->get_hash()); return lt < other.lt || (lt == other.lt && msg->get_hash() < other.msg->get_hash());
} }
bool operator>(const NewOutMsg& other) const & { bool operator>(const NewOutMsg& other) const& {
return lt > other.lt || (lt == other.lt && other.msg->get_hash() < msg->get_hash()); return lt > other.lt || (lt == other.lt && other.msg->get_hash() < msg->get_hash());
} }
}; };
@ -344,7 +344,7 @@ struct Transaction {
Ref<vm::Cell> _inmsg = {}); Ref<vm::Cell> _inmsg = {});
bool unpack_input_msg(bool ihr_delivered, const ActionPhaseConfig* cfg); bool unpack_input_msg(bool ihr_delivered, const ActionPhaseConfig* cfg);
bool check_in_msg_state_hash(); bool check_in_msg_state_hash();
bool prepare_storage_phase(const StoragePhaseConfig& cfg, bool force_collect = true); bool prepare_storage_phase(const StoragePhaseConfig& cfg, bool force_collect = true, bool adjust_msg_value = false);
bool prepare_credit_phase(); bool prepare_credit_phase();
bool compute_gas_limits(ComputePhase& cp, const ComputePhaseConfig& cfg); bool compute_gas_limits(ComputePhase& cp, const ComputePhaseConfig& cfg);
Ref<vm::Stack> prepare_vm_stack(ComputePhase& cp); Ref<vm::Stack> prepare_vm_stack(ComputePhase& cp);

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "bigexp.h" #include "bigexp.h"
#include "td/utils/bits.h" #include "td/utils/bits.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "common/bigint.hpp" #include "common/bigint.hpp"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "refcnt.hpp" #include "refcnt.hpp"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "Ed25519.h" #include "Ed25519.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "ellcurve/Fp25519.h" #include "ellcurve/Fp25519.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once
#include "common/refcnt.hpp" #include "common/refcnt.hpp"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "ellcurve/Montgomery.h" #include "ellcurve/Montgomery.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once
#include <iostream> #include <iostream>

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "ellcurve/TwEdwards.h" #include "ellcurve/TwEdwards.h"
#include <assert.h> #include <assert.h>

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once
#include <vector> #include <vector>

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "Dictionary.h" #include "Dictionary.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "Fift.h" #include "Fift.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "IntCtx.h" #include "IntCtx.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "SourceLookup.h" #include "SourceLookup.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once
#include <iostream> #include <iostream>

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "utils.h" #include "utils.h"
#include "words.h" #include "words.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once

View file

@ -23,7 +23,7 @@
exception statement from your version. If you delete this exception statement exception statement from your version. If you delete this exception statement
from all source files in the program, then also delete it here. from all source files in the program, then also delete it here.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "func.h" #include "func.h"
#include "parser/srcread.h" #include "parser/srcread.h"

View file

@ -63,7 +63,7 @@ inline bool is_special_ident(sym_idx_t idx) {
*/ */
// TE ::= TA | TA -> TE // TE ::= TA | TA -> TE
// TA ::= int | ... | cont | var | _ | () | ( TE { , TE } ) // TA ::= int | ... | cont | var | _ | () | ( TE { , TE } ) | [ TE { , TE } ]
TypeExpr* parse_type(Lexer& lex); TypeExpr* parse_type(Lexer& lex);
TypeExpr* parse_type1(Lexer& lex) { TypeExpr* parse_type1(Lexer& lex) {
@ -113,7 +113,7 @@ TypeExpr* parse_type1(Lexer& lex) {
return c == ')' ? TypeExpr::new_unit() : TypeExpr::new_tuple({}); return c == ')' ? TypeExpr::new_unit() : TypeExpr::new_tuple({});
} }
auto t1 = parse_type(lex); auto t1 = parse_type(lex);
if (lex.tp() != ',') { if (lex.tp() == ')') {
lex.expect(c); lex.expect(c);
return t1; return t1;
} }
@ -346,7 +346,7 @@ Expr* parse_expr100(Lexer& lex, CodeBlob& code, bool nv) {
return res; return res;
} }
Expr* res = parse_expr(lex, code, nv); Expr* res = parse_expr(lex, code, nv);
if (lex.tp() != ',') { if (lex.tp() == ')') {
lex.expect(clbr); lex.expect(clbr);
return res; return res;
} }

View file

@ -334,7 +334,7 @@ std::string UnifyError::message() const {
void check_width_compat(TypeExpr* te1, TypeExpr* te2) { void check_width_compat(TypeExpr* te1, TypeExpr* te2) {
if (te1->minw > te2->maxw || te2->minw > te1->maxw) { if (te1->minw > te2->maxw || te2->minw > te1->maxw) {
std::ostringstream os{"cannot unify types of widths "}; std::ostringstream os{"cannot unify types of widths ", std::ios_base::ate};
te1->show_width(os); te1->show_width(os);
os << " and "; os << " and ";
te2->show_width(os); te2->show_width(os);

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "openssl/rand.hpp" #include "openssl/rand.hpp"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once
#include <string> #include <string>

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "residue.h" #include "residue.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once
#include "bignum.h" #include "bignum.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "lexer.h" #include "lexer.h"
#include "symtable.h" #include "symtable.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once
#include "srcread.h" #include "srcread.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "symtable.h" #include "symtable.h"
#include <sstream> #include <sstream>

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once
#include "srcread.h" #include "srcread.h"

View file

@ -142,12 +142,12 @@ variable special-dict
{ make-msg-fwd-prices 24 config! } : config.mc_fwd_prices! { make-msg-fwd-prices 24 config! } : config.mc_fwd_prices!
{ make-msg-fwd-prices 25 config! } : config.fwd_prices! { make-msg-fwd-prices 25 config! } : config.fwd_prices!
// mc-cc-lifetime sh-cc-lifetime sh-val-lifetime sh-val-num // mc-cc-lifetime sh-cc-lifetime sh-val-lifetime sh-val-num mc-shuffle
{ 4 0 reverse <b x{c1} s, swap 32 u, swap 32 u, swap 32 u, swap 32 u, b> { 4 1 reverse <b x{c201_} s, swap 1 i, swap 32 u, swap 32 u, swap 32 u, swap 32 u, b>
} : make-catchain-params } : make-catchain-params
{ make-catchain-params 28 config! } : config.catchain_params! { make-catchain-params 28 config! } : config.catchain_params!
// round-candidates next-cand-delay-ms consensus-timeout-ms fast-attempts attempt-duration cc-max-deps max-block-size max-collated-size // round-candidates next-cand-delay-ms consensus-timeout-ms fast-attempts attempt-duration cc-max-deps max-block-size max-collated-size new-cc-ids
{ 8 0 reverse <b x{d6} s, { swap 32 u, } 8 times b> } : make-vsession-params { 8 1 reverse <b x{d701_} s, swap 1 i, swap 8 u, { swap 32 u, } 7 times b> } : make-vsession-params
{ make-vsession-params 29 config! } : config.consensus_params! { make-vsession-params 29 config! } : config.consensus_params!
// b [underload soft hard] -- b' // b [underload soft hard] -- b'

View file

@ -76,21 +76,22 @@ builder pack_complaint_status(cell complaint, cell voters, int vset_id, int weig
.store_int(weight_remaining, 64); .store_int(weight_remaining, 64);
} }
;; validator_complaint#ba validator_pubkey:uint256 description:^ComplaintDescr ;; validator_complaint#bc validator_pubkey:uint256 description:^ComplaintDescr
;; severity:uint8 reward_addr:uint256 paid:Grams suggested_fine:Grams ;; created_at:uint32 severity:uint8 reward_addr:uint256 paid:Grams suggested_fine:Grams
;; suggested_fine_part:uint32 = ValidatorComplaint; ;; suggested_fine_part:uint32 = ValidatorComplaint;
_ unpack_complaint(slice cs) inline_ref { _ unpack_complaint(slice cs) inline_ref {
throw_unless(9, cs~load_int(8) == 0xba - 0x100); throw_unless(9, cs~load_int(8) == 0xbc - 0x100);
var res = (cs~load_uint(256), cs~load_ref(), cs~load_uint(8), cs~load_uint(256), cs~load_grams(), cs~load_grams(), cs~load_uint(32)); var res = (cs~load_uint(256), cs~load_ref(), cs~load_uint(32), cs~load_uint(8), cs~load_uint(256), cs~load_grams(), cs~load_grams(), cs~load_uint(32));
cs.end_parse(); cs.end_parse();
return res; return res;
} }
builder pack_complaint(int validator_pubkey, cell description, int severity, int reward_addr, int paid, int suggested_fine, int suggested_fine_part) inline_ref { builder pack_complaint(int validator_pubkey, cell description, int created_at, int severity, int reward_addr, int paid, int suggested_fine, int suggested_fine_part) inline_ref {
return begin_cell() return begin_cell()
.store_int(0xba - 0x100, 8) .store_int(0xbc - 0x100, 8)
.store_uint(validator_pubkey, 256) .store_uint(validator_pubkey, 256)
.store_ref(description) .store_ref(description)
.store_uint(created_at, 32)
.store_uint(severity, 8) .store_uint(severity, 8)
.store_uint(reward_addr, 256) .store_uint(reward_addr, 256)
.store_grams(paid) .store_grams(paid)
@ -459,8 +460,9 @@ int register_complaint(s_addr, complaint, msg_value) {
if (expire_in <= 0) { ;; already expired if (expire_in <= 0) { ;; already expired
return -4; return -4;
} }
var (validator_pubkey, description, severity, reward_addr, paid, suggested_fine, suggested_fine_part) = unpack_complaint(complaint); var (validator_pubkey, description, created_at, severity, reward_addr, paid, suggested_fine, suggested_fine_part) = unpack_complaint(complaint);
reward_addr = src_addr; reward_addr = src_addr;
created_at = now();
;; compute complaint storage/creation price ;; compute complaint storage/creation price
var (deposit, bit_price, cell_price) = get_complaint_prices(); var (deposit, bit_price, cell_price) = get_complaint_prices();
var (_, bits, refs) = slice_compute_data_size(complaint, 4096); var (_, bits, refs) = slice_compute_data_size(complaint, 4096);
@ -470,7 +472,7 @@ int register_complaint(s_addr, complaint, msg_value) {
return -5; return -5;
} }
;; re-pack modified complaint ;; re-pack modified complaint
cell complaint = pack_complaint(validator_pubkey, description, severity, reward_addr, paid, suggested_fine, suggested_fine_part).end_cell(); cell complaint = pack_complaint(validator_pubkey, description, created_at, severity, reward_addr, paid, suggested_fine, suggested_fine_part).end_cell();
var (unfreeze_at, stake_held, vset_hash, frozen_dict, total_stake, bonuses, complaints) = unpack_past_election(fs); var (unfreeze_at, stake_held, vset_hash, frozen_dict, total_stake, bonuses, complaints) = unpack_past_election(fs);
var (fs, f) = frozen_dict.udict_get?(256, validator_pubkey); var (fs, f) = frozen_dict.udict_get?(256, validator_pubkey);
ifnot (f) { ;; no such validator, cannot complain ifnot (f) { ;; no such validator, cannot complain
@ -502,7 +504,7 @@ int register_complaint(s_addr, complaint, msg_value) {
} }
(cell, cell, int) punish(credits, frozen, complaint) inline_ref { (cell, cell, int) punish(credits, frozen, complaint) inline_ref {
var (validator_pubkey, description, severity, reward_addr, paid, suggested_fine, suggested_fine_part) = complaint.begin_parse().unpack_complaint(); var (validator_pubkey, description, created_at, severity, reward_addr, paid, suggested_fine, suggested_fine_part) = complaint.begin_parse().unpack_complaint();
var (cs, f) = frozen.udict_get?(256, validator_pubkey); var (cs, f) = frozen.udict_get?(256, validator_pubkey);
ifnot (f) { ifnot (f) {
;; no validator to punish ;; no validator to punish
@ -1073,3 +1075,73 @@ int compute_returned_stake(int wallet_addr) method_id {
var (val, f) = credits.udict_get?(256, wallet_addr); var (val, f) = credits.udict_get?(256, wallet_addr);
return f ? val~load_grams() : 0; return f ? val~load_grams() : 0;
} }
;; returns the list of past election ids
tuple past_election_ids() method_id {
var (elect, credits, past_elections, grams, active_id, active_hash) = load_data();
var id = (1 << 32);
var list = null();
do {
(id, var fs, var f) = past_elections.udict_get_prev?(32, id);
if (f) {
list = cons(id, list);
}
} until (~ f);
return list;
}
tuple past_elections() method_id {
var (elect, credits, past_elections, grams, active_id, active_hash) = load_data();
var id = (1 << 32);
var list = null();
do {
(id, var fs, var found) = past_elections.udict_get_prev?(32, id);
if (found) {
var info = [unpack_past_election(fs)];
list = cons(pair(id, info), list);
}
} until (~ found);
return list;
}
_ complete_unpack_complaint(slice cs) inline_ref {
var (complaint, voters, vset_id, weight_remaining) = cs.unpack_complaint_status();
var voters_list = null();
var voter_id = (1 << 32);
do {
(voter_id, _, var f) = voters.udict_get_prev?(16, voter_id);
if (f) {
voters_list = cons(voter_id, voters_list);
}
} until (~ f);
return [[complaint.begin_parse().unpack_complaint()], voters_list, vset_id, weight_remaining];
}
cell get_past_complaints(int election_id) inline_ref {
var (elect, credits, past_elections, grams, active_id, active_hash) = load_data();
var (fs, found?) = past_elections.udict_get?(32, election_id);
ifnot (found?) {
return null();
}
var (unfreeze_at, stake_held, vset_hash, frozen_dict, total_stake, bonuses, complaints) = unpack_past_election(fs);
return complaints;
}
_ show_complaint(int election_id, int chash) method_id {
var complaints = get_past_complaints(election_id);
var (cs, found) = complaints.udict_get?(256, chash);
return found ? complete_unpack_complaint(cs) : null();
}
tuple list_complaints(int election_id) method_id {
var complaints = get_past_complaints(election_id);
int id = (1 << 255) + ((1 << 255) - 1);
var list = null();
do {
(id, var cs, var found?) = complaints.udict_get_prev?(256, id);
if (found?) {
list = cons(pair(id, complete_unpack_complaint(cs)), list);
}
} until (~ found?);
return list;
}

View file

@ -25,7 +25,8 @@ hashu dup =: basestate0_rhash
."root hash=" dup 64x. space 256 u>B dup B>base64url type cr ."root hash=" dup 64x. space 256 u>B dup B>base64url type cr
"basestate0" +suffix +".rhash" B>file "basestate0" +suffix +".rhash" B>file
basestate0_rhash basestate0_fhash now 0 2 32 0 add-std-workchain // root-hash file-hash start-at actual-min-split min-split-depth max-split-depth wc-id
basestate0_rhash basestate0_fhash now 0 4 8 0 add-std-workchain
config.workchains! config.workchains!
// SmartContract #1 (Simple wallet) // SmartContract #1 (Simple wallet)
@ -157,7 +158,7 @@ Masterchain swap
* *
*/ */
// version capabilities // version capabilities
1 capCreateStats capBounceMsgBody or capReportVersion or capShortDeque or config.version! 1 capCreateStats capBounceMsgBody or capReportVersion or capShortDequeue or config.version!
// max-validators max-main-validators min-validators // max-validators max-main-validators min-validators
// 9 4 1 config.validator_num! // 9 4 1 config.validator_num!
1000 100 13 config.validator_num! 1000 100 13 config.validator_num!
@ -183,15 +184,15 @@ config.special!
// lump_price bit_price cell_price ihr_factor first_frac next_frac // lump_price bit_price cell_price ihr_factor first_frac next_frac
1000000 1000 sg* 100000 sg* 3/2 sg*/ 1/3 sg*/ 1/3 sg*/ config.fwd_prices! 1000000 1000 sg* 100000 sg* 3/2 sg*/ 1/3 sg*/ 1/3 sg*/ config.fwd_prices!
10000000 10000 sg* 1000000 sg* 3/2 sg*/ 1/3 sg*/ 1/3 sg*/ config.mc_fwd_prices! 10000000 10000 sg* 1000000 sg* 3/2 sg*/ 1/3 sg*/ 1/3 sg*/ config.mc_fwd_prices!
// mc-cc-lifetime sh-cc-lifetime sh-val-lifetime sh-val-num // mc-cc-lifetime sh-cc-lifetime sh-val-lifetime sh-val-num mc-shuffle
250 250 1000 7 config.catchain_params! 250 250 1000 7 true config.catchain_params!
// round-candidates next-cand-delay-ms consensus-timeout-ms fast-attempts attempt-duration cc-max-deps max-block-size max-collated-size // round-candidates next-cand-delay-ms consensus-timeout-ms fast-attempts attempt-duration cc-max-deps max-block-size max-collated-size new-cc-ids
3 2000 16000 3 8 4 2 *Mi 2 *Mi config.consensus_params! 3 2000 16000 3 8 4 2 *Mi 2 *Mi true config.consensus_params!
128 *Ki 512 *Ki 1 *Mi triple // [ underload soft hard ] : block bytes limit 128 *Ki 512 *Ki 1 *Mi triple // [ underload soft hard ] : block bytes limit
100000 500000 1000000 triple // gas limits 2000000 10000000 20000000 triple // gas limits
1000 5000 10000 triple // lt limits 1000 5000 10000 triple // lt limits
triple dup untriple config.mc_block_limits! triple dup untriple config.mc_block_limits!
untriple config.block_limits! untriple config.block_limits!

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "crypto/Ed25519.h" #include "crypto/Ed25519.h"
#include "td/utils/logging.h" #include "td/utils/logging.h"

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include "fift/words.h" #include "fift/words.h"
#include "fift/Fift.h" #include "fift/Fift.h"

View file

@ -23,7 +23,7 @@
exception statement from your version. If you delete this exception statement exception statement from your version. If you delete this exception statement
from all source files in the program, then also delete it here. from all source files in the program, then also delete it here.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP Copyright 2017-2020 Telegram Systems LLP
*/ */
#pragma once #pragma once
#include <vector> #include <vector>

Some files were not shown because too many files have changed in this diff Show more