├── .gitignore ├── .gitmodules ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE ├── README.md ├── bin ├── Elector.abi.json ├── adnl_ping.rs ├── adnl_resolve.rs ├── console.rs ├── dhtscan.rs ├── gendht.rs ├── keygen.rs ├── keyid.rs ├── print.rs └── zerostate.rs ├── catchain ├── Cargo.toml ├── README.md ├── src │ ├── activity_node.rs │ ├── block.rs │ ├── block_payload.rs │ ├── catchain.rs │ ├── database.rs │ ├── lib.rs │ ├── log_player.rs │ ├── profiling.rs │ ├── received_block.rs │ ├── receiver.rs │ ├── receiver_source.rs │ ├── utils.rs │ └── utils │ │ └── metrics.rs └── tests │ ├── test_catchain.rs │ ├── test_hash.rs │ ├── test_log_replay.rs │ ├── test_received_block.rs │ ├── test_receiver.rs │ ├── test_receiver_many_sources.rs │ └── test_ton_structs.rs ├── config.md ├── configs ├── default_config.json ├── default_config_mainet_initblock_test.json ├── default_config_mainet_test.json ├── ton-global.config-mainet-initblock-test.json ├── ton-global.config-mainet-test.json └── ton-global.config-sample.json ├── recomended_rust ├── rust-toolchain.toml ├── src ├── block.rs ├── block_proof.rs ├── boot.rs ├── collator_test_bundle.rs ├── config.rs ├── engine.rs ├── engine_operations.rs ├── engine_traits.rs ├── error.rs ├── ext_messages.rs ├── external_db │ ├── kafka_consumer.rs │ ├── kafka_producer.rs │ ├── mod.rs │ ├── processor.rs │ ├── stub_producer.rs │ └── tests │ │ ├── static │ │ ├── 4437297 │ │ ├── 705EE27D8C862EC367977465042211F9C72EB94D28040784F8424DEAB3AC642C.boc │ │ ├── 9CD0BCB4D40665E7928274894E98703E47CFC408048BA144CE913818692E7A15.boc │ │ ├── state_705EE27D8C862EC367977465042211F9C72EB94D28040784F8424DEAB3AC642C.boc │ │ └── state_9CD0BCB4D40665E7928274894E98703E47CFC408048BA144CE913818692E7A15.boc │ │ └── test.rs ├── full_node │ ├── apply_block.rs │ ├── counters.rs │ ├── mesh_client.rs │ ├── mod.rs │ ├── remp_client.rs │ ├── shard_client.rs │ ├── state_helper.rs │ └── telemetry.rs ├── internal_db │ ├── mod.rs │ ├── restore.rs │ ├── state_gc_resolver.rs │ └── update.rs ├── lib.rs ├── macros.rs ├── main.rs ├── mesh_queues_keeper.rs ├── network │ ├── catchain_client.rs │ ├── control.rs │ ├── full_node_client.rs │ ├── full_node_service.rs │ ├── mod.rs │ ├── neighbours.rs │ ├── node_network.rs │ ├── remp.rs │ ├── telemetry.rs │ └── tests │ │ ├── test_remp.rs │ │ └── test_telemetry.rs ├── rng │ ├── mod.rs │ ├── random.rs │ └── tests │ │ └── test_random.rs ├── shard_blocks.rs ├── shard_state.rs ├── shard_states_keeper.rs ├── sync.rs ├── tests │ ├── static │ │ ├── 368730B00DE6947DD549ABCF53730FC33FE96C8FAABDACBBB71E9D510525D639.boc │ │ ├── ABA8391BAF9DB3B48A6DAE91F8251DC031ACBCE22A80903C08B48BFDD5F6D7D0.boc │ │ ├── F2BC2888EAE466FC172140A90949EDBC7091D81CCB4194A225C56C0F1D095097.boc │ │ ├── archive.1459995.pack │ │ ├── b571525 │ │ ├── basestate0.boc │ │ ├── key_block.boc │ │ ├── message.boc │ │ ├── shards_73102.boc │ │ ├── shards_73107.boc │ │ ├── ss571525 │ │ ├── test_master_block_proof │ │ │ ├── block__3082182 │ │ │ ├── block__3082183 │ │ │ ├── block__3082184 │ │ │ ├── block__3082185 │ │ │ ├── block__3082186 │ │ │ ├── block__3082187 │ │ │ ├── block__3082188 │ │ │ ├── block__3082189 │ │ │ ├── block__3082190 │ │ │ ├── block__3082191 │ │ │ ├── block__3082192 │ │ │ ├── block__3082193 │ │ │ ├── block__3082194 │ │ │ ├── block__3082195 │ │ │ ├── block__3082196 │ │ │ ├── block__3082197 │ │ │ ├── block__3082198 │ │ │ ├── block__3082199 │ │ │ ├── block__3082200 │ │ │ ├── block__3082201 │ │ │ ├── key_block__3082181 │ │ │ ├── key_proof__3082181 │ │ │ ├── proof__3082182 │ │ │ ├── proof__3082183 │ │ │ ├── proof__3082184 │ │ │ ├── proof__3082185 │ │ │ ├── proof__3082186 │ │ │ ├── proof__3082187 │ │ │ ├── proof__3082188 │ │ │ ├── proof__3082189 │ │ │ ├── proof__3082190 │ │ │ ├── proof__3082191 │ │ │ ├── proof__3082192 │ │ │ ├── proof__3082193 │ │ │ ├── proof__3082194 │ │ │ ├── proof__3082195 │ │ │ ├── proof__3082196 │ │ │ ├── proof__3082197 │ │ │ ├── proof__3082198 │ │ │ ├── proof__3082199 │ │ │ ├── proof__3082200 │ │ │ └── proof__3082201 │ │ ├── test_master_block_proof_shuffle │ │ │ ├── block__3236531 │ │ │ ├── block__3236532 │ │ │ ├── block__3236533 │ │ │ ├── block__3236534 │ │ │ ├── block__3236535 │ │ │ ├── block__3236536 │ │ │ ├── block__3236537 │ │ │ ├── block__3236538 │ │ │ ├── block__3236539 │ │ │ ├── block__3236540 │ │ │ ├── block__3236541 │ │ │ ├── block__3236542 │ │ │ ├── block__3236543 │ │ │ ├── block__3236544 │ │ │ ├── block__3236545 │ │ │ ├── block__3236546 │ │ │ ├── block__3236547 │ │ │ ├── block__3236548 │ │ │ ├── block__3236549 │ │ │ ├── block__3236550 │ │ │ ├── key_block__3236530 │ │ │ ├── key_proof__3236530 │ │ │ ├── proof__3236531 │ │ │ ├── proof__3236532 │ │ │ ├── proof__3236533 │ │ │ ├── proof__3236534 │ │ │ ├── proof__3236535 │ │ │ ├── proof__3236536 │ │ │ ├── proof__3236537 │ │ │ ├── proof__3236538 │ │ │ ├── proof__3236539 │ │ │ ├── proof__3236540 │ │ │ ├── proof__3236541 │ │ │ ├── proof__3236542 │ │ │ ├── proof__3236543 │ │ │ ├── proof__3236544 │ │ │ ├── proof__3236545 │ │ │ ├── proof__3236546 │ │ │ ├── proof__3236547 │ │ │ ├── proof__3236548 │ │ │ ├── proof__3236549 │ │ │ └── proof__3236550 │ │ ├── test_shard_block_proof │ │ │ └── proof_4377262 │ │ ├── tvm_key_block.boc │ │ ├── tvm_msg_account.boc │ │ ├── tvm_stack_account.boc │ │ └── zerostate.boc │ ├── test_block.rs │ ├── test_block_proof.rs │ ├── test_control.rs │ ├── test_engine.rs │ ├── test_ext_messages.rs │ ├── test_helper.rs │ ├── test_internal_db.rs │ ├── test_remp_client.rs │ ├── test_shard_blocks.rs │ ├── test_shard_state.rs │ ├── test_sync.rs │ └── test_telemetry.rs ├── types │ ├── accounts.rs │ ├── awaiters_pool.rs │ ├── limits.rs │ ├── lockfree_cache.rs │ ├── messages.rs │ ├── mod.rs │ ├── mpmc_channel.rs │ ├── shard_blocks_observer.rs │ ├── tests │ │ ├── test_awaiters_pool.rs │ │ ├── test_lockfree_cache.rs │ │ ├── test_messages.rs │ │ └── test_mpmc_channel.rs │ └── top_block_descr.rs ├── validating_utils.rs └── validator │ ├── Elector.abi.json │ ├── accept_block.rs │ ├── candidate_db.rs │ ├── catchain_overlay.rs │ ├── collator.rs │ ├── fabric.rs │ ├── log_parser.rs │ ├── message_cache.rs │ ├── mod.rs │ ├── mutex_wrapper.rs │ ├── out_msg_queue.rs │ ├── out_msg_queue_cleaner.rs │ ├── reliable_message_queue.rs │ ├── remp_block_parser.rs │ ├── remp_catchain.rs │ ├── remp_manager.rs │ ├── remp_service.rs │ ├── sessions_computing.rs │ ├── slashing.rs │ ├── telemetry.rs │ ├── tests │ ├── static │ │ ├── test_log_parser.log │ │ ├── test_session_id_normal.log │ │ └── test_session_id_unsafe.log │ ├── test_collator.rs │ ├── test_log_parser.rs │ ├── test_message_cache.rs │ ├── test_out_msg_queue.rs │ ├── test_rmq_messages.rs │ ├── test_session_id.rs │ ├── test_slashing.rs │ ├── test_telemetry.rs │ ├── test_validate_query.rs │ └── test_validator_utils.rs │ ├── validate_query.rs │ ├── validator_group.rs │ ├── validator_manager.rs │ ├── validator_session_listener.rs │ ├── validator_utils.rs │ └── verification │ ├── README.md │ ├── block.rs │ ├── mod.rs │ ├── multi_signature_bls.rs │ ├── multi_signature_unsafe.rs │ ├── simulator │ └── new_consensus_simulator.py │ ├── utils.rs │ ├── verification_manager.rs │ ├── workchain.rs │ └── workchain_overlay.rs ├── storage ├── Cargo.toml ├── benches │ └── shardstate_db.rs └── src │ ├── archives │ ├── archive_manager.rs │ ├── archive_slice.rs │ ├── file_maps.rs │ ├── mod.rs │ ├── package.rs │ ├── package_entry.rs │ ├── package_entry_id.rs │ ├── package_entry_meta.rs │ ├── package_entry_meta_db.rs │ ├── package_id.rs │ ├── package_index_db.rs │ ├── package_info.rs │ ├── package_offsets_db.rs │ ├── package_status_db.rs │ ├── package_status_key.rs │ └── tests │ │ ├── test_archive_manager.rs │ │ ├── test_archive_slice.rs │ │ ├── test_package.rs │ │ ├── test_package_entry_id.rs │ │ ├── test_package_id.rs │ │ └── testdata │ │ ├── archive.00000-2.pack.gold │ │ ├── archive.00000.pack.gold │ │ ├── archive.00001.pack.gold │ │ ├── archive.00100.pack.gold │ │ ├── archive.00200.pack.gold │ │ └── key.archive.000000.pack │ ├── block_db.rs │ ├── block_handle_db.rs │ ├── block_info_db.rs │ ├── catchain_persistent_db.rs │ ├── db │ ├── filedb.rs │ ├── mod.rs │ ├── rocksdb.rs │ └── tests │ │ ├── mod.rs │ │ ├── test_filedb.rs │ │ └── test_rocksdb.rs │ ├── dynamic_boc_rc_db.rs │ ├── error.rs │ ├── lib.rs │ ├── macros.rs │ ├── shard_top_blocks_db.rs │ ├── shardstate_db_async.rs │ ├── status_db.rs │ ├── tests │ ├── mod.rs │ ├── test_block_db.rs │ ├── test_block_handle_db.rs │ ├── test_catchain_persistent_db.rs │ ├── test_dynamic_boc_rc_db.rs │ ├── test_shardstate_db_async.rs │ └── testdata │ │ ├── 2467080 │ │ ├── 2467081 │ │ ├── 2467082 │ │ ├── 2467083 │ │ ├── 2467084 │ │ ├── 2467085 │ │ ├── 2467086 │ │ ├── 2467087 │ │ ├── 2467088 │ │ ├── 2467089 │ │ ├── 2467090 │ │ ├── 2467091 │ │ ├── 2467092 │ │ ├── 2467093 │ │ ├── 2467094 │ │ ├── 2467095 │ │ ├── 2467096 │ │ ├── 2467097 │ │ ├── 2467098 │ │ ├── 2467099 │ │ ├── 2467100 │ │ ├── 2467101 │ │ ├── 2467102 │ │ ├── 2467103 │ │ ├── 2467104 │ │ ├── 2467105 │ │ ├── 2467106 │ │ ├── 2467107 │ │ ├── 2467108 │ │ ├── 2467109 │ │ ├── 2467110 │ │ ├── 2467111 │ │ ├── 2467112 │ │ ├── 2467113 │ │ ├── 2467114 │ │ ├── 2467115 │ │ ├── 2467116 │ │ ├── 2467117 │ │ ├── 2467118 │ │ ├── 2467119 │ │ └── shardstate_db_v5.zip │ ├── traits.rs │ └── types │ ├── block_id.rs │ ├── block_meta.rs │ ├── db_slice.rs │ ├── mod.rs │ ├── shard_ident_key.rs │ ├── status_key.rs │ ├── storage_cell.rs │ └── tests │ ├── mod.rs │ ├── test_block_id.rs │ ├── test_serialization.rs │ └── test_storage_cell.rs ├── tests ├── setup_test_paths.sh ├── test_high_load │ ├── .gitignore │ ├── Brazil.abi.json │ ├── Brazil.sol │ ├── Brazil.tvc │ ├── SafeMultisigWallet.abi.json │ ├── SetcodeMultisigWallet.abi.json │ ├── addrBrazil │ ├── deploy.keys.2.json │ ├── deploy.keys.json │ ├── msig.keys.json │ ├── remove_junk.sh │ ├── seedphrase │ ├── test_console.sh │ ├── test_high_load.sh │ └── test_one_message.sh ├── test_remp │ ├── .gitignore │ ├── no_replay.sol │ └── test_remp.sh └── test_run_net │ ├── .gitignore │ ├── README.md │ ├── console-template.json │ ├── default_config.json │ ├── default_config_fullnode.json │ ├── log_cfg.yml │ ├── remove_junk.sh │ ├── restart_nodes.sh │ ├── stop_network.sh │ ├── test_run_net.sh │ ├── test_run_net_ci_public.sh │ ├── ton-global.config_1.json │ ├── ton-global.config_2.json │ ├── zero_state_blanc_1.json │ └── zero_state_blanc_2.json └── validator-session ├── Cargo.toml ├── README.md ├── src ├── block_candidate.rs ├── cache.rs ├── lib.rs ├── old_round.rs ├── round.rs ├── round_attempt.rs ├── sent_block.rs ├── session.rs ├── session_description.rs ├── session_processor.rs ├── session_state.rs ├── slashing.rs ├── task_queue.rs ├── utils.rs ├── vector.rs ├── vector_bool.rs └── vote_candidate.rs └── tests ├── test_fast_session.rs └── test_hash.rs /.gitignore: -------------------------------------------------------------------------------- 1 | /Cargo.lock 2 | /target 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "common"] 2 | path = common 3 | url = https://github.com/everx-labs/common.git 4 | -------------------------------------------------------------------------------- /bin/gendht.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use adnl::{adnl_node_test_key, adnl_node_test_config, node::{AdnlNode, AdnlNodeConfig}}; 15 | use adnl::DhtNode; 16 | use std::{env, ops::Deref, sync::Arc}; 17 | use ever_block::{error, base64_encode, KeyOption, Result}; 18 | 19 | async fn gen(ip: &str, dht_key_enc: &str) -> Result<()> { 20 | let config = AdnlNodeConfig::from_json( 21 | adnl_node_test_config!(ip, adnl_node_test_key!(1_usize, dht_key_enc)) 22 | ).unwrap(); 23 | let adnl = AdnlNode::with_config(config).await.unwrap(); 24 | let dht = DhtNode::with_params(adnl.clone(), 1_usize, None).unwrap(); 25 | let node = dht.get_signed_node_of_network(None).unwrap(); 26 | let key: Arc = (&node.id).try_into()?; 27 | let adr = AdnlNode::parse_address_list(&node.addr_list)?.ok_or_else( 28 | || error!("Cannot parse address list {:?}", node.addr_list) 29 | )?.into_udp(); 30 | let json = serde_json::json!( 31 | { 32 | "@type": "dht.node", 33 | "id": { 34 | "@type": "pub.ed25519", 35 | "key": base64_encode(key.pub_key()?) 36 | }, 37 | "addr_list": { 38 | "@type": "adnl.addressList", 39 | "addrs": [ 40 | { 41 | "@type": "adnl.address.udp", 42 | "ip": adr.ip, 43 | "port": adr.port 44 | } 45 | ], 46 | "version": node.addr_list.version, 47 | "reinit_date": node.addr_list.reinit_date, 48 | "priority": node.addr_list.priority, 49 | "expire_at": node.addr_list.expire_at 50 | }, 51 | "version": node.version, 52 | "signature": base64_encode(node.signature.deref()) 53 | } 54 | ); 55 | println!("{}", serde_json::to_string_pretty(&json)?); 56 | Ok(()) 57 | } 58 | 59 | #[tokio::main] 60 | async fn main() { 61 | let args: Vec = env::args().collect(); 62 | if args.len() != 3 { 63 | println!("Usage: gendht "); 64 | return 65 | }; 66 | gen(&args[1], &args[2]).await.unwrap_or_else(|e| println!("gen error: {}", e)) 67 | } 68 | -------------------------------------------------------------------------------- /bin/keygen.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use ever_block::{base64_decode, base64_encode, Ed25519KeyOption, Result}; 15 | 16 | fn gen() -> Result<()> { 17 | let (private, public) = Ed25519KeyOption::generate_with_json()?; 18 | let private = serde_json::to_value(private)?; 19 | println!("{:#}", serde_json::json!({ 20 | "private": { 21 | "type_id": Ed25519KeyOption::KEY_TYPE, 22 | "pvt_key": private["pvt_key"], 23 | }, 24 | "public": { 25 | "type_id": Ed25519KeyOption::KEY_TYPE, 26 | "pub_key": base64_encode(public.pub_key()?), 27 | }, 28 | "keyhash": base64_encode(public.id().data()), 29 | "hex": { 30 | "secret": hex::encode(base64_decode(private["pvt_key"].as_str().unwrap())?), 31 | "public": hex::encode(public.pub_key()?) 32 | } 33 | })); 34 | Ok(()) 35 | } 36 | 37 | fn main() { 38 | gen().unwrap_or_else(|e| println!("Keypair generation error: {}", e)) 39 | } 40 | -------------------------------------------------------------------------------- /bin/keyid.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use std::{convert::TryInto, env}; 15 | use ever_block::{error, fail, base64_decode, base64_encode, Ed25519KeyOption, Result}; 16 | 17 | fn compute(typ: &str, key: &str) -> Result<()> { 18 | let key_bin = base64_decode(key)?; 19 | let key_bin: [u8; 32] = key_bin.try_into().map_err( 20 | |_| error!("Cannot decode key properly") 21 | )?; 22 | let key = if typ.to_lowercase().as_str() == "pub" { 23 | println!("Public key: {}", key); 24 | Ed25519KeyOption::from_public_key(&key_bin) 25 | } else if typ.to_lowercase().as_str() == "pvt" { 26 | println!("Private key: {}", key); 27 | let key = Ed25519KeyOption::from_private_key(&key_bin)?; 28 | println!("Public key: {}", base64_encode(key.pub_key()?)); 29 | #[cfg(feature = "export_key")] 30 | println!("Extended private key: {}", base64_encode(key.export_key()?)); 31 | key 32 | } else { 33 | fail!("Wrong key type: expected pub|pvt, found {}", typ) 34 | }; 35 | println!("Key id: {}", base64_encode(key.id().data())); 36 | Ok(()) 37 | } 38 | 39 | fn main() { 40 | let args: Vec = env::args().collect(); 41 | if args.len() != 3 { 42 | println!("Usage: keyid pub|pvt "); 43 | return 44 | }; 45 | compute(&args[1], &args[2]).unwrap_or_else(|e| println!("Key ID computing error: {}", e)); 46 | } 47 | -------------------------------------------------------------------------------- /catchain/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | build = '../common/build/build.rs' 3 | edition = '2021' 4 | name = 'catchain' 5 | version = '0.1.1' 6 | 7 | [dependencies] 8 | anyhow = '1.0' 9 | chrono = '0.4' 10 | crossbeam = '0.8' 11 | futures = '0.3' 12 | hex = '0.4' 13 | lazy_static = '1.4' 14 | log = '0.4' 15 | metrics = '0.21' 16 | metrics-util = '0.15' 17 | quanta = '0.11' 18 | rand = '0.8' 19 | regex = '1.10' 20 | tokio = { features = [ 'rt-multi-thread' ], version = '1.40' } 21 | adnl = { features = [ 'node' ], git = 'https://github.com/everx-labs/ever-adnl.git', tag = '0.11.32' } 22 | ever_block = { git = 'https://github.com/everx-labs/ever-block.git', tag = '1.11.20' } 23 | storage = { path = '../storage' } 24 | ton_api = { git = 'https://github.com/everx-labs/ever-tl.git', package = 'ton_api', tag = '0.4.29' } 25 | 26 | [dev-dependencies] 27 | env_logger = '0.11' 28 | pretty_assertions = '1.3' 29 | rocksdb = '0.22' 30 | 31 | [features] 32 | default = [ ] 33 | export_key = [ 'ever_block/export_key' ] 34 | 35 | -------------------------------------------------------------------------------- /catchain/src/block_payload.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::{BlockPayload, BlockPayloadPtr, RawBuffer}; 15 | use std::{fmt, sync::Arc, time::SystemTime}; 16 | 17 | /* 18 | Implementation details for BlockPayload 19 | */ 20 | 21 | pub(crate) struct BlockPayloadImpl { 22 | data: RawBuffer, //raw data 23 | creation_time: SystemTime, //time of block creation 24 | } 25 | 26 | /* 27 | Implementation for public BlockPayload trait 28 | */ 29 | 30 | impl BlockPayload for BlockPayloadImpl { 31 | fn data(&self) -> &RawBuffer { 32 | &self.data 33 | } 34 | 35 | fn get_creation_time(&self) -> std::time::SystemTime { 36 | self.creation_time 37 | } 38 | } 39 | 40 | /* 41 | Implementation for public Debug trait 42 | */ 43 | 44 | impl fmt::Debug for BlockPayloadImpl { 45 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 46 | write!(f, "{:?}", self.data) 47 | } 48 | } 49 | 50 | /* 51 | Implementation of BlockPayloadImpl 52 | */ 53 | 54 | impl BlockPayloadImpl { 55 | pub(crate) fn create(data: RawBuffer) -> BlockPayloadPtr { 56 | Arc::new(Self { 57 | data, 58 | creation_time: SystemTime::now(), 59 | }) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /catchain/tests/test_log_replay.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use catchain::*; 15 | use std::path::Path; 16 | use storage::db::rocksdb::destroy_rocks_db; 17 | 18 | 19 | const DB_PATH: &str = "../target/test"; 20 | 21 | #[tokio::test] 22 | async fn log_replay_multiple_players() { 23 | 24 | const DB_NAME: &str = "catchains_log_replay_multiple_players"; 25 | 26 | let db_path = Path::new(DB_PATH).join(DB_NAME).display().to_string(); 27 | let mut replay_opts = LogReplayOptions::with_db(db_path); 28 | replay_opts.log_file_name = "tests/log_header.log".to_string(); 29 | let log_players = CatchainFactory::create_log_players(&replay_opts); 30 | 31 | for log_player in log_players { 32 | println!( 33 | "Session {} with {} nodes and local_id {} has been detected", 34 | log_player.get_session_id().to_hex_string(), 35 | log_player.get_nodes().len(), 36 | log_player.get_local_id() 37 | ); 38 | } 39 | 40 | drop(replay_opts); 41 | destroy_rocks_db(DB_PATH, DB_NAME).await.unwrap() 42 | 43 | } 44 | -------------------------------------------------------------------------------- /catchain/tests/test_ton_structs.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use catchain::*; 15 | 16 | #[test] 17 | fn test_block_update() { 18 | let block_update = ton::BlockUpdateEvent::default(); 19 | pretty_assertions::assert_eq!( 20 | format!( 21 | "{:?}", block_update), 22 | "BlockUpdate { block: Block { incarnation: 0000000000000000000000000000000000000000000000000000000000000000, \ 23 | src: 0, height: 0, data: Data { prev: Dep { src: 0, height: 0, \ 24 | data_hash: 0000000000000000000000000000000000000000000000000000000000000000, signature: [] }, \ 25 | deps: [] }, signature: [] } }" 26 | ); 27 | } 28 | -------------------------------------------------------------------------------- /config.md: -------------------------------------------------------------------------------- 1 | Root section 2 | ------------ 3 | 4 | * `sync_by_archives`: possible values `true` and `false`. Default value `false`. If set `true` 5 | allows to synchronize node by archives instead of single blocks. It may be useful in some 6 | conditions, for example, long ping to other nodes. 7 | 8 | `remp` section 9 | ------------ 10 | 11 | * `service_enabled`: possible values `true` and `false`. 12 | Enables participation in validator REMP protocols. Default value is `true`. 13 | 14 | The service allows the node to validate in REMP networks, but does not affect validation 15 | in non-REMP networks. So if the Network REMP capability is turned off now but may be activated 16 | in the future, leave the default value. 17 | 18 | However, REMP protocols take some resources from the node even if the REMP capability is 19 | turned off. If the node is not expected to be a validator in REMP network, 20 | set this to `false`. 21 | 22 | * `client_enabled`: possible values `true` and `false`. Default value `true`. 23 | 24 | Enables participation in client REMP protocols. With this option 25 | set to `false`, the node may not send external messages to 26 | REMP network. As with `service_enabled` parameter, the client service is transparent 27 | for non-REMP networks, but may take extra hardware resources. 28 | 29 | * `message_queue_max_len`: non-negative integer value. 30 | When specified, sets maximal number of external messages 31 | which can be handled by REMP simultaneously. Handling means all 32 | message processing stages from its receiving by node till 33 | its expiration for replay protection purposes. The message count 34 | is performed for each shard separately. 35 | 36 | May be used to avoid node overloading by external messages. If the 37 | queue becomes too long, all new messages are rejected, until some of the 38 | messages from the queue become outdated (that is, their replay protection 39 | period expires). 40 | 41 | If the value is not specified, no check of the message queue length is performed. 42 | 43 | * `forcedly_disable_remp_cap`: possible values `true` and `false`. The parameter is 44 | available only in `remp_emergency` compilation configuration. Allows to locally 45 | disable REMP capability even if the capability is enabled by the network. May be 46 | used for network recovery. 47 | 48 | * `remp_client_pool`: integer value 0 to 255. Number of threads (as a percentage of CPU Cores number), 49 | used for preliminary message processing in REMP client. 50 | Default value is 100% (the number of threads equals the number of CPU Cores). 51 | At least one thread is started anyway. 52 | 53 | Before being sent to validators, any external REMP message is executed in test mode on a client 54 | (proper blockchain state is constructed, virtual machine is activated etc), and if the message 55 | processing results in error, it is rejected on the client and not sent to validators. 56 | 57 | * `max_incoming_broadcast_delay_millis`: non-negative integer value. When external 58 | messages are sent to validators via broadcast (legacy mechanism), they come to all nodes 59 | in the network simultaneously, which may create a significant overload in 60 | REMP Catchain. To overcome this, the messages coming to the validators may be 61 | delayed for a random time, in a hope that only one copy of the message is 62 | processed and transferred to REMP Catchain. The random time distribution of the message 63 | copies gives enough time for the network to propagate message over it, so copies delayed 64 | for longer periods will be easily identified as duplicates (the validator will 65 | already have the same message received through Catchain from another validtor). 66 | The parameter specifies maximal delay. 67 | 68 | * `smft_disabled`: manually disables participation of the node in SMFT protocol even if corresponding network config is set; false by default 69 | 70 | -------------------------------------------------------------------------------- /configs/default_config_mainet_initblock_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "log_config_name": "../common/config/log_cfg_debug.yml", 3 | "ton_global_config_name": "../configs/ton-global.config-mainet-initblock-test.json", 4 | "internal_db_path": "target/node_db", 5 | "ip_address": "0.0.0.0:30303", 6 | "control_server_port": 4925, 7 | "shard_keeper": { 8 | "get_peer_attempt_timeout_ms": 1000, 9 | "download_next_block_full_timeout_ms": 1000, 10 | "download_block_full_timeout_ms": 1000 11 | }, 12 | "kafka_consumer_config": { 13 | "group_id": "101", 14 | "brokers": "kafka", 15 | "topic": "requests", 16 | "session_timeout_ms": 6000, 17 | "run_attempt_timeout_ms": 1000 18 | }, 19 | "external_db_config": { 20 | "block_producer": { 21 | "enabled": true, 22 | "brokers": "kafka", 23 | "message_timeout_ms": 100, 24 | "topic": "blocks", 25 | "attempt_timeout_ms": 100, 26 | "message_max_size": 1000000, 27 | "big_messages_storage": "big-blocks" 28 | }, 29 | "message_producer": { 30 | "enabled": true, 31 | "brokers": "kafka", 32 | "message_timeout_ms": 100, 33 | "topic": "messages", 34 | "attempt_timeout_ms": 100, 35 | "message_max_size": 1000000, 36 | "big_messages_storage": "big-messages" 37 | }, 38 | "transaction_producer": { 39 | "enabled": true, 40 | "brokers": "kafka", 41 | "message_timeout_ms": 100, 42 | "topic": "transactions", 43 | "attempt_timeout_ms": 100, 44 | "message_max_size": 1000000, 45 | "big_messages_storage": "big-transactions" 46 | }, 47 | "account_producer": { 48 | "enabled": true, 49 | "brokers": "kafka", 50 | "message_timeout_ms": 100, 51 | "topic": "accounts", 52 | "attempt_timeout_ms": 100, 53 | "message_max_size": 2000000, 54 | "big_messages_storage": "big-accounts" 55 | }, 56 | "block_proof_producer": { 57 | "enabled": true, 58 | "brokers": "kafka", 59 | "message_timeout_ms": 100, 60 | "topic": "blocks_signatures", 61 | "attempt_timeout_ms": 100, 62 | "message_max_size": 2000000, 63 | "big_messages_storage": "big-block-proofs" 64 | }, 65 | "bad_blocks_storage": "bad-blocks" 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /configs/default_config_mainet_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "log_config_name": "../common/config/log_cfg_debug.yml", 3 | "ton_global_config_name": "../configs/ton-global.config-mainet-test.json", 4 | "internal_db_path": "target/node_db", 5 | "ip_address": "0.0.0.0:30303", 6 | "control_server_port": 4925, 7 | "shard_keeper": { 8 | "get_peer_attempt_timeout_ms": 1000, 9 | "download_next_block_full_timeout_ms": 1000, 10 | "download_block_full_timeout_ms": 1000 11 | }, 12 | "kafka_consumer_config": { 13 | "group_id": "101", 14 | "brokers": "kafka", 15 | "topic": "requests", 16 | "session_timeout_ms": 6000, 17 | "run_attempt_timeout_ms": 1000 18 | }, 19 | "external_db_config": { 20 | "block_producer": { 21 | "enabled": true, 22 | "brokers": "kafka", 23 | "message_timeout_ms": 100, 24 | "topic": "blocks", 25 | "attempt_timeout_ms": 100, 26 | "message_max_size": 1000000, 27 | "big_messages_storage": "big-blocks" 28 | }, 29 | "message_producer": { 30 | "enabled": true, 31 | "brokers": "kafka", 32 | "message_timeout_ms": 100, 33 | "topic": "messages", 34 | "attempt_timeout_ms": 100, 35 | "message_max_size": 1000000, 36 | "big_messages_storage": "big-messages" 37 | }, 38 | "transaction_producer": { 39 | "enabled": true, 40 | "brokers": "kafka", 41 | "message_timeout_ms": 100, 42 | "topic": "transactions", 43 | "attempt_timeout_ms": 100, 44 | "message_max_size": 1000000, 45 | "big_messages_storage": "big-transactions" 46 | }, 47 | "account_producer": { 48 | "enabled": true, 49 | "brokers": "kafka", 50 | "message_timeout_ms": 100, 51 | "topic": "accounts", 52 | "attempt_timeout_ms": 100, 53 | "message_max_size": 2000000, 54 | "big_messages_storage": "big-accounts" 55 | }, 56 | "block_proof_producer": { 57 | "enabled": true, 58 | "brokers": "kafka", 59 | "message_timeout_ms": 100, 60 | "topic": "blocks_signatures", 61 | "attempt_timeout_ms": 100, 62 | "message_max_size": 2000000, 63 | "big_messages_storage": "big-block-proofs" 64 | }, 65 | "bad_blocks_storage": "bad-blocks" 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /configs/ton-global.config-sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "@type": "config.global", 3 | "dht": { 4 | "@type": "dht.config.global", 5 | "k": 6, 6 | "a": 3, 7 | "static_nodes": { 8 | "@type": "dht.nodes", 9 | "nodes": [ 10 | { 11 | "@type": "dht.node", 12 | "id": { 13 | "@type": "pub.ed25519", 14 | "key": "qMDn6lmlG+pR4FskBHRkoW8nAD47sONI7TD0jW9rA9g=" 15 | }, 16 | "addr_list": { 17 | "@type": "adnl.addressList", 18 | "addrs": [ 19 | { 20 | "@type": "adnl.address.udp", 21 | "ip": 2130706433, 22 | "port": 5191 23 | } 24 | ], 25 | "version": 1667830754, 26 | "reinit_date": 1667830754, 27 | "priority": 0, 28 | "expire_at": 0 29 | }, 30 | "version": 1667830754, 31 | "signature": "E58ddlwR4dlpkV0m/97QVlyc/vEdXp6SAvRIFdiHDpVwz3slF0DQjOS/Ex6Nss/wPbxXL82ufP/cg4LRlAQNDQ==" 32 | } 33 | ] 34 | } 35 | }, 36 | "validator": { 37 | "@type": "validator.config.global", 38 | "zero_state": { 39 | "workchain": -1, 40 | "shard": -9223372036854775808, 41 | "seqno": 0, 42 | "root_hash": "nHr8CsL3so/Y2yB/wFrF4OjBmhVUIDEArkYicSpCt9M=", 43 | "file_hash": "VsBCvRsjDMiqEiVJjveFHh6T6nKpz0W1dpOxQ0g8gnM=" 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /recomended_rust: -------------------------------------------------------------------------------- 1 | 1.81.0 2 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "1.81.0" 3 | -------------------------------------------------------------------------------- /src/error.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | #[derive(Debug, thiserror::Error)] 15 | pub enum NodeError { 16 | #[error("Invalid argument: {0}")] 17 | InvalidArg(String), 18 | #[error("Invalid data: {0}")] 19 | InvalidData(String), 20 | #[error("Invalid operation: {0}")] 21 | InvalidOperation(String), 22 | #[error("{0}")] 23 | ValidatorReject(String), 24 | #[error("{0}")] 25 | ValidatorSoftReject(String), 26 | #[error("Timeout {0}")] 27 | Timeout(String), 28 | #[cfg(feature = "external_db")] 29 | #[error("{0}")] 30 | #[allow(dead_code)] 31 | Other(String), 32 | } 33 | -------------------------------------------------------------------------------- /src/external_db/stub_producer.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::external_db::WriteData; 15 | 16 | use ever_block::Result; 17 | 18 | #[derive(Clone)] 19 | pub struct StubProducer { 20 | pub enabled: bool 21 | } 22 | 23 | #[async_trait::async_trait] 24 | impl WriteData for StubProducer { 25 | fn enabled(&self) -> bool { self.enabled } 26 | fn sharding_depth(&self) -> u32 { 0 } 27 | async fn write_data(&self, _key: String, _data: String, _attributes: Option<&[(&str, &[u8])]>, _partition_key: Option) -> Result<()> { 28 | futures_timer::Delay::new(std::time::Duration::from_millis(3)).await; 29 | Ok(()) 30 | } 31 | async fn write_raw_data(&self, _key: Vec, _data: Vec, _attributes: Option<&[(&str, &[u8])]>, _partition_key: Option) -> Result<()> { 32 | futures_timer::Delay::new(std::time::Duration::from_millis(3)).await; 33 | Ok(()) 34 | } 35 | } -------------------------------------------------------------------------------- /src/external_db/tests/static/4437297: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/external_db/tests/static/4437297 -------------------------------------------------------------------------------- /src/external_db/tests/static/705EE27D8C862EC367977465042211F9C72EB94D28040784F8424DEAB3AC642C.boc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/external_db/tests/static/705EE27D8C862EC367977465042211F9C72EB94D28040784F8424DEAB3AC642C.boc -------------------------------------------------------------------------------- /src/external_db/tests/static/9CD0BCB4D40665E7928274894E98703E47CFC408048BA144CE913818692E7A15.boc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/external_db/tests/static/9CD0BCB4D40665E7928274894E98703E47CFC408048BA144CE913818692E7A15.boc -------------------------------------------------------------------------------- /src/external_db/tests/static/state_705EE27D8C862EC367977465042211F9C72EB94D28040784F8424DEAB3AC642C.boc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/external_db/tests/static/state_705EE27D8C862EC367977465042211F9C72EB94D28040784F8424DEAB3AC642C.boc -------------------------------------------------------------------------------- /src/external_db/tests/static/state_9CD0BCB4D40665E7928274894E98703E47CFC408048BA144CE913818692E7A15.boc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/external_db/tests/static/state_9CD0BCB4D40665E7928274894E98703E47CFC408048BA144CE913818692E7A15.boc -------------------------------------------------------------------------------- /src/full_node/counters.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use adnl::common::add_unbound_object_to_map_with_update; 15 | use std::{ 16 | time::{SystemTime, UNIX_EPOCH}, 17 | sync::atomic::{AtomicU32, Ordering}, 18 | }; 19 | use ever_block::{fail, Result}; 20 | 21 | const CLEAR_STAT_INTERVAL_BLOCKS: u32 = 10_000; 22 | const MAX_TPS_PERIOD_SEC: u64 = 3600; 23 | const TPS_PERIOD_LAG: u64 = 30; 24 | 25 | #[derive(Default)] 26 | pub struct TpsCounter { 27 | transactions: lockfree::map::Map, // unix time - transactions 28 | gc_counter: AtomicU32, 29 | } 30 | 31 | impl TpsCounter { 32 | pub fn submit_transactions(&self, block_time: u64, tr_count: usize) { 33 | let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_secs(); 34 | if now >= block_time && now - block_time <= MAX_TPS_PERIOD_SEC + TPS_PERIOD_LAG { 35 | add_unbound_object_to_map_with_update( 36 | &self.transactions, 37 | block_time, 38 | |found| if let Some(a) = found { 39 | a.fetch_add(tr_count as u32, Ordering::Relaxed); 40 | Ok(None) 41 | } else { 42 | Ok(Some(AtomicU32::new(tr_count as u32))) 43 | } 44 | ).expect("Can't return error"); 45 | } 46 | 47 | if self.gc_counter.fetch_update( 48 | Ordering::Relaxed, 49 | Ordering::Relaxed, 50 | |c| if c >= CLEAR_STAT_INTERVAL_BLOCKS { Some(0) } else { Some(c + 1) } 51 | ).unwrap_or(0) >= CLEAR_STAT_INTERVAL_BLOCKS { 52 | self.gc(); 53 | } 54 | } 55 | 56 | pub fn calc_tps(&self, period: u64) -> Result { 57 | let mut tr_count = 0; 58 | if period == 0 { 59 | fail!("period can't be zero"); 60 | } 61 | if period > MAX_TPS_PERIOD_SEC { 62 | fail!("period is too big (max is {})", MAX_TPS_PERIOD_SEC); 63 | } 64 | for guard in self.transactions.iter() { 65 | let time = SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_secs() - TPS_PERIOD_LAG; 66 | if time > *guard.key() && time <= guard.key() + period { 67 | tr_count += guard.val().load(Ordering::Relaxed); 68 | } 69 | } 70 | Ok(tr_count / period as u32) 71 | } 72 | 73 | fn gc(&self) { 74 | let time = SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_secs(); 75 | for guard in self.transactions.iter() { 76 | if time > guard.key() + MAX_TPS_PERIOD_SEC + TPS_PERIOD_LAG { 77 | self.transactions.remove(guard.key()); 78 | } 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /src/full_node/mod.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | pub mod state_helper; 15 | pub mod apply_block; 16 | pub mod shard_client; 17 | #[cfg(feature = "telemetry")] 18 | pub mod telemetry; 19 | pub mod counters; 20 | pub mod remp_client; 21 | pub mod mesh_client; -------------------------------------------------------------------------------- /src/internal_db/update.rs: -------------------------------------------------------------------------------- 1 | use crate::internal_db::{ 2 | InternalDb, CURRENT_DB_VERSION, DB_VERSION_5, DB_VERSION_4, 3 | }; 4 | use std::sync::atomic::AtomicBool; 5 | use ever_block::{Result, fail}; 6 | 7 | pub async fn update( 8 | db: InternalDb, 9 | mut version: u32, 10 | _check_stop: &(dyn Fn() -> Result<()> + Sync), 11 | _is_broken: Option<&AtomicBool>, 12 | _force_check_db: bool, 13 | _restore_db_enabled: bool, 14 | ) -> Result { 15 | if version == CURRENT_DB_VERSION { 16 | return Ok(db) 17 | } 18 | 19 | if version < DB_VERSION_4 { 20 | fail!("Detected tool old database version {version}. Last supported version is {DB_VERSION_4}. \ 21 | Please stop the node and clean database.", ); 22 | } 23 | if version == DB_VERSION_4 { 24 | log::info!("Detected old database version {version}. Migration to v5 will take some time..."); 25 | db.migrate_handles_to_v5()?; 26 | db.store_db_version(DB_VERSION_5)?; 27 | version = DB_VERSION_5; 28 | } 29 | if version == DB_VERSION_5 { 30 | log::info!("Detected old database version {version}. Migration to v6 will take some time..."); 31 | 32 | db.update_cells_db_to_v6().await?; 33 | 34 | db.store_db_version(CURRENT_DB_VERSION)?; 35 | version = CURRENT_DB_VERSION; 36 | } 37 | 38 | if version != CURRENT_DB_VERSION { 39 | fail!("Wrong database version {}, supported: {}", version, CURRENT_DB_VERSION); 40 | } 41 | 42 | Ok(db) 43 | } 44 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | pub mod block; 15 | pub mod block_proof; 16 | pub mod boot; 17 | pub mod collator_test_bundle; 18 | pub mod config; 19 | pub mod error; 20 | pub mod engine; 21 | pub mod engine_traits; 22 | pub mod engine_operations; 23 | pub mod full_node; 24 | pub mod internal_db; 25 | pub mod macros; 26 | pub mod network; 27 | pub mod rng; 28 | pub mod shard_state; 29 | pub mod sync; 30 | pub mod types; 31 | pub mod validating_utils; 32 | pub mod validator; 33 | pub mod shard_states_keeper; 34 | mod mesh_queues_keeper; 35 | 36 | pub mod ext_messages; 37 | 38 | mod shard_blocks; 39 | 40 | include!("../common/src/info.rs"); 41 | 42 | #[cfg(feature = "external_db")] 43 | mod external_db; 44 | 45 | #[cfg(test)] 46 | #[path = "tests/test_helper.rs"] 47 | pub mod test_helper; 48 | -------------------------------------------------------------------------------- /src/macros.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | #[macro_export] 15 | macro_rules! dump { 16 | ($data: expr) => { 17 | { 18 | let mut dump = String::new(); 19 | for i in 0..$data.len() { 20 | dump.push_str( 21 | &format!( 22 | "{:02x}{}", 23 | $data[i], 24 | if (i + 1) % 16 == 0 { '\n' } else { ' ' } 25 | ) 26 | ) 27 | } 28 | dump 29 | } 30 | }; 31 | (debug, $target:expr, $msg:expr, $data:expr) => { 32 | if log::log_enabled!(log::Level::Debug) { 33 | log::debug!(target: $target, "{}:\n{}", $msg, dump!($data)) 34 | } 35 | }; 36 | (trace, $target:expr, $msg:expr, $data:expr) => { 37 | if log::log_enabled!(log::Level::Trace) { 38 | log::trace!(target: $target, "{}:\n{}", $msg, dump!($data)) 39 | } 40 | } 41 | } 42 | 43 | #[macro_export] 44 | macro_rules! CHECK { 45 | ($exp:expr) => { 46 | // TODO: remove for production 47 | if !($exp) { 48 | ever_block::fail!("{} {}:{}", stringify!($exp), file!(), line!()) 49 | } 50 | }; 51 | ($exp:expr, inited) => { 52 | // TODO: remove for production 53 | if $exp == &Default::default() { 54 | ever_block::fail!("{} {}:{}", stringify!($exp), file!(), line!()) 55 | } 56 | }; 57 | ($exp:expr, default) => { 58 | // TODO: remove for production 59 | if $exp != &Default::default() { 60 | ever_block::fail!("{} {}:{}", stringify!($exp), file!(), line!()) 61 | } 62 | }; 63 | ($exp1:expr, $exp2:expr) => {{ 64 | // TODO: remove for production 65 | #[cfg(test)] 66 | pretty_assertions::assert_eq!($exp1, $exp2); 67 | if $exp1 != $exp2 { 68 | ever_block::fail!("{} != {} {}:{}", stringify!($exp1), stringify!($exp2), file!(), line!()) 69 | } 70 | }}; 71 | } 72 | -------------------------------------------------------------------------------- /src/mesh_queues_keeper.rs: -------------------------------------------------------------------------------- 1 | use std::sync::Arc; 2 | use storage::shardstate_db_async::AllowStateGcResolver; 3 | use ever_block::{BlockIdExt, ShardIdent, OutMsgQueueInfo, Result, fail}; 4 | 5 | pub struct MeshQueuesKeeper { 6 | queues: lockfree::map::Map<(i32, BlockIdExt, ShardIdent), Arc>, 7 | } 8 | 9 | impl MeshQueuesKeeper { 10 | pub fn new() -> Arc { 11 | Arc::new(Self { 12 | queues: lockfree::map::Map::new(), 13 | }) 14 | } 15 | 16 | // ShardStatesKeeper calls this method from clean_cache_worker if cache_resolver advanced 17 | pub fn gc( 18 | &self, 19 | cache_resolver: &dyn AllowStateGcResolver, 20 | ) -> Result<()> { 21 | log::debug!("MeshQueuesKeeper::gc: started"); 22 | let now = std::time::Instant::now(); 23 | let mut total = 0; 24 | let mut cleaned = 0; 25 | 26 | 27 | // TODO while mesh nw is not active it is not commited to our masterchain, so we don't know 28 | // what to delete. It is not a big deal, because queues are empty, but we should fix it somehow. 29 | 30 | 31 | for guard in &self.queues { 32 | total += 1; 33 | let (nw_id, mc_id, shard) = guard.key(); 34 | if cache_resolver.allow_state_gc(*nw_id, mc_id, 0, 0)? { 35 | log::trace!("MeshQueuesKeeper::gc: removing queue for {nw_id} {mc_id} {shard}"); 36 | self.queues.remove(guard.key()); 37 | cleaned +=1; 38 | } 39 | } 40 | log::debug!( 41 | "MeshQueuesKeeper::gc: finished TIME {time}ms, cleaned: {cleaned}, total: {total}", 42 | time = now.elapsed().as_millis() 43 | ); 44 | Ok(()) 45 | } 46 | 47 | pub fn store_mesh_queue( 48 | &self, 49 | nw_id: i32, 50 | mc_block_id: &BlockIdExt, 51 | shard: &ShardIdent, 52 | queue: Arc 53 | ) -> Result<()> { 54 | let key = (nw_id, mc_block_id.clone(), shard.clone()); 55 | let _ = self.queues.insert(key, queue); 56 | Ok(()) 57 | } 58 | 59 | pub fn load_mesh_queue( 60 | &self, 61 | nw_id: i32, 62 | mc_block_id: &BlockIdExt, 63 | shard: &ShardIdent 64 | ) -> Result> { 65 | let key = (nw_id, mc_block_id.clone(), shard.clone()); 66 | if let Some(queue_root) = self.queues.get(&key) { 67 | Ok(queue_root.val().clone()) 68 | } else { 69 | fail!("Mesh queue {nw_id} {mc_block_id} {shard} not found", ) 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /src/network/mod.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | pub mod catchain_client; 15 | pub mod node_network; 16 | pub mod neighbours; 17 | pub mod full_node_client; 18 | pub mod full_node_service; 19 | pub mod control; 20 | #[cfg(feature = "telemetry")] 21 | pub mod telemetry; 22 | pub mod remp; -------------------------------------------------------------------------------- /src/network/tests/test_telemetry.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use super::*; 15 | use std::time::Duration; 16 | use ton_api::ton::rpc::ton_node::PrepareBlockProof; 17 | 18 | #[test] 19 | pub fn test_fullnode_service_telemetry() { 20 | let t = FullNodeNetworkTelemetry::new_client(); 21 | for i in 1..1000 { 22 | t.consumed_query( 23 | std::any::type_name::().to_string(), 24 | i % 5 != 0, Duration::from_millis(1 + i), (1024 + i) as usize); 25 | } 26 | let r = t.report(5); 27 | println!("{}", r); 28 | assert_eq!(r, 29 | " query total bytes succeded time: min avg max failed time: min avg max 30 | ↓ton_api..c::ton_node::PrepareBlockProof 999 1522476 800( 80%) 2 501 1000 199( 20%) 6 501 996 31 | Total: 1522476 bytes, 304495 bytes/secons"); 32 | 33 | for i in 1..100 { 34 | t.consumed_query("query number two".to_owned(), i % 7 != 0, Duration::from_millis(1 + i), (1024 * 1024 + i) as usize); 35 | } 36 | let r = t.report(5); 37 | println!("{}", r); 38 | assert_eq!(r, 39 | " query total bytes succeded time: min avg max failed time: min avg max 40 | ↓ query number two 99 103813974 85( 86%) 2 50 100 14( 14%) 8 53 99 41 | Total: 103813974 bytes, 20762794 bytes/secons"); 42 | 43 | for i in 1..1024 { 44 | t.consumed_query("query number three".to_owned(), false, Duration::from_millis(1 + i), (1024 * i) as usize); 45 | } 46 | let r = t.report(5); 47 | println!("{}", r); 48 | assert_eq!(r, 49 | " query total bytes succeded time: min avg max failed time: min avg max 50 | ↓ query number three 1023 536346624 0 1023(100%) 2 513 1024 51 | Total: 536346624 bytes, 107269324 bytes/secons"); 52 | 53 | for i in 1..24 { 54 | t.consumed_query("query number four".to_owned(), true, Duration::from_millis(1 + i), 0); 55 | } 56 | let r = t.report(5); 57 | println!("{}", r); 58 | assert_eq!(r, 59 | " query total bytes succeded time: min avg max failed time: min avg max 60 | ↓ query number four 23 0 23(100%) 2 13 24 0 61 | Total: 0 bytes, 0 bytes/secons"); 62 | } -------------------------------------------------------------------------------- /src/rng/mod.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | pub mod random; 15 | -------------------------------------------------------------------------------- /src/rng/random.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | // We need big size buffer for good rand bytes 15 | 16 | #![allow(dead_code)] 17 | 18 | use openssl::rand::rand_bytes; 19 | 20 | #[cfg(test)] 21 | #[path = "tests/test_random.rs"] 22 | mod tests; 23 | 24 | /* 25 | pub struct Randbuf { 26 | buf: Vec, 27 | buf_size: usize 28 | } 29 | 30 | impl Randbuf { 31 | pub fn init (value: usize) -> Self { 32 | Self { 33 | buf: vec![0 as u8; 0], 34 | buf_size: value 35 | } 36 | } 37 | 38 | fn gen(&mut self) { 39 | rand_bytes(&mut self.buf).unwrap(); 40 | } 41 | 42 | pub fn secure_bytes (&mut self, mut orig: &mut Vec, mut size: usize){ 43 | if self.buf.len() == 0 { 44 | self.buf.resize(self.buf_size, 0 as u8); 45 | self.gen(); 46 | } 47 | if orig.len() != size { 48 | orig.resize(size, 0 as u8); 49 | } 50 | let ready = std::cmp::min(size, self.buf.len()); 51 | if size > self.buf_size { 52 | rand_bytes(&mut orig).unwrap(); 53 | return; 54 | } 55 | if ready != 0 { 56 | orig[..ready - 1].copy_from_slice(&self.buf[self.buf.len() - ready..self.buf.len() - 1]); 57 | size -= ready; 58 | self.buf.resize(size, 0 as u8); 59 | if size == 0 { 60 | return; 61 | } 62 | } 63 | self.buf.resize(self.buf_size, 0 as u8); 64 | self.gen(); 65 | orig[ready..].copy_from_slice(&self.buf[self.buf.len() - size..self.buf.len() - 1]); 66 | return; 67 | } 68 | } 69 | */ 70 | 71 | pub fn secure_bytes(orig: &mut Vec, size: usize) { 72 | orig.resize(size, 0); 73 | rand_bytes(orig).unwrap(); 74 | } 75 | 76 | pub fn secure_256_bits() -> [u8; 32] { 77 | let mut buf = [0; 32]; 78 | rand_bytes(&mut buf).unwrap(); 79 | buf 80 | } 81 | -------------------------------------------------------------------------------- /src/rng/tests/test_random.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::rng::random::secure_bytes; 15 | 16 | #[test] 17 | fn test_gen_rand() { 18 | let mut orig: Vec = Vec::new(); 19 | secure_bytes(&mut orig, 112); 20 | assert!(orig.len() == 112); 21 | println!("{:?}", &orig); 22 | secure_bytes(&mut orig, 630); 23 | assert!(orig.len() == 630); 24 | println!("{:?}", &orig); 25 | secure_bytes(&mut orig, 490); 26 | assert!(orig.len() == 490); 27 | println!("{:?}", &orig); 28 | secure_bytes(&mut orig, 110); 29 | assert!(orig.len() == 110); 30 | println!("{:?}", &orig); 31 | } 32 | 33 | -------------------------------------------------------------------------------- /src/tests/static/368730B00DE6947DD549ABCF53730FC33FE96C8FAABDACBBB71E9D510525D639.boc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/368730B00DE6947DD549ABCF53730FC33FE96C8FAABDACBBB71E9D510525D639.boc -------------------------------------------------------------------------------- /src/tests/static/ABA8391BAF9DB3B48A6DAE91F8251DC031ACBCE22A80903C08B48BFDD5F6D7D0.boc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/ABA8391BAF9DB3B48A6DAE91F8251DC031ACBCE22A80903C08B48BFDD5F6D7D0.boc -------------------------------------------------------------------------------- /src/tests/static/F2BC2888EAE466FC172140A90949EDBC7091D81CCB4194A225C56C0F1D095097.boc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/F2BC2888EAE466FC172140A90949EDBC7091D81CCB4194A225C56C0F1D095097.boc -------------------------------------------------------------------------------- /src/tests/static/archive.1459995.pack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/archive.1459995.pack -------------------------------------------------------------------------------- /src/tests/static/b571525: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/b571525 -------------------------------------------------------------------------------- /src/tests/static/basestate0.boc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/basestate0.boc -------------------------------------------------------------------------------- /src/tests/static/key_block.boc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/key_block.boc -------------------------------------------------------------------------------- /src/tests/static/message.boc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/message.boc -------------------------------------------------------------------------------- /src/tests/static/shards_73102.boc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/shards_73102.boc -------------------------------------------------------------------------------- /src/tests/static/shards_73107.boc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/shards_73107.boc -------------------------------------------------------------------------------- /src/tests/static/ss571525: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/ss571525 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/block__3082182: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/block__3082182 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/block__3082183: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/block__3082183 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/block__3082184: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/block__3082184 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/block__3082185: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/block__3082185 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/block__3082186: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/block__3082186 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/block__3082187: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/block__3082187 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/block__3082188: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/block__3082188 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/block__3082189: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/block__3082189 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/block__3082190: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/block__3082190 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/block__3082191: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/block__3082191 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/block__3082192: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/block__3082192 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/block__3082193: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/block__3082193 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/block__3082194: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/block__3082194 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/block__3082195: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/block__3082195 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/block__3082196: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/block__3082196 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/block__3082197: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/block__3082197 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/block__3082198: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/block__3082198 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/block__3082199: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/block__3082199 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/block__3082200: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/block__3082200 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/block__3082201: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/block__3082201 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/key_block__3082181: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/key_block__3082181 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/key_proof__3082181: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/key_proof__3082181 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/proof__3082182: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/proof__3082182 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/proof__3082183: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/proof__3082183 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/proof__3082184: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/proof__3082184 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/proof__3082185: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/proof__3082185 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/proof__3082186: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/proof__3082186 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/proof__3082187: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/proof__3082187 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/proof__3082188: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/proof__3082188 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/proof__3082189: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/proof__3082189 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/proof__3082190: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/proof__3082190 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/proof__3082191: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/proof__3082191 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/proof__3082192: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/proof__3082192 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/proof__3082193: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/proof__3082193 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/proof__3082194: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/proof__3082194 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/proof__3082195: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/proof__3082195 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/proof__3082196: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/proof__3082196 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/proof__3082197: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/proof__3082197 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/proof__3082198: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/proof__3082198 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/proof__3082199: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/proof__3082199 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/proof__3082200: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/proof__3082200 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof/proof__3082201: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof/proof__3082201 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/block__3236531: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/block__3236531 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/block__3236532: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/block__3236532 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/block__3236533: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/block__3236533 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/block__3236534: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/block__3236534 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/block__3236535: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/block__3236535 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/block__3236536: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/block__3236536 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/block__3236537: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/block__3236537 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/block__3236538: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/block__3236538 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/block__3236539: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/block__3236539 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/block__3236540: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/block__3236540 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/block__3236541: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/block__3236541 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/block__3236542: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/block__3236542 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/block__3236543: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/block__3236543 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/block__3236544: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/block__3236544 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/block__3236545: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/block__3236545 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/block__3236546: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/block__3236546 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/block__3236547: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/block__3236547 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/block__3236548: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/block__3236548 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/block__3236549: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/block__3236549 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/block__3236550: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/block__3236550 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/key_block__3236530: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/key_block__3236530 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/key_proof__3236530: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/key_proof__3236530 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/proof__3236531: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/proof__3236531 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/proof__3236532: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/proof__3236532 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/proof__3236533: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/proof__3236533 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/proof__3236534: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/proof__3236534 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/proof__3236535: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/proof__3236535 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/proof__3236536: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/proof__3236536 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/proof__3236537: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/proof__3236537 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/proof__3236538: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/proof__3236538 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/proof__3236539: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/proof__3236539 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/proof__3236540: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/proof__3236540 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/proof__3236541: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/proof__3236541 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/proof__3236542: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/proof__3236542 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/proof__3236543: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/proof__3236543 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/proof__3236544: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/proof__3236544 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/proof__3236545: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/proof__3236545 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/proof__3236546: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/proof__3236546 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/proof__3236547: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/proof__3236547 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/proof__3236548: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/proof__3236548 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/proof__3236549: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/proof__3236549 -------------------------------------------------------------------------------- /src/tests/static/test_master_block_proof_shuffle/proof__3236550: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_master_block_proof_shuffle/proof__3236550 -------------------------------------------------------------------------------- /src/tests/static/test_shard_block_proof/proof_4377262: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/test_shard_block_proof/proof_4377262 -------------------------------------------------------------------------------- /src/tests/static/tvm_key_block.boc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/tvm_key_block.boc -------------------------------------------------------------------------------- /src/tests/static/tvm_msg_account.boc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/tvm_msg_account.boc -------------------------------------------------------------------------------- /src/tests/static/tvm_stack_account.boc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/tvm_stack_account.boc -------------------------------------------------------------------------------- /src/tests/static/zerostate.boc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/src/tests/static/zerostate.boc -------------------------------------------------------------------------------- /src/tests/test_block_proof.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::{block::BlockStuff, block_proof::BlockProofStuff}; 15 | 16 | #[test] 17 | fn test_check_master_blocks_proof() { 18 | 19 | let name = "src/tests/static/test_master_block_proof/key_block__3082181"; 20 | let key_block = BlockStuff::read_block_from_file(name).unwrap(); 21 | 22 | let bytes = std::fs::read("src/tests/static/test_master_block_proof/key_proof__3082181").unwrap(); 23 | let key_block_proof = BlockProofStuff::deserialize(key_block.id(), bytes, false).unwrap(); 24 | 25 | for seqno in 3082182..=3082200 { 26 | let name = format!("src/tests/static/test_master_block_proof/block__{}", seqno); 27 | let block = BlockStuff::read_block_from_file(&name).unwrap(); 28 | 29 | let name = format!("src/tests/static/test_master_block_proof/proof__{}", seqno); 30 | let bytes = std::fs::read(&name).unwrap(); 31 | let block_proof = BlockProofStuff::deserialize(block.id(), bytes, false).unwrap(); 32 | 33 | block_proof.check_with_prev_key_block_proof(&key_block_proof).unwrap(); 34 | } 35 | } 36 | 37 | #[test] 38 | fn test_check_master_blocks_proof_shuffle() { 39 | 40 | let name = "src/tests/static/test_master_block_proof_shuffle/key_block__3236530"; 41 | let key_block = BlockStuff::read_block_from_file(name).unwrap(); 42 | 43 | let bytes = std::fs::read("src/tests/static/test_master_block_proof_shuffle/key_proof__3236530").unwrap(); 44 | let key_block_proof = BlockProofStuff::deserialize(key_block.id(), bytes, false).unwrap(); 45 | 46 | for seqno in 3236531..=3236550 { 47 | let name = format!("src/tests/static/test_master_block_proof_shuffle/block__{}", seqno); 48 | let block = BlockStuff::read_block_from_file(&name).unwrap(); 49 | 50 | let bytes = std::fs::read( 51 | format!("src/tests/static/test_master_block_proof_shuffle/proof__{}", seqno) 52 | ).unwrap(); 53 | let block_proof = BlockProofStuff::deserialize(block.id(), bytes, false).unwrap(); 54 | 55 | block_proof.check_with_prev_key_block_proof(&key_block_proof).unwrap(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/tests/test_shard_state.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use super::*; 15 | use crate::collator_test_bundle::create_engine_allocated; 16 | #[cfg(feature = "telemetry")] 17 | use crate::collator_test_bundle::create_engine_telemetry; 18 | use ever_block::{ShardIdent, write_boc}; 19 | 20 | #[test] 21 | fn test_shard_state_deserilaize() { 22 | let mut ss = ShardStateUnsplit::with_ident(ShardIdent::masterchain()); 23 | let mut zero_state_id = BlockIdExt::with_params( 24 | ShardIdent::masterchain(), 25 | 0, 26 | UInt256::default(), 27 | UInt256::default() 28 | ); 29 | #[cfg(feature = "telemetry")] 30 | let telemetry = create_engine_telemetry(); 31 | let allocated = create_engine_allocated(); 32 | let cell = ss.serialize().unwrap(); 33 | let bytes = write_boc(&cell).unwrap(); 34 | let check = ShardStateStuff::deserialize_zerostate( 35 | zero_state_id.clone(), 36 | &bytes, 37 | #[cfg(feature = "telemetry")] 38 | &telemetry, 39 | &allocated 40 | ); 41 | if check.is_ok() { 42 | panic!("zero state must be checked") 43 | } 44 | zero_state_id.root_hash = cell.repr_hash(); 45 | zero_state_id.file_hash = UInt256::calc_file_hash(&bytes); 46 | let new_ss = ShardStateStuff::deserialize_zerostate( 47 | zero_state_id.clone(), 48 | &bytes, 49 | #[cfg(feature = "telemetry")] 50 | &telemetry, 51 | &allocated 52 | ).expect("something wrong with zero state checking"); 53 | assert_eq!(new_ss.state().unwrap(), &ss); 54 | 55 | ss.set_seq_no(1); 56 | let cell = ss.serialize().unwrap(); 57 | let bytes = write_boc(&cell).unwrap(); 58 | let block_id = BlockIdExt { 59 | shard_id: ShardIdent::masterchain(), 60 | seq_no: 1, 61 | root_hash: Default::default(), 62 | file_hash: Default::default(), 63 | }; 64 | let new_ss = ShardStateStuff::deserialize_state( 65 | block_id, 66 | &bytes, 67 | #[cfg(feature = "telemetry")] 68 | &telemetry, 69 | &allocated 70 | ).expect("not zero state no need to be checked"); 71 | assert_eq!(new_ss.state().unwrap(), &ss); 72 | } 73 | 74 | -------------------------------------------------------------------------------- /src/tests/test_sync.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use super::*; 15 | 16 | #[tokio::test] 17 | async fn test_read_package() -> Result<()> { 18 | let data = tokio::fs::read("src/tests/static/archive.1459995.pack").await?; 19 | let maps = read_package(&data).await?; 20 | 21 | assert_eq!(maps.mc_blocks_ids.len(), 5); 22 | assert_eq!(maps.blocks.len(), 155); 23 | 24 | for (id, entry) in maps.blocks.iter() { 25 | if id.is_masterchain() { 26 | assert!(maps.mc_blocks_ids.contains_key(&id.seq_no())); 27 | } 28 | assert!(entry.block.is_some()); 29 | assert!(entry.proof.is_some()); 30 | } 31 | Ok(()) 32 | } 33 | 34 | -------------------------------------------------------------------------------- /src/tests/test_telemetry.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use super::*; 15 | use std::time::Duration; 16 | use ever_block::ShardIdent; 17 | 18 | #[test] 19 | pub fn test_fullnode_telemetry() { 20 | let t = FullNodeTelemetry::default(); 21 | for i in 1..1000 { 22 | let id = BlockIdExt::with_params( 23 | ShardIdent::masterchain(), 24 | i, 25 | Default::default(), 26 | Default::default() 27 | ); 28 | t.good_top_block_broadcast(&id); 29 | if i % 21 != 0 { 30 | t.good_top_block_broadcast(&id); 31 | t.good_top_block_broadcast(&id); 32 | } else { 33 | t.bad_top_block_broadcast(); 34 | } 35 | if i % 5 != 0 { 36 | std::thread::sleep(Duration::from_millis((1 + i % 3) as u64)); 37 | t.new_block_broadcast(&id, i % 11 == 0, i % 13 == 0); 38 | } 39 | if i % 4 == 0 { 40 | for _ in 0..((i % 48) / 4) + 1 { 41 | t.new_downloading_block_attempt(&id); 42 | std::thread::sleep(Duration::from_millis(1)); 43 | } 44 | t.new_downloaded_block(&id); 45 | } 46 | t.new_pre_applied_block(i % 5 != 0); 47 | if i % 31 != 0 { 48 | t.new_applied_block(); 49 | } 50 | t.sent_top_block_broadcast(); 51 | t.sent_block_broadcast(); 52 | t.sent_ext_msg_broadcast(); 53 | } 54 | let r = t.report(0, 0); 55 | print!("{}", r); 56 | assert!(r.starts_with( 57 | "applied blocks 967 97% 58 | pre-applied blocks 999 100% 59 | got by broadcast 800 80% 60 | downloaded 199 20% 61 | transactions per second 62 | for 300sec window 0 63 | for 60sec window 0 64 | *** 65 | sent broadcasts: 66 | top block descriptions 999 67 | blocks 999 68 | external messages 999 69 | *** 70 | bad top block broadcast 47 71 | good top block broadcast 999 100% 72 | top block broadcast dupl 1904 191% 73 | * 74 | lost block broadcasts 0 75 | block broadcast 800 100% 76 | block broadcast duplicates 72 9% 77 | unneeded block-broadcast 61 8% 78 | (block was already downloaded) 79 | *** 80 | block download attempts: 81 | 1 20 8% 82 | 2 21 8% 83 | 3 21 8% 84 | 4 21 8% 85 | 5 21 8% 86 | 6 21 8% 87 | 7 21 8% 88 | 8 21 8% 89 | 9 21 8% 90 | 10 21 8% 91 | more 40 16% 92 | *** 93 | block download time (min avg max)")); // last metrics are different from time to time 94 | } 95 | 96 | -------------------------------------------------------------------------------- /src/types/lockfree_cache.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use ever_block::Result; 15 | use adnl::common::{add_unbound_object_to_map_with_update, CountedObject}; 16 | use std::{ 17 | time::{SystemTime, Duration, UNIX_EPOCH}, 18 | sync::{Arc, atomic::{AtomicU64, Ordering}}, 19 | hash::Hash, 20 | marker::Sync, 21 | fmt::Display, 22 | }; 23 | 24 | pub struct TimeBasedCache { 25 | map: Arc>, 26 | } 27 | 28 | #[allow(dead_code)] 29 | impl TimeBasedCache where 30 | K: 'static + Hash + Ord + Sync + Send + Display, 31 | V: 'static + Clone + Sync + Send + CountedObject 32 | { 33 | pub fn new(ttl_sec: u64, name: String) -> Self { 34 | let map = Arc::new(lockfree::map::Map::new()); 35 | Self::gc(map.clone(), ttl_sec, name); 36 | Self{map} 37 | } 38 | 39 | pub fn get(&self, id: &K) -> Option { 40 | let guard = self.map.get(id)?; 41 | let now = Self::now(); 42 | guard.val().1.store(now, Ordering::Relaxed); 43 | Some(guard.val().0.clone()) 44 | } 45 | 46 | pub fn set(&self, key: K, factory: impl Fn(Option<&V>) -> Option) -> Result { 47 | add_unbound_object_to_map_with_update( 48 | &self.map, 49 | key, 50 | |prev| { 51 | let now = Self::now(); 52 | if let Some((v, t)) = prev { 53 | if let Some(new) = factory(Some(v)) { 54 | Ok(Some((new, AtomicU64::new(now)))) 55 | } else { 56 | t.store(now, Ordering::Relaxed); 57 | Ok(None) 58 | } 59 | } else if let Some(new) = factory(None) { 60 | Ok(Some((new, AtomicU64::new(now)))) 61 | } else { 62 | Ok(None) 63 | } 64 | } 65 | ) 66 | } 67 | 68 | fn gc(map: Arc>, ttl: u64, name: String) { 69 | tokio::spawn(async move{ 70 | loop { 71 | futures_timer::Delay::new(Duration::from_millis(ttl * 100)).await; 72 | let now = Self::now(); 73 | let mut len = 0; 74 | for guard in map.iter() { 75 | let time = guard.val().1.load(Ordering::Relaxed); 76 | if now > time && now - time > ttl { 77 | map.remove(guard.key()); 78 | } else { 79 | len += 1; 80 | } 81 | } 82 | log::trace!("{} capacity: {}", name, len); 83 | } 84 | }); 85 | } 86 | 87 | fn now() -> u64 { 88 | SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_secs() 89 | } 90 | } 91 | 92 | #[cfg(test)] 93 | #[path = "tests/test_lockfree_cache.rs"] 94 | mod tests; 95 | -------------------------------------------------------------------------------- /src/types/mod.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use futures::Future; 15 | 16 | pub mod accounts; 17 | pub mod awaiters_pool; 18 | pub mod top_block_descr; 19 | pub mod limits; 20 | pub mod messages; 21 | pub mod lockfree_cache; 22 | pub mod shard_blocks_observer; 23 | pub mod mpmc_channel; 24 | 25 | 26 | pub fn spawn_cancelable( 27 | cancellation_token: tokio_util::sync::CancellationToken, 28 | task: F 29 | ) where 30 | F: Future + Send + 'static 31 | { 32 | tokio::spawn( 33 | async move { 34 | tokio::select! { 35 | _ = task => {}, 36 | _ = cancellation_token.cancelled() => {} 37 | } 38 | } 39 | ); 40 | } 41 | -------------------------------------------------------------------------------- /src/types/mpmc_channel.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use std::sync::atomic::{AtomicU32, AtomicBool, Ordering}; 15 | use ever_block::{Result, fail}; 16 | 17 | #[cfg(test)] 18 | #[path = "tests/test_mpmc_channel.rs"] 19 | mod tests; 20 | 21 | pub struct MpmcChannel { 22 | queue: lockfree::queue::Queue, 23 | sync: lockfree::queue::Queue>, 24 | stop: AtomicBool, 25 | in_channel: AtomicU32, 26 | } 27 | 28 | impl Default for MpmcChannel { 29 | fn default() -> Self { 30 | MpmcChannel::new() 31 | } 32 | } 33 | 34 | impl MpmcChannel { 35 | pub fn new() -> Self { 36 | Self { 37 | queue: lockfree::queue::Queue::new(), 38 | sync: lockfree::queue::Queue::new(), 39 | stop: AtomicBool::new(false), 40 | in_channel: AtomicU32::new(0), 41 | } 42 | } 43 | 44 | pub fn send(&self, item: T) -> Result<()> { 45 | self.in_channel.fetch_add(1, Ordering::Relaxed); 46 | self.queue.push(item); 47 | if let Some(sender) = self.sync.pop() { 48 | if sender.send(()).is_err() { 49 | fail!("sender.send returns error"); 50 | } 51 | } 52 | Ok(()) 53 | } 54 | 55 | pub fn stop(&self) { 56 | self.stop.store(true, Ordering::Relaxed); 57 | while let Some(sender) = self.sync.pop() { 58 | sender.send(()).ok(); 59 | } 60 | } 61 | 62 | #[cfg(feature = "telemetry")] 63 | pub fn len(&self) -> u32 { 64 | self.in_channel.load(Ordering::Relaxed) 65 | } 66 | 67 | #[cfg(feature = "telemetry")] 68 | #[allow(dead_code)] 69 | pub fn is_empty(&self) -> bool { 70 | self.in_channel.load(Ordering::Relaxed) == 0 71 | } 72 | 73 | pub async fn receive(&self) -> Result { 74 | loop { 75 | if self.stop.load(Ordering::Relaxed) { 76 | fail!("Stopped"); 77 | } 78 | 79 | if let Some(item) = self.queue.pop() { 80 | self.in_channel.fetch_sub(1, Ordering::Relaxed); 81 | return Ok(item) 82 | } 83 | 84 | let (sender, receiver) = tokio::sync::oneshot::channel(); 85 | self.sync.push(sender); 86 | let _ = receiver.await; 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /src/types/tests/test_lockfree_cache.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use super::*; 15 | use adnl::{declare_counted, common::Counter}; 16 | 17 | declare_counted!( 18 | struct Test { 19 | val: String 20 | } 21 | ); 22 | 23 | #[tokio::test(flavor = "multi_thread")] 24 | async fn test_lockfree_cache() { 25 | 26 | let counter = Arc::new(AtomicU64::new(0)); 27 | let cache = TimeBasedCache::new(4, "test_lockfree_cache".to_string()); 28 | 29 | assert!(cache.get(&1).is_none()); 30 | assert!(cache.get(&2).is_none()); 31 | assert!(cache.get(&3).is_none()); 32 | 33 | assert!(cache.set(1, |prev| { 34 | assert!(prev.is_none()); 35 | let ret = Test { 36 | val: "1".to_string(), 37 | counter: counter.clone().into() 38 | }; 39 | Some(Arc::new(ret)) 40 | }).unwrap()); 41 | assert!(cache.set(2, |prev| { 42 | assert!(prev.is_none()); 43 | let ret = Test { 44 | val: "2".to_string(), 45 | counter: counter.clone().into() 46 | }; 47 | Some(Arc::new(ret)) 48 | }).unwrap()); 49 | assert!(cache.set(3, |prev| { 50 | assert!(prev.is_none()); 51 | let ret = Test { 52 | val: "3".to_string(), 53 | counter: counter.clone().into() 54 | }; 55 | Some(Arc::new(ret)) 56 | }).unwrap()); 57 | 58 | assert!(cache.get(&1).is_some()); 59 | assert!(cache.get(&2).is_some()); 60 | assert!(cache.get(&3).is_some()); 61 | 62 | assert!(!cache.set(2, |prev| { 63 | assert!(prev.is_some()); 64 | None 65 | }).unwrap()); 66 | 67 | futures_timer::Delay::new(Duration::from_secs(2)).await; 68 | 69 | assert!(cache.get(&1).is_some()); 70 | 71 | futures_timer::Delay::new(Duration::from_secs(4)).await; 72 | 73 | assert!(cache.get(&1).is_some()); 74 | assert!(cache.get(&2).is_none()); 75 | assert!(cache.get(&3).is_none()); 76 | 77 | futures_timer::Delay::new(Duration::from_secs(6)).await; 78 | assert!(cache.get(&1).is_none()); 79 | } -------------------------------------------------------------------------------- /src/types/tests/test_messages.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use super::*; 15 | use std::str::FromStr; 16 | use ever_block::{ 17 | CurrencyCollection, InternalMessageHeader, MsgAddressInt, Message, SERDE_OPTS_EMPTY 18 | }; 19 | 20 | #[test] 21 | fn test_msg_envelope() { 22 | let src = MsgAddressInt::from_str("0:a4cd3dfa89c5aa75c5542b3414d1c0c7974aaa5009fbe9c4ab6a5566c50cc607").unwrap(); 23 | let dst = MsgAddressInt::from_str("0:7c270a15afd9b685d6cabe4334172fa0d2e8ceb61ac033e7ce8876f2cf7122be").unwrap(); 24 | let src_shard = ShardIdent::with_tagged_prefix(0, 0xa400000000000000).unwrap(); 25 | let dst_shard = ShardIdent::with_tagged_prefix(0, 0x7c00000000000000).unwrap(); 26 | let hdr = InternalMessageHeader::with_addresses(src, dst, CurrencyCollection::default()); 27 | let msg = CommonMessage::Std(Message::with_int_header(hdr)); 28 | let env = MsgEnvelopeStuff::new(msg.clone(), &src_shard, Grams::default(), false, SERDE_OPTS_EMPTY).unwrap(); 29 | assert!(src_shard.contains_full_prefix(env.cur_prefix())); 30 | assert!(dst_shard.contains_full_prefix(env.next_prefix())); 31 | 32 | let env = MsgEnvelopeStuff::new(msg, &src_shard, Grams::default(), true, SERDE_OPTS_EMPTY).unwrap(); 33 | assert!(src_shard.contains_full_prefix(env.cur_prefix())); 34 | assert!(!dst_shard.contains_full_prefix(env.next_prefix())); 35 | let shard = ShardIdent::with_tagged_prefix(0, 0x7400000000000000).unwrap(); 36 | assert!(shard.contains_full_prefix(env.next_prefix())); 37 | } 38 | -------------------------------------------------------------------------------- /src/types/tests/test_mpmc_channel.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use std::{ 3 | sync::{ 4 | Arc, 5 | atomic::{AtomicU64, Ordering} 6 | }, 7 | time::Duration, 8 | }; 9 | 10 | #[tokio::test(flavor = "multi_thread")] 11 | async fn test_mpmc_channel() -> Result<()> { 12 | let mpmc = Arc::new(MpmcChannel::new()); 13 | let n = Arc::new(AtomicU64::new(0)); 14 | let mut s_tasks = vec!(); 15 | let mut r_tasks = vec!(); 16 | 17 | for i in 0..3 { 18 | let mpmc = mpmc.clone(); 19 | let n = n.clone(); 20 | s_tasks.push(tokio::spawn(async move { 21 | for _ in 0..100_000 { 22 | let m = rand::random::() % 10_000; 23 | n.fetch_add(m, Ordering::Relaxed); 24 | mpmc.send(m).unwrap(); 25 | } 26 | println!("sent #{}", i); 27 | })); 28 | } 29 | 30 | for i in 0..8 { 31 | let mpmc = mpmc.clone(); 32 | let n = n.clone(); 33 | r_tasks.push(tokio::spawn(async move { 34 | while let Ok(m) = mpmc.receive().await { 35 | n.fetch_sub(m, Ordering::Relaxed); 36 | } 37 | println!("received #{}", i); 38 | })); 39 | } 40 | 41 | futures::future::join_all(s_tasks).await; 42 | tokio::time::sleep(Duration::from_millis(1000)).await; 43 | 44 | mpmc.stop(); 45 | futures::future::join_all(r_tasks).await; 46 | 47 | assert_eq!(0, n.load(Ordering::Relaxed)); 48 | 49 | Ok(()) 50 | } -------------------------------------------------------------------------------- /src/validator/catchain_overlay.rs: -------------------------------------------------------------------------------- 1 | use crate::engine_traits::PrivateOverlayOperations; 2 | use adnl::PrivateOverlayShortId; 3 | use std::sync::Arc; 4 | use ever_block::{Result, UInt256}; 5 | use validator_session::{PublicKeyHash, CatchainOverlayPtr, CatchainNode}; 6 | 7 | pub(crate) struct CatchainOverlayManagerImpl { 8 | network: Arc, 9 | validator_list_id: UInt256 10 | } 11 | 12 | impl CatchainOverlayManagerImpl { 13 | pub fn new(network: Arc, validator_list_id: UInt256) -> Self { 14 | Self { 15 | network, 16 | validator_list_id 17 | } 18 | } 19 | } 20 | 21 | impl catchain::CatchainOverlayManager for CatchainOverlayManagerImpl { 22 | 23 | fn start_overlay( 24 | &self, 25 | _local_id: &PublicKeyHash, 26 | overlay_short_id: &Arc, 27 | nodes: &[CatchainNode], 28 | listener: catchain::CatchainOverlayListenerPtr, 29 | replay_listener: catchain::CatchainOverlayLogReplayListenerPtr, 30 | ) -> Result { 31 | self.network.create_catchain_client( 32 | self.validator_list_id.clone(), overlay_short_id, nodes, listener, replay_listener, None 33 | ) 34 | } 35 | 36 | /// Stop existing overlay 37 | fn stop_overlay( 38 | &self, 39 | overlay_short_id: &Arc, 40 | _overlay: &CatchainOverlayPtr, 41 | ) { 42 | let engine_network = self.network.clone(); 43 | engine_network.stop_catchain_client(overlay_short_id); 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /src/validator/log_parser.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | #![allow(dead_code)] 15 | 16 | extern crate regex; 17 | use std::str::FromStr; 18 | use self::regex::{Regex, escape}; 19 | 20 | pub struct LogParser { 21 | log: String 22 | } 23 | 24 | impl LogParser { 25 | pub fn new (s: &str) -> Self { 26 | let mut prepared_str = " ".to_string(); 27 | prepared_str.push_str(s); 28 | prepared_str.push(' '); 29 | LogParser { log: prepared_str } 30 | } 31 | 32 | pub fn get_field (&self, name: &str) -> Option { 33 | let it = Regex::new (&(format! (" {} = ([^ ]*) ", escape(name)))).unwrap(); 34 | it.captures (&self.log).map(|group| group.get(1).unwrap().as_str().to_string()) 35 | } 36 | 37 | pub fn parse_field_fromstr (&self, name: &str) -> T 38 | where T: FromStr, T::Err: std::fmt::Debug 39 | { 40 | match self.get_field (name) { 41 | None => panic!("Cannot find field `{}`", name), 42 | Some (v) => T::from_str(&v).unwrap() 43 | } 44 | } 45 | 46 | pub fn get_field_count (&self, name: &str) -> u32 { 47 | let it = Regex::new (&(format! (r" {}\.(\d+)[. ]", escape(name)))).unwrap(); 48 | let mut fields = 0; 49 | for nums in it.captures_iter (&self.log) { 50 | let fnew = u32::from_str(&nums[1]).unwrap(); 51 | if fnew >= fields { 52 | fields = fnew + 1; 53 | } 54 | } 55 | fields 56 | } 57 | 58 | pub fn parse_slice (&self, name: &str) -> ::ton_api::ton::bytes { 59 | let data = self.get_field (name).unwrap(); 60 | hex::decode (data).unwrap() 61 | } 62 | } 63 | 64 | #[cfg(test)] 65 | #[path = "tests/test_log_parser.rs"] 66 | mod tests; 67 | -------------------------------------------------------------------------------- /src/validator/mutex_wrapper.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | #[cfg(feature = "telemetry")] 15 | use std::time::Instant; 16 | use std::sync::Arc; 17 | use tokio::sync::OwnedMutexGuard; 18 | #[cfg(feature = "telemetry")] 19 | use adnl::telemetry::Metric; 20 | 21 | pub struct MutexWrapper { 22 | mutex: Arc>, 23 | id: String, 24 | #[cfg(feature = "telemetry")] 25 | mutex_awaiting_metric: Option> 26 | } 27 | 28 | impl MutexWrapper { 29 | pub fn new (t: T, id: String) -> Self { 30 | MutexWrapper{ 31 | mutex: Arc::new(tokio::sync::Mutex::new(t)), 32 | id, 33 | #[cfg(feature = "telemetry")] 34 | mutex_awaiting_metric: None, 35 | } 36 | } 37 | 38 | pub fn with_metric ( 39 | t: T, 40 | id: String, 41 | #[cfg(feature = "telemetry")] 42 | mutex_awaiting_metric: Arc 43 | ) -> Self { 44 | MutexWrapper{ 45 | mutex: Arc::new(tokio::sync::Mutex::new(t)), 46 | id, 47 | #[cfg(feature = "telemetry")] 48 | mutex_awaiting_metric: Some(mutex_awaiting_metric), 49 | } 50 | } 51 | 52 | pub async fn execute_sync (&self, f: F) -> Res 53 | where 54 | F: FnOnce(&mut T) -> Res, 55 | { 56 | log::trace!(target: "validator", "Lock {} started acquire", self.id); 57 | 58 | let mut guard: OwnedMutexGuard; 59 | #[cfg(feature = "telemetry")] { 60 | if let Some(metric) = &self.mutex_awaiting_metric { 61 | let started = Instant::now(); 62 | guard = self.mutex.clone().lock_owned().await; 63 | metric.update(started.elapsed().as_micros() as u64); 64 | } else { 65 | guard = self.mutex.clone().lock_owned().await; 66 | } 67 | } 68 | #[cfg(not(feature = "telemetry"))] { 69 | guard = self.mutex.clone().lock_owned().await; 70 | } 71 | 72 | let guard_ref: &mut T = &mut guard; 73 | log::trace!(target: "validator", "Lock {} acquired", self.id); 74 | let res = f (guard_ref); 75 | log::trace!(target: "validator", "Lock {} released", self.id); 76 | res 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/validator/remp_service.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::{ 15 | engine_traits::{EngineOperations, RempCoreInterface, RempDuplicateStatus}, 16 | network::remp::RempMessagesSubscriber 17 | }; 18 | 19 | use std::sync::{Arc, Weak}; 20 | use ever_block::{error, fail, KeyId, Result, UInt256}; 21 | 22 | #[derive(Default)] 23 | pub struct RempService { 24 | engine: tokio::sync::OnceCell>, 25 | remp_core: tokio::sync::OnceCell>, 26 | } 27 | 28 | impl RempService { 29 | pub fn new() -> Self { 30 | Self::default() 31 | } 32 | 33 | pub fn set_engine(&self, engine: Arc) -> Result<()> { 34 | self.engine.set(Arc::downgrade(&engine)).map_err(|_| error!("Attempt to set engine twice")) 35 | } 36 | 37 | pub fn set_remp_core_interface(&self, remp_core: Arc) -> Result<()> { 38 | self.remp_core.set(Arc::downgrade(&remp_core)).map_err(|_| error!("Attempt to set remp_core twice")) 39 | } 40 | 41 | fn get_core_interface(&self) -> Result> { 42 | self.remp_core.get() 43 | .ok_or_else(|| error!("remp_core was not set"))? 44 | .upgrade().ok_or_else(|| error!("remp_core weak reference is null")) 45 | } 46 | 47 | pub fn check_remp_duplicate(&self, id: &UInt256) -> Result { 48 | self.get_core_interface()?.check_remp_duplicate(id) 49 | } 50 | 51 | async fn process_incoming_message(&self, message: &ton_api::ton::ton_node::RempMessage, source: &Arc) -> Result<()> { 52 | // TODO send error receipt in case of any error 53 | let engine = self.engine 54 | .get().ok_or_else(|| error!("engine was not set"))? 55 | .upgrade().ok_or_else(|| error!("engine weak reference is null"))?; 56 | 57 | let remp_core = self.get_core_interface()?; 58 | 59 | #[cfg(feature = "telemetry")] 60 | engine.remp_core_telemetry().message_from_fullnode(); 61 | 62 | if !engine.check_sync().await? { 63 | fail!("Can't process REMP message because validator is out of sync"); 64 | } 65 | 66 | // push into remp catchain 67 | remp_core.process_incoming_message(message, source.clone()).await 68 | } 69 | } 70 | 71 | #[async_trait::async_trait] 72 | impl RempMessagesSubscriber for RempService { 73 | async fn new_remp_message(&self, message: ton_api::ton::ton_node::RempMessage, source: &Arc) -> Result<()> { 74 | // TODO send error receipt in case of any error 75 | 76 | let id = message.id().clone(); 77 | log::trace!(target: "remp", "Point 0. Processing incoming REMP message {:x}", id); 78 | match self.process_incoming_message(&message, source).await { 79 | Ok(_) => log::trace!(target: "remp", "Point 0. Processed incoming REMP message {:x}", id), 80 | Err(e) => log::error!(target: "remp", "Point 0. Error processing incoming REMP message {:x}: {}", id, e) 81 | } 82 | Ok(()) 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/validator/tests/test_log_parser.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use std::fs; 15 | use super::*; 16 | 17 | #[test] 18 | fn test_log_parser() { 19 | let contents = fs::read_to_string("src/validator/tests/static/test_log_parser.log") 20 | .expect("File cannot be read/not found") 21 | .replace("\n"," "); 22 | println!("Contents: {}", contents); 23 | let parser = LogParser::new (&contents); 24 | 25 | // Basic value parsing 26 | assert_eq!(parser.parse_field_fromstr::("shard.workchain"), 0); 27 | assert_eq!(parser.parse_field_fromstr::("min_masterchain_block.id.workchain"), -1); 28 | 29 | // Slice parsing 30 | let collated_file_hash = parser.parse_slice("candidate.collated_file_hash"); 31 | assert_eq!(collated_file_hash[31], 0x55); 32 | assert_eq!(collated_file_hash, hex::decode("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855").unwrap()); 33 | 34 | // Empty slice parsing 35 | assert_eq!(parser.parse_slice("candidate.collated_data_snd"), Vec::::default()); 36 | 37 | // Indexed fields counting 38 | let validator_count = parser.get_field_count ("validator"); 39 | assert_eq!(validator_count, 5); 40 | 41 | // Indexed fields parsing 42 | for validator in 0..validator_count { 43 | let field_name = format!("validator.{}.data.size", validator); 44 | assert_eq!(parser.parse_field_fromstr::(&field_name), 32); 45 | 46 | let data_name = format!("validator.{}.data", validator); 47 | assert_eq!(parser.parse_slice(&data_name).len(), 32); 48 | } 49 | 50 | // Last field 51 | assert_eq!(parser.parse_field_fromstr::("validator.4.weight"), 1); 52 | } 53 | 54 | #[test] 55 | fn test_log_parser2() { 56 | let parser = LogParser::new (" .. = 1 *\\.0 = 7 *\\.1 = 14 *\\.11.w = 12 *\\.21a = 77 ., = 2 ** = 3 [[](.,& = 101 "); 57 | assert_eq!(parser.parse_field_fromstr::(".."), 1); 58 | assert_eq!(parser.parse_field_fromstr::(".,"), 2); 59 | assert_eq!(parser.parse_field_fromstr::("**"), 3); 60 | assert_eq!(parser.parse_field_fromstr::("[[](.,&"), 101); 61 | assert_eq!(parser.get_field_count ("*\\"), 12); 62 | } 63 | 64 | -------------------------------------------------------------------------------- /src/validator/tests/test_slashing.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use super::*; 15 | use ever_block::KeyOption; 16 | 17 | fn key_from_str(key: &str) -> Arc { 18 | Ed25519KeyOption::from_public_key(key.parse::().unwrap().as_slice()) 19 | // Ed25519KeyOption::from_private_key(key.parse::().unwrap().as_slice()).unwrap() 20 | } 21 | 22 | fn save_slash_validator_message(reporter: &str, victim: &str, file_name: &str) { 23 | let reporter = key_from_str(reporter); 24 | let victim = key_from_str(victim); 25 | let metric_id = SlashingAggregatedMetric::ValidationScore; 26 | let time_now_ms = 16590899030001; // 1658862426000; 27 | 28 | let message = SlashingManager::prepare_slash_validator_message( 29 | ELECTOR_ADDRESS.clone(), 30 | &reporter, 31 | &victim, 32 | metric_id, 33 | time_now_ms 34 | ).unwrap().unwrap(); 35 | 36 | message.write_to_file(file_name).unwrap(); 37 | } 38 | 39 | #[test] 40 | fn test_prepare_slash_validator_message() { 41 | // let reporter_privkey = key_from_str("fd9dea47d76da90db2853d7ac1d3f5807fc737740bd10ac90a302e59decc305f"); 42 | // let validator_pubkey = key_from_str("2cae5b04e05a879a8ace1e503d65a9d6e46ef1f1a47ed06c067736f27bd208ac"); 43 | 44 | let victim = "0x0e1b4f5827ac7c54bb7617ba54310cf12016151969b9af250abe6353bdd8f869"; 45 | let reporters = [ 46 | "0x4529bfebbcc05f3777443547c4e7bf8d17adaa0d5cda907c49f1bb3ec301a500", 47 | "0xb28c9ae6d4b6c89f3bb6c475de733172701b5ad1c99b811112cd8e8ba9ac0402", 48 | "0xccc7b7ff86157b4d18a513ec24e6d7d1cf4a0825adc58a70ba357b7693cd347d", 49 | "0xe1d5fb5a7817771d791482014ebf86e74c73389d0c468987198b4104daf5f46a", 50 | "0xe833f4344dd1d2ff68ff88709269f94e5c4e30c4da8ba9cf10689eb4812f49ad", 51 | ]; 52 | 53 | for (i, reporter) in reporters.iter().enumerate() { 54 | let file_name = format!("target/elector_msg_{}.boc", i + 1); 55 | save_slash_validator_message(reporter, victim, &file_name); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/validator/tests/test_validate_query.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | -------------------------------------------------------------------------------- /src/validator/verification/mod.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2022 TON Labs. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific TON DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | extern crate catchain; 15 | 16 | use crate::engine_traits::EngineOperations; 17 | use crate::validator::BlockCandidate; 18 | use std::collections::HashMap; 19 | /// API dependencies 20 | use std::sync::Arc; 21 | use std::sync::Weak; 22 | use ever_block::{BlockIdExt, KeyOption, Result, UInt256, ValidatorDescr}; 23 | use validator_session::PrivateKey; 24 | use validator_session::PublicKeyHash; 25 | use catchain::profiling::InstanceCounter; 26 | 27 | mod block; 28 | mod multi_signature_bls; 29 | mod multi_signature_unsafe; 30 | mod verification_manager; 31 | mod workchain; 32 | mod workchain_overlay; 33 | mod utils; 34 | 35 | pub const DEFAULT_USE_DEBUG_BLS_KEYS: bool = true; //generate missing BLS key from ED25519 public key (only for testing) 36 | pub const USE_VALIDATORS_WEIGHTS: bool = false; //use weights from ValidatorDescr for BLS signature weight aggregation 37 | pub const DEBUG_NACK_APPEARENCE: bool = false; //emulate appearance of NACK messages 38 | 39 | /// Engine ptr 40 | type EnginePtr = Arc; 41 | 42 | /// Verification manager pointer 43 | pub type VerificationManagerPtr = Arc; 44 | 45 | /// Pointer to verification listener 46 | pub type VerificationListenerPtr = Weak; 47 | 48 | /// Trait for verification events 49 | #[async_trait::async_trait] 50 | pub trait VerificationListener: Sync + Send { 51 | /// Verify block candidate 52 | async fn verify(&self, block_candidate: &BlockCandidate) -> bool; 53 | } 54 | 55 | /// Verficiation manager config 56 | #[derive(Clone, Debug)] 57 | pub struct VerificationManagerConfig { 58 | /// Max wait time for delivery of shardchain block to MC validator 59 | pub max_mc_delivery_wait_timeout: Option, 60 | } 61 | 62 | /// Verification manager 63 | #[async_trait::async_trait] 64 | pub trait VerificationManager: Sync + Send { 65 | /// New block broadcast has been generated 66 | async fn send_new_block_candidate(&self, candidate: &BlockCandidate); 67 | 68 | /// Wait for block verification 69 | fn wait_for_block_verification( 70 | &self, 71 | block_id: &BlockIdExt, 72 | timeout: Option, 73 | ) -> bool; 74 | 75 | /// Update workchains 76 | #[allow(clippy::too_many_arguments)] 77 | async fn update_workchains( 78 | &self, 79 | local_key_id: PublicKeyHash, 80 | local_bls_key: PrivateKey, 81 | workchain_id: i32, 82 | utime_since: u32, 83 | workchain_validators: &[ValidatorDescr], 84 | mc_validators: &[ValidatorDescr], 85 | listener: &VerificationListenerPtr, 86 | use_debug_bls_keys: bool, 87 | ); 88 | } 89 | 90 | /// Factory for verification objects 91 | pub struct VerificationFactory {} 92 | 93 | impl VerificationFactory { 94 | /// Create new verification manager 95 | pub fn create_manager(engine: EnginePtr, runtime: tokio::runtime::Handle, config: VerificationManagerConfig) -> VerificationManagerPtr { 96 | verification_manager::VerificationManagerImpl::create(engine, runtime, config) 97 | } 98 | 99 | /// Generate test BLS key based on public key 100 | pub fn generate_test_bls_key(public_key: &Arc) -> Result> { 101 | utils::generate_test_bls_key(public_key) 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/validator/verification/utils.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2021 TON Labs. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific TON DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | pub use super::*; 15 | 16 | use tokio::time::sleep; 17 | use std::time::Duration; 18 | use std::sync::atomic::AtomicBool; 19 | use std::sync::atomic::Ordering; 20 | use log::warn; 21 | use ever_block::{KeyId, KeyOption, Result}; 22 | use ton_api::IntoBoxed; 23 | 24 | /* 25 | Constants 26 | */ 27 | 28 | const HANG_CHECKER_WARN_DUMP_PERIOD: Duration = Duration::from_millis(2000); //latency warning dump period 29 | 30 | /* 31 | =================================================================================================== 32 | HangChecker 33 | =================================================================================================== 34 | */ 35 | 36 | pub struct HangCheck { 37 | is_running: Arc, //is code still running 38 | } 39 | 40 | impl HangCheck { 41 | pub fn new(runtime: tokio::runtime::Handle, name: String, warn_delay: std::time::Duration) -> Self { 42 | let is_running = Arc::new(AtomicBool::new(true)); 43 | let is_running_clone = is_running.clone(); 44 | let start_time = std::time::SystemTime::now(); 45 | let warn_time = start_time + warn_delay; 46 | 47 | runtime.spawn(async move { 48 | if let Ok(delay) = warn_time.duration_since(std::time::SystemTime::now()) { 49 | sleep(delay).await; 50 | } 51 | 52 | loop { 53 | if !is_running.load(Ordering::Relaxed) { 54 | break; 55 | } 56 | 57 | let processing_delay = start_time.elapsed().unwrap_or_default(); 58 | 59 | warn!(target: "verificator", "{} is hanging for {:.3}s", name, processing_delay.as_secs_f64()); 60 | 61 | sleep(HANG_CHECKER_WARN_DUMP_PERIOD).await; 62 | } 63 | }); 64 | 65 | Self { 66 | is_running: is_running_clone, 67 | } 68 | } 69 | } 70 | 71 | impl Drop for HangCheck { 72 | fn drop(&mut self) { 73 | self.is_running.store(false, Ordering::Release); 74 | } 75 | } 76 | 77 | /* 78 | Utils 79 | */ 80 | 81 | pub(crate) fn get_adnl_id(validator: &ValidatorDescr) -> Arc { 82 | super::super::validator_utils::get_adnl_id(validator) 83 | //ever_block::KeyId::from_data(validator.compute_node_id_short().inner()) 84 | } 85 | 86 | pub(crate) fn into_public_key_tl(opt: &Arc) -> Result { 87 | let pub_key = opt.pub_key()?; 88 | use ton_api::ton::pub_::publickey::Bls; 89 | Ok(Bls { 90 | bls_key: pub_key.to_vec() 91 | }.into_boxed()) 92 | } 93 | 94 | pub(crate) fn generate_test_bls_key(public_key: &Arc) -> Result> { 95 | use ever_block::{BlsKeyOption, BLS_KEY_MATERIAL_LEN}; 96 | 97 | log::debug!(target: "verificator", "Generate BLS key from public validator's key {}", public_key.id()); 98 | 99 | let public_key_data = public_key.pub_key()?; 100 | let mut ikm: [u8; BLS_KEY_MATERIAL_LEN] = [0; BLS_KEY_MATERIAL_LEN]; 101 | ikm.copy_from_slice(public_key_data); 102 | 103 | let bls_key = Arc::new(BlsKeyOption::from_key_material(&ikm)?); 104 | 105 | log::debug!(target: "verificator", "BLS key generation is done for public validator's key {}", public_key.id()); 106 | 107 | Ok(bls_key) 108 | } 109 | -------------------------------------------------------------------------------- /storage/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = '2021' 3 | name = 'storage' 4 | version = '0.6.1' 5 | 6 | [dependencies] 7 | ahash = '0.8' 8 | anyhow = '1.0' 9 | async-trait = '0.1' 10 | bytes = '1.1' 11 | fnv = '1.0' 12 | futures = '0.3' 13 | hex = '0.4' 14 | log = '0.4' 15 | log4rs = '1.2' 16 | lru = '0.11' 17 | metrics = '0.21' 18 | parking_lot = '0.12' 19 | quick_cache = '0.4' 20 | rand = { features = [ 'small_rng' ], version = '0.8' } 21 | rocksdb = '0.22' 22 | serde = '1.0' 23 | serde_cbor = '0.11' 24 | serde_derive = '1.0' 25 | strum = '0.18' 26 | strum_macros = '0.18' 27 | thiserror = '1.0' 28 | tokio = { features = [ 'fs', 'rt-multi-thread' ], version = '1.5' } 29 | tokio-util = '0.7' 30 | adnl = { git = 'https://github.com/everx-labs/ever-adnl.git', tag = '0.11.32' } 31 | ever_block = { git = 'https://github.com/everx-labs/ever-block.git', tag = '1.11.20' } 32 | lockfree = { git = 'https://github.com/everx-labs/lockfree.git' } 33 | ton_api = { git = 'https://github.com/everx-labs/ever-tl.git', package = 'ton_api', tag = '0.4.29' } 34 | 35 | [build-dependencies] 36 | cc = { features = [ 'parallel' ], version = '1.0.61' } 37 | 38 | [dev-dependencies] 39 | zip = '2.2' 40 | 41 | [features] 42 | default = [ ] 43 | telemetry = [ ] 44 | 45 | [[bench]] 46 | harness = false 47 | name = 'shardstate_db' 48 | path = 'benches/shardstate_db.rs' 49 | 50 | -------------------------------------------------------------------------------- /storage/src/archives/mod.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::block_handle_db::BlockHandle; 15 | 16 | mod package_index_db; 17 | 18 | pub mod archive_manager; 19 | pub mod package; 20 | pub mod package_entry_id; 21 | pub mod package_entry; 22 | 23 | mod package_status_db; 24 | mod package_status_key; 25 | mod file_maps; 26 | mod package_offsets_db; 27 | mod package_info; 28 | mod archive_slice; 29 | mod package_entry_meta_db; 30 | mod package_entry_meta; 31 | mod package_id; 32 | 33 | pub const ARCHIVE_SIZE: u32 = 100_000; 34 | pub const ARCHIVE_SLICE_SIZE: u32 = 20_000; 35 | pub const ARCHIVE_PACKAGE_SIZE: u32 = 100; 36 | 37 | pub const KEY_ARCHIVE_SIZE: u32 = 10_000_000; 38 | pub const KEY_ARCHIVE_SLICE_SIZE: u32 = 2_000_000; 39 | pub const KEY_ARCHIVE_PACKAGE_SIZE: u32 = 200_000; 40 | 41 | fn get_mc_seq_no_opt(block_handle: Option<&BlockHandle>) -> u32 { 42 | if let Some(handle) = block_handle { 43 | get_mc_seq_no(handle) 44 | } else { 45 | 0 46 | } 47 | } 48 | 49 | fn get_mc_seq_no(handle: &BlockHandle) -> u32 { 50 | if handle.id().shard().is_masterchain() { 51 | handle.id().seq_no() 52 | } else { 53 | handle.masterchain_ref_seq_no() 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /storage/src/archives/package_entry_meta.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | 15 | #[derive(Debug, serde::Serialize, serde::Deserialize)] 16 | pub struct PackageEntryMeta { 17 | entry_size: u64, 18 | version: u32, 19 | } 20 | 21 | impl PackageEntryMeta { 22 | pub const fn with_data(entry_size: u64, version: u32) -> Self { 23 | Self { entry_size, version } 24 | } 25 | 26 | pub const fn entry_size(&self) -> u64 { 27 | self.entry_size 28 | } 29 | 30 | pub const fn version(&self) -> u32 { 31 | self.version 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /storage/src/archives/package_entry_meta_db.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::{ 15 | db_impl_cbor, archives::package_entry_meta::PackageEntryMeta, 16 | db::U32Key, 17 | }; 18 | 19 | db_impl_cbor!(PackageEntryMetaDb, U32Key, PackageEntryMeta); 20 | -------------------------------------------------------------------------------- /storage/src/archives/package_index_db.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::{db_impl_cbor, db::U32Key}; 15 | use std::convert::TryInto; 16 | use ever_block::Result; 17 | 18 | #[derive(serde::Serialize, serde::Deserialize)] 19 | pub struct PackageIndexEntry { 20 | deleted: bool, 21 | finalized: bool, 22 | } 23 | 24 | impl PackageIndexEntry { 25 | pub const fn new() -> Self { 26 | Self::with_data(false, false) 27 | } 28 | 29 | pub const fn with_data(deleted: bool, finalized: bool) -> Self { 30 | Self { deleted, finalized } 31 | } 32 | 33 | pub const fn deleted(&self) -> bool { 34 | self.deleted 35 | } 36 | 37 | pub const fn finalized(&self) -> bool { 38 | self.finalized 39 | } 40 | } 41 | 42 | db_impl_cbor!(PackageIndexDb, U32Key, PackageIndexEntry); 43 | 44 | impl PackageIndexDb { 45 | pub fn for_each_deserialized(&self, mut predicate: impl FnMut(u32, PackageIndexEntry) -> Result) -> Result { 46 | self.for_each(&mut |key_data, data| { 47 | let key = u32::from_le_bytes(key_data.try_into()?); 48 | let value = serde_cbor::from_slice(data)?; 49 | predicate(key, value) 50 | }) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /storage/src/archives/package_info.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::{StorageAlloc, archives::{package::Package, package_id::PackageId}}; 15 | #[cfg(feature = "telemetry")] 16 | use crate::StorageTelemetry; 17 | use adnl::{declare_counted, common::{CountedObject, Counter}}; 18 | use std::sync::Arc; 19 | #[cfg(feature = "telemetry")] 20 | use std::sync::atomic::Ordering; 21 | use ever_block::Result; 22 | 23 | //#[derive(Debug)] 24 | declare_counted!( 25 | pub struct PackageInfo { 26 | package_id: PackageId, 27 | package: Package, 28 | idx: u32, 29 | version: u32 30 | } 31 | ); 32 | 33 | impl PackageInfo { 34 | 35 | pub fn with_data( 36 | package_id: PackageId, 37 | package: Package, 38 | idx: u32, 39 | version: u32, 40 | #[cfg(feature = "telemetry")] 41 | telemetry: &Arc, 42 | allocated: &Arc 43 | ) -> Self { 44 | #[cfg(feature = "telemetry")] 45 | telemetry.packages.update( 46 | allocated.packages.load(Ordering::Relaxed) 47 | ); 48 | Self { 49 | package_id, 50 | package, 51 | idx, 52 | version, 53 | counter: allocated.packages.clone().into() 54 | } 55 | } 56 | 57 | #[allow(dead_code)] 58 | pub const fn package_id(&self) -> &PackageId { 59 | &self.package_id 60 | } 61 | 62 | pub const fn package(&self) -> &Package { 63 | &self.package 64 | } 65 | 66 | pub fn package_mut(&mut self) -> &mut Package { 67 | &mut self.package 68 | } 69 | 70 | pub const fn idx(&self) -> u32 { 71 | self.idx 72 | } 73 | 74 | pub const fn version(&self) -> u32 { 75 | self.version 76 | } 77 | 78 | pub async fn destroy(&mut self) -> Result<()> { 79 | self.package.remove().await 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /storage/src/archives/package_offsets_db.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::{ 15 | db_impl_cbor, archives::package_entry_id::PackageEntryId, 16 | db::DbKey, 17 | }; 18 | use std::{borrow::Borrow, collections::hash_map::DefaultHasher, hash::{Hash, Hasher}}; 19 | use ever_block::BlockIdExt; 20 | use ever_block::UInt256; 21 | 22 | #[derive(Debug)] 23 | pub struct PackageOffsetKey { 24 | entry_id_hash: [u8; 8], 25 | } 26 | 27 | impl PackageOffsetKey { 28 | pub fn from_entry_type(entry_id: &PackageEntryId) -> Self 29 | where 30 | B: Borrow + Hash, 31 | U256: Borrow + Hash, 32 | PK: Borrow + Hash 33 | { 34 | let mut hasher = DefaultHasher::new(); 35 | entry_id.hash(&mut hasher); 36 | 37 | Self { entry_id_hash: hasher.finish().to_le_bytes() } 38 | } 39 | } 40 | 41 | impl From<&PackageEntryId> for PackageOffsetKey 42 | where 43 | B: Borrow + Hash, 44 | U256: Borrow + Hash, 45 | PK: Borrow + Hash 46 | { 47 | fn from(entry_id: &PackageEntryId) -> Self { 48 | Self::from_entry_type(entry_id) 49 | } 50 | } 51 | 52 | impl DbKey for PackageOffsetKey { 53 | fn key_name(&self) -> &'static str { 54 | "PackageOffsetKey" 55 | } 56 | 57 | fn key(&self) -> &[u8] { 58 | &self.entry_id_hash 59 | } 60 | } 61 | 62 | db_impl_cbor!(PackageOffsetsDb, PackageOffsetKey, u64); 63 | -------------------------------------------------------------------------------- /storage/src/archives/package_status_db.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::{ 15 | db_impl_base, archives::package_status_key::PackageStatusKey, 16 | traits::Serializable 17 | }; 18 | use std::borrow::Borrow; 19 | use ever_block::Result; 20 | 21 | db_impl_base!(PackageStatusDb, PackageStatusKey); 22 | 23 | impl PackageStatusDb { 24 | pub fn try_get_value(&self, key: &PackageStatusKey) -> Result> { 25 | Ok(if let Some(db_slice) = self.try_get(key)? { 26 | Some(T::from_slice(db_slice.as_ref())?) 27 | } else { 28 | None 29 | }) 30 | } 31 | 32 | pub fn get_value(&self, key: &PackageStatusKey) -> Result { 33 | T::from_slice(self.get(key)?.as_ref()) 34 | } 35 | 36 | pub fn put_value(&self, key: &PackageStatusKey, value: impl Borrow) -> Result<()> { 37 | self.put(key, value.borrow().to_vec()?.as_slice()) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /storage/src/archives/package_status_key.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::db::DbKey; 15 | use strum_macros::AsRefStr; 16 | 17 | #[derive(Debug, AsRefStr)] 18 | pub enum PackageStatusKey { 19 | SlicedMode, 20 | SliceSize, 21 | NonSlicedSize, 22 | TotalSlices, 23 | } 24 | 25 | impl DbKey for PackageStatusKey { 26 | fn key_name(&self) -> &'static str { 27 | "PackageStatusKey" 28 | } 29 | 30 | fn as_string(&self) -> String { 31 | self.as_ref().to_string() 32 | } 33 | 34 | fn key(&self) -> &[u8] { 35 | self.as_ref().as_bytes() 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /storage/src/archives/tests/test_package_entry_id.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use super::*; 15 | use crate::archives::package_entry_id::{GetFileName, PackageEntryId}; 16 | use ever_block::{BlockIdExt, ShardIdent}; 17 | use ever_block::UInt256; 18 | 19 | #[test] 20 | fn test_filenames() { 21 | let id = BlockIdExt::with_params( 22 | ShardIdent::with_tagged_prefix(0, 0x0d80000000000000).unwrap(), 23 | 135, 24 | UInt256::default(), 25 | UInt256::default(), 26 | ); 27 | let id_str = id.filename(); 28 | assert_eq!(id_str, concat!("(0,0d80000000000000,135)", 29 | ":0000000000000000000000000000000000000000000000000000000000000000", 30 | ":0000000000000000000000000000000000000000000000000000000000000000") 31 | ); 32 | 33 | let id_master = BlockIdExt::with_params( 34 | ShardIdent::masterchain(), 35 | 0, 36 | UInt256::default(), 37 | UInt256::default(), 38 | ); 39 | let id_master_str = id_master.filename(); 40 | 41 | assert_eq!(id_master_str, concat!("(-1,8000000000000000,0)", 42 | ":0000000000000000000000000000000000000000000000000000000000000000", 43 | ":0000000000000000000000000000000000000000000000000000000000000000") 44 | ); 45 | 46 | test_entry(PackageEntryId::Empty, "empty".to_string()); 47 | test_entry(PackageEntryId::Block(id.clone()), format!("block_{}", id_str)); 48 | test_entry(PackageEntryId::ZeroState(id.clone()), format!("zerostate_{}", id_str)); 49 | test_entry(PackageEntryId::PersistentState { mc_block_id: id_master, block_id: id.clone() }, 50 | format!("state_{}_{}", id_master_str, id_str)); 51 | test_entry(PackageEntryId::Proof(id.clone()), format!("proof_{}", id_str)); 52 | test_entry(PackageEntryId::ProofLink(id.clone()), format!("prooflink_{}", id_str)); 53 | test_entry(PackageEntryId::Signatures(id.clone()), format!("signatures_{}", id_str)); 54 | 55 | // TODO: Add test for PackageEntryId::Dummy 56 | 57 | test_entry(PackageEntryId::BlockInfo(id.clone()), format!("info_{}", id_str)); 58 | } 59 | 60 | fn test_entry(entry_id: PackageEntryId, expected: String) { 61 | let filename = entry_id.filename(); 62 | assert_eq!(filename, expected); 63 | let parsed = PackageEntryId::from_filename(&filename).unwrap(); 64 | assert_eq!(parsed, entry_id) 65 | } 66 | 67 | use crate::archives::package_entry_id::GetFileNameShort; 68 | 69 | #[test] 70 | fn test_package_with_parse() { 71 | let shard_id = ShardIdent::with_tagged_prefix(555, 0xF8000000_00000000).unwrap(); 72 | let id = BlockIdExt::with_params(shard_id.clone(), 100, UInt256::rand(), UInt256::rand()); 73 | 74 | let filename = PackageEntryId::<_, UInt256, UInt256>::Block(id.clone()).filename_short(); 75 | 76 | let (workchain_id, shard_ident, seq_no) = parse_short_filename(&filename).unwrap(); 77 | assert_eq!(workchain_id, 555); 78 | assert_eq!(shard_ident, 0xF8000000_00000000); 79 | assert_eq!(seq_no, 100); 80 | } 81 | -------------------------------------------------------------------------------- /storage/src/archives/tests/test_package_id.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::archives::package_id::PackageType; 15 | use super::PackageId; 16 | use std::path::Path; 17 | use ever_block::UnixTime32; 18 | 19 | #[test] 20 | fn test_construction() { 21 | assert_eq!(PackageId::for_block(0xFFFF_FFF0), PackageId::with_values(0xFFFF_FFF0, PackageType::Blocks)); 22 | assert_eq!(PackageId::for_key_block(0xFFFF_FFF0), PackageId::with_values(0xFFFF_FFF0, PackageType::KeyBlocks)); 23 | 24 | assert_eq!(PackageId::for_temp(&UnixTime32::new(5000)), PackageId::with_values(3600, PackageType::Temp)); 25 | assert_eq!(PackageId::for_temp(&UnixTime32::new(20_000)), PackageId::with_values(18_000, PackageType::Temp)); 26 | 27 | // At least one of checks must success (other can fail because of time changing): 28 | assert!(PackageId::for_temp_now() == PackageId::for_temp(&UnixTime32::now()) 29 | || PackageId::for_temp_now() == PackageId::for_temp(&UnixTime32::now())); 30 | } 31 | 32 | #[test] 33 | fn test_paths() { 34 | let id = PackageId::for_block(123); 35 | assert_eq!(id.name(), Path::new("archive.00123")); 36 | assert_eq!(id.path(), Path::new("archive/packages/arch0000/")); 37 | 38 | let id = PackageId::for_block(123_456); 39 | assert_eq!(id.name(), Path::new("archive.123456")); 40 | assert_eq!(id.path(), Path::new("archive/packages/arch0001/")); 41 | 42 | let id = PackageId::for_block(6_123_456); 43 | assert_eq!(id.name(), Path::new("archive.6123456")); 44 | assert_eq!(id.path(), Path::new("archive/packages/arch0061/")); 45 | 46 | let id = PackageId::for_key_block(123); 47 | assert_eq!(id.name(), Path::new("key.archive.000123")); 48 | assert_eq!(id.path(), Path::new("archive/packages/key000/")); 49 | 50 | let id = PackageId::for_key_block(223_456); 51 | assert_eq!(id.name(), Path::new("key.archive.223456")); 52 | assert_eq!(id.path(), Path::new("archive/packages/key000/")); 53 | 54 | let id = PackageId::for_key_block(12_223_456); 55 | assert_eq!(id.name(), Path::new("key.archive.12223456")); 56 | assert_eq!(id.path(), Path::new("archive/packages/key001/")); 57 | 58 | let temp = PackageId::for_temp(&UnixTime32::new(20_000)); 59 | assert_eq!(temp.name(), Path::new("temp.archive.18000")); 60 | assert_eq!(temp.path(), Path::new("files/packages/")); 61 | 62 | assert_eq!(temp.full_path(Path::new("/tmp/"), "pack"), 63 | Path::new("/tmp/files/packages/temp.archive.18000.pack")); 64 | } 65 | -------------------------------------------------------------------------------- /storage/src/archives/tests/testdata/archive.00000-2.pack.gold: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/archives/tests/testdata/archive.00000-2.pack.gold -------------------------------------------------------------------------------- /storage/src/archives/tests/testdata/archive.00000.pack.gold: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/archives/tests/testdata/archive.00000.pack.gold -------------------------------------------------------------------------------- /storage/src/archives/tests/testdata/archive.00001.pack.gold: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/archives/tests/testdata/archive.00001.pack.gold -------------------------------------------------------------------------------- /storage/src/archives/tests/testdata/archive.00100.pack.gold: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/archives/tests/testdata/archive.00100.pack.gold -------------------------------------------------------------------------------- /storage/src/archives/tests/testdata/archive.00200.pack.gold: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/archives/tests/testdata/archive.00200.pack.gold -------------------------------------------------------------------------------- /storage/src/archives/tests/testdata/key.archive.000000.pack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/archives/tests/testdata/key.archive.000000.pack -------------------------------------------------------------------------------- /storage/src/block_db.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::db_impl_base; 15 | use ever_block::BlockIdExt; 16 | 17 | db_impl_base!(BlockDb, BlockIdExt); 18 | -------------------------------------------------------------------------------- /storage/src/block_info_db.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::db_impl_base; 15 | use ever_block::BlockIdExt; 16 | 17 | db_impl_base!(BlockInfoDb, BlockIdExt); 18 | -------------------------------------------------------------------------------- /storage/src/catchain_persistent_db.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::{db_impl_single, db::rocksdb::RocksDb}; 15 | 16 | db_impl_single!(CatchainPersistentDb, ever_types::types::UInt256); 17 | -------------------------------------------------------------------------------- /storage/src/db/mod.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | pub mod rocksdb; 15 | pub mod filedb; 16 | 17 | #[cfg(test)] 18 | mod tests; 19 | 20 | use ever_block::UInt256; 21 | 22 | /// Trait for database key 23 | pub trait DbKey { 24 | fn key_name(&self) -> &'static str; 25 | 26 | fn as_string(&self) -> String { 27 | hex::encode(self.key()) 28 | } 29 | 30 | fn key(&self) -> &[u8]; 31 | } 32 | 33 | impl DbKey for &str { 34 | fn key_name(&self) -> &'static str { 35 | "&str" 36 | } 37 | 38 | fn as_string(&self) -> String { 39 | String::from_utf8_lossy(self.key()).to_string() 40 | } 41 | 42 | fn key(&self) -> &[u8] { 43 | self.as_bytes() 44 | } 45 | } 46 | 47 | impl DbKey for UInt256 { 48 | fn key_name(&self) -> &'static str { 49 | "UInt256" 50 | } 51 | 52 | fn key(&self) -> &[u8] { 53 | self.as_slice() 54 | } 55 | } 56 | 57 | #[derive(Debug)] 58 | pub struct U32Key { 59 | key: [u8; 4], 60 | } 61 | 62 | impl U32Key { 63 | pub fn with_value(value: u32) -> Self { 64 | Self { key: value.to_le_bytes() } 65 | } 66 | } 67 | 68 | impl From for U32Key { 69 | fn from(value: u32) -> Self { 70 | Self::with_value(value) 71 | } 72 | } 73 | 74 | impl DbKey for U32Key { 75 | fn key_name(&self) -> &'static str { 76 | "U32Key" 77 | } 78 | 79 | fn as_string(&self) -> String { 80 | u32::from_le_bytes(self.key).to_string() 81 | } 82 | 83 | fn key(&self) -> &[u8] { 84 | &self.key 85 | } 86 | } 87 | 88 | impl DbKey for Vec { 89 | fn key_name(&self) -> &'static str { 90 | "&[u8]" 91 | } 92 | 93 | fn key(&self) -> &[u8] { 94 | self 95 | } 96 | } -------------------------------------------------------------------------------- /storage/src/db/tests/mod.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | pub mod test_filedb; 15 | pub mod test_rocksdb; 16 | 17 | pub mod utils { 18 | 19 | use crate::{db::DbKey, error::StorageError}; 20 | use ever_block::Result; 21 | 22 | pub fn expect_key_not_found_error(result: Result, key: K) { 23 | match result { 24 | Ok(_) => panic!("We don't expect any value to return"), 25 | Err(error) => { 26 | let kind = error.downcast::() 27 | .expect("Expected error of type StorageError"); 28 | match kind { 29 | StorageError::KeyNotFound(_key_name, err_key) => 30 | assert!(err_key.starts_with(key.as_string().as_str())), 31 | _ => panic!("Expected KeyNotFound error"), 32 | } 33 | }, 34 | } 35 | } 36 | 37 | pub fn expect_error(result: Result, expected_error: StorageError) { 38 | match result { 39 | Ok(_) => panic!("We don't expect any value to return"), 40 | Err(error) => { 41 | let kind = error.downcast::() 42 | .expect("Expected error of type StorageError"); 43 | if kind != expected_error { 44 | panic!("Expected {} error", expected_error) 45 | } 46 | }, 47 | } 48 | } 49 | 50 | } 51 | 52 | impl super::DbKey for &[u8] { 53 | fn key_name(&self) -> &'static str { 54 | "&[u8]" 55 | } 56 | 57 | fn key(&self) -> &[u8] { 58 | self 59 | } 60 | } -------------------------------------------------------------------------------- /storage/src/error.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use ever_block::BlockIdExt; 15 | 16 | #[derive(Debug, PartialEq, thiserror::Error)] 17 | pub enum StorageError { 18 | /// Key not found 19 | #[error("Key not found: {0}({1})")] 20 | KeyNotFound(&'static str, String), 21 | 22 | /// Reading out of buffer range 23 | #[error("Reading out of buffer range")] 24 | OutOfRange, 25 | 26 | #[error("Attempt to load state {0} which is already allowed to GC")] 27 | StateIsAllowedToGc(BlockIdExt), 28 | } 29 | -------------------------------------------------------------------------------- /storage/src/shard_top_blocks_db.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::db_impl_base; 15 | 16 | db_impl_base!(ShardTopBlocksDb, Vec); -------------------------------------------------------------------------------- /storage/src/status_db.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use std::borrow::Borrow; 15 | 16 | use ever_block::Result; 17 | 18 | use crate::{db_impl_base, db::rocksdb::RocksDbTable, traits::Serializable, types::StatusKey}; 19 | 20 | db_impl_base!(StatusDb, StatusKey); 21 | 22 | impl StatusDb { 23 | pub fn try_get_value(&self, key: &StatusKey) -> Result> { 24 | Ok(if let Some(db_slice) = self.try_get(key)? { 25 | Some(T::from_slice(db_slice.as_ref())?) 26 | } else { 27 | None 28 | }) 29 | } 30 | 31 | pub fn get_value(&self, key: &StatusKey) -> Result { 32 | T::from_slice(self.get(key)?.as_ref()) 33 | } 34 | 35 | pub fn put_value(&self, key: &StatusKey, value: impl Borrow) -> Result<()> { 36 | self.put(key, value.borrow().to_vec()?.as_slice()) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /storage/src/tests/test_block_db.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::{block_db::BlockDb, tests::utils::*, db::rocksdb::RocksDb}; 15 | use ever_block::Result; 16 | 17 | const DB_PATH: &str = "../target/test"; 18 | 19 | #[test] 20 | fn test_get_put_raw_block() -> Result<()> { 21 | const DB_NAME: &str = "test_get_put_raw_block"; 22 | 23 | let db = RocksDb::with_path(DB_PATH, DB_NAME).unwrap(); 24 | let block_db = BlockDb::with_db(db, "block_db", true)?; 25 | 26 | let block_id = get_test_block_id(); 27 | let data = get_test_raw_boc(); 28 | 29 | block_db.put(&block_id, &data)?; 30 | assert_eq!(block_db.len()?, 1); 31 | 32 | let result = block_db.get(&block_id)?; 33 | assert_eq!(result.as_ref(), data.as_slice()); 34 | 35 | Ok(()) 36 | } 37 | -------------------------------------------------------------------------------- /storage/src/tests/test_catchain_persistent_db.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::catchain_persistent_db::CatchainPersistentDb; 15 | use ever_block::Result; 16 | 17 | #[test] 18 | fn test_destroy() -> Result<()> { 19 | let mut db = CatchainPersistentDb::with_path("../target/test", "catchains")?; 20 | db.destroy()?; 21 | 22 | Ok(()) 23 | } -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467080: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467080 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467081: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467081 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467082: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467082 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467083: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467083 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467084: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467084 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467085: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467085 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467086: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467086 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467087: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467087 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467088: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467088 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467089: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467089 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467090: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467090 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467091: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467091 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467092: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467092 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467093: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467093 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467094: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467094 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467095: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467095 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467096: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467096 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467097: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467097 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467098: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467098 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467099: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467099 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467100: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467100 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467101: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467101 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467102: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467102 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467103: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467103 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467104: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467104 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467105: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467105 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467106: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467106 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467107: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467107 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467108: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467108 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467109: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467109 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467110: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467110 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467111: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467111 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467112: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467112 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467113: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467113 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467114: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467114 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467115: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467115 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467116: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467116 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467117: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467117 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467118: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467118 -------------------------------------------------------------------------------- /storage/src/tests/testdata/2467119: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/2467119 -------------------------------------------------------------------------------- /storage/src/tests/testdata/shardstate_db_v5.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/storage/src/tests/testdata/shardstate_db_v5.zip -------------------------------------------------------------------------------- /storage/src/traits.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use std::io::{Cursor, Read, Write}; 15 | 16 | use ever_block::{BlockIdExt, ShardIdent}; 17 | use ever_block::{ByteOrderRead, Result, UInt256}; 18 | 19 | pub trait Serializable { 20 | fn serialize(&self, writer: &mut W) -> Result<()>; 21 | 22 | fn deserialize(reader: &mut R) -> Result where Self: Sized; 23 | 24 | fn from_slice(data: &[u8]) -> Result where Self: Sized { 25 | Self::deserialize(&mut Cursor::new(data)) 26 | } 27 | 28 | fn to_vec(&self) -> Result> { 29 | let mut result = Vec::new(); 30 | self.serialize(&mut result)?; 31 | 32 | Ok(result) 33 | } 34 | } 35 | 36 | impl Serializable for ShardIdent { 37 | fn serialize(&self, writer: &mut W) -> Result<()> { 38 | writer.write_all(&self.workchain_id().to_le_bytes())?; 39 | writer.write_all(&self.shard_prefix_with_tag().to_le_bytes())?; 40 | 41 | Ok(()) 42 | } 43 | 44 | fn deserialize(reader: &mut R) -> Result { 45 | let workchain_id = reader.read_le_u32()? as i32; 46 | let shard_prefix_tagged = reader.read_le_u64()?; 47 | 48 | Self::with_tagged_prefix(workchain_id, shard_prefix_tagged) 49 | } 50 | } 51 | 52 | impl Serializable for BlockIdExt { 53 | fn serialize(&self, writer: &mut W) -> Result<()> { 54 | self.shard_id.serialize(writer)?; 55 | writer.write_all(&self.seq_no().to_le_bytes())?; 56 | writer.write_all(self.root_hash().as_ref())?; 57 | writer.write_all(self.file_hash().as_ref())?; 58 | 59 | Ok(()) 60 | } 61 | 62 | fn deserialize(reader: &mut R) -> Result where Self: Sized { 63 | let shard_id = ShardIdent::deserialize(reader)?; 64 | let seq_no = reader.read_le_u32()?; 65 | let root_hash = UInt256::from(reader.read_u256()?); 66 | let file_hash = UInt256::from(reader.read_u256()?); 67 | 68 | Ok(Self::with_params(shard_id, seq_no, root_hash, file_hash)) 69 | } 70 | } 71 | 72 | impl Serializable for u32 { 73 | fn serialize(&self, writer: &mut W) -> Result<()> { 74 | Ok(writer.write_all(&self.to_le_bytes())?) 75 | } 76 | 77 | fn deserialize(reader: &mut R) -> Result where Self: Sized { 78 | Ok(reader.read_le_u32()?) 79 | } 80 | } 81 | 82 | impl Serializable for u64 { 83 | fn serialize(&self, writer: &mut W) -> Result<()> { 84 | Ok(writer.write_all(&self.to_le_bytes())?) 85 | } 86 | 87 | fn deserialize(reader: &mut R) -> Result where Self: Sized { 88 | Ok(reader.read_le_u64()?) 89 | } 90 | } 91 | 92 | impl Serializable for bool { 93 | fn serialize(&self, writer: &mut W) -> Result<()> { 94 | Ok(writer.write_all(&[*self as u8])?) 95 | } 96 | 97 | fn deserialize(reader: &mut R) -> Result where Self: Sized { 98 | Ok(reader.read_byte()? != 0) 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /storage/src/types/block_id.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::db::DbKey; 15 | use ever_block::BlockIdExt; 16 | 17 | impl DbKey for BlockIdExt { 18 | fn key_name(&self) -> &'static str { 19 | "BlockId" 20 | } 21 | fn as_string(&self) -> String { 22 | format!("{}", self) 23 | } 24 | fn key(&self) -> &[u8] { 25 | self.root_hash().as_slice() 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /storage/src/types/db_slice.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use rocksdb::DBPinnableSlice; 15 | use std::ops::Deref; 16 | 17 | /// Represents memory slice, returned by database (in a case of RocksDB), or vector, in a case of MemoryDb 18 | pub enum DbSlice<'a> { 19 | RocksDbTable(DBPinnableSlice<'a>), 20 | Vector(Vec), 21 | Slice(&'a [u8]), 22 | } 23 | 24 | impl AsRef<[u8]> for DbSlice<'_> { 25 | fn as_ref(&self) -> &[u8] { 26 | match self { 27 | DbSlice::RocksDbTable(slice) => slice.as_ref(), 28 | DbSlice::Vector(vector) => vector.as_slice(), 29 | DbSlice::Slice(slice) => slice, 30 | } 31 | } 32 | } 33 | 34 | impl Deref for DbSlice<'_> { 35 | type Target = [u8]; 36 | 37 | fn deref(&self) -> &Self::Target { 38 | self.as_ref() 39 | } 40 | } 41 | 42 | impl<'a> From> for DbSlice<'a> { 43 | fn from(slice: DBPinnableSlice<'a>) -> Self { 44 | DbSlice::RocksDbTable(slice) 45 | } 46 | } 47 | 48 | impl<'a> From<&'a [u8]> for DbSlice<'a> { 49 | fn from(slice: &'a [u8]) -> Self { 50 | DbSlice::Slice(slice) 51 | } 52 | } 53 | 54 | impl<'a> From> for DbSlice<'a> { 55 | fn from(vector: Vec) -> Self { 56 | DbSlice::Vector(vector) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /storage/src/types/mod.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | #[cfg(test)] 15 | mod tests; 16 | 17 | mod block_id; 18 | mod block_meta; 19 | mod db_slice; 20 | mod shard_ident_key; 21 | mod status_key; 22 | mod storage_cell; 23 | 24 | pub use block_meta::*; 25 | pub use db_slice::*; 26 | pub use shard_ident_key::*; 27 | pub use status_key::*; 28 | pub use storage_cell::*; 29 | 30 | /* 31 | /// Usually >= 1; 0 used to indicate the initial state, i.e. "zerostate" 32 | pub type BlockSeqNo = i32; 33 | pub type BlockVertSeqNo = u32; 34 | pub type WorkchainId = i32; 35 | pub type ShardId = i64; 36 | */ -------------------------------------------------------------------------------- /storage/src/types/shard_ident_key.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::{db::DbKey, traits::Serializable}; 15 | use ever_block::{ShardIdent, Result}; 16 | 17 | pub struct ShardIdentKey(Vec); 18 | 19 | impl ShardIdentKey { 20 | pub fn new(shard_ident: &ShardIdent) -> Result { 21 | let mut key = Vec::with_capacity(std::mem::size_of::()); 22 | shard_ident.serialize(&mut key)?; 23 | 24 | Ok(Self(key)) 25 | } 26 | } 27 | 28 | impl DbKey for ShardIdentKey { 29 | fn key_name(&self) -> &'static str { 30 | "ShardIdentKey" 31 | } 32 | 33 | fn as_string(&self) -> String { 34 | ShardIdent::from_slice(self.key()) 35 | .map(|shard_ident| format!("{}", shard_ident)) 36 | .unwrap_or_else(|_err| hex::encode(self.key())) 37 | } 38 | 39 | fn key(&self) -> &[u8] { 40 | self.0.as_slice() 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /storage/src/types/status_key.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::db::DbKey; 15 | use strum_macros::AsRefStr; 16 | 17 | #[derive(Debug, AsRefStr)] 18 | pub enum StatusKey { 19 | // TODO: Reserved for DynamicBocDb 20 | } 21 | 22 | impl DbKey for StatusKey { 23 | fn key_name(&self) -> &'static str { 24 | "StatusKey" 25 | } 26 | 27 | fn as_string(&self) -> String { 28 | self.as_ref().to_string() 29 | } 30 | fn key(&self) -> &[u8] { 31 | self.as_ref().as_bytes() 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /storage/src/types/tests/mod.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | mod test_serialization; 15 | mod test_block_id; 16 | -------------------------------------------------------------------------------- /storage/src/types/tests/test_block_id.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::{db::DbKey, tests::utils::{FILE_HASH, ROOT_HASH}}; 15 | use ever_block::{BlockIdExt, ShardIdent}; 16 | use ever_block::UInt256; 17 | 18 | fn create_block_id() -> BlockIdExt { 19 | BlockIdExt::with_params( 20 | ShardIdent::with_tagged_prefix(-1, 0x8000_0000_0000_0000).unwrap(), 21 | 1, 22 | UInt256::from(ROOT_HASH), 23 | UInt256::from(FILE_HASH) 24 | ) 25 | } 26 | 27 | #[test] 28 | fn test_block_id_formatting() { 29 | let block_id = create_block_id(); 30 | assert_eq!( 31 | block_id.to_string().to_lowercase(), 32 | format!( 33 | "(-1:8000000000000000, 1, rh {}, fh {})", 34 | hex::encode(ROOT_HASH), 35 | hex::encode(FILE_HASH) 36 | ).to_lowercase() 37 | ); 38 | } 39 | 40 | #[test] 41 | fn test_block_key_formatting() { 42 | let block_id = create_block_id(); 43 | assert_eq!(block_id.key(), ROOT_HASH); 44 | } -------------------------------------------------------------------------------- /storage/src/types/tests/test_serialization.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2024 EverX. All Rights Reserved. 3 | * 4 | * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use 5 | * this file except in compliance with the License. 6 | * 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific EVERX DEV software governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | use crate::{ 15 | tests::utils::{FILE_HASH, get_test_block_id, get_test_shard_ident, ROOT_HASH}, 16 | traits::Serializable, types::BlockMeta 17 | }; 18 | use std::{cell::RefCell, sync::atomic::Ordering}; 19 | use ever_block::{BlockIdExt, ShardIdent}; 20 | use ever_block::Result; 21 | 22 | static SHARD_IDENT_SERIALIZED: [u8; 12] = [ 23 | // workchain_id = -1 (4 bytes) 24 | 0xFF, 0xFF, 0xFF, 0xFF, 25 | // prefix = 0x8000_0000_0000_0000 (8 bytes) 26 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 27 | ]; 28 | 29 | static SEQ_NO_SERIALIZED: [u8; 4] = [ 30 | // seq_no = 1830539 (4 bytes) 31 | 0x8B, 0xEE, 0x1B, 0x00, 32 | ]; 33 | 34 | #[test] 35 | fn test_shard_ident_serialization() -> Result<()> { 36 | let shard_ident = get_test_shard_ident(); 37 | let data = shard_ident.to_vec()?; 38 | assert_eq!(data, SHARD_IDENT_SERIALIZED); 39 | 40 | let new_shard_ident = ShardIdent::from_slice(data.as_slice())?; 41 | assert_eq!(new_shard_ident, shard_ident); 42 | 43 | Ok(()) 44 | } 45 | 46 | #[test] 47 | fn test_block_id_ext_serialization() -> Result<()> { 48 | let block_id_ext = get_test_block_id(); 49 | let data = block_id_ext.to_vec()?; 50 | assert_eq!(data, [ 51 | &SHARD_IDENT_SERIALIZED[..], 52 | &SEQ_NO_SERIALIZED[..], 53 | &ROOT_HASH[..], 54 | &FILE_HASH[..] 55 | ].concat()); 56 | 57 | let new_block_id_ext = BlockIdExt::from_slice(data.as_slice())?; 58 | assert_eq!(new_block_id_ext, block_id_ext); 59 | 60 | Ok(()) 61 | } 62 | 63 | #[test] 64 | fn test_block_meta_serialization() -> Result<()> { 65 | 66 | let meta = BlockMeta::with_data(0x00_00_56_78, 0x90_AB_CD_EF, 0x11_22_33_44_55_66_77_88, 0x01_02_03_04, 0x01_01_00_00); 67 | let expected = RefCell::new( 68 | vec![ 69 | 0x04, 0x03, 0x02, 0x01, 70 | 0x78, 0x56, 0x00, 0x00, 71 | 0xEF, 0xCD, 0xAB, 0x90, 72 | 0x88, 0x77, 0x66, 0x55, 73 | 0x44, 0x33, 0x22, 0x11, 74 | 0x00, 0x00, 0x01, 0x01, 75 | ] 76 | ); 77 | 78 | meta.test_counter.store(0x10203040, Ordering::Relaxed); 79 | let mut counter_stored = vec![0x40, 0x30, 0x20, 0x10]; 80 | expected.borrow_mut().append(&mut counter_stored); 81 | 82 | let data = meta.to_vec()?; 83 | assert_eq!(data, *expected.borrow()); 84 | 85 | let new_meta = BlockMeta::from_slice(data.as_slice())?; 86 | assert_eq!(new_meta.flags(), meta.flags()); 87 | assert_eq!(new_meta.gen_utime, meta.gen_utime); 88 | assert_eq!(new_meta.gen_lt, meta.gen_lt); 89 | assert_eq!(new_meta.masterchain_ref_seq_no(), meta.masterchain_ref_seq_no()); 90 | 91 | #[cfg(test)] 92 | assert_eq!(new_meta.test_counter.load(Ordering::SeqCst), meta.test_counter.load(Ordering::SeqCst)); 93 | Ok(()) 94 | 95 | } -------------------------------------------------------------------------------- /tests/setup_test_paths.sh: -------------------------------------------------------------------------------- 1 | TESTS_DIR=$(realpath $(dirname "${BASH_SOURCE:-$0}")) 2 | BASE_DIR=${TESTS_DIR}/../../ 3 | TOOLS_DIR=${BASE_DIR}/ever-node/target/release/ 4 | CONFIG_PATH=${BASE_DIR}/ever-node/target/release/ 5 | CONSOLE_CONFIG_0=${CONFIG_PATH}configs_0/console.json 6 | -------------------------------------------------------------------------------- /tests/test_high_load/.gitignore: -------------------------------------------------------------------------------- 1 | *.boc 2 | logs/* 3 | -------------------------------------------------------------------------------- /tests/test_high_load/Brazil.abi.json: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": ["time"], 4 | "functions": [ 5 | { 6 | "name": "constructor", 7 | "inputs": [ 8 | ], 9 | "outputs": [ 10 | ] 11 | }, 12 | { 13 | "name": "setC", 14 | "inputs": [ 15 | {"name":"counter","type":"uint128"} 16 | ], 17 | "outputs": [ 18 | ] 19 | }, 20 | { 21 | "name": "deployWorker", 22 | "inputs": [ 23 | ], 24 | "outputs": [ 25 | ] 26 | }, 27 | { 28 | "name": "stopWorker", 29 | "inputs": [ 30 | ], 31 | "outputs": [ 32 | ] 33 | }, 34 | { 35 | "name": "NeedMoney", 36 | "inputs": [ 37 | {"name":"id","type":"uint128"} 38 | ], 39 | "outputs": [ 40 | ] 41 | }, 42 | { 43 | "name": "build", 44 | "inputs": [ 45 | ], 46 | "outputs": [ 47 | ] 48 | }, 49 | { 50 | "name": "init", 51 | "inputs": [ 52 | ], 53 | "outputs": [ 54 | ] 55 | }, 56 | { 57 | "name": "setNumber", 58 | "inputs": [ 59 | {"name":"number","type":"uint128"} 60 | ], 61 | "outputs": [ 62 | ] 63 | }, 64 | { 65 | "name": "setCode2", 66 | "inputs": [ 67 | {"name":"c","type":"cell"} 68 | ], 69 | "outputs": [ 70 | ] 71 | }, 72 | { 73 | "name": "setData2", 74 | "inputs": [ 75 | {"name":"c","type":"cell"} 76 | ], 77 | "outputs": [ 78 | ] 79 | }, 80 | { 81 | "name": "setContract2", 82 | "inputs": [ 83 | {"name":"c","type":"cell"} 84 | ], 85 | "outputs": [ 86 | ] 87 | }, 88 | { 89 | "name": "setKey", 90 | "inputs": [ 91 | {"name":"key","type":"uint256"} 92 | ], 93 | "outputs": [ 94 | ] 95 | }, 96 | { 97 | "name": "setdGrant", 98 | "inputs": [ 99 | {"name":"dgrant","type":"uint128"} 100 | ], 101 | "outputs": [ 102 | ] 103 | }, 104 | { 105 | "name": "upgrade", 106 | "inputs": [ 107 | {"name":"newcode","type":"cell"} 108 | ], 109 | "outputs": [ 110 | ] 111 | }, 112 | { 113 | "name": "grant", 114 | "inputs": [ 115 | {"name":"addr","type":"address"}, 116 | {"name":"value","type":"uint128"} 117 | ], 118 | "outputs": [ 119 | ] 120 | } 121 | ], 122 | "data": [ 123 | ], 124 | "events": [ 125 | ] 126 | } 127 | -------------------------------------------------------------------------------- /tests/test_high_load/Brazil.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-node/e4068621a96d78969dd6df3087504d25b06fca6e/tests/test_high_load/Brazil.tvc -------------------------------------------------------------------------------- /tests/test_high_load/SafeMultisigWallet.abi.json: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": ["pubkey", "time", "expire"], 4 | "functions": [ 5 | { 6 | "name": "constructor", 7 | "inputs": [ 8 | {"name":"owners","type":"uint256[]"}, 9 | {"name":"reqConfirms","type":"uint8"} 10 | ], 11 | "outputs": [ 12 | ] 13 | }, 14 | { 15 | "name": "acceptTransfer", 16 | "inputs": [ 17 | {"name":"payload","type":"bytes"} 18 | ], 19 | "outputs": [ 20 | ] 21 | }, 22 | { 23 | "name": "sendTransaction", 24 | "inputs": [ 25 | {"name":"dest","type":"address"}, 26 | {"name":"value","type":"uint128"}, 27 | {"name":"bounce","type":"bool"}, 28 | {"name":"flags","type":"uint8"}, 29 | {"name":"payload","type":"cell"} 30 | ], 31 | "outputs": [ 32 | ] 33 | }, 34 | { 35 | "name": "submitTransaction", 36 | "inputs": [ 37 | {"name":"dest","type":"address"}, 38 | {"name":"value","type":"uint128"}, 39 | {"name":"bounce","type":"bool"}, 40 | {"name":"allBalance","type":"bool"}, 41 | {"name":"payload","type":"cell"} 42 | ], 43 | "outputs": [ 44 | {"name":"transId","type":"uint64"} 45 | ] 46 | }, 47 | { 48 | "name": "confirmTransaction", 49 | "inputs": [ 50 | {"name":"transactionId","type":"uint64"} 51 | ], 52 | "outputs": [ 53 | ] 54 | }, 55 | { 56 | "name": "isConfirmed", 57 | "inputs": [ 58 | {"name":"mask","type":"uint32"}, 59 | {"name":"index","type":"uint8"} 60 | ], 61 | "outputs": [ 62 | {"name":"confirmed","type":"bool"} 63 | ] 64 | }, 65 | { 66 | "name": "getParameters", 67 | "inputs": [ 68 | ], 69 | "outputs": [ 70 | {"name":"maxQueuedTransactions","type":"uint8"}, 71 | {"name":"maxCustodianCount","type":"uint8"}, 72 | {"name":"expirationTime","type":"uint64"}, 73 | {"name":"minValue","type":"uint128"}, 74 | {"name":"requiredTxnConfirms","type":"uint8"} 75 | ] 76 | }, 77 | { 78 | "name": "getTransaction", 79 | "inputs": [ 80 | {"name":"transactionId","type":"uint64"} 81 | ], 82 | "outputs": [ 83 | {"components":[{"name":"id","type":"uint64"},{"name":"confirmationsMask","type":"uint32"},{"name":"signsRequired","type":"uint8"},{"name":"signsReceived","type":"uint8"},{"name":"creator","type":"uint256"},{"name":"index","type":"uint8"},{"name":"dest","type":"address"},{"name":"value","type":"uint128"},{"name":"sendFlags","type":"uint16"},{"name":"payload","type":"cell"},{"name":"bounce","type":"bool"}],"name":"trans","type":"tuple"} 84 | ] 85 | }, 86 | { 87 | "name": "getTransactions", 88 | "inputs": [ 89 | ], 90 | "outputs": [ 91 | {"components":[{"name":"id","type":"uint64"},{"name":"confirmationsMask","type":"uint32"},{"name":"signsRequired","type":"uint8"},{"name":"signsReceived","type":"uint8"},{"name":"creator","type":"uint256"},{"name":"index","type":"uint8"},{"name":"dest","type":"address"},{"name":"value","type":"uint128"},{"name":"sendFlags","type":"uint16"},{"name":"payload","type":"cell"},{"name":"bounce","type":"bool"}],"name":"transactions","type":"tuple[]"} 92 | ] 93 | }, 94 | { 95 | "name": "getTransactionIds", 96 | "inputs": [ 97 | ], 98 | "outputs": [ 99 | {"name":"ids","type":"uint64[]"} 100 | ] 101 | }, 102 | { 103 | "name": "getCustodians", 104 | "inputs": [ 105 | ], 106 | "outputs": [ 107 | {"components":[{"name":"index","type":"uint8"},{"name":"pubkey","type":"uint256"}],"name":"custodians","type":"tuple[]"} 108 | ] 109 | } 110 | ], 111 | "data": [ 112 | ], 113 | "events": [ 114 | { 115 | "name": "TransferAccepted", 116 | "inputs": [ 117 | {"name":"payload","type":"bytes"} 118 | ], 119 | "outputs": [ 120 | ] 121 | } 122 | ] 123 | } 124 | 125 | -------------------------------------------------------------------------------- /tests/test_high_load/addrBrazil: -------------------------------------------------------------------------------- 1 | 0:2fbb0d78c8428f1770f19b622a8e2426daeb347d7b3f26d4e1e2888c55b6b1c2 2 | 0:95235ccbcc3dce4e5cb2e748fccd6745a4271ed325df7364c8778b0e8bd597e2 3 | 0:4a5ed5323d510dedb4cd8b6bf322b89b73eaec0b359ce46e3557c46499f2d64c 4 | -------------------------------------------------------------------------------- /tests/test_high_load/deploy.keys.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "public": "553f9351ca08417c8c338413c2fd4b30eb7f6d35694e3e1b8ceb3d5729a34520", 3 | "secret": "4211ad17d7ae93c0e9df877bff1bebea86d2ea4aca39309a967341c5e2c854a4" 4 | } -------------------------------------------------------------------------------- /tests/test_high_load/deploy.keys.json: -------------------------------------------------------------------------------- 1 | { 2 | "public": "21e0e3a0302b3d6b3e70802ca20af6b9901e6007afcd3087e16db1474c2dcf62", 3 | "secret": "69b0b784c01a4eec1d5edaa334d741ad4e9f590bcecdf5f30743fc19cd6e0ddf" 4 | } -------------------------------------------------------------------------------- /tests/test_high_load/msig.keys.json: -------------------------------------------------------------------------------- 1 | { 2 | "public": "c86b504dbbcf2263c6d5985743f1b248eca31d9ae37d273102ddd2b6ccd95c8a", 3 | "secret": "9e8148716bca7aa1c33266eedcbaa56c3d00b6f58caaa78561bab54037f717e8" 4 | } -------------------------------------------------------------------------------- /tests/test_high_load/remove_junk.sh: -------------------------------------------------------------------------------- 1 | rm msg*.boc 2 | -------------------------------------------------------------------------------- /tests/test_high_load/seedphrase: -------------------------------------------------------------------------------- 1 | Config: /shared/Brazil/tonos-cli/target/release/tonos-cli.conf.json 2 | Succeeded. 3 | Seed phrase: "rifle normal planet still modify broom unique axis marine gallery hurry parent" 4 | -------------------------------------------------------------------------------- /tests/test_high_load/test_console.sh: -------------------------------------------------------------------------------- 1 | source ../setup_test_paths.sh 2 | $TOOLS_DIR/console -C ${CONSOLE_CONFIG_0} -c "getstats" 3 | -------------------------------------------------------------------------------- /tests/test_high_load/test_one_message.sh: -------------------------------------------------------------------------------- 1 | source ../setup_test_paths.sh 2 | 3 | RUN_TEST_ROOT=../test_run_net/ 4 | TEST_ROOT=$(pwd) 5 | mkdir logs 6 | export ROOT=$(pwd)/logs 7 | export REMP_TEST=true 8 | DELAY=20 9 | 10 | cd $RUN_TEST_ROOT 11 | if ! $RUN_TEST_ROOT/test_run_net.sh 12 | then 13 | exit 1 14 | fi 15 | 16 | cd ../../../ 17 | if ! [ -d "tonos-cli" ] 18 | then 19 | git clone "git@github.com:tonlabs/tonos-cli.git" 20 | fi 21 | cd tonos-cli 22 | cargo build --release 23 | cd target/release 24 | CLI=$(pwd) 25 | 26 | cd $TEST_ROOT 27 | 28 | echo "Press ENTER to start transactions" 29 | read -r input 30 | 31 | echo "Preparation (0/6) deploing giver" 32 | $CLI/ever-cli \ 33 | message "-1:7777777777777777777777777777777777777777777777777777777777777777" \ 34 | constructor '{ 35 | "owners":["0xc86b504dbbcf2263c6d5985743f1b248eca31d9ae37d273102ddd2b6ccd95c8a"], 36 | "reqConfirms":1 37 | }' \ 38 | --abi SetcodeMultisigWallet.abi.json \ 39 | --sign deploy.keys.2.json \ 40 | --output "$TEST_ROOT/msg0.boc" \ 41 | --raw 42 | 43 | echo $TOOLS_DIR/console -C ${CONSOLE_CONFIG_0} -c "sendmessage $TEST_ROOT/msg0.boc" 44 | $TOOLS_DIR/console -C ${CONSOLE_CONFIG_0} -c "sendmessage $TEST_ROOT/msg0.boc" 45 | 46 | while true; do 47 | echo "Enter amount of money to transfer: " 48 | read -r input 49 | echo "Preparation (1/6) sending money to Brazil contract" 50 | $CLI/ever-cli \ 51 | message "-1:7777777777777777777777777777777777777777777777777777777777777777" \ 52 | submitTransaction "{ 53 | \"dest\" : \"0:4a5ed5323d510dedb4cd8b6bf322b89b73eaec0b359ce46e3557c46499f2d64c\", 54 | \"value\":\"$input\", 55 | \"bounce\":false, 56 | \"allBalance\":false, 57 | \"payload\":\"\" 58 | }" \ 59 | --abi SafeMultisigWallet.abi.json \ 60 | --sign msig.keys.json \ 61 | --output "$TEST_ROOT/msg1.boc" \ 62 | --raw 63 | $TOOLS_DIR/console -C ${CONSOLE_CONFIG_0} -c "sendmessage $TEST_ROOT/msg1.boc" 64 | done 65 | 66 | pkill ever-node 67 | -------------------------------------------------------------------------------- /tests/test_remp/.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | *__address 3 | *.boc 4 | *.tvc 5 | *.json 6 | *.code -------------------------------------------------------------------------------- /tests/test_remp/no_replay.sol: -------------------------------------------------------------------------------- 1 | pragma ton-solidity >= 0.55.0; 2 | //pragma AbiHeader time; 3 | 4 | // This contract demonstrates custom replay protection functionality. 5 | contract CustomReplaySample { 6 | 7 | uint public value; 8 | 9 | function addValue(uint num) public { 10 | tvm.accept(); 11 | value += num; 12 | } 13 | 14 | function getValue() public view returns (uint) { 15 | return value; 16 | } 17 | 18 | // Function with predefined name which is used to replace custom replay protection. 19 | function afterSignatureCheck(TvmSlice body, TvmCell) private pure inline returns (TvmSlice) { 20 | // Via TvmSlice methods we read header fields from the message body 21 | 22 | body.decode(uint64); // The first 64 bits contain timestamp which is usually used to differentiate messages. 23 | 24 | // After reading message headers this function must return the rest of the body slice. 25 | return body; 26 | } 27 | } -------------------------------------------------------------------------------- /tests/test_run_net/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !console-template.json 3 | !default_config.json 4 | !default_config_fullnode.json 5 | !log_cfg.yml 6 | !README.md 7 | !remove_junk.sh 8 | !restart_nodes.sh 9 | !run_full_node.sh 10 | !stop_network.sh 11 | !test_run_net.sh 12 | !test_run_net_ci.sh 13 | !test_run_net_ci_public.sh 14 | !test_run_net_ci_venom.sh 15 | !test_run_workchains.sh 16 | !ton-global.config_1.json 17 | !ton-global.config_2.json 18 | !zero_state_blanc_1.json 19 | !zero_state_blanc_2.json -------------------------------------------------------------------------------- /tests/test_run_net/README.md: -------------------------------------------------------------------------------- 1 | # How to run EverX blockchain emulation 2 | 3 | Use following command to run nodes and create blockchain network on local host: 4 | 5 | ``` 6 | bash ./test_run_net.sh 7 | ``` 8 | 9 | All required build procedures will be performed automatically. Then script will ensure that network was started ok and exits. Node processes will remain running. There should be all validator nodes except node #0 which is not validaing. Next run of this script will destroy previously running nodes, clean up data and restart network anew. 10 | 11 | It is possible to check specific node status by its log: 12 | 13 | ``` 14 | tail -f ./tmp/output_N.log # N is the number of the node, 15 | ``` 16 | 17 | It is also possible to restart nodes (and rebuild if necessary): 18 | 19 | ``` 20 | bash ./restart_nodes.sh 21 | ``` 22 | 23 | Finally it is possible to kill all nodes and remove blockchain data: 24 | 25 | ``` 26 | bash ./stop_network.sh 27 | ``` 28 | -------------------------------------------------------------------------------- /tests/test_run_net/console-template.json: -------------------------------------------------------------------------------- 1 | { 2 | "config": null, 3 | "wallet_id": null, 4 | "max_factor": 3 5 | } -------------------------------------------------------------------------------- /tests/test_run_net/default_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "log_config_name": "log_cfg_nodenumber.yml", 3 | "ton_global_config_name": "ton-global.config.json", 4 | "internal_db_path": "node_db_nodenumber", 5 | "ip_address": "0.0.0.0:main_port", 6 | "control_server_port": control_port, 7 | workchain_id 8 | "shard_keeper": { 9 | "get_peer_attempt_timeout_ms": 1000, 10 | "download_next_block_full_timeout_ms": 1000, 11 | "download_block_full_timeout_ms": 1000 12 | }, 13 | "validation_countdown_mode": "except-zerostate", 14 | "remp": { 15 | "client_enabled": true, 16 | "service_enabled": true 17 | }, 18 | "kafka_consumer_config": { 19 | "group_id": "101", 20 | "brokers": "kafka", 21 | "topic": "requests", 22 | "session_timeout_ms": 6000, 23 | "run_attempt_timeout_ms": 1000 24 | }, 25 | "external_db_config": { 26 | "block_producer": { 27 | "enabled": true, 28 | "brokers": "kafka", 29 | "message_timeout_ms": 100, 30 | "topic": "blocks", 31 | "attempt_timeout_ms": 100, 32 | "message_max_size": 3000000, 33 | "big_messages_storage": "big-blocks" 34 | }, 35 | "message_producer": { 36 | "enabled": true, 37 | "brokers": "kafka", 38 | "message_timeout_ms": 100, 39 | "topic": "messages", 40 | "attempt_timeout_ms": 100, 41 | "message_max_size": 3000000, 42 | "big_messages_storage": "big-messages" 43 | }, 44 | "transaction_producer": { 45 | "enabled": true, 46 | "brokers": "kafka", 47 | "message_timeout_ms": 100, 48 | "topic": "transactions", 49 | "attempt_timeout_ms": 100, 50 | "message_max_size": 3000000, 51 | "big_messages_storage": "big-transactions" 52 | }, 53 | "account_producer": { 54 | "enabled": true, 55 | "brokers": "kafka", 56 | "message_timeout_ms": 100, 57 | "topic": "accounts", 58 | "attempt_timeout_ms": 100, 59 | "message_max_size": 3000000, 60 | "big_messages_storage": "big-accounts" 61 | }, 62 | "block_proof_producer": { 63 | "enabled": true, 64 | "brokers": "kafka", 65 | "message_timeout_ms": 100, 66 | "topic": "blocks_signatures", 67 | "attempt_timeout_ms": 100, 68 | "message_max_size": 3000000, 69 | "big_messages_storage": "big-block-proofs" 70 | }, 71 | "bad_blocks_storage": "bad-blocks" 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /tests/test_run_net/default_config_fullnode.json: -------------------------------------------------------------------------------- 1 | { 2 | "log_config_name": "log_cfg_nodenumber.yml", 3 | "ton_global_config_name": "ton-global.config.json", 4 | "internal_db_path": "node_db_nodenumber", 5 | "ip_address": "0.0.0.0:main_port", 6 | "control_server_port": control_port, 7 | workchain_id 8 | "shard_keeper": { 9 | "get_peer_attempt_timeout_ms": 1000, 10 | "download_next_block_full_timeout_ms": 1000, 11 | "download_block_full_timeout_ms": 1000 12 | }, 13 | "kafka_consumer_config": { 14 | "group_id": "101", 15 | "brokers": "kafka", 16 | "topic": "requests", 17 | "session_timeout_ms": 6000, 18 | "run_attempt_timeout_ms": 1000 19 | }, 20 | "remp": { 21 | "client_enabled": true, 22 | "service_enabled": true 23 | }, 24 | "external_db_config": { 25 | "block_producer": { 26 | "enabled": true, 27 | "brokers": "kafka", 28 | "message_timeout_ms": 100, 29 | "topic": "blocks", 30 | "attempt_timeout_ms": 100, 31 | "message_max_size": 3000000, 32 | "big_messages_storage": "big-blocks" 33 | }, 34 | "message_producer": { 35 | "enabled": true, 36 | "brokers": "kafka", 37 | "message_timeout_ms": 100, 38 | "topic": "messages", 39 | "attempt_timeout_ms": 100, 40 | "message_max_size": 3000000, 41 | "big_messages_storage": "big-messages" 42 | }, 43 | "transaction_producer": { 44 | "enabled": true, 45 | "brokers": "kafka", 46 | "message_timeout_ms": 100, 47 | "topic": "transactions", 48 | "attempt_timeout_ms": 100, 49 | "message_max_size": 3000000, 50 | "big_messages_storage": "big-transactions" 51 | }, 52 | "account_producer": { 53 | "enabled": true, 54 | "brokers": "kafka", 55 | "message_timeout_ms": 100, 56 | "topic": "accounts", 57 | "attempt_timeout_ms": 100, 58 | "message_max_size": 3000000, 59 | "big_messages_storage": "big-accounts" 60 | }, 61 | "block_proof_producer": { 62 | "enabled": true, 63 | "brokers": "kafka", 64 | "message_timeout_ms": 100, 65 | "topic": "blocks_signatures", 66 | "attempt_timeout_ms": 100, 67 | "message_max_size": 3000000, 68 | "big_messages_storage": "big-block-proofs" 69 | }, 70 | "bad_blocks_storage": "bad-blocks" 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /tests/test_run_net/log_cfg.yml: -------------------------------------------------------------------------------- 1 | # Scan this file for changes every 30 seconds 2 | # https://docs.rs/log4rs/0.8.3/log4rs/encode/pattern/index.html 3 | refresh_rate: 30 seconds 4 | 5 | appenders: 6 | stdout: 7 | kind: console 8 | encoder: 9 | pattern: "{d(%Y-%m-%d %H:%M:%S.%f)} {l} [{h({t})}] {I}: {m}{n}" 10 | 11 | stdout_ref: 12 | kind: console 13 | encoder: 14 | pattern: "{f}:{L} {l} [{h({t})}] {I}: {m}{n}" 15 | 16 | rolling_logfile: 17 | kind: rolling_file 18 | encoder: 19 | pattern: "{d(%Y-%m-%d %H:%M:%S.%f)} {l} [{h({t})}] {I}: {m}{n}" 20 | path: '/shared/output_NODE_NUM.log' 21 | policy: 22 | kind: compound 23 | trigger: 24 | kind: size 25 | limit: 5 gb 26 | roller: 27 | kind: fixed_window 28 | pattern: '/shared/output_NODE_NUM_{}.log' 29 | base: 1 30 | count: 10 31 | 32 | root: 33 | level: error 34 | appenders: 35 | - rolling_logfile 36 | 37 | loggers: 38 | # node messages 39 | ever_node: 40 | level: trace 41 | boot: 42 | level: trace 43 | sync: 44 | level: trace 45 | 46 | # adnl messages 47 | adnl: 48 | level: warn 49 | adnl_query: 50 | level: info 51 | 52 | overlay: 53 | level: warn 54 | 55 | rldp: 56 | level: warn 57 | 58 | dht: 59 | level: warn 60 | 61 | # block messages 62 | ever_block: 63 | level: off 64 | 65 | # block messages 66 | executor: 67 | level: off 68 | 69 | # tvm messages 70 | tvm: 71 | level: off 72 | 73 | librdkafka: 74 | level: error 75 | 76 | validator: 77 | level: debug 78 | 79 | validator_manager: 80 | level: trace 81 | 82 | remp: 83 | level: trace 84 | 85 | verificator: 86 | level: trace 87 | 88 | catchain: 89 | level: error 90 | 91 | validator_session: 92 | level: debug 93 | 94 | storage: 95 | level: info 96 | 97 | telemetry: 98 | level: debug 99 | 100 | ext_messages: 101 | level: trace 102 | -------------------------------------------------------------------------------- /tests/test_run_net/remove_junk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | NODE_PATH=$1 4 | NODES=$2 5 | if [ "$NODES" == "" ] ; then 6 | NODES=20 7 | fi 8 | 9 | if ! [ "$NODE_PATH" == "" ] ; then 10 | rm -f $NODE_PATH/*.boc 11 | rm -f $NODE_PATH/config.json 12 | rm -f $NODE_PATH/console_config.json 13 | rm -f $NODE_PATH/console_public_json 14 | rm -f $NODE_PATH/default_config.json 15 | rm -f $NODE_PATH/tmp_output 16 | rm -f $NODE_PATH/ton-global.config.json 17 | rm -f $NODE_PATH/zero_state_tmp.json 18 | rm -f $NODE_PATH/zero_state_tmp_2.json 19 | fi 20 | 21 | rm -f tmp_output 22 | rm -f ton-global.config.json 23 | rm -f ton-global.config.json.tmp 24 | rm -f zero_state.json 25 | rm -f zero_state_tmp.json 26 | rm -f zero_state_tmp_2.json 27 | rm -rdf tmp 28 | 29 | for (( N=0; N <= $NODES; N++ )) 30 | do 31 | rm -f /shared/output_$N.log 32 | if ! [ "$NODE_PATH" == "" ] ; then 33 | rm -f $NODE_PATH/default_config$N.json 34 | rm -f $NODE_PATH/log_cfg_$N.yml 35 | rm -rdf $NODE_PATH/configs_$N 36 | rm -rdf $NODE_PATH/node_db_$N 37 | fi 38 | rm -f config$N.json 39 | rm -f console$N.json 40 | rm -f default_config$N.json 41 | rm -f genkey$N 42 | done 43 | -------------------------------------------------------------------------------- /tests/test_run_net/restart_nodes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | NODES=$(pgrep ever-node | wc -l) 4 | 5 | echo "Stopping $NODES nodes..." 6 | 7 | pkill ever-node 8 | while pgrep -x "ever-node" > /dev/null 9 | do 10 | sleep 1 11 | done 12 | 13 | echo "Rebuilding..." 14 | if ! cargo build --release 15 | then 16 | exit 1 17 | fi 18 | 19 | TEST_ROOT=$(pwd); 20 | NODE_TARGET=$TEST_ROOT/../../target/release/ 21 | 22 | echo "Restarting $NODES nodes..." 23 | 24 | cd $NODE_TARGET 25 | 26 | for (( N=0; N < $NODES; N++ )) 27 | do 28 | echo " Starting node #$N..." 29 | ./ever-node --configs configs_$N -z . > "$TEST_ROOT/tmp/output_$N.log" 2>&1 & 30 | done 31 | -------------------------------------------------------------------------------- /tests/test_run_net/stop_network.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | NODES=$(pgrep ever-node | wc -l) 4 | NODES=$((NODES - 1)) 5 | TEST_ROOT=$(pwd); 6 | NODE_TARGET=$TEST_ROOT/../../target/release/ 7 | 8 | pkill -9 ever-node 9 | bash ./remove_junk.sh "$NODE_TARGET" "$NODES" > /dev/null 2>&1 10 | -------------------------------------------------------------------------------- /tests/test_run_net/ton-global.config_1.json: -------------------------------------------------------------------------------- 1 | { 2 | "@type": "config.global", 3 | "dht": { 4 | "@type": "dht.config.global", 5 | "k": 6, 6 | "a": 3, 7 | "static_nodes": { 8 | "@type": "dht.nodes", 9 | "nodes": [ 10 | -------------------------------------------------------------------------------- /tests/test_run_net/ton-global.config_2.json: -------------------------------------------------------------------------------- 1 | ] 2 | } 3 | }, 4 | "validator": { 5 | "@type": "validator.config.global", 6 | "zero_state": { 7 | "workchain": -1, 8 | "shard": -9223372036854775808, 9 | "seqno": 0, 10 | "root_hash": "pNdgJxYEfATRklM60dbBcTnH7vKq7OxK2iU/UvgK0UI=", 11 | "file_hash": "IOCRo45AkZ9xA/klQ6QEkAJG7nccFYnfSZlQyArgf6c=" 12 | } 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /validator-session/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | build = '../common/build/build.rs' 3 | edition = '2021' 4 | name = 'validator_session' 5 | version = '0.0.3' 6 | 7 | [dependencies] 8 | anyhow = '1.0' 9 | backtrace = '0.3' 10 | crossbeam = '0.8' 11 | hex = '0.4' 12 | lazy_static = '1.4' 13 | log = '0.4' 14 | metrics = '0.21' 15 | num-derive = '0.4' 16 | num-traits = '0.2' 17 | rand = '0.8' 18 | adnl = { git = 'https://github.com/everx-labs/ever-adnl.git', tag = '0.11.32' } 19 | catchain = { path = '../catchain' } 20 | ever_block = { git = 'https://github.com/everx-labs/ever-block.git', tag = '1.11.20' } 21 | storage = { path = '../storage' } 22 | ton_api = { git = 'https://github.com/everx-labs/ever-tl.git', package = 'ton_api', tag = '0.4.29' } 23 | 24 | [dev-dependencies] 25 | chrono = '0.4' 26 | colored = '1.9' 27 | env_logger = '0.11' 28 | 29 | [features] 30 | export_key = [ ] 31 | slashing = [ ] 32 | 33 | --------------------------------------------------------------------------------