2019-09-07 10:03:22 +00:00
|
|
|
/*
|
|
|
|
This file is part of TON Blockchain Library.
|
|
|
|
|
|
|
|
TON Blockchain Library is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
TON Blockchain Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Lesser General Public License for more details.
|
|
|
|
|
|
|
|
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/>.
|
|
|
|
|
2020-03-11 10:19:31 +00:00
|
|
|
Copyright 2017-2020 Telegram Systems LLP
|
2019-09-07 10:03:22 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "interfaces/validator-manager.h"
|
|
|
|
#include "shard.hpp"
|
|
|
|
#include "top-shard-descr.hpp"
|
|
|
|
#include "common/refcnt.hpp"
|
|
|
|
#include "vm/cells.h"
|
|
|
|
#include "vm/dict.h"
|
|
|
|
#include "block/mc-config.h"
|
|
|
|
#include "block/block.h"
|
|
|
|
#include "block/transaction.h"
|
|
|
|
#include "block/block-db.h"
|
|
|
|
#include "block/output-queue-merger.h"
|
|
|
|
#include "vm/cells/MerkleProof.h"
|
|
|
|
#include "vm/cells/MerkleUpdate.h"
|
|
|
|
#include <map>
|
|
|
|
#include <queue>
|
TVM Upgrade (#686)
* New TVM instructions
* Remove PREVBLOCKS
* Separate target ton_crypto into TVM-related and -unrelared code
* Add fine for failed "send message"; rework SENDMSG
* Fix include
* Fix bugs, improve action fines
* Disable fines for special accounts
* Handle msg_balance_remaining.grams == null in transaction.cpp
* Bugfixes in SENDMSG
* Fix fee calculation in SENDMSG
* Fix CellStorageStat and transaction.cpp after merge
* SETBOUNCEONACTIONPHASEFAIL instruction
* ADDDIVMOD instructions
* RUNVM, RUNVMX instructions
* Changes in RUNVM
* Tests for adddiv and runvm
* HASHEXT instruction
* Improve opcode-timing
More iterations
Don't measure preliminary run
Remove logs and other excessive operations
Add "error" to output
* Increase RUNVM gas price
* Optimize HASHEXT, adjust gas price
* Add "bounce of action fail" flag to actions
* Stack operations with unlimited arguments
* Ristretto255 instructions
* Adjust gas consumption
* Optional fixed number of return values in RUNVM, fix exception handling
* Adjust gas consumption
* Simplify gas consumption logic
* Support of secp256k1 and sodium libraries in builds (#11)
* add support of secp256k1 library to the builds (linux, win)
* add support of secp256k1 library to the builds (linux, win)
* install secp256k1 via brew
* install libsodium via brew;
change sodium to upper case in FindSodium.cmake
* install libsodium via brew;
change sodium to upper case in FindSodium.cmake
* simplify FindSodium.cmake
* bug fixing
* bug fixing
* bug fixing
* add macro SODIUM_STATIC
* adjust build command for windows
* put back original FindSodium.cmake
* put back original FindSodium.cmake
* fix sodium unzipped path for windows;
add ninja
* fix sodium unzipped path for windows;
add ninja
* fix sodium unzipped path for windows;
add ninja
* Win32 github build for secp256k1
* x64 architecture github build for secp256k1
* fix sodium linking on linux
* enable docker buildx arm64 builds from forked repos
* enable docker buildx arm64 builds from forked repos
* enable docker buildx arm64 builds from forked repos
* adjust mac builds for secp2561k and sodium
* fix tonlib jni generation
* minor fix
* sync fixes across platforms
* add libsodium build script for android and precompiled static libraries
* build tonlib for android (fails)
* FindSodium uppercase
* remove system libsodium for android, use precompiled instead;
specify SECP256K1_INCLUDE_DIR fir mac 12.6
* uppercase sodium
* simplify FindSodium
* fix windows build sodium path;
use ninja for windows
* simplify sodium 2
* adjust windows sodium paths;
add paths to android jni
* add ninja build windows
* add ninja build windows
* add ninja build windows 2
* remove win ninja
* fix 1
* fix 2
* fix win 3
* fix linux compile 3
* fix jni 1
* fix jni 2 and mac
* fix jni 3
* fix jni 4
* fix jni 5
* fix mac 6
* fix mac 7 and jni paths
* fix jni 8
* rework sodium for android
* rework sodium for android
* rework sodium for android 2
* fixed sodium for android 2
* fixed sodium for android 3
* static secp256k1 for android
* add precompiled arm secp256k1
* add precompiled arm secp256k1
* build native-lib with secp256k1 x86-64 (non arm)
* update precompiled with NDK libsecp256k1.a
* update precompiled with NDK libsecp256k1.a
* update precompiled with NDK libsecp256k1.a
* refactor llvm-strip location
* refactor llvm-strip location
* add native-lib.so for armv7a, armv8a
* add native-lib.so for armv7a, armv8a
* test armv7a, armv8a
* armv7a - fails linking on sodium, test -> armv8a
* works x86-64, armv7a - fails linking on sodium, armv8a - fails linking secp256k1 (incompatible with aarch64linux)
* update libpsec256k1, sodium static libs
* test x86 android native-lib
* test armv7 android native-lib
* test armv8 android native-lib
* x86_64 and arm64 android native-lib works
* x86_64 and arm64 android native-lib works
* x86_64 and arm64 android native-lib works
* test armv7 android native-lib
* test all android native-libs
* test all android native-libs
* test all android native-libs
* test all android native-libs - without SodiumAndroid
* test all android native-libs - with FindSodiumAndroid.cmake
* win, with Sodium via SODIUM_DIR
* win, with Sodium via SODIUM_DIR env
* win, with Sodium via SODIUM_DIR env
* win, with Sodium via SODIUM_DIR env and SODIUM_USE_STATIC_LIBS
* win, with Sodium via SODIUM_DIR, SODIUM_USE_STATIC_LIBS and SODIUM_INCLUDE_DIR
* android, with FindSodium
* android, with FindSodium with SODIUM_USE_STATIC_LIBS
* remove if not apple
* target_link_libraries(ton_crypto_core PUBLIC secp256k1)
* android SECP256K1_INCLUDE_DIRS
* android SECP256K1_INCLUDE_DIR
* add libsecp256k1.a/so pre-compiled with ubuntu 22 x86-64
* add libsecp256k1.a/so pre-compiled with ubuntu 22 x86-64
* sodium dirs
* sodium dirs
* sodium dirs
* remove NOT APPLE and SodiumAndroid
* add NOT APPLE and remove SodiumAndroid
* add NOT APPLE and remove SodiumAndroid
* remove build scripts for 18.04, reduce CMakeLists.txt
* remove build scripts for 18.04, reduce CMakeLists.txt
* Fix cas consumption during library load
* Fix fetch_config_params after merge
* Add all ADDDIVMOD ops to Asm.fif
* Save unpaid storage fee to due_payment
* Add "set prev blocks info" to emulator
* Adjusted builds (#13)
* Update flake.nix
Add libsodium
* add libsecp256k1-dev and libsodium-dev into wasm build
* make back emulator a shared library;
put emulator to artifacts;
compile wasm artifacts with sodium and secp256k1.
* add secp256k1 to nix
* compile emulator statically with nix
* compile emulator statically with nix
* compile emulator lib statically with nix
* compile emulator lib statically with nix
* add libemulator to artifacts
* add shared libemulator library to artifacts
* minor release fix
* update set-output commands;
add recent_changelog.md
* releases fixes
* releases fixes, multiline
* releases fixes, multiline
* releases fixes, multiline
* put back multiline changelog
* put back multiline changelog
* ConfigParam 19 (global-id) and GLOBALID instruction
* Fix gas consumption in HASHEXT
* Add blst library
* Add bls instructions
* Allow passing long code to opcode-timing
* Add bls testcase
* More BLS instructions
* Fix tests, add bls tests
* Add more bls tests
* Improve some bls operations
* Adjust some BLS gas prices
* Adjust BLS gas prices
* Enable __BLST_PORTABLE__ flag only if PORTABLE flag is set
* Add tests for BLS_PAIRING
* GASCONSUMED instruction
* Fix compilation against docker with blst library; (#14)
* fix compilation against docker with blst library;
add precompiled libblst.a to android builds
* minor fix
* Adjust BLKSWX gas
* Fix comparison with NAN
* Allow arbitrary integers for scalars in ristretto multiplication, fix test
* Adjust nix builds according to PR 694 (#15)
* integrate and test PR-694
* integrate and test PR-694, test 2
* Add P256_CHKSIGN (secp256r1)
---------
Co-authored-by: SpyCheese <mikle98@yandex.ru>
Co-authored-by: neodiX42 <namlem@gmail.com>
2023-05-24 18:14:13 +00:00
|
|
|
#include "common/global-version.h"
|
2019-09-07 10:03:22 +00:00
|
|
|
|
|
|
|
namespace ton {
|
|
|
|
|
|
|
|
namespace validator {
|
|
|
|
using td::Ref;
|
|
|
|
|
|
|
|
class Collator final : public td::actor::Actor {
|
2020-03-24 07:00:14 +00:00
|
|
|
static constexpr int supported_version() {
|
TVM Upgrade (#686)
* New TVM instructions
* Remove PREVBLOCKS
* Separate target ton_crypto into TVM-related and -unrelared code
* Add fine for failed "send message"; rework SENDMSG
* Fix include
* Fix bugs, improve action fines
* Disable fines for special accounts
* Handle msg_balance_remaining.grams == null in transaction.cpp
* Bugfixes in SENDMSG
* Fix fee calculation in SENDMSG
* Fix CellStorageStat and transaction.cpp after merge
* SETBOUNCEONACTIONPHASEFAIL instruction
* ADDDIVMOD instructions
* RUNVM, RUNVMX instructions
* Changes in RUNVM
* Tests for adddiv and runvm
* HASHEXT instruction
* Improve opcode-timing
More iterations
Don't measure preliminary run
Remove logs and other excessive operations
Add "error" to output
* Increase RUNVM gas price
* Optimize HASHEXT, adjust gas price
* Add "bounce of action fail" flag to actions
* Stack operations with unlimited arguments
* Ristretto255 instructions
* Adjust gas consumption
* Optional fixed number of return values in RUNVM, fix exception handling
* Adjust gas consumption
* Simplify gas consumption logic
* Support of secp256k1 and sodium libraries in builds (#11)
* add support of secp256k1 library to the builds (linux, win)
* add support of secp256k1 library to the builds (linux, win)
* install secp256k1 via brew
* install libsodium via brew;
change sodium to upper case in FindSodium.cmake
* install libsodium via brew;
change sodium to upper case in FindSodium.cmake
* simplify FindSodium.cmake
* bug fixing
* bug fixing
* bug fixing
* add macro SODIUM_STATIC
* adjust build command for windows
* put back original FindSodium.cmake
* put back original FindSodium.cmake
* fix sodium unzipped path for windows;
add ninja
* fix sodium unzipped path for windows;
add ninja
* fix sodium unzipped path for windows;
add ninja
* Win32 github build for secp256k1
* x64 architecture github build for secp256k1
* fix sodium linking on linux
* enable docker buildx arm64 builds from forked repos
* enable docker buildx arm64 builds from forked repos
* enable docker buildx arm64 builds from forked repos
* adjust mac builds for secp2561k and sodium
* fix tonlib jni generation
* minor fix
* sync fixes across platforms
* add libsodium build script for android and precompiled static libraries
* build tonlib for android (fails)
* FindSodium uppercase
* remove system libsodium for android, use precompiled instead;
specify SECP256K1_INCLUDE_DIR fir mac 12.6
* uppercase sodium
* simplify FindSodium
* fix windows build sodium path;
use ninja for windows
* simplify sodium 2
* adjust windows sodium paths;
add paths to android jni
* add ninja build windows
* add ninja build windows
* add ninja build windows 2
* remove win ninja
* fix 1
* fix 2
* fix win 3
* fix linux compile 3
* fix jni 1
* fix jni 2 and mac
* fix jni 3
* fix jni 4
* fix jni 5
* fix mac 6
* fix mac 7 and jni paths
* fix jni 8
* rework sodium for android
* rework sodium for android
* rework sodium for android 2
* fixed sodium for android 2
* fixed sodium for android 3
* static secp256k1 for android
* add precompiled arm secp256k1
* add precompiled arm secp256k1
* build native-lib with secp256k1 x86-64 (non arm)
* update precompiled with NDK libsecp256k1.a
* update precompiled with NDK libsecp256k1.a
* update precompiled with NDK libsecp256k1.a
* refactor llvm-strip location
* refactor llvm-strip location
* add native-lib.so for armv7a, armv8a
* add native-lib.so for armv7a, armv8a
* test armv7a, armv8a
* armv7a - fails linking on sodium, test -> armv8a
* works x86-64, armv7a - fails linking on sodium, armv8a - fails linking secp256k1 (incompatible with aarch64linux)
* update libpsec256k1, sodium static libs
* test x86 android native-lib
* test armv7 android native-lib
* test armv8 android native-lib
* x86_64 and arm64 android native-lib works
* x86_64 and arm64 android native-lib works
* x86_64 and arm64 android native-lib works
* test armv7 android native-lib
* test all android native-libs
* test all android native-libs
* test all android native-libs
* test all android native-libs - without SodiumAndroid
* test all android native-libs - with FindSodiumAndroid.cmake
* win, with Sodium via SODIUM_DIR
* win, with Sodium via SODIUM_DIR env
* win, with Sodium via SODIUM_DIR env
* win, with Sodium via SODIUM_DIR env and SODIUM_USE_STATIC_LIBS
* win, with Sodium via SODIUM_DIR, SODIUM_USE_STATIC_LIBS and SODIUM_INCLUDE_DIR
* android, with FindSodium
* android, with FindSodium with SODIUM_USE_STATIC_LIBS
* remove if not apple
* target_link_libraries(ton_crypto_core PUBLIC secp256k1)
* android SECP256K1_INCLUDE_DIRS
* android SECP256K1_INCLUDE_DIR
* add libsecp256k1.a/so pre-compiled with ubuntu 22 x86-64
* add libsecp256k1.a/so pre-compiled with ubuntu 22 x86-64
* sodium dirs
* sodium dirs
* sodium dirs
* remove NOT APPLE and SodiumAndroid
* add NOT APPLE and remove SodiumAndroid
* add NOT APPLE and remove SodiumAndroid
* remove build scripts for 18.04, reduce CMakeLists.txt
* remove build scripts for 18.04, reduce CMakeLists.txt
* Fix cas consumption during library load
* Fix fetch_config_params after merge
* Add all ADDDIVMOD ops to Asm.fif
* Save unpaid storage fee to due_payment
* Add "set prev blocks info" to emulator
* Adjusted builds (#13)
* Update flake.nix
Add libsodium
* add libsecp256k1-dev and libsodium-dev into wasm build
* make back emulator a shared library;
put emulator to artifacts;
compile wasm artifacts with sodium and secp256k1.
* add secp256k1 to nix
* compile emulator statically with nix
* compile emulator statically with nix
* compile emulator lib statically with nix
* compile emulator lib statically with nix
* add libemulator to artifacts
* add shared libemulator library to artifacts
* minor release fix
* update set-output commands;
add recent_changelog.md
* releases fixes
* releases fixes, multiline
* releases fixes, multiline
* releases fixes, multiline
* put back multiline changelog
* put back multiline changelog
* ConfigParam 19 (global-id) and GLOBALID instruction
* Fix gas consumption in HASHEXT
* Add blst library
* Add bls instructions
* Allow passing long code to opcode-timing
* Add bls testcase
* More BLS instructions
* Fix tests, add bls tests
* Add more bls tests
* Improve some bls operations
* Adjust some BLS gas prices
* Adjust BLS gas prices
* Enable __BLST_PORTABLE__ flag only if PORTABLE flag is set
* Add tests for BLS_PAIRING
* GASCONSUMED instruction
* Fix compilation against docker with blst library; (#14)
* fix compilation against docker with blst library;
add precompiled libblst.a to android builds
* minor fix
* Adjust BLKSWX gas
* Fix comparison with NAN
* Allow arbitrary integers for scalars in ristretto multiplication, fix test
* Adjust nix builds according to PR 694 (#15)
* integrate and test PR-694
* integrate and test PR-694, test 2
* Add P256_CHKSIGN (secp256r1)
---------
Co-authored-by: SpyCheese <mikle98@yandex.ru>
Co-authored-by: neodiX42 <namlem@gmail.com>
2023-05-24 18:14:13 +00:00
|
|
|
return SUPPORTED_VERSION;
|
2020-03-24 07:00:14 +00:00
|
|
|
}
|
|
|
|
static constexpr long long supported_capabilities() {
|
2020-04-06 21:27:34 +00:00
|
|
|
return ton::capCreateStatsEnabled | ton::capBounceMsgBody | ton::capReportVersion | ton::capShortDequeue;
|
2020-03-24 07:00:14 +00:00
|
|
|
}
|
2019-09-07 10:03:22 +00:00
|
|
|
using LtCellRef = block::LtCellRef;
|
|
|
|
using NewOutMsg = block::NewOutMsg;
|
2020-04-11 14:08:57 +00:00
|
|
|
const ShardIdFull shard_;
|
2019-09-07 10:03:22 +00:00
|
|
|
ton::BlockId new_id;
|
2020-04-11 14:08:57 +00:00
|
|
|
bool busy_{false};
|
2019-09-07 10:03:22 +00:00
|
|
|
bool before_split_{false};
|
|
|
|
bool after_split_{false};
|
|
|
|
bool after_merge_{false};
|
|
|
|
bool want_split_{false};
|
|
|
|
bool want_merge_{false};
|
|
|
|
bool right_child_{false};
|
|
|
|
bool preinit_complete{false};
|
|
|
|
bool is_key_block_{false};
|
|
|
|
bool block_full_{false};
|
|
|
|
bool inbound_queues_empty_{false};
|
|
|
|
bool libraries_changed_{false};
|
2019-09-18 17:46:32 +00:00
|
|
|
bool prev_key_block_exists_{false};
|
2020-04-27 12:01:46 +00:00
|
|
|
bool is_hardfork_{false};
|
2019-09-07 10:03:22 +00:00
|
|
|
UnixTime min_ts;
|
|
|
|
BlockIdExt min_mc_block_id;
|
|
|
|
std::vector<BlockIdExt> prev_blocks;
|
|
|
|
std::vector<Ref<ShardState>> prev_states;
|
|
|
|
std::vector<Ref<BlockData>> prev_block_data;
|
2019-09-18 17:46:32 +00:00
|
|
|
Ed25519_PublicKey created_by_;
|
2020-04-11 14:08:57 +00:00
|
|
|
Ref<ValidatorSet> validator_set_;
|
2019-09-07 10:03:22 +00:00
|
|
|
td::actor::ActorId<ValidatorManager> manager;
|
|
|
|
td::Timestamp timeout;
|
2023-04-26 06:15:16 +00:00
|
|
|
td::Timestamp queue_cleanup_timeout_, soft_timeout_, medium_timeout_;
|
2019-09-07 10:03:22 +00:00
|
|
|
td::Promise<BlockCandidate> main_promise;
|
|
|
|
ton::BlockSeqno last_block_seqno{0};
|
|
|
|
ton::BlockSeqno prev_mc_block_seqno{0};
|
|
|
|
ton::BlockSeqno new_block_seqno{0};
|
|
|
|
ton::BlockSeqno prev_key_block_seqno_{0};
|
|
|
|
int step{0};
|
|
|
|
int pending{0};
|
|
|
|
static constexpr int max_ihr_msg_size = 65535; // 64k
|
|
|
|
static constexpr int max_ext_msg_size = 65535; // 64k
|
|
|
|
static constexpr int max_blk_sign_size = 65535; // 64k
|
|
|
|
static constexpr bool shard_splitting_enabled = true;
|
|
|
|
|
|
|
|
public:
|
2020-04-27 12:01:46 +00:00
|
|
|
Collator(ShardIdFull shard, bool is_hardfork, td::uint32 min_ts, BlockIdExt min_masterchain_block_id,
|
|
|
|
std::vector<BlockIdExt> prev, Ref<ValidatorSet> validator_set, Ed25519_PublicKey collator_id,
|
|
|
|
td::actor::ActorId<ValidatorManager> manager, td::Timestamp timeout, td::Promise<BlockCandidate> promise);
|
2019-09-07 10:03:22 +00:00
|
|
|
~Collator() override = default;
|
|
|
|
bool is_busy() const {
|
2020-04-11 14:08:57 +00:00
|
|
|
return busy_;
|
2019-09-07 10:03:22 +00:00
|
|
|
}
|
|
|
|
ShardId get_shard() const {
|
2020-04-11 14:08:57 +00:00
|
|
|
return shard_.shard;
|
2019-09-07 10:03:22 +00:00
|
|
|
}
|
|
|
|
WorkchainId workchain() const {
|
2020-04-11 14:08:57 +00:00
|
|
|
return shard_.workchain;
|
2019-09-07 10:03:22 +00:00
|
|
|
}
|
|
|
|
static constexpr td::uint32 priority() {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2023-02-02 07:03:45 +00:00
|
|
|
static td::Result<std::unique_ptr<block::transaction::Transaction>>
|
2021-11-13 20:28:06 +00:00
|
|
|
impl_create_ordinary_transaction(Ref<vm::Cell> msg_root,
|
|
|
|
block::Account* acc,
|
|
|
|
UnixTime utime, LogicalTime lt,
|
|
|
|
block::StoragePhaseConfig* storage_phase_cfg,
|
|
|
|
block::ComputePhaseConfig* compute_phase_cfg,
|
|
|
|
block::ActionPhaseConfig* action_phase_cfg,
|
|
|
|
bool external, LogicalTime after_lt);
|
|
|
|
|
2019-09-07 10:03:22 +00:00
|
|
|
private:
|
|
|
|
void start_up() override;
|
|
|
|
void alarm() override;
|
|
|
|
int verbosity{3 * 0};
|
|
|
|
int verify{1};
|
|
|
|
ton::LogicalTime start_lt, max_lt;
|
|
|
|
ton::UnixTime now_;
|
|
|
|
ton::UnixTime prev_now_;
|
|
|
|
ton::UnixTime now_upper_limit_{~0U};
|
|
|
|
unsigned out_msg_queue_ops_{}, in_descr_cnt_{}, out_descr_cnt_{};
|
|
|
|
Ref<MasterchainStateQ> mc_state_;
|
|
|
|
Ref<BlockData> prev_mc_block;
|
|
|
|
BlockIdExt mc_block_id_;
|
|
|
|
Ref<vm::Cell> mc_state_root;
|
|
|
|
Ref<vm::Cell> mc_block_root;
|
2023-07-14 11:50:03 +00:00
|
|
|
td::BitArray<256> rand_seed_ = td::Bits256::zero();
|
2019-09-07 10:03:22 +00:00
|
|
|
std::unique_ptr<block::ConfigInfo> config_;
|
|
|
|
std::unique_ptr<block::ShardConfig> shard_conf_;
|
|
|
|
std::map<BlockSeqno, Ref<MasterchainStateQ>> aux_mc_states_;
|
|
|
|
std::vector<block::McShardDescr> neighbors_;
|
|
|
|
std::unique_ptr<block::OutputQueueMerger> nb_out_msgs_;
|
|
|
|
std::vector<ton::StdSmcAddress> special_smcs;
|
|
|
|
std::vector<std::pair<ton::StdSmcAddress, int>> ticktock_smcs;
|
|
|
|
Ref<vm::Cell> prev_block_root;
|
|
|
|
Ref<vm::Cell> prev_state_root_, prev_state_root_pure_;
|
|
|
|
Ref<vm::Cell> state_root; // (new) shardchain state
|
|
|
|
Ref<vm::Cell> state_update; // Merkle update from prev_state_root to state_root
|
|
|
|
std::shared_ptr<vm::CellUsageTree> state_usage_tree_; // used to construct Merkle update
|
|
|
|
Ref<vm::CellSlice> new_config_params_;
|
2020-03-11 10:19:31 +00:00
|
|
|
Ref<vm::Cell> old_mparams_;
|
2019-09-07 10:03:22 +00:00
|
|
|
ton::LogicalTime prev_state_lt_;
|
|
|
|
ton::LogicalTime shards_max_end_lt_{0};
|
|
|
|
ton::UnixTime prev_state_utime_;
|
|
|
|
int global_id_{0};
|
|
|
|
ton::BlockSeqno min_ref_mc_seqno_{~0U};
|
2019-10-07 09:08:23 +00:00
|
|
|
ton::BlockSeqno vert_seqno_{~0U}, prev_vert_seqno_{~0U};
|
2019-09-07 10:03:22 +00:00
|
|
|
ton::BlockIdExt prev_key_block_;
|
|
|
|
ton::LogicalTime prev_key_block_lt_;
|
|
|
|
bool accept_msgs_{true};
|
|
|
|
bool shard_conf_adjusted_{false};
|
2019-09-18 17:46:32 +00:00
|
|
|
bool ihr_enabled_{false};
|
|
|
|
bool create_stats_enabled_{false};
|
2020-03-23 23:32:16 +00:00
|
|
|
bool report_version_{false};
|
2020-04-06 11:22:14 +00:00
|
|
|
bool skip_topmsgdescr_{false};
|
|
|
|
bool skip_extmsg_{false};
|
2020-04-06 20:08:53 +00:00
|
|
|
bool short_dequeue_records_{false};
|
2019-09-07 10:03:22 +00:00
|
|
|
td::uint64 overload_history_{0}, underload_history_{0};
|
|
|
|
td::uint64 block_size_estimate_{};
|
|
|
|
Ref<block::WorkchainInfo> wc_info_;
|
|
|
|
std::vector<Ref<ShardTopBlockDescription>> shard_block_descr_;
|
|
|
|
std::vector<Ref<ShardTopBlockDescrQ>> used_shard_block_descr_;
|
|
|
|
std::unique_ptr<vm::Dictionary> shard_libraries_;
|
2019-09-18 17:46:32 +00:00
|
|
|
Ref<vm::Cell> mc_state_extra_;
|
2019-09-07 10:03:22 +00:00
|
|
|
std::unique_ptr<vm::AugmentedDictionary> account_dict;
|
|
|
|
std::map<ton::StdSmcAddress, std::unique_ptr<block::Account>> accounts;
|
|
|
|
std::vector<block::StoragePrices> storage_prices_;
|
|
|
|
block::StoragePhaseConfig storage_phase_cfg_{&storage_prices_};
|
|
|
|
block::ComputePhaseConfig compute_phase_cfg_;
|
|
|
|
block::ActionPhaseConfig action_phase_cfg_;
|
|
|
|
td::RefInt256 masterchain_create_fee_, basechain_create_fee_;
|
|
|
|
std::unique_ptr<block::BlockLimits> block_limits_;
|
|
|
|
std::unique_ptr<block::BlockLimitStatus> block_limit_status_;
|
|
|
|
ton::LogicalTime min_new_msg_lt{std::numeric_limits<td::uint64>::max()};
|
|
|
|
block::CurrencyCollection total_balance_, old_total_balance_, total_validator_fees_;
|
|
|
|
block::CurrencyCollection global_balance_, old_global_balance_, import_created_{0};
|
|
|
|
Ref<vm::Cell> recover_create_msg_, mint_msg_;
|
|
|
|
Ref<vm::Cell> new_block;
|
|
|
|
block::ValueFlow value_flow_{block::ValueFlow::SetZero()};
|
|
|
|
std::unique_ptr<vm::AugmentedDictionary> fees_import_dict_;
|
|
|
|
std::map<ton::Bits256, int> ext_msg_map;
|
2024-04-01 13:44:08 +00:00
|
|
|
struct ExtMsg {
|
|
|
|
Ref<vm::Cell> cell;
|
|
|
|
ExtMessage::Hash hash;
|
|
|
|
int priority;
|
|
|
|
};
|
|
|
|
std::vector<ExtMsg> ext_msg_list_;
|
2019-09-07 10:03:22 +00:00
|
|
|
std::priority_queue<NewOutMsg, std::vector<NewOutMsg>, std::greater<NewOutMsg>> new_msgs;
|
|
|
|
std::pair<ton::LogicalTime, ton::Bits256> last_proc_int_msg_, first_unproc_int_msg_;
|
|
|
|
std::unique_ptr<vm::AugmentedDictionary> in_msg_dict, out_msg_dict, out_msg_queue_, sibling_out_msg_queue_;
|
2023-12-13 09:57:34 +00:00
|
|
|
td::uint32 out_msg_queue_size_ = 0;
|
2019-09-07 10:03:22 +00:00
|
|
|
std::unique_ptr<vm::Dictionary> ihr_pending;
|
|
|
|
std::shared_ptr<block::MsgProcessedUptoCollection> processed_upto_, sibling_processed_upto_;
|
2019-09-18 17:46:32 +00:00
|
|
|
std::unique_ptr<vm::Dictionary> block_create_stats_;
|
|
|
|
std::map<td::Bits256, int> block_create_count_;
|
|
|
|
unsigned block_create_total_{0};
|
2019-09-07 10:03:22 +00:00
|
|
|
std::vector<ExtMessage::Hash> bad_ext_msgs_, delay_ext_msgs_;
|
|
|
|
Ref<vm::Cell> shard_account_blocks_; // ShardAccountBlocks
|
|
|
|
std::vector<Ref<vm::Cell>> collated_roots_;
|
|
|
|
std::unique_ptr<ton::BlockCandidate> block_candidate;
|
|
|
|
|
2022-09-10 09:57:13 +00:00
|
|
|
td::PerfWarningTimer perf_timer_;
|
2019-09-07 10:03:22 +00:00
|
|
|
//
|
|
|
|
block::Account* lookup_account(td::ConstBitPtr addr) const;
|
|
|
|
std::unique_ptr<block::Account> make_account_from(td::ConstBitPtr addr, Ref<vm::CellSlice> account,
|
2023-11-03 11:43:34 +00:00
|
|
|
bool force_create);
|
2019-09-07 10:03:22 +00:00
|
|
|
td::Result<block::Account*> make_account(td::ConstBitPtr addr, bool force_create = false);
|
|
|
|
td::actor::ActorId<Collator> get_self() {
|
|
|
|
return actor_id(this);
|
|
|
|
}
|
|
|
|
bool init_utime();
|
|
|
|
bool init_lt();
|
|
|
|
bool fetch_config_params();
|
|
|
|
bool fatal_error(td::Status error);
|
|
|
|
bool fatal_error(int err_code, std::string err_msg);
|
|
|
|
bool fatal_error(std::string err_msg, int err_code = -666);
|
|
|
|
void check_pending();
|
|
|
|
void after_get_mc_state(td::Result<std::pair<Ref<MasterchainState>, BlockIdExt>> res);
|
|
|
|
void after_get_shard_state(int idx, td::Result<Ref<ShardState>> res);
|
|
|
|
void after_get_block_data(int idx, td::Result<Ref<BlockData>> res);
|
|
|
|
void after_get_shard_blocks(td::Result<std::vector<Ref<ShardTopBlockDescription>>> res);
|
|
|
|
bool preprocess_prev_mc_state();
|
|
|
|
bool register_mc_state(Ref<MasterchainStateQ> other_mc_state);
|
|
|
|
bool request_aux_mc_state(BlockSeqno seqno, Ref<MasterchainStateQ>& state);
|
|
|
|
Ref<MasterchainStateQ> get_aux_mc_state(BlockSeqno seqno) const;
|
|
|
|
void after_get_aux_shard_state(ton::BlockIdExt blkid, td::Result<Ref<ShardState>> res);
|
|
|
|
bool fix_one_processed_upto(block::MsgProcessedUpto& proc, const ton::ShardIdFull& owner);
|
|
|
|
bool fix_processed_upto(block::MsgProcessedUptoCollection& upto);
|
|
|
|
void got_neighbor_out_queue(int i, td::Result<Ref<MessageQueue>> res);
|
2023-12-13 09:57:34 +00:00
|
|
|
void got_out_queue_size(size_t i, td::Result<td::uint32> res);
|
2019-09-07 10:03:22 +00:00
|
|
|
bool adjust_shard_config();
|
|
|
|
bool store_shard_fees(ShardIdFull shard, const block::CurrencyCollection& fees,
|
|
|
|
const block::CurrencyCollection& created);
|
|
|
|
bool store_shard_fees(Ref<block::McShardHash> descr);
|
|
|
|
bool import_new_shard_top_blocks();
|
2019-09-18 17:46:32 +00:00
|
|
|
bool register_shard_block_creators(std::vector<td::Bits256> creator_list);
|
2019-09-07 10:03:22 +00:00
|
|
|
bool init_block_limits();
|
|
|
|
bool compute_minted_amount(block::CurrencyCollection& to_mint);
|
|
|
|
bool init_value_create();
|
|
|
|
bool try_collate();
|
|
|
|
bool do_preinit();
|
|
|
|
bool do_collate();
|
|
|
|
bool create_special_transactions();
|
|
|
|
bool create_special_transaction(block::CurrencyCollection amount, Ref<vm::Cell> dest_addr_cell,
|
|
|
|
Ref<vm::Cell>& in_msg);
|
|
|
|
bool create_ticktock_transactions(int mask);
|
|
|
|
bool create_ticktock_transaction(const ton::StdSmcAddress& smc_addr, ton::LogicalTime req_start_lt, int mask);
|
2024-01-22 18:56:11 +00:00
|
|
|
Ref<vm::Cell> create_ordinary_transaction(Ref<vm::Cell> msg_root, bool is_special_tx = false);
|
2020-04-11 14:08:57 +00:00
|
|
|
bool check_cur_validator_set();
|
2019-09-07 10:03:22 +00:00
|
|
|
bool unpack_last_mc_state();
|
|
|
|
bool unpack_last_state();
|
|
|
|
bool unpack_merge_last_state();
|
|
|
|
bool unpack_one_last_state(block::ShardState& ss, BlockIdExt blkid, Ref<vm::Cell> prev_state_root);
|
|
|
|
bool split_last_state(block::ShardState& ss);
|
|
|
|
bool import_shard_state_data(block::ShardState& ss);
|
|
|
|
bool add_trivial_neighbor();
|
|
|
|
bool add_trivial_neighbor_after_merge();
|
|
|
|
bool out_msg_queue_cleanup();
|
|
|
|
bool dequeue_message(Ref<vm::Cell> msg_envelope, ton::LogicalTime delivered_lt);
|
|
|
|
bool check_prev_block(const BlockIdExt& listed, const BlockIdExt& prev, bool chk_chain_len = true);
|
|
|
|
bool check_prev_block_exact(const BlockIdExt& listed, const BlockIdExt& prev);
|
|
|
|
bool check_this_shard_mc_info();
|
|
|
|
bool request_neighbor_msg_queues();
|
2023-12-13 09:57:34 +00:00
|
|
|
bool request_out_msg_queue_size();
|
2019-09-07 10:03:22 +00:00
|
|
|
void update_max_lt(ton::LogicalTime lt);
|
|
|
|
bool is_masterchain() const {
|
2020-04-11 14:08:57 +00:00
|
|
|
return shard_.is_masterchain();
|
2019-09-07 10:03:22 +00:00
|
|
|
}
|
|
|
|
bool is_our_address(Ref<vm::CellSlice> addr_ref) const;
|
|
|
|
bool is_our_address(ton::AccountIdPrefixFull addr_prefix) const;
|
|
|
|
bool is_our_address(const ton::StdSmcAddress& addr) const;
|
2024-04-01 13:44:08 +00:00
|
|
|
void after_get_external_messages(td::Result<std::vector<std::pair<Ref<ExtMessage>, int>>> res);
|
|
|
|
td::Result<bool> register_external_message_cell(Ref<vm::Cell> ext_msg, const ExtMessage::Hash& ext_hash,
|
|
|
|
int priority);
|
2019-09-07 10:03:22 +00:00
|
|
|
// td::Result<bool> register_external_message(td::Slice ext_msg_boc);
|
|
|
|
void register_new_msg(block::NewOutMsg msg);
|
2023-02-02 07:03:45 +00:00
|
|
|
void register_new_msgs(block::transaction::Transaction& trans);
|
2019-09-07 10:03:22 +00:00
|
|
|
bool process_new_messages(bool enqueue_only = false);
|
|
|
|
int process_one_new_message(block::NewOutMsg msg, bool enqueue_only = false, Ref<vm::Cell>* is_special = nullptr);
|
|
|
|
bool process_inbound_internal_messages();
|
|
|
|
bool process_inbound_message(Ref<vm::CellSlice> msg, ton::LogicalTime lt, td::ConstBitPtr key,
|
|
|
|
const block::McShardDescr& src_nb);
|
|
|
|
bool process_inbound_external_messages();
|
|
|
|
int process_external_message(Ref<vm::Cell> msg);
|
|
|
|
bool enqueue_message(block::NewOutMsg msg, td::RefInt256 fwd_fees_remaining, ton::LogicalTime enqueued_lt);
|
|
|
|
bool enqueue_transit_message(Ref<vm::Cell> msg, Ref<vm::Cell> old_msg_env, ton::AccountIdPrefixFull prev_prefix,
|
|
|
|
ton::AccountIdPrefixFull cur_prefix, ton::AccountIdPrefixFull dest_prefix,
|
2023-11-03 11:43:34 +00:00
|
|
|
td::RefInt256 fwd_fee_remaining);
|
2019-09-07 10:03:22 +00:00
|
|
|
bool delete_out_msg_queue_msg(td::ConstBitPtr key);
|
|
|
|
bool insert_in_msg(Ref<vm::Cell> in_msg);
|
|
|
|
bool insert_out_msg(Ref<vm::Cell> out_msg);
|
2020-04-06 20:08:53 +00:00
|
|
|
bool insert_out_msg(Ref<vm::Cell> out_msg, td::ConstBitPtr msg_hash);
|
2019-09-07 10:03:22 +00:00
|
|
|
bool register_out_msg_queue_op(bool force = false);
|
|
|
|
bool update_min_mc_seqno(ton::BlockSeqno some_mc_seqno);
|
|
|
|
bool combine_account_transactions();
|
|
|
|
bool update_public_libraries();
|
|
|
|
bool update_account_public_libraries(Ref<vm::Cell> orig_libs, Ref<vm::Cell> final_libs, const td::Bits256& addr);
|
|
|
|
bool add_public_library(td::ConstBitPtr key, td::ConstBitPtr addr, Ref<vm::Cell> library);
|
|
|
|
bool remove_public_library(td::ConstBitPtr key, td::ConstBitPtr addr);
|
|
|
|
bool check_block_overload();
|
2019-09-18 17:46:32 +00:00
|
|
|
bool update_block_creator_count(td::ConstBitPtr key, unsigned shard_incr, unsigned mc_incr);
|
|
|
|
int creator_count_outdated(td::ConstBitPtr key, vm::CellSlice& cs);
|
|
|
|
bool update_block_creator_stats();
|
2019-09-07 10:03:22 +00:00
|
|
|
bool create_mc_state_extra();
|
|
|
|
bool create_shard_state();
|
|
|
|
td::Result<Ref<vm::Cell>> get_config_data_from_smc(const ton::StdSmcAddress& cfg_addr);
|
|
|
|
bool try_fetch_new_config(const ton::StdSmcAddress& cfg_addr, Ref<vm::Cell>& new_config);
|
|
|
|
bool update_processed_upto();
|
|
|
|
bool compute_out_msg_queue_info(Ref<vm::Cell>& out_msg_queue_info);
|
|
|
|
bool compute_total_balance();
|
|
|
|
bool store_master_ref(vm::CellBuilder& cb);
|
|
|
|
bool store_prev_blk_ref(vm::CellBuilder& cb, bool after_merge);
|
|
|
|
bool store_zero_state_ref(vm::CellBuilder& cb);
|
2020-03-23 23:32:16 +00:00
|
|
|
bool store_version(vm::CellBuilder& cb) const;
|
2019-09-07 10:03:22 +00:00
|
|
|
bool create_block_info(Ref<vm::Cell>& block_info);
|
|
|
|
bool check_value_flow();
|
|
|
|
bool create_block_extra(Ref<vm::Cell>& block_extra);
|
|
|
|
bool update_shard_config(const block::WorkchainSet& wc_set, const block::CatchainValidatorsConfig& ccvc,
|
|
|
|
bool update_cc);
|
|
|
|
bool create_mc_block_extra(Ref<vm::Cell>& mc_block_extra);
|
|
|
|
bool create_block();
|
|
|
|
Ref<vm::Cell> collate_shard_block_descr_set();
|
|
|
|
bool create_collated_data();
|
|
|
|
bool create_block_candidate();
|
|
|
|
void return_block_candidate(td::Result<td::Unit> saved);
|
|
|
|
bool update_last_proc_int_msg(const std::pair<ton::LogicalTime, ton::Bits256>& new_lt_hash);
|
2024-03-26 12:55:58 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
static td::uint32 get_skip_externals_queue_size();
|
2019-09-07 10:03:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace validator
|
|
|
|
|
|
|
|
} // namespace ton
|