├── .cargo ├── audit.toml └── config.toml ├── .config └── nextest.toml ├── .dockerignore ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── 01_BUG_REPORT.md │ └── 02_FEATURE_REQUEST.md ├── PULL_REQUEST_TEMPLATE.md ├── RELEASE_TEMPLATE.md └── workflows │ ├── calculate-alpha-release.bash │ ├── crates_publish.yml │ ├── default.yml │ ├── gh_pages.yml │ ├── issue_metrics.yml │ ├── release_binaries.yml │ └── release_docker.yml ├── .gitignore ├── .gitmodules ├── .pre-commit-config.yaml ├── .style.yapf ├── ATTRIBUTIONS.md ├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Cargo.lock ├── Cargo.toml ├── Dockerfile ├── Justfile ├── LICENSE-GPL2 ├── LICENSE-GPL2.1 ├── Makefile ├── README.md ├── SECURITY.md ├── buf.yaml ├── chain ├── chain-primitives │ ├── Cargo.toml │ ├── LICENSE-GPL2 │ ├── LICENSE-GPL2.1 │ ├── README.md │ └── src │ │ ├── error.rs │ │ └── lib.rs ├── chain │ ├── Cargo.toml │ └── src │ │ ├── block_processing_utils.rs │ │ ├── blocks_delay_tracker.rs │ │ ├── chain.rs │ │ ├── chain_update.rs │ │ ├── chunks_store.rs │ │ ├── crypto_hash_timer.rs │ │ ├── doomslug.rs │ │ ├── flat_storage_creator.rs │ │ ├── garbage_collection.rs │ │ ├── lib.rs │ │ ├── lightclient.rs │ │ ├── metrics.rs │ │ ├── migrations.rs │ │ ├── missing_chunks.rs │ │ ├── orphan.rs │ │ ├── resharding.rs │ │ ├── sharding.rs │ │ ├── state_request_tracker.rs │ │ ├── state_snapshot_actor.rs │ │ ├── store.rs │ │ ├── store_validator.rs │ │ ├── store_validator │ │ └── validate.rs │ │ ├── test_utils.rs │ │ ├── test_utils │ │ ├── kv_runtime.rs │ │ └── validator_schedule.rs │ │ ├── tests │ │ ├── challenges.rs │ │ ├── doomslug.rs │ │ ├── garbage_collection.rs │ │ ├── mod.rs │ │ ├── simple_chain.rs │ │ └── sync_chain.rs │ │ ├── types.rs │ │ ├── update_shard.rs │ │ └── validate.rs ├── chunks-primitives │ ├── Cargo.toml │ ├── LICENSE-GPL2 │ ├── LICENSE-GPL2.1 │ ├── README.md │ └── src │ │ ├── error.rs │ │ └── lib.rs ├── chunks │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── adapter.rs │ │ ├── chunk_cache.rs │ │ ├── client.rs │ │ ├── lib.rs │ │ ├── logic.rs │ │ ├── metrics.rs │ │ ├── shards_manager_actor.rs │ │ ├── test │ │ ├── basic.rs │ │ └── multi.rs │ │ ├── test_loop.rs │ │ └── test_utils.rs ├── client-primitives │ ├── Cargo.toml │ ├── LICENSE-GPL2 │ ├── LICENSE-GPL2.1 │ └── src │ │ ├── debug.rs │ │ ├── lib.rs │ │ └── types.rs ├── client │ ├── Cargo.toml │ └── src │ │ ├── adapter.rs │ │ ├── adversarial.rs │ │ ├── chunk_validation.rs │ │ ├── client.rs │ │ ├── client_actor.rs │ │ ├── config_updater.rs │ │ ├── debug.rs │ │ ├── info.rs │ │ ├── lib.rs │ │ ├── metrics.rs │ │ ├── sync │ │ ├── adapter.rs │ │ ├── block.rs │ │ ├── epoch.rs │ │ ├── external.rs │ │ ├── header.rs │ │ ├── mod.rs │ │ ├── state.rs │ │ └── sync_actor.rs │ │ ├── sync_jobs_actor.rs │ │ ├── test_utils │ │ ├── block_stats.rs │ │ ├── client.rs │ │ ├── mod.rs │ │ ├── peer_manager_mock.rs │ │ ├── setup.rs │ │ ├── test_env.rs │ │ └── test_env_builder.rs │ │ ├── tests │ │ ├── bug_repros.rs │ │ ├── catching_up.rs │ │ ├── chunks_management.rs │ │ ├── consensus.rs │ │ ├── cross_shard_tx.rs │ │ ├── doomslug.rs │ │ ├── maintenance_windows.rs │ │ ├── mod.rs │ │ ├── process_blocks.rs │ │ └── query_client.rs │ │ └── view_client.rs ├── epoch-manager │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── adapter.rs │ │ ├── lib.rs │ │ ├── proposals.rs │ │ ├── reward_calculator.rs │ │ ├── shard_assignment.rs │ │ ├── shard_tracker.rs │ │ ├── test_utils.rs │ │ ├── tests │ │ ├── mod.rs │ │ └── random_epochs.rs │ │ ├── types.rs │ │ └── validator_selection.rs ├── indexer-primitives │ ├── Cargo.toml │ ├── LICENSE-GPL2 │ ├── LICENSE-GPL2.1 │ ├── README.md │ └── src │ │ └── lib.rs ├── indexer │ ├── CHANGELOG.md │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── lib.rs │ │ └── streamer │ │ ├── errors.rs │ │ ├── fetchers.rs │ │ ├── metrics.rs │ │ ├── mod.rs │ │ └── utils.rs ├── jsonrpc-adversarial-primitives │ ├── Cargo.toml │ └── src │ │ └── lib.rs ├── jsonrpc-primitives │ ├── Cargo.toml │ ├── LICENSE-GPL2 │ ├── LICENSE-GPL2.1 │ └── src │ │ ├── errors.rs │ │ ├── lib.rs │ │ ├── message.rs │ │ └── types │ │ ├── all_miners.rs │ │ ├── blocks.rs │ │ ├── changes.rs │ │ ├── chunks.rs │ │ ├── client_config.rs │ │ ├── config.rs │ │ ├── entity_debug.rs │ │ ├── gas_price.rs │ │ ├── light_client.rs │ │ ├── maintenance.rs │ │ ├── mod.rs │ │ ├── network_info.rs │ │ ├── provider.rs │ │ ├── query.rs │ │ ├── receipts.rs │ │ ├── sandbox.rs │ │ ├── split_storage.rs │ │ ├── status.rs │ │ ├── transactions.rs │ │ └── validator.rs ├── jsonrpc │ ├── CHANGELOG.md │ ├── Cargo.toml │ ├── README.md │ ├── client │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ ├── fuzz │ │ ├── .gitignore │ │ ├── Cargo.toml │ │ └── fuzz_targets_disabled │ │ │ └── fuzz_target_1.rs │ ├── jsonrpc-tests │ │ ├── Cargo.toml │ │ ├── res │ │ │ └── genesis_config.json │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ ├── http_query.rs │ │ │ ├── rpc_query.rs │ │ │ └── rpc_transactions.rs │ ├── res │ │ ├── chain_n_chunk_info.css │ │ ├── chain_n_chunk_info.html │ │ ├── debug.html │ │ ├── epoch_info.css │ │ ├── epoch_info.html │ │ ├── last_blocks.css │ │ ├── last_blocks.html │ │ ├── last_blocks.js │ │ ├── network_info.css │ │ ├── network_info.html │ │ ├── network_info.js │ │ ├── rpc_errors_schema.json │ │ ├── split_store.html │ │ ├── sync.css │ │ ├── sync.html │ │ ├── tier1_network_info.html │ │ ├── validator.css │ │ └── validator.html │ └── src │ │ ├── api │ │ ├── all_miners.rs │ │ ├── blocks.rs │ │ ├── changes.rs │ │ ├── chunks.rs │ │ ├── client_config.rs │ │ ├── config.rs │ │ ├── gas_price.rs │ │ ├── light_client.rs │ │ ├── maintenance.rs │ │ ├── mod.rs │ │ ├── network_info.rs │ │ ├── provider.rs │ │ ├── query.rs │ │ ├── receipts.rs │ │ ├── sandbox.rs │ │ ├── split_storage.rs │ │ ├── status.rs │ │ ├── transactions.rs │ │ └── validator.rs │ │ ├── lib.rs │ │ └── metrics.rs ├── network │ ├── Cargo.toml │ ├── build.rs │ └── src │ │ ├── accounts_data │ │ ├── mod.rs │ │ └── tests.rs │ │ ├── actix.rs │ │ ├── announce_accounts │ │ ├── mod.rs │ │ └── tests.rs │ │ ├── blacklist.rs │ │ ├── broadcast │ │ ├── mod.rs │ │ └── tests.rs │ │ ├── client.rs │ │ ├── concurrency │ │ ├── arc_mutex.rs │ │ ├── atomic_cell.rs │ │ ├── ctx │ │ │ ├── mod.rs │ │ │ ├── tests.rs │ │ │ └── time.rs │ │ ├── demux.rs │ │ ├── mod.rs │ │ ├── rate.rs │ │ ├── rayon.rs │ │ ├── runtime.rs │ │ ├── scope │ │ │ ├── mod.rs │ │ │ └── tests.rs │ │ ├── signal.rs │ │ └── tests.rs │ │ ├── config.rs │ │ ├── config_json.rs │ │ ├── debug.rs │ │ ├── lib.rs │ │ ├── network_protocol │ │ ├── borsh.rs │ │ ├── borsh_conv.rs │ │ ├── edge.rs │ │ ├── mod.rs │ │ ├── network.proto │ │ ├── peer.rs │ │ ├── proto_conv │ │ │ ├── account_key.rs │ │ │ ├── crypto.rs │ │ │ ├── handshake.rs │ │ │ ├── mod.rs │ │ │ ├── net.rs │ │ │ ├── peer_message.rs │ │ │ ├── time.rs │ │ │ ├── trace_context.rs │ │ │ └── util.rs │ │ ├── state_sync.rs │ │ ├── testonly.rs │ │ └── tests.rs │ │ ├── peer │ │ ├── mod.rs │ │ ├── peer_actor.rs │ │ ├── stream.rs │ │ ├── testonly.rs │ │ ├── tests │ │ │ ├── communication.rs │ │ │ ├── mod.rs │ │ │ └── stream.rs │ │ ├── tracker.rs │ │ └── transfer_stats.rs │ │ ├── peer_manager │ │ ├── connection │ │ │ ├── mod.rs │ │ │ └── tests.rs │ │ ├── connection_store │ │ │ ├── mod.rs │ │ │ ├── testonly.rs │ │ │ └── tests.rs │ │ ├── mod.rs │ │ ├── network_state │ │ │ ├── mod.rs │ │ │ ├── routing.rs │ │ │ └── tier1.rs │ │ ├── peer_manager_actor.rs │ │ ├── peer_store │ │ │ ├── mod.rs │ │ │ ├── testonly.rs │ │ │ └── tests.rs │ │ ├── testonly.rs │ │ └── tests │ │ │ ├── accounts_data.rs │ │ │ ├── connection_pool.rs │ │ │ ├── mod.rs │ │ │ ├── nonce.rs │ │ │ ├── routing.rs │ │ │ ├── snapshot_hosts.rs │ │ │ ├── tier1.rs │ │ │ └── tier2.rs │ │ ├── private_actix.rs │ │ ├── raw │ │ ├── connection.rs │ │ ├── mod.rs │ │ └── tests.rs │ │ ├── routing │ │ ├── bfs.rs │ │ ├── edge.rs │ │ ├── edge_cache │ │ │ ├── mod.rs │ │ │ ├── testonly.rs │ │ │ └── tests.rs │ │ ├── graph │ │ │ ├── mod.rs │ │ │ └── tests.rs │ │ ├── graph_v2 │ │ │ ├── mod.rs │ │ │ ├── testonly.rs │ │ │ └── tests.rs │ │ ├── mod.rs │ │ ├── route_back_cache.rs │ │ └── routing_table_view │ │ │ ├── mod.rs │ │ │ └── tests.rs │ │ ├── shards_manager.rs │ │ ├── sink.rs │ │ ├── snapshot_hosts │ │ ├── mod.rs │ │ └── tests.rs │ │ ├── state_sync.rs │ │ ├── stats │ │ ├── metrics.rs │ │ └── mod.rs │ │ ├── store │ │ ├── mod.rs │ │ ├── schema │ │ │ ├── mod.rs │ │ │ ├── testonly.rs │ │ │ └── tests.rs │ │ └── testonly.rs │ │ ├── stun │ │ ├── mod.rs │ │ ├── testonly.rs │ │ └── tests.rs │ │ ├── tcp.rs │ │ ├── test_loop.rs │ │ ├── test_utils.rs │ │ ├── testonly │ │ ├── fake_client.rs │ │ ├── mod.rs │ │ └── stream.rs │ │ └── types.rs ├── pool │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── lib.rs │ │ ├── metrics.rs │ │ └── types.rs └── telemetry │ ├── Cargo.toml │ ├── README.md │ └── src │ ├── lib.rs │ └── metrics.rs ├── cliff.toml ├── codecov.yml ├── core ├── async │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── actix.rs │ │ ├── examples │ │ ├── async_component.rs │ │ ├── async_component_test.rs │ │ ├── mod.rs │ │ ├── multi_instance_test.rs │ │ ├── sum_numbers.rs │ │ ├── sum_numbers_test.rs │ │ ├── timed_component.rs │ │ └── timed_component_test.rs │ │ ├── futures.rs │ │ ├── lib.rs │ │ ├── messaging.rs │ │ ├── test_loop.rs │ │ ├── test_loop │ │ ├── adhoc.rs │ │ ├── delay_sender.rs │ │ ├── event_handler.rs │ │ ├── futures.rs │ │ └── multi_instance.rs │ │ └── time.rs ├── chain-configs │ ├── Cargo.toml │ ├── LICENSE-GPL2 │ ├── LICENSE-GPL2.1 │ ├── README.md │ └── src │ │ ├── client_config.rs │ │ ├── genesis_config.rs │ │ ├── genesis_validate.rs │ │ ├── lib.rs │ │ ├── metrics.rs │ │ └── updateable_config.rs ├── crypto │ ├── Cargo.toml │ ├── LICENSE-GPL2 │ ├── LICENSE-GPL2.1 │ └── src │ │ ├── errors.rs │ │ ├── hash.rs │ │ ├── key_conversion.rs │ │ ├── key_file.rs │ │ ├── lib.rs │ │ ├── signature.rs │ │ ├── signer.rs │ │ ├── test_utils.rs │ │ ├── traits.rs │ │ ├── util.rs │ │ └── vrf.rs ├── dyn-configs │ ├── Cargo.toml │ ├── LICENSE-GPL2 │ ├── LICENSE-GPL2.1 │ ├── README.md │ └── src │ │ ├── lib.rs │ │ └── metrics.rs ├── o11y │ ├── Cargo.toml │ ├── LICENSE-GPL2 │ ├── LICENSE-GPL2.1 │ ├── README.md │ ├── benches │ │ └── metrics.rs │ └── src │ │ ├── context.rs │ │ ├── delay_detector.rs │ │ ├── env_filter.rs │ │ ├── io_tracer.rs │ │ ├── lib.rs │ │ ├── log_config.rs │ │ ├── log_counter.rs │ │ ├── macros.rs │ │ ├── metrics.rs │ │ ├── opentelemetry.rs │ │ ├── reload.rs │ │ ├── span_duration_logger.rs │ │ ├── subscriber.rs │ │ ├── testonly.rs │ │ └── testonly │ │ └── tracing_capture.rs ├── parameters │ ├── Cargo.toml │ ├── LICENSE-GPL2 │ ├── LICENSE-GPL2.1 │ ├── res │ │ ├── README.md │ │ └── runtime_configs │ │ │ ├── 129.yaml │ │ │ ├── 138.yaml │ │ │ ├── 35.yaml │ │ │ ├── 42.yaml │ │ │ ├── 46.yaml │ │ │ ├── 48.yaml │ │ │ ├── 49.yaml │ │ │ ├── 50.yaml │ │ │ ├── 52.yaml │ │ │ ├── 53.yaml │ │ │ ├── 55.yaml │ │ │ ├── 57.yaml │ │ │ ├── 59.yaml │ │ │ ├── 61.yaml │ │ │ ├── 62.yaml │ │ │ ├── 63.yaml │ │ │ ├── 64.yaml │ │ │ ├── parameters.snap │ │ │ ├── parameters.yaml │ │ │ └── parameters_testnet.yaml │ └── src │ │ ├── config.rs │ │ ├── config_store.rs │ │ ├── cost.rs │ │ ├── lib.rs │ │ ├── parameter.rs │ │ ├── parameter_table.rs │ │ ├── snapshots │ │ ├── unc_parameters__config_store__tests__138.json.snap │ │ ├── unc_parameters__config_store__tests__testnet_138.json.snap │ │ └── unc_parameters__view__tests__runtime_config_view.snap │ │ ├── view.rs │ │ └── vm.rs ├── primitives-core │ ├── Cargo.toml │ ├── LICENSE-GPL2 │ ├── LICENSE-GPL2.1 │ └── src │ │ ├── account.rs │ │ ├── chains.rs │ │ ├── config.rs │ │ ├── hash.rs │ │ ├── lib.rs │ │ ├── serialize.rs │ │ ├── types.rs │ │ └── version.rs ├── primitives │ ├── Cargo.toml │ ├── LICENSE-GPL2 │ ├── LICENSE-GPL2.1 │ ├── benches │ │ └── serialization.rs │ └── src │ │ ├── action │ │ ├── delegate.rs │ │ └── mod.rs │ │ ├── block.rs │ │ ├── block_header.rs │ │ ├── challenge.rs │ │ ├── chunk_validation.rs │ │ ├── epoch_manager.rs │ │ ├── epoch_sync.rs │ │ ├── errors.rs │ │ ├── lib.rs │ │ ├── merkle.rs │ │ ├── network.rs │ │ ├── rand.rs │ │ ├── receipt.rs │ │ ├── runtime │ │ ├── apply_state.rs │ │ ├── migration_data.rs │ │ └── mod.rs │ │ ├── sandbox.rs │ │ ├── shard_layout.rs │ │ ├── sharding.rs │ │ ├── sharding │ │ └── shard_chunk_header_inner.rs │ │ ├── signable_message.rs │ │ ├── snapshots │ │ ├── unc_primitives__views__tests__exec_metadata_v1_view.snap │ │ ├── unc_primitives__views__tests__exec_metadata_v2_view.snap │ │ ├── unc_primitives__views__tests__exec_metadata_v3_view.snap │ │ └── unc_primitives__views__tests__runtime_config_view.snap │ │ ├── state.rs │ │ ├── state_part.rs │ │ ├── state_record.rs │ │ ├── state_sync.rs │ │ ├── static_clock.rs │ │ ├── telemetry.rs │ │ ├── test_utils.rs │ │ ├── transaction.rs │ │ ├── trie_key.rs │ │ ├── types.rs │ │ ├── upgrade_schedule.rs │ │ ├── utils.rs │ │ ├── utils │ │ └── min_heap.rs │ │ ├── validator_mandates.rs │ │ ├── validator_signer.rs │ │ ├── version.rs │ │ └── views.rs └── store │ ├── Cargo.toml │ ├── benches │ ├── finalize_bench.rs │ ├── store_bench.rs │ └── trie_bench.rs │ └── src │ ├── cold_storage.rs │ ├── columns.rs │ ├── config.rs │ ├── db.rs │ ├── db │ ├── colddb.rs │ ├── database_tests.rs │ ├── refcount.rs │ ├── rocksdb.rs │ ├── rocksdb │ │ ├── instance_tracker.rs │ │ └── snapshot.rs │ ├── slice.rs │ ├── splitdb.rs │ └── testdb.rs │ ├── flat │ ├── chunk_view.rs │ ├── delta.rs │ ├── inlining_migration.rs │ ├── manager.rs │ ├── metrics.rs │ ├── mod.rs │ ├── storage.rs │ ├── store_helper.rs │ ├── test_utils.rs │ └── types.rs │ ├── genesis │ ├── initialization.rs │ ├── mod.rs │ └── state_applier.rs │ ├── lib.rs │ ├── metadata.rs │ ├── metrics.rs │ ├── migrations.rs │ ├── opener.rs │ ├── rocksdb_metrics.rs │ ├── sync_utils.rs │ ├── test_utils.rs │ └── trie │ ├── accounting_cache.rs │ ├── config.rs │ ├── from_flat.rs │ ├── insert_delete.rs │ ├── iterator.rs │ ├── mem │ ├── arena │ │ ├── alloc.rs │ │ ├── metrics.rs │ │ └── mod.rs │ ├── construction.rs │ ├── flexible_data │ │ ├── children.rs │ │ ├── encoding.rs │ │ ├── extension.rs │ │ ├── mod.rs │ │ └── value.rs │ ├── loading.rs │ ├── lookup.rs │ ├── metrics.rs │ ├── mod.rs │ ├── node │ │ ├── encoding.rs │ │ ├── mod.rs │ │ ├── mutation.rs │ │ ├── tests.rs │ │ └── view.rs │ └── updating.rs │ ├── mod.rs │ ├── nibble_slice.rs │ ├── prefetching_trie_storage.rs │ ├── raw_node.rs │ ├── resharding.rs │ ├── shard_tries.rs │ ├── state_parts.rs │ ├── state_snapshot.rs │ ├── trie_recording.rs │ ├── trie_storage.rs │ ├── trie_tests.rs │ ├── update.rs │ └── update │ └── iterator.rs ├── deny.toml ├── docs ├── README.md ├── SUMMARY.md ├── advanced_configuration │ └── networking.md ├── architecture │ ├── README.md │ ├── gas │ │ ├── README.md │ │ ├── estimator.md │ │ ├── gas_profile.md │ │ └── parameter_definition.md │ ├── how │ │ ├── README.md │ │ ├── epoch.md │ │ ├── gas.md │ │ ├── gc.md │ │ ├── meta-tx.md │ │ ├── proofs.md │ │ ├── serialization.md │ │ ├── sync.md │ │ ├── tx_receipts.md │ │ └── tx_routing.md │ ├── network.md │ ├── next │ │ ├── README.md │ │ ├── catchup_and_state_sync.md │ │ └── malicious_chunk_producer_and_phase2.md │ ├── storage.md │ └── storage │ │ ├── database.md │ │ ├── flat_storage.md │ │ ├── flow.md │ │ └── trie.md ├── book.toml ├── images │ ├── architecture.svg │ └── logo.gif ├── misc │ ├── README.md │ ├── state_sync_dump.md │ └── state_sync_from_external_storage.md ├── practices │ ├── README.md │ ├── docs.md │ ├── engaging_and_effective_communication.md │ ├── fast_builds.md │ ├── protocol_upgrade.md │ ├── rust.md │ ├── security_vulnerabilities.md │ ├── style.md │ ├── testing │ │ ├── README.md │ │ ├── python_tests.md │ │ └── test_utils.md │ ├── tracking_issues.md │ ├── when_to_use_private_repository.md │ └── workflows │ │ ├── README.md │ │ ├── deploy_a_contract.md │ │ ├── gas_estimations.md │ │ ├── io_trace.md │ │ ├── localnet_on_many_machines.md │ │ └── run_a_node.md └── test_networks │ └── mainnet_spoon.md ├── genesis-tools ├── README.md ├── genesis-csv-to-json │ ├── Cargo.toml │ ├── res │ │ └── test_accounts.csv │ └── src │ │ ├── csv_parser.rs │ │ ├── csv_to_json_configs.rs │ │ ├── main.rs │ │ └── serde_with.rs ├── genesis-populate │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ ├── main.rs │ │ └── state_dump.rs └── keypair-generator │ ├── Cargo.toml │ └── src │ └── main.rs ├── infra ├── Cargo.toml ├── benches │ └── store.rs ├── res │ ├── example-config-gc.json │ └── example-config-no-gc.json ├── src │ ├── append_only_map.rs │ ├── cold_storage.rs │ ├── config.rs │ ├── config_validate.rs │ ├── download_file.rs │ ├── dyn_config.rs │ ├── entity_debug.rs │ ├── entity_debug_serializer.rs │ ├── lib.rs │ ├── metrics.rs │ ├── migrations.rs │ ├── runtime │ │ ├── errors.rs │ │ ├── mod.rs │ │ └── tests.rs │ ├── state_sync.rs │ └── test_utils.rs └── tests │ └── economics.rs ├── integration-tests ├── Cargo.toml └── src │ ├── genesis_helpers.rs │ ├── lib.rs │ ├── node │ ├── mod.rs │ ├── process_node.rs │ ├── runtime_node.rs │ └── thread_node.rs │ ├── runtime_utils.rs │ ├── test_helpers.rs │ ├── tests │ ├── client │ │ ├── access_key_nonce_for_implicit_accounts.rs │ │ ├── account_id_in_function_call_permission.rs │ │ ├── adversarial_behaviors.rs │ │ ├── benchmarks.rs │ │ ├── block_corruption.rs │ │ ├── cap_max_gas_price.rs │ │ ├── challenges.rs │ │ ├── chunk_nodes_cache.rs │ │ ├── chunk_validation.rs │ │ ├── chunks_management.rs │ │ ├── cold_storage.rs │ │ ├── epoch_sync.rs │ │ ├── fix_contract_loading_cost.rs │ │ ├── fix_storage_usage.rs │ │ ├── flat_storage.rs │ │ ├── in_memory_tries.rs │ │ ├── increase_deployment_cost.rs │ │ ├── increase_storage_compute_cost.rs │ │ ├── limit_contract_functions_number.rs │ │ ├── lower_storage_key_limit.rs │ │ ├── mod.rs │ │ ├── process_blocks.rs │ │ ├── restore_receipts_after_fix_apply_chunks.rs │ │ ├── runtimes.rs │ │ ├── sandbox.rs │ │ ├── state_dump.rs │ │ ├── state_snapshot.rs │ │ ├── sync_state_nodes.rs │ │ ├── uncvm.rs │ │ ├── undo_block.rs │ │ ├── wallet_contract.rs │ │ └── zero_balance_account.rs │ ├── framework │ │ ├── mod.rs │ │ ├── node_cluster.rs │ │ ├── pledge_nodes.rs │ │ ├── rpc_error_structs.rs │ │ ├── rpc_nodes.rs │ │ ├── run_nodes.rs │ │ ├── sync_nodes.rs │ │ └── track_shards.rs │ ├── mod.rs │ ├── network │ │ ├── churn_attack.rs │ │ ├── full_network.rs │ │ ├── mod.rs │ │ ├── peer_handshake.rs │ │ ├── runner.rs │ │ └── stress_network.rs │ ├── runtime │ │ ├── deployment.rs │ │ ├── mod.rs │ │ ├── sanity_checks.rs │ │ ├── snapshots │ │ │ ├── integration_tests__tests__runtime__sanity_checks__receipts_gas_profile.snap │ │ │ ├── integration_tests__tests__runtime__sanity_checks__receipts_gas_profile_nightly.snap │ │ │ ├── integration_tests__tests__runtime__sanity_checks__receipts_gas_profile_nondeterministic.snap │ │ │ ├── integration_tests__tests__runtime__sanity_checks__receipts_gas_profile_nondeterministic_nightly.snap │ │ │ ├── integration_tests__tests__runtime__sanity_checks__receipts_status.snap │ │ │ └── integration_tests__tests__runtime__sanity_checks__receipts_status_nondeterministic.snap │ │ ├── state_viewer.rs │ │ └── test_evil_contracts.rs │ ├── standard_cases │ │ ├── mod.rs │ │ ├── rpc.rs │ │ └── runtime.rs │ ├── test_catchup.rs │ ├── test_errors.rs │ ├── test_overflows.rs │ ├── test_simple.rs │ └── test_tps_regression.rs │ ├── unc_utils.rs │ └── user │ ├── mod.rs │ ├── rpc_user.rs │ └── runtime_user.rs ├── lychee.toml ├── node ├── Cargo.toml ├── build.rs ├── res │ ├── invalid_proof.json │ └── proof_example.json └── src │ ├── cli.rs │ └── main.rs ├── pytest ├── Pipfile ├── README.md ├── __init__.py ├── debug_scripts │ ├── Pipfile │ ├── Pipfile.lock │ ├── READEME.md │ ├── __init__.py │ ├── request_chain_info.py │ ├── send_validator_logs.py │ └── tests │ │ ├── __init__.py │ │ ├── data │ │ └── node0.logs │ │ └── send_validator_logs_test.py ├── endtoend │ ├── __init__.py │ └── endtoend.py ├── lib │ ├── __init__.py │ ├── account.py │ ├── branches.py │ ├── cluster.py │ ├── configured_logger.py │ ├── data.py │ ├── key.py │ ├── lightclient.py │ ├── messages │ │ ├── __init__.py │ │ ├── block.py │ │ ├── bridge.py │ │ ├── crypto.py │ │ ├── network.py │ │ ├── shard.py │ │ └── tx.py │ ├── metrics.py │ ├── mocknet.py │ ├── mocknet_helpers.py │ ├── network.py │ ├── peer.py │ ├── populate.py │ ├── proxy.py │ ├── proxy_instances.py │ ├── resharding_lib.py │ ├── serializer.py │ ├── state_sync_lib.py │ ├── transaction.py │ └── utils.py ├── remote.json ├── requirements.txt ├── tests │ ├── __init__.py │ ├── delete_remote_nodes.py │ └── loadtest │ │ ├── README.md │ │ ├── contract │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ ├── build.sh │ │ └── src │ │ │ └── lib.rs │ │ ├── loadtest.py │ │ ├── loadtest2.py │ │ ├── locust │ │ ├── README.md │ │ ├── common │ │ │ ├── base.py │ │ │ ├── congestion.py │ │ │ ├── ft.py │ │ │ └── social.py │ │ ├── locustfiles │ │ │ ├── congestion.py │ │ │ ├── ft.py │ │ │ └── social.py │ │ └── res │ │ │ ├── congestion.wasm │ │ │ ├── fungible_token.wasm │ │ │ └── social_db.wasm │ │ └── setup.py └── tools │ ├── mirror │ ├── contract │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ ├── mirror_utils.py │ ├── offline_test.py │ └── online_test.py │ └── prober │ ├── prober.py │ ├── prober_split.py │ └── prober_util.py ├── runtime ├── runtime-params-estimator │ ├── .gitignore │ ├── Cargo.toml │ ├── README.md │ ├── compiler.sh │ ├── costs.txt │ ├── emu-cost │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── build.sh │ │ ├── counter_plugin │ │ │ ├── 0001-linux-user-fix-page-table-trashing-when-mmap-munmap-.patch │ │ │ ├── 0002-linux-user-strace-better-format-mmap-logs-support-mr.patch │ │ │ ├── 0003-plugins-avoid-failing-plugin-when-CPU-is-inited-seve.patch │ │ │ ├── Makefile │ │ │ ├── counter.c │ │ │ ├── libcounter.so │ │ │ ├── qemu-x86_64 │ │ │ └── test.c │ │ ├── data_builder.py │ │ ├── io_cost.sh │ │ └── run.sh │ ├── estimate.sh │ ├── estimator-warehouse │ │ ├── .gitignore │ │ ├── Cargo.toml │ │ ├── README.md │ │ └── src │ │ │ ├── check.rs │ │ │ ├── db.rs │ │ │ ├── estimate.rs │ │ │ ├── import.rs │ │ │ ├── init.sql │ │ │ ├── main.rs │ │ │ ├── snapshots │ │ │ ├── estimator_warehouse__check__tests__check_command-2.snap │ │ │ ├── estimator_warehouse__check__tests__check_command-3.snap │ │ │ ├── estimator_warehouse__check__tests__check_command-4.snap │ │ │ ├── estimator_warehouse__check__tests__check_command.snap │ │ │ └── estimator_warehouse__tests__stats.snap │ │ │ └── zulip.rs │ ├── res │ │ ├── 75220100-75220101.s0.io_trace │ │ ├── fungible_token.wasm │ │ ├── lockup_contract.wasm │ │ ├── mission_control.wasm │ │ ├── staking_pool.wasm │ │ ├── status_message.wasm │ │ ├── voting_contract.wasm │ │ └── whitelist.wasm │ ├── setup.sh │ └── src │ │ ├── action_costs.rs │ │ ├── config.rs │ │ ├── cost.rs │ │ ├── cost_table.rs │ │ ├── costs_to_runtime_config.rs │ │ ├── estimator_context.rs │ │ ├── estimator_params.rs │ │ ├── function_call.rs │ │ ├── gas_cost.rs │ │ ├── gas_metering.rs │ │ ├── least_squares.rs │ │ ├── lib.rs │ │ ├── main.rs │ │ ├── qemu.rs │ │ ├── replay.rs │ │ ├── replay │ │ ├── cache_stats.rs │ │ ├── fold_db_ops.rs │ │ └── gas_charges.rs │ │ ├── rocksdb.rs │ │ ├── snapshots │ │ ├── runtime_params_estimator__replay__tests__CacheStats-75220100-75220101.s0.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__CacheStats-75220100-75220101.s1.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__CacheStats-75220100-75220101.s2.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__CacheStats-75220100-75220101.s3.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__ChunkCacheStats-75220100-75220101.s0.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__ChunkCacheStats-75220100-75220101.s1.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__ChunkCacheStats-75220100-75220101.s2.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__ChunkCacheStats-75220100-75220101.s3.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__ChunkDbStats-75220100-75220101.s0.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__ChunkDbStats-75220100-75220101.s1.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__ChunkDbStats-75220100-75220101.s2.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__ChunkDbStats-75220100-75220101.s3.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__GasCharges-75220100-75220101.s0.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__GasCharges-75220100-75220101.s1.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__GasCharges-75220100-75220101.s2.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__GasCharges-75220100-75220101.s3.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__ReceiptCacheStats-75220100-75220101.s0.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__ReceiptCacheStats-75220100-75220101.s1.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__ReceiptCacheStats-75220100-75220101.s2.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__ReceiptCacheStats-75220100-75220101.s3.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__ReceiptDbStats-75220100-75220101.s0.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__ReceiptDbStats-75220100-75220101.s1.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__ReceiptDbStats-75220100-75220101.s2.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__ReceiptDbStats-75220100-75220101.s3.io_trace.snap │ │ ├── runtime_params_estimator__replay__tests__account_filter_CacheStats.snap │ │ ├── runtime_params_estimator__replay__tests__account_filter_ReceiptCacheStats.snap │ │ └── runtime_params_estimator__replay__tests__account_filter_ReceiptDbStats.snap │ │ ├── transaction_builder.rs │ │ ├── trie.rs │ │ ├── utils.rs │ │ └── vm_estimator.rs ├── runtime │ ├── Cargo.toml │ ├── src │ │ ├── actions.rs │ │ ├── adapter.rs │ │ ├── balance_checker.rs │ │ ├── config.rs │ │ ├── ext.rs │ │ ├── lib.rs │ │ ├── metrics.rs │ │ ├── prefetch.rs │ │ ├── receipt_manager.rs │ │ ├── state_viewer │ │ │ ├── errors.rs │ │ │ └── mod.rs │ │ └── verifier.rs │ └── tests │ │ ├── runtime_group_tools │ │ ├── mod.rs │ │ └── random_config.rs │ │ └── test_async_calls.rs ├── unc-test-contracts │ ├── Cargo.toml │ ├── README.md │ ├── build.rs │ ├── contract-for-fuzzing-rs │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ ├── estimator-contract │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ ├── res │ │ ├── .gitignore │ │ ├── ZombieOwnership.bin │ │ ├── test_contract_ts.wasm │ │ └── unc_evm.wasm │ ├── src │ │ └── lib.rs │ └── test-contract-rs │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ └── src │ │ └── lib.rs ├── unc-vm-runner │ ├── Cargo.toml │ ├── FAQ.md │ ├── LICENSE-GPL2 │ ├── LICENSE-GPL2.1 │ ├── README.md │ ├── RUNTIMES.md │ ├── fuzz │ │ ├── .gitignore │ │ ├── Cargo.toml │ │ ├── fuzz_targets │ │ │ ├── diffrunner.rs │ │ │ └── runner.rs │ │ └── src │ │ │ └── lib.rs │ └── src │ │ ├── cache.rs │ │ ├── code.rs │ │ ├── errors.rs │ │ ├── features.rs │ │ ├── imports.rs │ │ ├── instrument.rs │ │ ├── instrument │ │ ├── gas │ │ │ ├── mod.rs │ │ │ └── validation.rs │ │ ├── rules.rs │ │ └── stack_height │ │ │ ├── max_height.rs │ │ │ ├── mod.rs │ │ │ └── thunk.rs │ │ ├── lib.rs │ │ ├── logic │ │ ├── alt_bn128.rs │ │ ├── context.rs │ │ ├── dependencies.rs │ │ ├── errors.rs │ │ ├── gas_counter.rs │ │ ├── logic.rs │ │ ├── mocks │ │ │ ├── mock_external.rs │ │ │ ├── mock_memory.rs │ │ │ └── mod.rs │ │ ├── mod.rs │ │ ├── test_utils.rs │ │ ├── tests │ │ │ ├── alt_bn128.rs │ │ │ ├── context.rs │ │ │ ├── ecrecover-tests.json │ │ │ ├── ed25519_verify.rs │ │ │ ├── gas_counter.rs │ │ │ ├── helpers.rs │ │ │ ├── iterators.rs │ │ │ ├── logs.rs │ │ │ ├── miscs.rs │ │ │ ├── mod.rs │ │ │ ├── promises.rs │ │ │ ├── registers.rs │ │ │ ├── storage_read_write.rs │ │ │ ├── storage_usage.rs │ │ │ ├── view_method.rs │ │ │ └── vm_logic_builder.rs │ │ ├── types.rs │ │ ├── utils.rs │ │ └── vmstate.rs │ │ ├── memory.rs │ │ ├── prepare.rs │ │ ├── prepare │ │ ├── prepare_v0.rs │ │ ├── prepare_v1.rs │ │ └── prepare_v2.rs │ │ ├── profile.rs │ │ ├── profile │ │ └── profile_v2.rs │ │ ├── runner.rs │ │ ├── tests.rs │ │ ├── tests │ │ ├── cache.rs │ │ ├── compile_errors.rs │ │ ├── fuzzers.rs │ │ ├── regression_tests.rs │ │ ├── rs_contract.rs │ │ ├── runtime_errors.rs │ │ ├── test_builder.rs │ │ ├── ts_contract.rs │ │ └── wasm_validation.rs │ │ ├── unc_vm_runner.rs │ │ ├── utils.rs │ │ ├── wasmer2_runner.rs │ │ ├── wasmer_runner.rs │ │ └── wasmtime_runner.rs ├── unc-vm │ ├── .gitignore │ ├── ATTRIBUTIONS.md │ ├── README.md │ ├── compiler-singlepass │ │ ├── Cargo.toml │ │ ├── LICENSE-GPL2 │ │ ├── LICENSE-GPL2.1 │ │ ├── README.md │ │ └── src │ │ │ ├── address_map.rs │ │ │ ├── codegen_x64.rs │ │ │ ├── compiler.rs │ │ │ ├── config.rs │ │ │ ├── emitter_x64.rs │ │ │ ├── lib.rs │ │ │ ├── machine.rs │ │ │ └── x64_decl.rs │ ├── compiler-test-derive │ │ ├── Cargo.toml │ │ ├── build.rs │ │ └── src │ │ │ ├── ignores.rs │ │ │ └── lib.rs │ ├── compiler │ │ ├── Cargo.toml │ │ ├── LICENSE-GPL2 │ │ ├── LICENSE-GPL2.1 │ │ ├── README.md │ │ └── src │ │ │ ├── address_map.rs │ │ │ ├── compiler.rs │ │ │ ├── error.rs │ │ │ ├── function.rs │ │ │ ├── jump_table.rs │ │ │ ├── lib.rs │ │ │ ├── module.rs │ │ │ ├── relocation.rs │ │ │ ├── section.rs │ │ │ ├── sourceloc.rs │ │ │ ├── target.rs │ │ │ ├── translator │ │ │ ├── environ.rs │ │ │ ├── error.rs │ │ │ ├── mod.rs │ │ │ ├── module.rs │ │ │ ├── sections.rs │ │ │ └── state.rs │ │ │ └── trap.rs │ ├── engine │ │ ├── Cargo.toml │ │ ├── LICENSE-GPL2 │ │ ├── LICENSE-GPL2.1 │ │ ├── README.md │ │ └── src │ │ │ ├── engine.rs │ │ │ ├── error.rs │ │ │ ├── export.rs │ │ │ ├── lib.rs │ │ │ ├── resolver.rs │ │ │ ├── trap │ │ │ ├── error.rs │ │ │ ├── frame_info.rs │ │ │ └── mod.rs │ │ │ └── universal │ │ │ ├── artifact.rs │ │ │ ├── builder.rs │ │ │ ├── code_memory.rs │ │ │ ├── engine.rs │ │ │ ├── executable.rs │ │ │ ├── link.rs │ │ │ └── mod.rs │ ├── test-api │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── build.rs │ │ └── src │ │ │ ├── lib.rs │ │ │ └── sys │ │ │ ├── env.rs │ │ │ ├── exports.rs │ │ │ ├── externals │ │ │ ├── function.rs │ │ │ ├── global.rs │ │ │ ├── memory.rs │ │ │ ├── mod.rs │ │ │ └── table.rs │ │ │ ├── import_object.rs │ │ │ ├── instance.rs │ │ │ ├── mod.rs │ │ │ ├── module.rs │ │ │ ├── native.rs │ │ │ ├── ptr.rs │ │ │ ├── store.rs │ │ │ ├── tunables.rs │ │ │ └── types.rs │ ├── test-generator │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── lib.rs │ │ │ └── processors.rs │ ├── tests │ │ ├── compilers │ │ │ ├── compilation.rs │ │ │ ├── config.rs │ │ │ ├── deterministic.rs │ │ │ ├── imports.rs │ │ │ ├── issues.rs │ │ │ ├── main.rs │ │ │ ├── multi_value_imports.rs │ │ │ ├── native_functions.rs │ │ │ ├── serialize.rs │ │ │ ├── stack_limiter.rs │ │ │ ├── traps.rs │ │ │ └── wast.rs │ │ ├── deprecated.rs │ │ ├── deprecated │ │ │ └── README.md │ │ ├── examples │ │ │ ├── add.wat │ │ │ ├── call_indirect.wat │ │ │ ├── fac.wat │ │ │ ├── fib.wat │ │ │ ├── global.wat │ │ │ ├── invalid.wat │ │ │ ├── memory.wat │ │ │ ├── no_start.wat │ │ │ └── trap.wat │ │ ├── ignores.txt │ │ ├── lib │ │ │ └── compiler-test-derive │ │ │ │ └── src │ │ │ │ └── lib.rs.orig │ │ └── wast │ │ │ ├── README.md │ │ │ ├── spec │ │ │ ├── .gitignore │ │ │ ├── Contributing.md │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── address.wast │ │ │ ├── align.wast │ │ │ ├── binary-leb128.wast │ │ │ ├── binary.wast │ │ │ ├── block.wast │ │ │ ├── br.wast │ │ │ ├── br_if.wast │ │ │ ├── br_table.wast │ │ │ ├── bulk.wast │ │ │ ├── call.wast │ │ │ ├── call_indirect.wast │ │ │ ├── comments.wast │ │ │ ├── const.wast │ │ │ ├── conversions.wast │ │ │ ├── custom.wast │ │ │ ├── data.wast │ │ │ ├── elem.wast │ │ │ ├── endianness.wast │ │ │ ├── exports.wast │ │ │ ├── extract-parts.sh │ │ │ ├── f32.wast │ │ │ ├── f32_bitwise.wast │ │ │ ├── f32_cmp.wast │ │ │ ├── f64.wast │ │ │ ├── f64_bitwise.wast │ │ │ ├── f64_cmp.wast │ │ │ ├── fac.wast │ │ │ ├── float_exprs.wast │ │ │ ├── float_literals.wast │ │ │ ├── float_memory.wast │ │ │ ├── float_misc.wast │ │ │ ├── forward.wast │ │ │ ├── func.wast │ │ │ ├── func_ptrs.wast │ │ │ ├── global.wast │ │ │ ├── i32.wast │ │ │ ├── i64.wast │ │ │ ├── if.wast │ │ │ ├── imports.wast │ │ │ ├── inline-module.wast │ │ │ ├── int_exprs.wast │ │ │ ├── int_literals.wast │ │ │ ├── labels.wast │ │ │ ├── left-to-right.wast │ │ │ ├── linking.wast │ │ │ ├── load.wast │ │ │ ├── local_get.wast │ │ │ ├── local_set.wast │ │ │ ├── local_tee.wast │ │ │ ├── loop.wast │ │ │ ├── memory.wast │ │ │ ├── memory_copy.wast │ │ │ ├── memory_fill.wast │ │ │ ├── memory_grow.wast │ │ │ ├── memory_init.wast │ │ │ ├── memory_redundancy.wast │ │ │ ├── memory_size.wast │ │ │ ├── memory_trap.wast │ │ │ ├── names.wast │ │ │ ├── nop.wast │ │ │ ├── proposals │ │ │ │ ├── annotations │ │ │ │ │ └── annotations.wast │ │ │ │ ├── bulk-memory-operations │ │ │ │ │ ├── binary.wast │ │ │ │ │ ├── bulk.wast │ │ │ │ │ ├── custom.wast │ │ │ │ │ ├── data.wast │ │ │ │ │ ├── elem.wast │ │ │ │ │ ├── imports.wast │ │ │ │ │ ├── linking.wast │ │ │ │ │ ├── memory_copy.wast │ │ │ │ │ ├── memory_fill.wast │ │ │ │ │ ├── memory_init.wast │ │ │ │ │ ├── table_copy.wast │ │ │ │ │ └── table_init.wast │ │ │ │ ├── gc │ │ │ │ │ ├── array.wast │ │ │ │ │ ├── binary.wast │ │ │ │ │ ├── br_on.wast │ │ │ │ │ ├── br_on_cast.wast │ │ │ │ │ ├── br_on_null.wast │ │ │ │ │ ├── br_table.wast │ │ │ │ │ ├── call_ref.wast │ │ │ │ │ ├── func.wast │ │ │ │ │ ├── func_bind.wast │ │ │ │ │ ├── i31.wast │ │ │ │ │ ├── if.wast │ │ │ │ │ ├── let.wast │ │ │ │ │ ├── linking.wast │ │ │ │ │ ├── ref.wast │ │ │ │ │ ├── ref_as.wast │ │ │ │ │ ├── ref_as_non_null.wast │ │ │ │ │ ├── ref_cast.wast │ │ │ │ │ ├── ref_eq.wast │ │ │ │ │ ├── ref_is.wast │ │ │ │ │ ├── ref_is_null.wast │ │ │ │ │ ├── ref_null.wast │ │ │ │ │ ├── ref_test.wast │ │ │ │ │ ├── return_call_ref.wast │ │ │ │ │ ├── select.wast │ │ │ │ │ ├── struct.wast │ │ │ │ │ ├── table-sub.wast │ │ │ │ │ ├── table.wast │ │ │ │ │ ├── type-equivalence.wast │ │ │ │ │ └── unreached-invalid.wast │ │ │ │ ├── multi-value │ │ │ │ │ ├── binary.wast │ │ │ │ │ ├── block.wast │ │ │ │ │ ├── br.wast │ │ │ │ │ ├── call.wast │ │ │ │ │ ├── call_indirect.wast │ │ │ │ │ ├── fac.wast │ │ │ │ │ ├── func.wast │ │ │ │ │ ├── if.wast │ │ │ │ │ ├── loop.wast │ │ │ │ │ └── type.wast │ │ │ │ ├── mutable-global │ │ │ │ │ ├── globals.wast │ │ │ │ │ └── linking.wast │ │ │ │ ├── nontrapping-float-to-int-conversions │ │ │ │ │ └── conversions.wast │ │ │ │ ├── reference-types │ │ │ │ │ ├── binary.wast │ │ │ │ │ ├── br_table.wast │ │ │ │ │ ├── bulk.wast │ │ │ │ │ ├── custom.wast │ │ │ │ │ ├── data.wast │ │ │ │ │ ├── elem.wast │ │ │ │ │ ├── exports.wast │ │ │ │ │ ├── globals.wast │ │ │ │ │ ├── imports.wast │ │ │ │ │ ├── linking.wast │ │ │ │ │ ├── memory_copy.wast │ │ │ │ │ ├── memory_fill.wast │ │ │ │ │ ├── memory_grow.wast │ │ │ │ │ ├── memory_init.wast │ │ │ │ │ ├── ref_func.wast │ │ │ │ │ ├── ref_is_null.wast │ │ │ │ │ ├── ref_null.wast │ │ │ │ │ ├── select.wast │ │ │ │ │ ├── table-sub.wast │ │ │ │ │ ├── table_copy.wast │ │ │ │ │ ├── table_fill.wast │ │ │ │ │ ├── table_get.wast │ │ │ │ │ ├── table_grow.wast │ │ │ │ │ ├── table_init.wast │ │ │ │ │ ├── table_set.wast │ │ │ │ │ ├── table_size.wast │ │ │ │ │ └── unreached-invalid.wast │ │ │ │ ├── sign-extension-ops │ │ │ │ │ ├── i32.wast │ │ │ │ │ └── i64.wast │ │ │ │ ├── simd │ │ │ │ │ ├── simd_address.wast │ │ │ │ │ ├── simd_align.wast │ │ │ │ │ ├── simd_bit_shift.wast │ │ │ │ │ ├── simd_bitwise.wast │ │ │ │ │ ├── simd_boolean.wast │ │ │ │ │ ├── simd_const.wast │ │ │ │ │ ├── simd_conversions.wast │ │ │ │ │ ├── simd_f32x4.wast │ │ │ │ │ ├── simd_f32x4_arith.wast │ │ │ │ │ ├── simd_f32x4_cmp.wast │ │ │ │ │ ├── simd_f32x4_pmin_pmax.wast │ │ │ │ │ ├── simd_f32x4_rounding.wast │ │ │ │ │ ├── simd_f64x2.wast │ │ │ │ │ ├── simd_f64x2_arith.wast │ │ │ │ │ ├── simd_f64x2_cmp.wast │ │ │ │ │ ├── simd_f64x2_pmin_pmax.wast │ │ │ │ │ ├── simd_f64x2_rounding.wast │ │ │ │ │ ├── simd_i16x8_arith.wast │ │ │ │ │ ├── simd_i16x8_arith2.wast │ │ │ │ │ ├── simd_i16x8_cmp.wast │ │ │ │ │ ├── simd_i16x8_extadd_pairwise_i8x16.wast │ │ │ │ │ ├── simd_i16x8_extmul_i8x16.wast │ │ │ │ │ ├── simd_i16x8_q15mulr_sat_s.wast │ │ │ │ │ ├── simd_i16x8_sat_arith.wast │ │ │ │ │ ├── simd_i32x4_arith.wast │ │ │ │ │ ├── simd_i32x4_arith2.wast │ │ │ │ │ ├── simd_i32x4_cmp.wast │ │ │ │ │ ├── simd_i32x4_dot_i16x8.wast │ │ │ │ │ ├── simd_i32x4_extadd_pairwise_i16x8.wast │ │ │ │ │ ├── simd_i32x4_extmul_i16x8.wast │ │ │ │ │ ├── simd_i32x4_trunc_sat_f32x4.wast │ │ │ │ │ ├── simd_i32x4_trunc_sat_f64x2.wast │ │ │ │ │ ├── simd_i64x2_arith.wast │ │ │ │ │ ├── simd_i64x2_arith2.wast │ │ │ │ │ ├── simd_i64x2_cmp.wast │ │ │ │ │ ├── simd_i64x2_extmul_i32x4.wast │ │ │ │ │ ├── simd_i8x16_arith.wast │ │ │ │ │ ├── simd_i8x16_arith2.wast │ │ │ │ │ ├── simd_i8x16_cmp.wast │ │ │ │ │ ├── simd_i8x16_sat_arith.wast │ │ │ │ │ ├── simd_int_to_int_extend.wast │ │ │ │ │ ├── simd_lane.wast │ │ │ │ │ ├── simd_load.wast │ │ │ │ │ ├── simd_load16_lane.wast │ │ │ │ │ ├── simd_load32_lane.wast │ │ │ │ │ ├── simd_load64_lane.wast │ │ │ │ │ ├── simd_load8_lane.wast │ │ │ │ │ ├── simd_load_extend.wast │ │ │ │ │ ├── simd_load_splat.wast │ │ │ │ │ ├── simd_load_zero.wast │ │ │ │ │ ├── simd_splat.wast │ │ │ │ │ ├── simd_store.wast │ │ │ │ │ ├── simd_store16_lane.wast │ │ │ │ │ ├── simd_store32_lane.wast │ │ │ │ │ ├── simd_store64_lane.wast │ │ │ │ │ └── simd_store8_lane.wast │ │ │ │ ├── tail-call │ │ │ │ │ ├── return_call.wast │ │ │ │ │ └── return_call_indirect.wast │ │ │ │ └── threads │ │ │ │ │ ├── atomic.wast │ │ │ │ │ ├── exports.wast │ │ │ │ │ ├── imports.wast │ │ │ │ │ └── memory.wast │ │ │ ├── ref_func.wast │ │ │ ├── ref_is_null.wast │ │ │ ├── ref_null.wast │ │ │ ├── return.wast │ │ │ ├── select.wast │ │ │ ├── skip-stack-guard-page.wast │ │ │ ├── stack.wast │ │ │ ├── start.wast │ │ │ ├── store.wast │ │ │ ├── switch.wast │ │ │ ├── table-sub.wast │ │ │ ├── table.wast │ │ │ ├── table_copy.wast │ │ │ ├── table_fill.wast │ │ │ ├── table_get.wast │ │ │ ├── table_grow.wast │ │ │ ├── table_init.wast │ │ │ ├── table_set.wast │ │ │ ├── table_size.wast │ │ │ ├── token.wast │ │ │ ├── traps.wast │ │ │ ├── type.wast │ │ │ ├── unreachable.wast │ │ │ ├── unreached-invalid.wast │ │ │ ├── unwind.wast │ │ │ ├── update-testsuite.sh │ │ │ ├── utf8-custom-section-id.wast │ │ │ ├── utf8-import-field.wast │ │ │ ├── utf8-import-module.wast │ │ │ └── utf8-invalid-encoding.wast │ │ │ └── wasmer │ │ │ ├── README.md │ │ │ ├── call-indirect-spilled-stack.wast │ │ │ ├── fac.wast │ │ │ ├── int-extend-garbage.wast │ │ │ ├── max_locals.wast │ │ │ ├── max_size_of_memory.wast │ │ │ ├── multiple-traps.wast │ │ │ ├── nan-canonicalization-issue-2159.wast │ │ │ ├── nan-canonicalization-issue-2347.wast │ │ │ ├── nan-canonicalization.wast │ │ │ ├── rotate-shift-overflow.wast │ │ │ ├── stack-overflow-sret.wast │ │ │ └── stack-overflow.wast │ ├── types │ │ ├── Cargo.toml │ │ ├── LICENSE-GPL2 │ │ ├── LICENSE-GPL2.1 │ │ ├── README.md │ │ ├── src │ │ │ ├── archives.rs │ │ │ ├── entity │ │ │ │ ├── boxed_slice.rs │ │ │ │ ├── iter.rs │ │ │ │ ├── keys.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── packed_option.rs │ │ │ │ ├── primary_map.rs │ │ │ │ └── secondary_map.rs │ │ │ ├── extern_ref.rs │ │ │ ├── features.rs │ │ │ ├── indexes.rs │ │ │ ├── initializers.rs │ │ │ ├── lib.rs │ │ │ ├── memory_view.rs │ │ │ ├── module.rs │ │ │ ├── native.rs │ │ │ ├── partial_sum_map.rs │ │ │ ├── types.rs │ │ │ ├── units.rs │ │ │ └── values.rs │ │ └── tests │ │ │ └── partial-sum-map │ │ │ ├── corpus │ │ │ └── .gitkeep │ │ │ ├── crashes │ │ │ └── .gitkeep │ │ │ └── main.rs │ ├── vm │ │ ├── Cargo.toml │ │ ├── LICENSE-GPL2 │ │ ├── LICENSE-GPL2.1 │ │ ├── README.md │ │ ├── build.rs │ │ └── src │ │ │ ├── artifact.rs │ │ │ ├── export.rs │ │ │ ├── func_data_registry.rs │ │ │ ├── global.rs │ │ │ ├── imports.rs │ │ │ ├── instance │ │ │ ├── allocator.rs │ │ │ ├── mod.rs │ │ │ └── ref.rs │ │ │ ├── lib.rs │ │ │ ├── libcalls.rs │ │ │ ├── memory.rs │ │ │ ├── mmap.rs │ │ │ ├── probestack.rs │ │ │ ├── resolver.rs │ │ │ ├── sig_registry.rs │ │ │ ├── table.rs │ │ │ ├── trap │ │ │ ├── handlers.c │ │ │ ├── mod.rs │ │ │ ├── trapcode.rs │ │ │ └── traphandlers.rs │ │ │ ├── tunables.rs │ │ │ ├── vmcontext.rs │ │ │ └── vmoffsets.rs │ └── wast │ │ ├── Cargo.toml │ │ ├── README.md │ │ └── src │ │ ├── error.rs │ │ ├── lib.rs │ │ ├── spectest.rs │ │ └── wast.rs └── unc-wallet-contract │ ├── Cargo.toml │ ├── README.md │ ├── build.rs │ ├── res │ └── .gitignore │ ├── src │ └── lib.rs │ └── wallet-contract │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ └── lib.rs ├── rust-toolchain.toml ├── rustfmt.toml ├── scripts ├── __init__.py ├── binaries │ ├── build.sh │ ├── build_all.sh │ └── x86_64 │ │ ├── arch.Dockerfile │ │ ├── debian-11.Dockerfile │ │ ├── debian-12.Dockerfile │ │ ├── shared.dockerignore │ │ ├── ubuntu-2004.Dockerfile │ │ ├── ubuntu-2204.Dockerfile │ │ └── ubuntu-2404.Dockerfile ├── check_nightly.py ├── check_pytests.py ├── coverage-wrapper-rustc ├── fix_nightly_feature_flags.py ├── flaky_test_check.py ├── formatting ├── install_precommit.sh ├── parallel_coverage.py ├── requirements_check.sh ├── run_docker.sh ├── setup_hooks.sh ├── split_storage_migration.sh ├── state │ ├── mega-migrate.py │ ├── split-genesis.py │ └── update_res.py └── testlib.py ├── test-utils ├── actix-test-utils │ ├── Cargo.toml │ └── src │ │ └── lib.rs ├── logger │ └── Cargo.toml ├── runtime-tester │ ├── Cargo.toml │ ├── README.md │ ├── fuzz │ │ ├── .gitignore │ │ ├── Cargo.toml │ │ ├── README.md │ │ └── fuzz_targets_disabled │ │ │ └── runtime_fuzzer.rs │ └── src │ │ ├── fuzzing.rs │ │ ├── lib.rs │ │ ├── run_test.rs │ │ └── scenario_builder.rs ├── store-validator │ ├── Cargo.toml │ └── src │ │ └── main.rs └── testlib │ ├── Cargo.toml │ └── src │ ├── fees_utils.rs │ ├── lib.rs │ ├── process_blocks.rs │ └── runtime_utils.rs ├── tools ├── amend-genesis │ ├── Cargo.toml │ └── src │ │ ├── cli.rs │ │ └── lib.rs ├── chainsync-loadtest │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── concurrency │ │ ├── mod.rs │ │ ├── once.rs │ │ ├── rate_limiter.rs │ │ └── weak_map.rs │ │ ├── fetch_chain.rs │ │ ├── main.rs │ │ └── network.rs ├── cold-store │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── cli.rs │ │ └── lib.rs ├── crates-publish-checker │ ├── Cargo.toml │ └── src │ │ ├── main.rs │ │ ├── rules.rs │ │ ├── style.rs │ │ ├── types.rs │ │ └── utils.rs ├── database │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── adjust_database.rs │ │ ├── analyse_data_size_distribution.rs │ │ ├── analyse_gas_usage.rs │ │ ├── block_iterators │ │ ├── height_range.rs │ │ ├── last_blocks.rs │ │ └── mod.rs │ │ ├── commands.rs │ │ ├── compact.rs │ │ ├── corrupt.rs │ │ ├── lib.rs │ │ ├── make_snapshot.rs │ │ ├── memtrie.rs │ │ ├── run_migrations.rs │ │ ├── state_perf.rs │ │ └── utils.rs ├── debug-ui │ ├── .dockerignore │ ├── .eslintrc.yml │ ├── .gitignore │ ├── .prettierrc.json │ ├── Dockerfile │ ├── README.md │ ├── nginx.conf │ ├── package-lock.json │ ├── package.json │ ├── public │ │ └── index.html │ ├── src │ │ ├── App.scss │ │ ├── App.tsx │ │ ├── BlocksView.scss │ │ ├── BlocksView.tsx │ │ ├── ChainAndChunkInfoView.scss │ │ ├── ChainAndChunkInfoView.tsx │ │ ├── ChainInfoSummaryView.scss │ │ ├── ChainInfoSummaryView.tsx │ │ ├── ClusterNodeView.scss │ │ ├── ClusterNodeView.tsx │ │ ├── ClusterView.scss │ │ ├── ClusterView.tsx │ │ ├── ConnectionStorageView.scss │ │ ├── ConnectionStorageView.tsx │ │ ├── CurrentPeersView.scss │ │ ├── CurrentPeersView.tsx │ │ ├── EpochInfoView.scss │ │ ├── EpochInfoView.tsx │ │ ├── EpochShardsView.scss │ │ ├── EpochShardsView.tsx │ │ ├── EpochValidatorsView.scss │ │ ├── EpochValidatorsView.tsx │ │ ├── FloatingChunksView.scss │ │ ├── FloatingChunksView.tsx │ │ ├── HeaderBar.scss │ │ ├── HeaderBar.tsx │ │ ├── LandingPage.scss │ │ ├── LandingPage.tsx │ │ ├── LatestBlocksView.scss │ │ ├── LatestBlocksView.tsx │ │ ├── LogFileDrop.tsx │ │ ├── NetworkInfoView.scss │ │ ├── NetworkInfoView.tsx │ │ ├── PeerStorageView.scss │ │ ├── PeerStorageView.tsx │ │ ├── RecentEpochsView.scss │ │ ├── RecentEpochsView.tsx │ │ ├── RoutingTableView.scss │ │ ├── RoutingTableView.tsx │ │ ├── SnapshotHostsView.scss │ │ ├── SnapshotHostsView.tsx │ │ ├── Tier1View.scss │ │ ├── Tier1View.tsx │ │ ├── api.tsx │ │ ├── entity_debug │ │ │ ├── AllQueriesDisplay.scss │ │ │ ├── AllQueriesDisplay.tsx │ │ │ ├── EntityDataRootView.scss │ │ │ ├── EntityDataRootView.tsx │ │ │ ├── EntityDataValueView.scss │ │ │ ├── EntityDataValueView.tsx │ │ │ ├── EntityDebugView.scss │ │ │ ├── EntityDebugView.tsx │ │ │ ├── EntityQueryComposer.scss │ │ │ ├── EntityQueryComposer.tsx │ │ │ ├── KeyInput.scss │ │ │ ├── KeyInput.tsx │ │ │ ├── PinnedKeysView.scss │ │ │ ├── PinnedKeysView.tsx │ │ │ ├── all_queries.tsx │ │ │ ├── composing_query.tsx │ │ │ ├── fetcher.tsx │ │ │ ├── fields.tsx │ │ │ ├── keys.tsx │ │ │ ├── pinned_keys.tsx │ │ │ └── types.tsx │ │ ├── index.css │ │ ├── index.tsx │ │ ├── log_visualizer │ │ │ ├── LogVisualizer.scss │ │ │ ├── LogVisualizer.tsx │ │ │ ├── arrows.ts │ │ │ ├── events.ts │ │ │ ├── interval.ts │ │ │ └── layout.ts │ │ ├── pretty-print.ts │ │ ├── react-app-env.d.ts │ │ └── utils.tsx │ └── tsconfig.json ├── epoch-sync │ ├── Cargo.toml │ └── src │ │ ├── cli.rs │ │ └── lib.rs ├── flat-storage │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── commands.rs │ │ └── lib.rs ├── fork-network │ ├── Cargo.toml │ └── src │ │ ├── cli.rs │ │ ├── lib.rs │ │ ├── single_shard_storage_mutator.rs │ │ └── storage_mutator.rs ├── indexer │ └── example │ │ ├── Cargo.toml │ │ ├── README.md │ │ └── src │ │ ├── configs.rs │ │ └── main.rs ├── mirror │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── chain_tracker.rs │ │ ├── cli.rs │ │ ├── genesis.rs │ │ ├── key_mapping.rs │ │ ├── lib.rs │ │ ├── metrics.rs │ │ ├── offline.rs │ │ ├── online.rs │ │ └── secret.rs ├── mock-node │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── lib.rs │ │ ├── main.rs │ │ └── setup.rs ├── ping │ ├── Cargo.toml │ └── src │ │ ├── cli.rs │ │ ├── csv.rs │ │ ├── lib.rs │ │ └── metrics.rs ├── re-pledged │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── rpctypegen │ ├── core │ │ ├── Cargo.toml │ │ ├── LICENSE-GPL2 │ │ ├── LICENSE-GPL2.1 │ │ └── src │ │ │ └── lib.rs │ └── macro │ │ ├── Cargo.toml │ │ ├── LICENSE-GPL2 │ │ ├── LICENSE-GPL2.1 │ │ └── src │ │ └── lib.rs ├── speedy_sync │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── state-parts-dump-check │ ├── Cargo.toml │ └── src │ │ ├── cli.rs │ │ ├── lib.rs │ │ └── metrics.rs ├── state-parts │ ├── Cargo.toml │ └── src │ │ ├── cli.rs │ │ └── lib.rs ├── state-viewer │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── apply_chain_range.rs │ │ ├── apply_chunk.rs │ │ ├── cli.rs │ │ ├── commands.rs │ │ ├── contract_accounts.rs │ │ ├── epoch_info.rs │ │ ├── lib.rs │ │ ├── rocksdb_stats.rs │ │ ├── scan_db.rs │ │ ├── state_changes.rs │ │ ├── state_dump.rs │ │ ├── state_parts.rs │ │ ├── trie_iteration_benchmark.rs │ │ └── tx_dump.rs ├── storage-usage-delta-calculator │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs └── undo-block │ ├── Cargo.toml │ └── src │ ├── cli.rs │ └── lib.rs └── utils ├── config ├── Cargo.toml ├── LICENSE-GPL2 ├── LICENSE-GPL2.1 └── src │ └── lib.rs ├── fmt ├── Cargo.toml ├── LICENSE-GPL2 ├── LICENSE-GPL2.1 ├── README.md └── src │ └── lib.rs ├── mainnet-res ├── Cargo.toml ├── README.md ├── res │ ├── mainnet_genesis.json │ ├── mainnet_restored_receipts.json │ └── storage_usage_delta.json ├── src │ └── lib.rs └── tests │ └── load_genesis.rs ├── stdx ├── Cargo.toml ├── LICENSE-GPL2 ├── LICENSE-GPL2.1 └── src │ └── lib.rs ├── unc-cache ├── Cargo.toml ├── LICENSE-GPL2 ├── LICENSE-GPL2.1 ├── README.md ├── benches │ └── cache.rs └── src │ ├── cell.rs │ ├── lib.rs │ └── sync.rs ├── unc-performance-metrics-macros ├── Cargo.toml └── src │ └── lib.rs ├── unc-performance-metrics ├── Cargo.toml └── src │ ├── actix_disabled.rs │ ├── actix_enabled.rs │ ├── lib.rs │ ├── process.rs │ ├── stats_disabled.rs │ └── stats_enabled.rs └── unc-stable-hasher ├── Cargo.toml ├── LICENSE-GPL2 ├── LICENSE-GPL2.1 ├── README.md └── src └── lib.rs /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | # We compile with `panic=abort`, so we need `-Cforce-unwind-tables=y` 3 | # to get a useful backtrace on panic. 4 | rustflags = ["-Cforce-unwind-tables=y"] 5 | 6 | [target.'cfg(target_arch = "x86_64")'] 7 | rustflags = ["-Ctarget-feature=+sse4.1,+sse4.2", "-Cforce-unwind-tables=y"] 8 | -------------------------------------------------------------------------------- /.config/nextest.toml: -------------------------------------------------------------------------------- 1 | [profile.default] 2 | slow-timeout = { period = "60s", terminate-after = 2, grace-period = "0s" } 3 | 4 | [[profile.default.overrides]] 5 | filter = 'test(test_full_estimator)' 6 | slow-timeout = { period = "10m", terminate-after = 3 } 7 | retries = 0 8 | threads-required = 2 9 | 10 | # Unfortunately no support for inheriting profiles yet: 11 | # https://github.com/nextest-rs/nextest/issues/387 12 | [profile.ci] 13 | slow-timeout = { period = "120s", terminate-after = 5 } 14 | # Try a few times before failing the whole test suite on a potentially spurious tests. 15 | # The hope is that people will fix the spurious tests as they encounter them locally... 16 | retries = { backoff = "fixed", count = 3, delay = "30s" } 17 | failure-output = "final" 18 | fail-fast = false 19 | 20 | [[profile.ci.overrides]] 21 | filter = 'test(test_full_estimator)' 22 | slow-timeout = { period = "10m", terminate-after = 3 } 23 | retries = 0 24 | threads-required = 2 25 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vscode/ 3 | 4 | docker/ 5 | !docker/scripts/ 6 | ops/ 7 | !ops/run.sh 8 | !ops/tendermint-config.toml 9 | 10 | **/target 11 | storage/ 12 | keystore/ 13 | tmp/ 14 | sandbox/ 15 | 16 | # Ignore Vim swapfiles 17 | *.swp 18 | 19 | # Docker files shouldn't invalidate the cache because Docker itself will use these appropriately 20 | .dockerignore 21 | Dockerfile 22 | Dockerfile.nightly 23 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | **/package-lock.json linguist-generated=true -diff 2 | # Disable linguist for WebAssembly files. 3 | # Those are used to test the runtime and should not be indexed. 4 | *.wasm linguist-detectable=false 5 | *.wast linguist-detectable=false 6 | *.wat linguist-detectable=false 7 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/01_BUG_REPORT.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: In case you have found a bug in our product. 4 | title: "bug: " 5 | labels: "bug" 6 | assignees: "" 7 | --- 8 | 9 | # Bug Report 10 | 11 | Check the [contributing guide](https://github.com/utnet-org/utility/blob/main/CONTRIBUTING.md) 12 | 13 | ## Description 14 | 15 | 16 | ## Steps to Reproduce 17 | 18 | 19 | 1. 20 | 2. 21 | 3. 22 | 23 | ## Expected Behavior 24 | 25 | 26 | ## Actual Behavior 27 | 28 | 29 | ## Additional Information 30 | 31 | -------------------------------------------------------------------------------- /.github/RELEASE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # unc-node vx.x.x 2 | 3 | # Versions 4 | 5 | Node Version: x.x.x 6 | 7 | # Breaking changes 8 | 9 | 10 | 11 | # Added 12 | 13 | - Scope - Description 14 | 15 | # Changed 16 | 17 | - Scope - Description 18 | 19 | # Fixed 20 | 21 | - Scope - Description 22 | 23 | # New Runtime 24 | 25 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "ops"] 2 | path = ops 3 | url = https://github.com/utnet-org/ops.git 4 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | - repo: https://github.com/doublify/pre-commit-rust 2 | rev: master 3 | hooks: 4 | - id: fmt -------------------------------------------------------------------------------- /.style.yapf: -------------------------------------------------------------------------------- 1 | [style] 2 | based_on_style = google 3 | indent_width = 4 4 | column_limit = 80 5 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # CODEOWNERS: https://help.github.com/articles/about-codeowners/ 2 | 3 | * @utnet-org/utility-codeowners 4 | -------------------------------------------------------------------------------- /buf.yaml: -------------------------------------------------------------------------------- 1 | version: v1 2 | breaking: 3 | use: 4 | - WIRE 5 | -------------------------------------------------------------------------------- /chain/chain-primitives/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-chain-primitives" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | description = "This crate hosts UNC chain-related error types" 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = true 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | chrono.workspace = true 16 | thiserror.workspace = true 17 | tracing.workspace = true 18 | 19 | unc-primitives.workspace = true 20 | unc-crypto.workspace = true 21 | 22 | [features] 23 | new_epoch_sync = [] 24 | -------------------------------------------------------------------------------- /chain/chain-primitives/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2 -------------------------------------------------------------------------------- /chain/chain-primitives/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /chain/chain-primitives/README.md: -------------------------------------------------------------------------------- 1 | # unc-chain-primitives 2 | 3 | This crate hosts UNC chain-related error types. -------------------------------------------------------------------------------- /chain/chain-primitives/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod error; 2 | 3 | pub use error::Error; 4 | -------------------------------------------------------------------------------- /chain/chain/src/tests/challenges.rs: -------------------------------------------------------------------------------- 1 | use crate::test_utils::setup; 2 | use crate::Error; 3 | use unc_o11y::testonly::init_test_logger; 4 | use unc_primitives::test_utils::TestBlockBuilder; 5 | 6 | #[test] 7 | fn test_no_challenge_on_same_header() { 8 | init_test_logger(); 9 | let (mut chain, _, _, signer) = setup(); 10 | let prev_hash = *chain.head_header().unwrap().hash(); 11 | let prev = chain.get_block(&prev_hash).unwrap(); 12 | let block = TestBlockBuilder::new(&prev, signer).build(); 13 | chain.process_block_test(&None, block.clone()).unwrap(); 14 | assert_eq!(chain.head().unwrap().height, 1); 15 | let mut challenges = vec![]; 16 | if let Err(e) = chain.process_block_header(block.header(), &mut challenges) { 17 | match e { 18 | Error::BlockKnown(_) => {} 19 | _ => panic!("Wrong error kind {}", e), 20 | } 21 | assert!(challenges.is_empty()); 22 | } else { 23 | panic!("Process the same header twice should produce error"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /chain/chunks-primitives/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-chunks-primitives" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | description = "This crate hosts Utility chunks-related error types" 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = true 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | unc-chain-primitives.workspace = true 16 | unc-primitives.workspace = true 17 | -------------------------------------------------------------------------------- /chain/chunks-primitives/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2 -------------------------------------------------------------------------------- /chain/chunks-primitives/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /chain/chunks-primitives/README.md: -------------------------------------------------------------------------------- 1 | # unc-chunk-primitives 2 | 3 | This crate hosts Utility chunks-related error types. 4 | -------------------------------------------------------------------------------- /chain/chunks-primitives/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod error; 2 | 3 | pub use error::Error; 4 | -------------------------------------------------------------------------------- /chain/client-primitives/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2 -------------------------------------------------------------------------------- /chain/client-primitives/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /chain/client-primitives/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod debug; 2 | pub mod types; 3 | -------------------------------------------------------------------------------- /chain/client/src/sync/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod adapter; 2 | pub mod block; 3 | pub mod epoch; 4 | pub mod external; 5 | pub mod header; 6 | pub mod state; 7 | pub mod sync_actor; 8 | -------------------------------------------------------------------------------- /chain/client/src/test_utils/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod block_stats; 2 | pub mod client; 3 | pub mod peer_manager_mock; 4 | pub mod setup; 5 | pub mod test_env; 6 | pub mod test_env_builder; 7 | 8 | pub use block_stats::*; 9 | pub use client::*; 10 | pub use peer_manager_mock::*; 11 | pub use setup::*; 12 | pub use test_env::*; 13 | pub use test_env_builder::*; 14 | -------------------------------------------------------------------------------- /chain/client/src/tests/mod.rs: -------------------------------------------------------------------------------- 1 | mod bug_repros; 2 | mod catching_up; 3 | mod chunks_management; 4 | mod consensus; 5 | mod cross_shard_tx; 6 | mod doomslug; 7 | mod maintenance_windows; 8 | mod process_blocks; 9 | mod query_client; 10 | -------------------------------------------------------------------------------- /chain/indexer-primitives/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-indexer-primitives" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | description = "This crate hosts structures for the UNC Indexer Framework types" 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = true 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | serde.workspace = true 16 | serde_json.workspace = true 17 | 18 | unc-primitives.workspace = true 19 | 20 | [features] 21 | nightly = [ 22 | "nightly_protocol", 23 | "unc-primitives/nightly", 24 | ] 25 | nightly_protocol = [ 26 | "unc-primitives/nightly_protocol", 27 | ] 28 | -------------------------------------------------------------------------------- /chain/indexer-primitives/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2 -------------------------------------------------------------------------------- /chain/indexer-primitives/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /chain/indexer-primitives/README.md: -------------------------------------------------------------------------------- 1 | # unc-indexer-primitives 2 | 3 | This crate holds the types that is used in UNC Indexer Framework to allow other projects to use them without a need to depend on entire `unc-infra.. 4 | -------------------------------------------------------------------------------- /chain/indexer/src/streamer/errors.rs: -------------------------------------------------------------------------------- 1 | use actix::MailboxError; 2 | 3 | /// Error occurs in case of failed data fetch 4 | #[derive(Debug)] 5 | pub enum FailedToFetchData { 6 | MailboxError(MailboxError), 7 | String(String), 8 | } 9 | 10 | impl From for FailedToFetchData { 11 | fn from(actix_error: MailboxError) -> Self { 12 | FailedToFetchData::MailboxError(actix_error) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chain/jsonrpc-adversarial-primitives/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-jsonrpc-adversarial-primitives" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | serde.workspace = true 16 | 17 | unc-primitives.workspace = true 18 | unc-network.workspace = true 19 | 20 | [features] 21 | nightly_protocol = [ 22 | "unc-network/nightly_protocol", 23 | "unc-primitives/nightly_protocol", 24 | ] 25 | nightly = [ 26 | "nightly_protocol", 27 | "unc-network/nightly", 28 | "unc-primitives/nightly", 29 | ] 30 | test_features = ["unc-network/test_features"] 31 | -------------------------------------------------------------------------------- /chain/jsonrpc-adversarial-primitives/src/lib.rs: -------------------------------------------------------------------------------- 1 | use unc_primitives::network::PeerId; 2 | 3 | #[derive(serde::Deserialize)] 4 | pub struct StartRoutingTableSyncRequest { 5 | pub peer_id: PeerId, 6 | } 7 | -------------------------------------------------------------------------------- /chain/jsonrpc-primitives/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2 -------------------------------------------------------------------------------- /chain/jsonrpc-primitives/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /chain/jsonrpc-primitives/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod errors; 2 | pub mod message; 3 | pub mod types; 4 | -------------------------------------------------------------------------------- /chain/jsonrpc-primitives/src/types/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod all_miners; 2 | pub mod blocks; 3 | pub mod changes; 4 | pub mod chunks; 5 | pub mod client_config; 6 | pub mod config; 7 | pub mod entity_debug; 8 | pub mod gas_price; 9 | pub mod light_client; 10 | pub mod maintenance; 11 | pub mod network_info; 12 | pub mod provider; 13 | pub mod query; 14 | pub mod receipts; 15 | pub mod sandbox; 16 | pub mod split_storage; 17 | pub mod status; 18 | pub mod transactions; 19 | pub mod validator; 20 | -------------------------------------------------------------------------------- /chain/jsonrpc/client/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-jsonrpc-client" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | actix-http.workspace = true 16 | awc.workspace = true 17 | futures.workspace = true 18 | serde.workspace = true 19 | serde_json.workspace = true 20 | 21 | unc-jsonrpc-primitives.workspace = true 22 | unc-primitives.workspace = true 23 | 24 | [features] 25 | nightly = [ 26 | "nightly_protocol", 27 | "unc-jsonrpc-primitives/nightly", 28 | "unc-primitives/nightly", 29 | ] 30 | nightly_protocol = [ 31 | "unc-jsonrpc-primitives/nightly_protocol", 32 | "unc-primitives/nightly_protocol", 33 | ] 34 | -------------------------------------------------------------------------------- /chain/jsonrpc/fuzz/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | target 3 | corpus 4 | artifacts 5 | -------------------------------------------------------------------------------- /chain/jsonrpc/fuzz/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-jsonrpc-fuzz" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [package.metadata] 15 | cargo-fuzz = true 16 | 17 | [dependencies] 18 | actix.workspace = true 19 | arbitrary.workspace = true 20 | awc.workspace = true 21 | libfuzzer-sys.workspace = true 22 | once_cell.workspace = true 23 | serde.workspace = true 24 | serde_json.workspace = true 25 | tokio.workspace = true 26 | 27 | unc-jsonrpc.workspace = true 28 | unc-jsonrpc-primitives.workspace = true 29 | unc-jsonrpc-tests.workspace = true 30 | unc-primitives.workspace = true 31 | 32 | [[bin]] 33 | name = "fuzz_target_1" 34 | path = "fuzz_targets_disabled/fuzz_target_1.rs" 35 | test = false 36 | doc = false 37 | -------------------------------------------------------------------------------- /chain/jsonrpc/jsonrpc-tests/tests/http_query.rs: -------------------------------------------------------------------------------- 1 | use actix::System; 2 | use futures::{future, FutureExt}; 3 | 4 | use unc_actix_test_utils::run_actix; 5 | use unc_jsonrpc::client::new_http_client; 6 | use unc_o11y::testonly::init_test_logger; 7 | 8 | use unc_jsonrpc_tests as test_utils; 9 | 10 | /// Retrieve client status via HTTP GET. 11 | #[test] 12 | fn test_status() { 13 | init_test_logger(); 14 | 15 | run_actix(async { 16 | let (_view_client_addr, addr) = test_utils::start_all(test_utils::NodeType::NonValidator); 17 | 18 | let client = new_http_client(&format!("http://{}", addr)); 19 | actix::spawn(client.status().then(|res| { 20 | let res = res.unwrap(); 21 | assert_eq!(res.chain_id, "unittest"); 22 | assert_eq!(res.sync_info.latest_block_height, 0); 23 | assert_eq!(res.sync_info.syncing, false); 24 | System::current().stop(); 25 | future::ready(()) 26 | })); 27 | }); 28 | } 29 | -------------------------------------------------------------------------------- /chain/jsonrpc/res/chain_n_chunk_info.css: -------------------------------------------------------------------------------- 1 | table { 2 | width: 100%; 3 | border-collapse: collapse; 4 | } 5 | 6 | table, 7 | th, 8 | td { 9 | border: 1px solid black; 10 | } 11 | 12 | td { 13 | text-align: left; 14 | vertical-align: top; 15 | padding: 8px; 16 | } 17 | 18 | th { 19 | text-align: center; 20 | vertical-align: center; 21 | padding: 8px; 22 | background-color: lightgrey; 23 | } 24 | 25 | tr.active { 26 | background-color: #eff8bf; 27 | } -------------------------------------------------------------------------------- /chain/jsonrpc/res/epoch_info.css: -------------------------------------------------------------------------------- 1 | table { 2 | width: 100%; 3 | border-collapse: collapse; 4 | } 5 | 6 | table, 7 | th, 8 | td { 9 | border: 1px solid black; 10 | } 11 | 12 | td { 13 | text-align: left; 14 | vertical-align: top; 15 | padding: 8px; 16 | } 17 | 18 | th { 19 | text-align: center; 20 | vertical-align: center; 21 | padding: 8px; 22 | background-color: lightgrey; 23 | } 24 | 25 | tr.active { 26 | background-color: #eff8bf; 27 | } -------------------------------------------------------------------------------- /chain/jsonrpc/res/last_blocks.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /chain/jsonrpc/res/network_info.css: -------------------------------------------------------------------------------- 1 | table { 2 | width: 100%; 3 | border-collapse: collapse; 4 | } 5 | 6 | table, 7 | th, 8 | td { 9 | border: 1px solid black; 10 | } 11 | 12 | td { 13 | text-align: left; 14 | vertical-align: top; 15 | padding: 8px; 16 | } 17 | 18 | th { 19 | text-align: center; 20 | vertical-align: center; 21 | padding: 8px; 22 | background-color: lightgrey; 23 | } 24 | 25 | tr.active { 26 | background-color: #eff8bf; 27 | } 28 | 29 | .peer_in_sync { 30 | background-color: green; 31 | } 32 | 33 | .peer_ahead { 34 | background-color: lightblue; 35 | } 36 | 37 | .peer_ahead_alot { 38 | background-color: blueviolet; 39 | } 40 | 41 | .peer_behind_a_little { 42 | background-color: yellowgreen; 43 | } 44 | 45 | .peer_behind { 46 | background-color: yellow; 47 | } 48 | 49 | .peer_far_behind { 50 | background-color: red; 51 | } 52 | -------------------------------------------------------------------------------- /chain/jsonrpc/res/sync.css: -------------------------------------------------------------------------------- 1 | table { 2 | width: 100%; 3 | border-collapse: collapse; 4 | } 5 | 6 | table, 7 | th, 8 | td { 9 | border: 1px solid black; 10 | } 11 | 12 | td { 13 | text-align: left; 14 | vertical-align: top; 15 | padding: 8px; 16 | } 17 | 18 | th { 19 | text-align: center; 20 | vertical-align: center; 21 | padding: 8px; 22 | background-color: lightgrey; 23 | } 24 | 25 | tr.active { 26 | background-color: #eff8bf; 27 | } -------------------------------------------------------------------------------- /chain/network/build.rs: -------------------------------------------------------------------------------- 1 | fn main() -> anyhow::Result<()> { 2 | println!("cargo:rerun-if-changed=src/network_protocol/network.proto"); 3 | protobuf_codegen::Codegen::new() 4 | .pure() 5 | .includes(["src/"]) 6 | .input("src/network_protocol/network.proto") 7 | .cargo_out_dir("proto") 8 | .run() 9 | } 10 | -------------------------------------------------------------------------------- /chain/network/src/broadcast/tests.rs: -------------------------------------------------------------------------------- 1 | use crate::broadcast; 2 | 3 | #[tokio::test] 4 | async fn channel() { 5 | let (send, mut recv) = broadcast::unbounded_channel(); 6 | send.send(1); 7 | send.send(2); 8 | send.send(3); 9 | assert_eq!(1, recv.recv().await); 10 | let mut recv2 = recv.clone(); 11 | assert_eq!(2, recv.recv().await); 12 | assert_eq!(3, recv.recv().await); 13 | assert_eq!(2, recv2.recv().await); 14 | assert_eq!(3, recv2.recv().await); 15 | } 16 | -------------------------------------------------------------------------------- /chain/network/src/concurrency/atomic_cell.rs: -------------------------------------------------------------------------------- 1 | use std::sync::Mutex; 2 | 3 | // AtomicCell narrows down a Mutex API to load/store calls. 4 | pub(crate) struct AtomicCell(Mutex); 5 | 6 | impl AtomicCell { 7 | pub fn new(v: T) -> Self { 8 | Self(Mutex::new(v)) 9 | } 10 | pub fn load(&self) -> T { 11 | self.0.lock().unwrap().clone() 12 | } 13 | pub fn store(&self, v: T) { 14 | *self.0.lock().unwrap() = v; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /chain/network/src/concurrency/ctx/time.rs: -------------------------------------------------------------------------------- 1 | use crate::concurrency::ctx; 2 | use unc_async::time; 3 | 4 | pub fn now() -> time::Instant { 5 | ctx::local().0.clock.now() 6 | } 7 | 8 | pub fn now_utc() -> time::Utc { 9 | ctx::local().0.clock.now_utc() 10 | } 11 | 12 | pub async fn sleep(d: time::Duration) -> ctx::OrCanceled<()> { 13 | let ctx = ctx::local(); 14 | ctx.wait(ctx.0.clock.sleep(d)).await 15 | } 16 | 17 | pub async fn sleep_until(t: time::Instant) -> ctx::OrCanceled<()> { 18 | let ctx = ctx::local(); 19 | ctx.wait(ctx.0.clock.sleep_until(t)).await 20 | } 21 | -------------------------------------------------------------------------------- /chain/network/src/concurrency/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod arc_mutex; 2 | pub mod atomic_cell; 3 | pub mod ctx; 4 | pub mod demux; 5 | pub mod rate; 6 | pub mod rayon; 7 | pub mod runtime; 8 | pub mod scope; 9 | mod signal; 10 | 11 | #[cfg(test)] 12 | mod tests; 13 | -------------------------------------------------------------------------------- /chain/network/src/debug.rs: -------------------------------------------------------------------------------- 1 | use ::actix::Message; 2 | use unc_primitives::views::{ 3 | NetworkGraphView, NetworkRoutesView, PeerStoreView, RecentOutboundConnectionsView, 4 | SnapshotHostsView, 5 | }; 6 | 7 | // Different debug requests that can be sent by HTML pages, via GET. 8 | pub enum GetDebugStatus { 9 | PeerStore, 10 | Graph, 11 | RecentOutboundConnections, 12 | Routes, 13 | SnapshotHosts, 14 | } 15 | 16 | #[derive(actix::MessageResponse, Debug)] 17 | pub enum DebugStatus { 18 | PeerStore(PeerStoreView), 19 | Graph(NetworkGraphView), 20 | RecentOutboundConnections(RecentOutboundConnectionsView), 21 | Routes(NetworkRoutesView), 22 | SnapshotHosts(SnapshotHostsView), 23 | } 24 | 25 | impl Message for GetDebugStatus { 26 | type Result = DebugStatus; 27 | } 28 | -------------------------------------------------------------------------------- /chain/network/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub use crate::peer_manager::peer_manager_actor::{Event, PeerManagerActor}; 2 | 3 | mod accounts_data; 4 | mod announce_accounts; 5 | mod network_protocol; 6 | mod peer; 7 | mod peer_manager; 8 | mod private_actix; 9 | mod snapshot_hosts; 10 | mod stats; 11 | mod store; 12 | mod stun; 13 | 14 | pub mod actix; 15 | pub mod blacklist; 16 | pub mod client; 17 | pub mod concurrency; 18 | pub mod config; 19 | pub mod config_json; 20 | pub mod debug; 21 | pub mod raw; 22 | pub mod routing; 23 | pub mod shards_manager; 24 | pub mod state_sync; 25 | pub mod tcp; 26 | pub mod test_loop; 27 | pub mod test_utils; 28 | pub mod types; 29 | 30 | #[cfg(test)] 31 | pub(crate) mod testonly; 32 | 33 | // TODO(gprusak): these should be testonly, once all network integration tests are moved to unc_network. 34 | pub mod broadcast; 35 | pub mod sink; 36 | -------------------------------------------------------------------------------- /chain/network/src/network_protocol/proto_conv/mod.rs: -------------------------------------------------------------------------------- 1 | mod account_key; 2 | mod crypto; 3 | mod handshake; 4 | mod net; 5 | mod peer_message; 6 | mod time; 7 | pub mod trace_context; 8 | /// Contains protobuf <-> network_protocol conversions. 9 | mod util; 10 | 11 | use self::time::*; 12 | use account_key::*; 13 | use crypto::*; 14 | use handshake::*; 15 | use net::*; 16 | pub(crate) use peer_message::*; 17 | use util::*; 18 | -------------------------------------------------------------------------------- /chain/network/src/network_protocol/proto_conv/time.rs: -------------------------------------------------------------------------------- 1 | pub use protobuf::well_known_types::timestamp::Timestamp as ProtoTimestamp; 2 | /// Conversion functions for the proto timestamp messages. 3 | use unc_async::time; 4 | 5 | pub type ParseTimestampError = time::error::ComponentRange; 6 | 7 | pub fn utc_to_proto(x: &time::Utc) -> ProtoTimestamp { 8 | ProtoTimestamp { 9 | seconds: x.unix_timestamp(), 10 | // x.nanosecond() is guaranteed to be in range [0,10^9). 11 | nanos: x.nanosecond() as i32, 12 | ..Default::default() 13 | } 14 | } 15 | 16 | pub fn utc_from_proto(x: &ProtoTimestamp) -> Result { 17 | time::Utc::from_unix_timestamp_nanos((x.seconds as i128 * 1_000_000_000) + (x.nanos as i128)) 18 | } 19 | -------------------------------------------------------------------------------- /chain/network/src/peer/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod peer_actor; 2 | mod stream; 3 | mod tracker; 4 | mod transfer_stats; 5 | 6 | #[cfg(test)] 7 | pub(crate) mod testonly; 8 | #[cfg(test)] 9 | mod tests; 10 | -------------------------------------------------------------------------------- /chain/network/src/peer/tests/mod.rs: -------------------------------------------------------------------------------- 1 | mod communication; 2 | mod stream; 3 | -------------------------------------------------------------------------------- /chain/network/src/peer_manager/connection_store/testonly.rs: -------------------------------------------------------------------------------- 1 | use crate::types::ConnectionInfo; 2 | 3 | impl super::ConnectionStore { 4 | pub(crate) fn insert_outbound_connections(&self, outbound: Vec) { 5 | self.0.update(|mut inner| { 6 | inner.push_front_outbound(outbound); 7 | ((), inner) 8 | }); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /chain/network/src/peer_manager/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod connection; 2 | pub(crate) mod connection_store; 3 | pub(crate) mod network_state; 4 | pub(crate) mod peer_manager_actor; 5 | pub(crate) mod peer_store; 6 | 7 | #[cfg(test)] 8 | pub(crate) mod testonly; 9 | 10 | #[cfg(test)] 11 | mod tests; 12 | -------------------------------------------------------------------------------- /chain/network/src/peer_manager/peer_store/testonly.rs: -------------------------------------------------------------------------------- 1 | use crate::types::KnownPeerState; 2 | 3 | impl super::PeerStore { 4 | pub fn dump(&self) -> Vec { 5 | self.0.lock().peer_states.iter().map(|(_, v)| v.clone()).collect() 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /chain/network/src/peer_manager/tests/mod.rs: -------------------------------------------------------------------------------- 1 | mod accounts_data; 2 | mod connection_pool; 3 | mod nonce; 4 | mod routing; 5 | mod snapshot_hosts; 6 | mod tier1; 7 | mod tier2; 8 | -------------------------------------------------------------------------------- /chain/network/src/private_actix.rs: -------------------------------------------------------------------------------- 1 | /// This file is contains all types used for communication between `Actors` within this crate. 2 | /// They are not meant to be used outside. 3 | use crate::network_protocol::PeerMessage; 4 | use crate::peer_manager::connection; 5 | use std::fmt::Debug; 6 | use std::sync::Arc; 7 | 8 | #[derive(Debug, Clone, PartialEq, Eq)] 9 | pub(crate) enum RegisterPeerError { 10 | Blacklisted, 11 | Banned, 12 | PoolError(connection::PoolError), 13 | ConnectionLimitExceeded, 14 | NotTier1Peer, 15 | Tier1InboundDisabled, 16 | InvalidEdge, 17 | } 18 | 19 | #[derive(actix::Message, Clone, Debug)] 20 | #[rtype(result = "()")] 21 | pub(crate) struct SendMessage { 22 | pub message: Arc, 23 | } 24 | -------------------------------------------------------------------------------- /chain/network/src/raw/mod.rs: -------------------------------------------------------------------------------- 1 | mod connection; 2 | 3 | pub use connection::{ConnectError, Connection, DirectMessage, Listener, Message, RoutedMessage}; 4 | 5 | #[cfg(test)] 6 | mod tests; 7 | -------------------------------------------------------------------------------- /chain/network/src/routing/mod.rs: -------------------------------------------------------------------------------- 1 | mod bfs; 2 | pub(crate) mod edge; 3 | mod edge_cache; 4 | mod graph; 5 | mod graph_v2; 6 | pub(crate) mod route_back_cache; 7 | pub mod routing_table_view; 8 | 9 | pub(crate) use graph::{DistanceTable, Graph, GraphConfig, NextHopTable}; 10 | pub(crate) use graph_v2::{GraphConfigV2, GraphV2, NetworkTopologyChange}; 11 | -------------------------------------------------------------------------------- /chain/network/src/shards_manager.rs: -------------------------------------------------------------------------------- 1 | use std::time::Instant; 2 | 3 | use actix::Message; 4 | use unc_primitives::{hash::CryptoHash, sharding::PartialEncodedChunk}; 5 | 6 | use crate::types::{ 7 | PartialEncodedChunkForwardMsg, PartialEncodedChunkRequestMsg, PartialEncodedChunkResponseMsg, 8 | }; 9 | 10 | #[derive(Message, Debug, strum::IntoStaticStr)] 11 | #[rtype(result = "()")] 12 | pub enum ShardsManagerRequestFromNetwork { 13 | ProcessPartialEncodedChunk(PartialEncodedChunk), 14 | ProcessPartialEncodedChunkForward(PartialEncodedChunkForwardMsg), 15 | ProcessPartialEncodedChunkResponse { 16 | partial_encoded_chunk_response: PartialEncodedChunkResponseMsg, 17 | received_time: Instant, 18 | }, 19 | ProcessPartialEncodedChunkRequest { 20 | partial_encoded_chunk_request: PartialEncodedChunkRequestMsg, 21 | route_back: CryptoHash, 22 | }, 23 | } 24 | -------------------------------------------------------------------------------- /chain/network/src/state_sync.rs: -------------------------------------------------------------------------------- 1 | use unc_store::ShardUId; 2 | 3 | /// State sync response from peers. 4 | #[derive(actix::Message, Debug)] 5 | #[rtype(result = "()")] 6 | pub enum StateSyncResponse { 7 | HeaderResponse, 8 | PartResponse, 9 | } 10 | 11 | /// A strongly typed asynchronous API for the State Sync logic 12 | /// It abstracts away the fact that it is implemented using actix 13 | /// actors. 14 | #[async_trait::async_trait] 15 | pub trait StateSync: Send + Sync + 'static { 16 | async fn send(&self, shard_uid: ShardUId, msg: StateSyncResponse); 17 | } 18 | -------------------------------------------------------------------------------- /chain/network/src/stats/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod metrics; 2 | -------------------------------------------------------------------------------- /chain/network/src/store/schema/testonly.rs: -------------------------------------------------------------------------------- 1 | use crate::store::schema::{Column, Error, Format}; 2 | 3 | impl super::Store { 4 | pub fn iter( 5 | &self, 6 | ) -> impl Iterator::T, ::T), Error>> + '_ 7 | { 8 | debug_assert!(!C::COL.is_rc()); 9 | self.0 10 | .iter_raw_bytes(C::COL) 11 | .map(|item| item.and_then(|(k, v)| Ok((C::Key::decode(&k)?, C::Value::decode(&v)?)))) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /chain/network/src/store/schema/tests.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use crate::network_protocol::testonly as data; 3 | use crate::testonly::make_rng; 4 | 5 | #[test] 6 | fn borsh_wrapper_is_transparent() { 7 | let mut rng = make_rng(423423); 8 | let rng = &mut rng; 9 | let s1 = data::make_secret_key(rng); 10 | let s2 = data::make_secret_key(rng); 11 | let e = data::make_edge(&s1, &s2, 1); 12 | assert_eq!(borsh::to_vec(&Borsh(e.clone())).unwrap(), borsh::to_vec(&e).unwrap()); 13 | } 14 | -------------------------------------------------------------------------------- /chain/network/src/stun/tests.rs: -------------------------------------------------------------------------------- 1 | use crate::stun; 2 | use unc_async::time; 3 | use unc_o11y::testonly::init_test_logger; 4 | 5 | #[tokio::test] 6 | async fn test_query() { 7 | init_test_logger(); 8 | let clock = time::FakeClock::default(); 9 | let server = stun::testonly::Server::new().await; 10 | let ip = stun::query(&clock.clock(), &server.addr()).await.unwrap(); 11 | assert_eq!(std::net::Ipv6Addr::LOCALHOST, ip); 12 | server.close().await; 13 | } 14 | -------------------------------------------------------------------------------- /chain/network/src/test_loop.rs: -------------------------------------------------------------------------------- 1 | use unc_primitives::types::AccountId; 2 | 3 | /// A multi-instance test using the TestLoop unc-infra.can support routing 4 | /// lookup for network messages, as long as the Data type contains AccountId. 5 | /// This trait is just a helper for looking up the index. 6 | pub trait SupportsRoutingLookup { 7 | fn index_for_account(&self, account: &AccountId) -> usize; 8 | } 9 | 10 | impl> SupportsRoutingLookup for Vec { 11 | fn index_for_account(&self, account: &AccountId) -> usize { 12 | self.iter() 13 | .position(|data| data.as_ref() == account) 14 | .unwrap_or_else(|| panic!("Account not found: {}", account)) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /chain/pool/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-pool" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | borsh.workspace = true 16 | once_cell.workspace = true 17 | rand.workspace = true 18 | 19 | unc-crypto.workspace = true 20 | unc-o11y.workspace = true 21 | unc-primitives.workspace = true 22 | 23 | [features] 24 | nightly = [ 25 | "nightly_protocol", 26 | "unc-o11y/nightly", 27 | "unc-primitives/nightly", 28 | ] 29 | nightly_protocol = [ 30 | "unc-o11y/nightly_protocol", 31 | "unc-primitives/nightly_protocol", 32 | ] 33 | -------------------------------------------------------------------------------- /chain/pool/README.md: -------------------------------------------------------------------------------- 1 | # unc-pool crate 2 | 3 | This crate holds TransactionPool (with PoolIterator), that is used to keep track of transactions that were not yet accepted into the blockchain. -------------------------------------------------------------------------------- /chain/pool/src/metrics.rs: -------------------------------------------------------------------------------- 1 | use once_cell::sync::Lazy; 2 | use unc_o11y::metrics::IntGaugeVec; 3 | 4 | pub static TRANSACTION_POOL_COUNT: Lazy = Lazy::new(|| { 5 | unc_o11y::metrics::try_create_int_gauge_vec( 6 | "unc_transaction_pool_entries", 7 | "Total number of transactions currently tracked by the node in a given shard pool", 8 | &["shard_id"], 9 | ) 10 | .unwrap() 11 | }); 12 | 13 | pub static TRANSACTION_POOL_SIZE: Lazy = Lazy::new(|| { 14 | unc_o11y::metrics::try_create_int_gauge_vec( 15 | "unc_transaction_pool_size", 16 | "Total size in bytes of transactions currently tracked by the node in a given shard pool", 17 | &["shard_id"], 18 | ) 19 | .unwrap() 20 | }); 21 | -------------------------------------------------------------------------------- /chain/telemetry/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-telemetry" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | actix.workspace = true 16 | awc.workspace = true 17 | futures.workspace = true 18 | once_cell.workspace = true 19 | openssl.workspace = true 20 | serde.workspace = true 21 | serde_json.workspace = true 22 | tracing.workspace = true 23 | 24 | unc-o11y.workspace = true 25 | unc-performance-metrics.workspace = true 26 | unc-performance-metrics-macros.workspace = true 27 | unc-primitives.workspace = true 28 | 29 | [features] 30 | nightly = [ 31 | "nightly_protocol", 32 | "unc-o11y/nightly", 33 | "unc-primitives/nightly", 34 | ] 35 | nightly_protocol = [ 36 | "unc-o11y/nightly_protocol", 37 | "unc-primitives/nightly_protocol", 38 | ] 39 | -------------------------------------------------------------------------------- /chain/telemetry/README.md: -------------------------------------------------------------------------------- 1 | # unc Telemetry 2 | 3 | A small utility (TelemetryActor), that tries to send the telemetry (metrics) information as JSON over HTTP-post to selected list of servers. 4 | Telemetry is sent from all the unc-infra.binaries (that enabled it in the config.json) - like validators, RPC nodes etc. 5 | 6 | The data that is sent over is of type TelemetryInfo, and is signed with the server's key. 7 | 8 | It contains info about the code (release version), server (cpu, memory and network speeds), and chain (node_id, status, peer connected, block height etc). 9 | 10 | TODO: add pointer to the code, that is used by the receiving server. 11 | -------------------------------------------------------------------------------- /chain/telemetry/src/metrics.rs: -------------------------------------------------------------------------------- 1 | use once_cell::sync::Lazy; 2 | 3 | pub(crate) static TELEMETRY_RESULT: Lazy = Lazy::new(|| { 4 | unc_o11y::metrics::try_create_int_counter_vec( 5 | "unc_telemetry_result", 6 | "Count of 'ok' or 'failed' results of uploading telemetry data", 7 | &["success"], 8 | ) 9 | .unwrap() 10 | }); 11 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | notify: 3 | after_n_builds: 10 # Keep in sync with .github/workflows/ci.yml 4 | 5 | coverage: 6 | status: 7 | project: 8 | default: 9 | target: auto 10 | threshold: 5% 11 | patch: 12 | default: false 13 | 14 | component_management: 15 | default_rules: 16 | paths: 17 | - "!debug_scripts/**" 18 | - "!docs/**" 19 | - "!genesis-tools/**" 20 | - "!nightly/**" 21 | - "!tools/**" 22 | statuses: 23 | - type: project 24 | target: auto 25 | threshold: 0.1% 26 | - type: patch 27 | target: auto 28 | individual_components: 29 | - component_id: unit-tests 30 | flag_regexes: ["unittests"] 31 | - component_id: all-tests 32 | -------------------------------------------------------------------------------- /core/async/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-async" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | description = "This crate contains the async helpers specific for unc-infra" 8 | repository.workspace = true 9 | license.workspace = true 10 | publish = false 11 | 12 | [lints] 13 | workspace = true 14 | 15 | [dependencies] 16 | actix.workspace = true 17 | derive-enum-from-into.workspace = true 18 | derive_more.workspace = true 19 | futures.workspace = true 20 | once_cell.workspace = true 21 | serde.workspace = true 22 | serde_json.workspace = true 23 | time.workspace = true 24 | tokio.workspace = true 25 | 26 | unc-primitives.workspace = true 27 | unc-o11y.workspace = true 28 | unc-performance-metrics.workspace = true 29 | 30 | [features] 31 | nightly = [ 32 | "nightly_protocol", 33 | "unc-o11y/nightly", 34 | "unc-primitives/nightly", 35 | ] 36 | nightly_protocol = [ 37 | "unc-o11y/nightly_protocol", 38 | "unc-primitives/nightly_protocol", 39 | ] 40 | -------------------------------------------------------------------------------- /core/async/src/examples/mod.rs: -------------------------------------------------------------------------------- 1 | mod async_component; 2 | mod async_component_test; 3 | mod multi_instance_test; 4 | mod sum_numbers; 5 | mod sum_numbers_test; 6 | mod timed_component; 7 | mod timed_component_test; 8 | -------------------------------------------------------------------------------- /core/async/src/examples/timed_component.rs: -------------------------------------------------------------------------------- 1 | use crate::messaging::Sender; 2 | 3 | pub(crate) struct TimedComponent { 4 | buffered_messages: Vec, 5 | message_sender: Sender>, 6 | } 7 | 8 | /// Mimics a component that has a specific function that is supposed to be 9 | /// triggered by a timer. 10 | impl TimedComponent { 11 | pub fn new(message_sender: Sender>) -> Self { 12 | Self { buffered_messages: vec![], message_sender } 13 | } 14 | 15 | pub fn send_message(&mut self, msg: String) { 16 | self.buffered_messages.push(msg); 17 | } 18 | 19 | /// This is supposed to be triggered by a timer so it flushes the 20 | /// messages every tick. 21 | pub fn flush(&mut self) { 22 | if self.buffered_messages.is_empty() { 23 | return; 24 | } 25 | self.message_sender.send(self.buffered_messages.clone()); 26 | self.buffered_messages.clear(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /core/async/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod actix; 2 | #[cfg(test)] 3 | mod examples; 4 | pub mod futures; 5 | pub mod messaging; 6 | pub mod test_loop; 7 | pub mod time; 8 | -------------------------------------------------------------------------------- /core/chain-configs/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2 -------------------------------------------------------------------------------- /core/chain-configs/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /core/chain-configs/README.md: -------------------------------------------------------------------------------- 1 | # Chain configs crate 2 | 3 | This crate provides typed interfaces to the UNC Genesis and Client Configs, together with the functions to validate their correctness. 4 | 5 | ## Genesis config 6 | Genesis config is the one that 'defines' the chain. It was set at the beginning and generally is not mutable. 7 | 8 | ## Client config 9 | 10 | Client config is the part of the config that client can configure on their own - it controls things like: how many peers it should connect to before syncing, which shards to track etc. 11 | 12 | ## Protocol config 13 | This is the type that is spanning over GenesisConfig and RuntimeConfig. People should not use it directly, but use the ProtocolConfigView class instead. -------------------------------------------------------------------------------- /core/chain-configs/src/metrics.rs: -------------------------------------------------------------------------------- 1 | use once_cell::sync::Lazy; 2 | use unc_o11y::metrics::{try_create_int_gauge_vec, IntGaugeVec}; 3 | 4 | pub static CONFIG_MUTABLE_FIELD: Lazy = Lazy::new(|| { 5 | try_create_int_gauge_vec( 6 | "unc_config_mutable_field", 7 | "Timestamp and value of a mutable config field", 8 | &["field_name", "timestamp", "value"], 9 | ) 10 | .unwrap() 11 | }); 12 | -------------------------------------------------------------------------------- /core/crypto/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2 -------------------------------------------------------------------------------- /core/crypto/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /core/crypto/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![deny(clippy::arithmetic_side_effects)] 2 | 3 | pub use errors::{ParseKeyError, ParseKeyTypeError, ParseSignatureError}; 4 | pub use key_file::KeyFile; 5 | pub use signature::{ 6 | ED25519PublicKey, ED25519SecretKey, KeyType, PublicKey, Rsa2048PublicKey, Rsa2048Signature, 7 | Secp256K1PublicKey, Secp256K1Signature, SecretKey, Signature, 8 | }; 9 | pub use signer::{EmptySigner, InMemorySigner, Signer}; 10 | 11 | #[macro_use] 12 | mod hash; 13 | #[macro_use] 14 | mod traits; 15 | #[macro_use] 16 | mod util; 17 | 18 | mod errors; 19 | pub mod key_conversion; 20 | mod key_file; 21 | mod signature; 22 | mod signer; 23 | mod test_utils; 24 | pub mod vrf; 25 | -------------------------------------------------------------------------------- /core/dyn-configs/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2 -------------------------------------------------------------------------------- /core/dyn-configs/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /core/dyn-configs/README.md: -------------------------------------------------------------------------------- 1 | Dynamic config helpers for the UNC codebase. 2 | 3 | This crate contains utilities that allow to reconfigure the node while it is running. 4 | 5 | ## How to: 6 | 7 | ### Logging and tracing 8 | 9 | Make changes to `log_config.json` and send `SIGHUP` signal to the `unc-node` process. 10 | 11 | ### Other config values 12 | 13 | Makes changes to `config.json` and send `SIGHUP` signal to the `unc-node` process. 14 | 15 | #### Fields of config that can be changed while the node is running: 16 | 17 | - `expected_shutdown`: the specified block height unc-node will gracefully shutdown at. 18 | 19 | #### Changing other fields of `config.json` 20 | 21 | The changes to other fields of `config.json` will be silently ignored as long as 22 | `config.json` remains a valid json object and passes internal validation. 23 | 24 | Please be careful about making changes to `config.json` because when a node 25 | starts (or restarts), it checks the validity of the config files and crashes if 26 | detects any issues. 27 | -------------------------------------------------------------------------------- /core/dyn-configs/src/metrics.rs: -------------------------------------------------------------------------------- 1 | use once_cell::sync::Lazy; 2 | use unc_o11y::metrics::{try_create_int_counter, try_create_int_gauge, IntCounter, IntGauge}; 3 | 4 | pub static CONFIG_RELOADS: Lazy = Lazy::new(|| { 5 | try_create_int_counter( 6 | "unc_config_reloads_total", 7 | "Number of times the configs were reloaded during the current run of the process", 8 | ) 9 | .unwrap() 10 | }); 11 | 12 | pub static CONFIG_RELOAD_TIMESTAMP: Lazy = Lazy::new(|| { 13 | try_create_int_gauge( 14 | "unc_config_reload_timestamp_seconds", 15 | "Timestamp of the last reload of the config", 16 | ) 17 | .unwrap() 18 | }); 19 | -------------------------------------------------------------------------------- /core/o11y/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2 -------------------------------------------------------------------------------- /core/o11y/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /core/o11y/README.md: -------------------------------------------------------------------------------- 1 | Observability (o11y) helpers for the Utility codebase. 2 | 3 | This crate contains all sorts of utilities to enable a more convenient observability implementation 4 | in the UNC codebase. 5 | 6 | The are three unc-infra.tructures: 7 | 8 | * `tracing`, for structured, hierarchical logging of events (see [`default_subscriber`] function function in particular) 9 | * `metrics` -- convenience wrappers around prometheus metric, for reporting statistics. 10 | * `io-tracer` -- custom unc-infra.tructure for observing DB accesses in particular (mostly for parameter estimator) 11 | -------------------------------------------------------------------------------- /core/o11y/src/context.rs: -------------------------------------------------------------------------------- 1 | use tracing::Span; 2 | use tracing_opentelemetry::OpenTelemetrySpanExt; 3 | 4 | /// Wraps an actix message with the current Span's context. 5 | /// This lets us trace execution across several actix Actors. 6 | #[derive(actix::Message, Debug)] 7 | #[rtype(result = "::Result")] 8 | pub struct WithSpanContext { 9 | pub msg: T, 10 | pub context: opentelemetry::Context, 11 | } 12 | 13 | impl WithSpanContext { 14 | pub fn new(msg: T) -> Self { 15 | Self { msg, context: Span::current().context() } 16 | } 17 | } 18 | 19 | /// Allows easily attaching the current span's context to a Message. 20 | pub trait WithSpanContextExt: actix::Message { 21 | fn with_span_context(self) -> WithSpanContext 22 | where 23 | Self: Sized, 24 | { 25 | WithSpanContext::::new(self) 26 | } 27 | } 28 | impl WithSpanContextExt for T {} 29 | -------------------------------------------------------------------------------- /core/o11y/src/log_config.rs: -------------------------------------------------------------------------------- 1 | use crate::OpenTelemetryLevel; 2 | use serde::{Deserialize, Serialize}; 3 | use std::path::Path; 4 | use std::{fs::File, io::Write}; 5 | 6 | /// Configures logging. 7 | #[derive(Default, Serialize, Deserialize, Clone, Debug)] 8 | pub struct LogConfig { 9 | /// Comma-separated list of EnvFitler directives. 10 | pub rust_log: Option, 11 | /// Some("") enables global debug logging. 12 | /// Some("module") enables debug logging for "module". 13 | pub verbose_module: Option, 14 | /// Verbosity level of collected traces. 15 | pub opentelemetry_level: Option, 16 | } 17 | 18 | impl LogConfig { 19 | pub fn write_to_file(&self, path: &Path) -> std::io::Result<()> { 20 | let mut file = File::create(path)?; 21 | let str = serde_json::to_string_pretty(self)?; 22 | file.write_all(str.as_bytes()) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/parameters/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2 -------------------------------------------------------------------------------- /core/parameters/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /core/parameters/res/runtime_configs/129.yaml: -------------------------------------------------------------------------------- 1 | fix_contract_loading_cost: { old: false, new: true } 2 | -------------------------------------------------------------------------------- /core/parameters/res/runtime_configs/138.yaml: -------------------------------------------------------------------------------- 1 | eth_accounts: { old: false, new: true } 2 | -------------------------------------------------------------------------------- /core/parameters/res/runtime_configs/35.yaml: -------------------------------------------------------------------------------- 1 | implicit_account_creation: { old: false, new: true } 2 | -------------------------------------------------------------------------------- /core/parameters/res/runtime_configs/42.yaml: -------------------------------------------------------------------------------- 1 | storage_amount_per_byte: { old: 100_000_000_000_000_000_000, new: 10_000_000_000_000_000_000 } 2 | -------------------------------------------------------------------------------- /core/parameters/res/runtime_configs/46.yaml: -------------------------------------------------------------------------------- 1 | math_extension: { old: false, new: true } 2 | -------------------------------------------------------------------------------- /core/parameters/res/runtime_configs/48.yaml: -------------------------------------------------------------------------------- 1 | wasm_regular_op_cost: { old: 3_856_371, new: 2_207_874 } 2 | wasm_ecrecover_base: { old: 3_365_369_625_000, new: 278_821_988_457 } 3 | data_receipt_creation_base: { 4 | old: { 5 | send_sir: 4_697_339_419_375, 6 | send_not_sir: 4_697_339_419_375, 7 | execution: 4_697_339_419_375, 8 | }, 9 | new: { 10 | send_sir: 36_486_732_312, 11 | send_not_sir: 36_486_732_312, 12 | execution: 36_486_732_312, 13 | }, 14 | } 15 | 16 | data_receipt_creation_per_byte: { 17 | old: { 18 | send_sir: 59_357_464, 19 | send_not_sir: 59_357_464, 20 | execution: 59_357_464, 21 | }, 22 | new: { 23 | send_sir: 17_212_011, 24 | send_not_sir: 17_212_011, 25 | execution: 17_212_011, 26 | }, 27 | } 28 | vm_kind: { old: Wasmer0, new: Wasmer2 } 29 | -------------------------------------------------------------------------------- /core/parameters/res/runtime_configs/49.yaml: -------------------------------------------------------------------------------- 1 | wasm_regular_op_cost: { old: 2_207_874, new: 822_756 } 2 | max_functions_number_per_contract: { new: 10_000 } 3 | -------------------------------------------------------------------------------- /core/parameters/res/runtime_configs/50.yaml: -------------------------------------------------------------------------------- 1 | contract_prepare_version: { old: 0, new: 1 } 2 | -------------------------------------------------------------------------------- /core/parameters/res/runtime_configs/52.yaml: -------------------------------------------------------------------------------- 1 | max_gas_burnt: { old: 200_000_000_000_000, new: 300_000_000_000_000 } 2 | max_gas_burnt_view: { old: 200_000_000_000_000, new: 300_000_000_000_000 } 3 | -------------------------------------------------------------------------------- /core/parameters/res/runtime_configs/53.yaml: -------------------------------------------------------------------------------- 1 | action_deploy_contract_per_byte: { 2 | old: { 3 | send_sir: 6_812_999, 4 | send_not_sir: 6_812_999, 5 | execution: 6_812_999, 6 | }, 7 | new: { 8 | send_sir: 6_812_999, 9 | send_not_sir: 6_812_999, 10 | execution: 64_572_944, 11 | }, 12 | } 13 | wasmer2_stack_limit: { new: 204_800 } 14 | max_length_storage_key: { old: 4_194_304, new: 2_048 } 15 | max_locals_per_contract: { new: 1_000_000 } 16 | function_call_weight: { old: false, new: true } 17 | -------------------------------------------------------------------------------- /core/parameters/res/runtime_configs/55.yaml: -------------------------------------------------------------------------------- 1 | alt_bn128: { old: false, new: true } 2 | -------------------------------------------------------------------------------- /core/parameters/res/runtime_configs/57.yaml: -------------------------------------------------------------------------------- 1 | account_id_validity_rules_version: { old: 0, new: 1 } 2 | -------------------------------------------------------------------------------- /core/parameters/res/runtime_configs/59.yaml: -------------------------------------------------------------------------------- 1 | ed25519_verify: { old: false, new: true } 2 | action_create_account: { 3 | old: { 4 | send_sir: 99_607_375_000, 5 | send_not_sir: 99_607_375_000, 6 | execution: 99_607_375_000, 7 | }, 8 | new: { 9 | send_sir: 3_850_000_000_000, 10 | send_not_sir: 3_850_000_000_000, 11 | execution: 3_850_000_000_000, 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/parameters/res/runtime_configs/61.yaml: -------------------------------------------------------------------------------- 1 | # Compute costs to allow for flat storage read-only MVP. 2 | # See https://github.com/utnet-org/utility/issues/8006 3 | wasm_touching_trie_node: { old: 16_101_955_926, new: { gas: 16_101_955_926, compute: 110_000_000_000 } } 4 | wasm_storage_write_base: { old: 64_196_736_000, new: { gas: 64_196_736_000, compute: 200_000_000_000 } } 5 | wasm_storage_remove_base: { old: 53_473_030_500, new: { gas: 53_473_030_500, compute: 200_000_000_000 } } 6 | wasm_storage_read_base: { old: 56_356_845_750, new: { gas: 56_356_845_750, compute: 200_000_000_000 } } 7 | wasm_storage_has_key_base: { old: 54_039_896_625, new: { gas: 54_039_896_625, compute: 200_000_000_000 } } 8 | flat_storage_reads: { old: false, new: true } 9 | -------------------------------------------------------------------------------- /core/parameters/res/runtime_configs/62.yaml: -------------------------------------------------------------------------------- 1 | # Finite-wasm counts in bytes, parity-wasm was counting in stack slots, so there’s a factor of at 2 | # least 8. Plus some additional slack for the new algorithm potentially being more accurate or 3 | # correct. 4 | max_stack_height: { old: 16384, new: 262144 } 5 | contract_prepare_version: { old: 1, new: 2 } 6 | 7 | # There was a bug for a short period of time that we need to reproduce... 8 | disable_9393_fix: { old: false, new: true } 9 | vm_kind: { old: Wasmer2, new: UncVm } 10 | -------------------------------------------------------------------------------- /core/parameters/res/runtime_configs/63.yaml: -------------------------------------------------------------------------------- 1 | disable_9393_fix: { old: true, new: false } 2 | -------------------------------------------------------------------------------- /core/parameters/res/runtime_configs/64.yaml: -------------------------------------------------------------------------------- 1 | # disallowing all top-level accounts. 2 | min_allowed_top_level_account_length: { old: 0, new: 0 } -------------------------------------------------------------------------------- /core/parameters/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod config; 2 | pub mod config_store; 3 | pub mod cost; 4 | pub mod parameter; 5 | pub mod parameter_table; 6 | pub mod view; 7 | pub mod vm; 8 | 9 | pub use config::{AccountCreationConfig, RuntimeConfig}; 10 | pub use config_store::RuntimeConfigStore; 11 | pub use cost::{ 12 | transfer_exec_fee, transfer_send_fee, ActionCosts, ExtCosts, ExtCostsConfig, Fee, 13 | ParameterCost, RuntimeFeesConfig, StorageUsageConfig, 14 | }; 15 | pub use parameter::Parameter; 16 | pub use view::{RuntimeConfigView, RuntimeFeesConfigView}; 17 | -------------------------------------------------------------------------------- /core/primitives-core/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2 -------------------------------------------------------------------------------- /core/primitives-core/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /core/primitives-core/src/chains.rs: -------------------------------------------------------------------------------- 1 | /// Chain IDs of commonly used environment. 2 | 3 | /// Main production environment. 4 | pub const MAINNET: &str = "mainnet"; 5 | 6 | /// Primary testing environment. 7 | pub const TESTNET: &str = "testnet"; 8 | -------------------------------------------------------------------------------- /core/primitives-core/src/config.rs: -------------------------------------------------------------------------------- 1 | use crate::types::Gas; 2 | use std::hash::Hash; 3 | 4 | #[derive( 5 | Debug, 6 | Clone, 7 | Copy, 8 | Hash, 9 | PartialEq, 10 | Eq, 11 | serde_repr::Serialize_repr, 12 | serde_repr::Deserialize_repr, 13 | )] 14 | #[repr(u8)] 15 | pub enum AccountIdValidityRulesVersion { 16 | /// Skip account ID validation according to legacy rules. 17 | V0, 18 | /// Limit `receiver_id` in `FunctionCallPermission` to be a valid account ID. 19 | V1, 20 | } 21 | 22 | impl AccountIdValidityRulesVersion { 23 | pub fn v0() -> AccountIdValidityRulesVersion { 24 | AccountIdValidityRulesVersion::V0 25 | } 26 | } 27 | 28 | /// Configuration of view methods execution, during which no costs should be charged. 29 | #[derive(Default, Clone, serde::Serialize, serde::Deserialize, Debug, Hash, PartialEq, Eq)] 30 | pub struct ViewConfig { 31 | /// If specified, defines max burnt gas per view method. 32 | pub max_gas_burnt: Gas, 33 | } 34 | -------------------------------------------------------------------------------- /core/primitives-core/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub use borsh; 2 | pub use num_rational; 3 | 4 | pub mod account; 5 | pub mod chains; 6 | pub mod config; 7 | pub mod hash; 8 | pub mod serialize; 9 | pub mod types; 10 | pub mod version; 11 | 12 | pub use enum_map; 13 | -------------------------------------------------------------------------------- /core/primitives/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2 -------------------------------------------------------------------------------- /core/primitives/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /core/primitives/src/runtime/migration_data.rs: -------------------------------------------------------------------------------- 1 | use crate::receipt::ReceiptResult; 2 | use crate::types::AccountId; 3 | use crate::types::Gas; 4 | use std::fmt; 5 | use std::fmt::{Debug, Formatter}; 6 | 7 | #[derive(Default)] 8 | pub struct MigrationData { 9 | pub storage_usage_delta: Vec<(AccountId, u64)>, 10 | pub storage_usage_fix_gas: Gas, 11 | pub restored_receipts: ReceiptResult, 12 | } 13 | 14 | impl Debug for MigrationData { 15 | fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { 16 | f.debug_struct("MigrationData").finish() 17 | } 18 | } 19 | 20 | #[derive(Debug, Default)] 21 | pub struct MigrationFlags { 22 | // True iff the current block is the first one in the chain with current protocol version 23 | pub is_first_block_of_version: bool, 24 | // True iff, among all blocks containing chunk for some specific shard, the current block is the 25 | // first one in the first epoch with the current protocol version 26 | pub is_first_block_with_chunk_of_version: bool, 27 | } 28 | -------------------------------------------------------------------------------- /core/primitives/src/runtime/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod apply_state; 2 | pub mod migration_data; 3 | -------------------------------------------------------------------------------- /core/primitives/src/snapshots/unc_primitives__views__tests__exec_metadata_v1_view.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: core/primitives/src/views.rs 3 | expression: view 4 | --- 5 | { 6 | "version": 1, 7 | "gas_profile": null 8 | } 9 | -------------------------------------------------------------------------------- /core/primitives/src/state_part.rs: -------------------------------------------------------------------------------- 1 | // to specify a part we always specify both part_id and num_parts together 2 | #[derive(Copy, Clone, Debug)] 3 | pub struct PartId { 4 | pub idx: u64, 5 | pub total: u64, 6 | } 7 | impl PartId { 8 | pub fn new(part_id: u64, num_parts: u64) -> PartId { 9 | assert!(part_id < num_parts); 10 | PartId { idx: part_id, total: num_parts } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/store/src/genesis/mod.rs: -------------------------------------------------------------------------------- 1 | //! This module contains helper functions for initialization of genesis data in store 2 | //! We first check if store has the genesis hash and state_roots, if not, we go ahead with initialization 3 | 4 | mod initialization; 5 | mod state_applier; 6 | 7 | pub use initialization::initialize_genesis_state; 8 | pub use state_applier::compute_genesis_storage_usage; 9 | pub use state_applier::compute_storage_usage; 10 | pub use state_applier::GenesisStateApplier; 11 | -------------------------------------------------------------------------------- /docs/architecture/next/README.md: -------------------------------------------------------------------------------- 1 | # How unc-node will work 2 | The documents under this chapter are talking about the future of UNC - what we're planning on improving and how. 3 | 4 | (This also means that they can get out of date quickly :-). 5 | 6 | If you have comments, suggestions or want to help us designing and implementing some of these things here - please reach out on Zulip or github. 7 | -------------------------------------------------------------------------------- /docs/architecture/storage.md: -------------------------------------------------------------------------------- 1 | # Storage 2 | 3 | This is our work-in-progress storage documentation. Things are raw and 4 | incomplete. You are encouraged to help improve it, in any capacity you can! -------------------------------------------------------------------------------- /docs/architecture/storage/flow.md: -------------------------------------------------------------------------------- 1 | # Read and Write Flow for Storage Requests 2 | 3 | The storage subsystem of unc-infra.is complex and has many layers. Here we 4 | present the flow of a single read or write request from the transaction runtime 5 | all the way to the OS. As you can see, there are many layers of read-caching and 6 | write-buffering involved. 7 | 8 | 9 | ![Diagram with read and write request flow](https://user-images.githubusercontent.com/6342444/215088748-028b754f-16be-4f56-9edd-6ce58ff1c9ef.svg) -------------------------------------------------------------------------------- /docs/book.toml: -------------------------------------------------------------------------------- 1 | [book] 2 | language = "en" 3 | multilingual = false 4 | src = "." 5 | title = "Guide to Utility Development" 6 | 7 | [build] 8 | # Let's re-use the existing target dir for all build artifacts. 9 | build-dir = "../target/book" 10 | 11 | [output.html] 12 | git-repository-url = "https://github.com/utnet-org/utility/tree/master/docs" 13 | edit-url-template = "https://github.com/utnet-org/utility/edit/master/docs/{path}" 14 | -------------------------------------------------------------------------------- /docs/images/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/docs/images/logo.gif -------------------------------------------------------------------------------- /docs/practices/README.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | This chapter describes various development processes and best practices employed 4 | at unc-infra. 5 | -------------------------------------------------------------------------------- /docs/practices/workflows/README.md: -------------------------------------------------------------------------------- 1 | # Workflows 2 | 3 | This chapter documents various ways you can run `unc-node` during development: 4 | running a local net, joining a test net, doing benchmarking and load testing. 5 | -------------------------------------------------------------------------------- /genesis-tools/genesis-csv-to-json/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "genesis-csv-to-json" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | chrono.workspace = true 16 | clap.workspace = true 17 | csv.workspace = true 18 | serde.workspace = true 19 | 20 | unc-infra.workspace = true 21 | unc-chain-configs.workspace = true 22 | unc-crypto.workspace = true 23 | unc-primitives.workspace = true 24 | unc-network.workspace = true 25 | 26 | [dev-dependencies] 27 | tempfile.workspace = true 28 | serde_json.workspace = true 29 | serde.workspace = true 30 | -------------------------------------------------------------------------------- /genesis-tools/genesis-csv-to-json/res/test_accounts.csv: -------------------------------------------------------------------------------- 1 | genesis_time,account_id,regular_pks,privileged_pks,foundation_pks,full_pks,amount,is_treasury,validator_stake,validator_key,peer_info,smart_contract,lockup,vesting_start,vesting_end,vesting_cliff 2 | 2019-12-21T23:00:00Z,alice_unc,"ed25519:11111111111111111111111111111111,ed25519:11111111111111111111111111111111",ed25519:11111111111111111111111111111111,ed25519:11111111111111111111111111111111,,1000,false,100,ed25519:11111111111111111111111111111111,ed25519:11111111111111111111111111111111@127.0.0.1:8080,,2019-12-21T23:00:00Z,2019-12-21T22:00:00Z,2019-12-21T23:30:00Z,2019-12-21T22:30:20Z 3 | ,bob_unc,,ed25519:11111111111111111111111111111111,ed25519:11111111111111111111111111111111,,2000,true,0,,,,2019-12-21T23:00:00Z,,, 4 | -------------------------------------------------------------------------------- /genesis-tools/keypair-generator/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "keypair-generator" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | clap.workspace = true 16 | 17 | unc-infra.workspace = true 18 | unc-crypto.workspace = true 19 | -------------------------------------------------------------------------------- /infra/src/append_only_map.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | use std::hash::Hash; 3 | use std::sync::{Arc, RwLock}; 4 | 5 | const POISONED_LOCK_ERR: &str = "The lock was poisoned."; 6 | 7 | pub struct AppendOnlyMap { 8 | map: RwLock>>, 9 | } 10 | 11 | impl AppendOnlyMap 12 | where 13 | K: Eq + Hash + Clone, 14 | { 15 | pub fn new() -> Self { 16 | Self { map: RwLock::new(HashMap::new()) } 17 | } 18 | 19 | pub fn get_or_insert V>(&self, key: &K, value: F) -> Arc { 20 | let mut map = self.map.write().expect(POISONED_LOCK_ERR); 21 | if !map.contains_key(key) { 22 | map.insert(key.clone(), Arc::new(value())); 23 | } 24 | map.get(key).unwrap().clone() 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /integration-tests/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod genesis_helpers; 2 | pub mod node; 3 | pub mod runtime_utils; 4 | pub mod test_helpers; 5 | pub mod unc_utils; 6 | pub mod user; 7 | 8 | #[cfg(test)] 9 | mod tests; 10 | -------------------------------------------------------------------------------- /integration-tests/src/tests/framework/mod.rs: -------------------------------------------------------------------------------- 1 | mod node_cluster; 2 | mod pledge_nodes; 3 | mod rpc_error_structs; 4 | mod rpc_nodes; 5 | mod run_nodes; 6 | mod sync_nodes; 7 | mod track_shards; 8 | -------------------------------------------------------------------------------- /integration-tests/src/tests/mod.rs: -------------------------------------------------------------------------------- 1 | mod client; 2 | mod framework; 3 | mod network; 4 | mod runtime; 5 | mod standard_cases; 6 | mod test_catchup; 7 | mod test_errors; 8 | mod test_overflows; 9 | mod test_simple; 10 | mod test_tps_regression; 11 | -------------------------------------------------------------------------------- /integration-tests/src/tests/network/mod.rs: -------------------------------------------------------------------------------- 1 | mod churn_attack; 2 | mod full_network; 3 | mod peer_handshake; 4 | mod runner; 5 | mod stress_network; 6 | -------------------------------------------------------------------------------- /integration-tests/src/tests/runtime/mod.rs: -------------------------------------------------------------------------------- 1 | mod deployment; 2 | mod sanity_checks; 3 | mod state_viewer; 4 | mod test_evil_contracts; 5 | -------------------------------------------------------------------------------- /integration-tests/src/tests/runtime/snapshots/integration_tests__tests__runtime__sanity_checks__receipts_gas_profile_nondeterministic.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: integration-tests/src/tests/runtime/sanity_checks.rs 3 | expression: receipts_gas_profile 4 | --- 5 | [ 6 | [ 7 | CostGasUsed { 8 | cost_category: "WASM_HOST_COST", 9 | cost: "CONTRACT_LOADING_BASE", 10 | gas_used: 35445963, 11 | }, 12 | CostGasUsed { 13 | cost_category: "WASM_HOST_COST", 14 | cost: "CONTRACT_LOADING_BYTES", 15 | gas_used: 8236500, 16 | }, 17 | CostGasUsed { 18 | cost_category: "WASM_HOST_COST", 19 | cost: "WASM_INSTRUCTION", 20 | gas_used: 8227560, 21 | }, 22 | ], 23 | [], 24 | ] 25 | -------------------------------------------------------------------------------- /integration-tests/src/tests/runtime/snapshots/integration_tests__tests__runtime__sanity_checks__receipts_gas_profile_nondeterministic_nightly.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: integration-tests/src/tests/runtime/sanity_checks.rs 3 | expression: receipts_gas_profile 4 | --- 5 | [ 6 | [ 7 | CostGasUsed { 8 | cost_category: "WASM_HOST_COST", 9 | cost: "CONTRACT_LOADING_BASE", 10 | gas_used: 35445963, 11 | }, 12 | CostGasUsed { 13 | cost_category: "WASM_HOST_COST", 14 | cost: "CONTRACT_LOADING_BYTES", 15 | gas_used: 8236500, 16 | }, 17 | CostGasUsed { 18 | cost_category: "WASM_HOST_COST", 19 | cost: "WASM_INSTRUCTION", 20 | gas_used: 8227560, 21 | }, 22 | ], 23 | [], 24 | ] 25 | -------------------------------------------------------------------------------- /integration-tests/src/tests/runtime/snapshots/integration_tests__tests__runtime__sanity_checks__receipts_status_nondeterministic.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: integration-tests/src/tests/runtime/sanity_checks.rs 3 | expression: receipts_status 4 | 5 | --- 6 | - SuccessValue: "" 7 | - SuccessValue: "" 8 | 9 | -------------------------------------------------------------------------------- /integration-tests/src/tests/test_overflows.rs: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn test_overflow() { 3 | let a = u64::MAX; 4 | let b = 5u64; 5 | std::panic::catch_unwind(move || { 6 | let c = u128::from(a + b); 7 | println!("{} + {} = {}", a, b, c); 8 | }) 9 | .unwrap_err(); 10 | } 11 | 12 | #[test] 13 | fn test_underflow() { 14 | let a = 10u64; 15 | let b = 5u64; 16 | std::panic::catch_unwind(move || { 17 | let c = u128::from(b - a); 18 | println!("{} - {} = {}", b, a, c); 19 | }) 20 | .unwrap_err(); 21 | } 22 | -------------------------------------------------------------------------------- /lychee.toml: -------------------------------------------------------------------------------- 1 | exclude = [ 2 | # these are private repositories, presumably any link to it are in internal documentation only. 3 | "^https://github.com/utnet-org/utility-private", 4 | 5 | # localhost is linked to refer to services supposed to be running on the host. 6 | "^http://localhost", 7 | 8 | # jsonrpc internal links 9 | "^file://.*/chain/jsonrpc/res/debug/", 10 | 11 | # used as placeholders for a template 12 | "^https://github.com/utnet-org/utility/pull/XXXX$", 13 | ] 14 | -------------------------------------------------------------------------------- /pytest/Pipfile: -------------------------------------------------------------------------------- 1 | [[source]] 2 | url = "https://pypi.org/simple" 3 | verify_ssl = true 4 | name = "pypi" 5 | 6 | [packages] 7 | pygithub = "*" 8 | base58 = "*" 9 | cython = "*" 10 | deepdiff = "*" 11 | ed25519 = "*" 12 | numpy = "*" 13 | prometheus-client = "*" 14 | psutil = "*" 15 | pynacl = "*" 16 | python-rc = "==0.3.9" 17 | requests = "*" 18 | retrying = "*" 19 | scikit-learn = "*" 20 | scipy = "*" 21 | semver = "*" 22 | toml = "*" 23 | tqdm = "*" 24 | urllib3 = "<2" 25 | 26 | [dev-packages] 27 | 28 | [requires] 29 | python_version = "3.12" 30 | -------------------------------------------------------------------------------- /pytest/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/pytest/__init__.py -------------------------------------------------------------------------------- /pytest/debug_scripts/Pipfile: -------------------------------------------------------------------------------- 1 | [[source]] 2 | url = "https://pypi.org/simple" 3 | verify_ssl = true 4 | name = "pypi" 5 | 6 | [packages] 7 | boto3 = "==1.21.34" 8 | requests = "==2.31.0" 9 | 10 | [dev-packages] 11 | 12 | [requires] 13 | python_version = "3" 14 | -------------------------------------------------------------------------------- /pytest/debug_scripts/READEME.md: -------------------------------------------------------------------------------- 1 | # Debug Scripts 2 | 3 | ## Content 4 | 5 | * request_chain_info.py 6 | 7 | This script can be used to request blockchain info 8 | 9 | * send_validator_logs.py 10 | 11 | This script can be used to send Validator logs to a S3 bucket when issues are encountered. The core team can use the logs to help the validators troubleshoot issues. 12 | 13 | ## Instruction to run test 14 | 15 | Add debug_scripts to your PYTHONPATH 16 | 17 | ```sh 18 | export PYTHONPATH="/debug_scripts:$PYTHONPATH" 19 | ``` 20 | 21 | ```sh 22 | cd /debug_scripts 23 | python3 -m pip install pipenv 24 | pipenv install 25 | python3 -m pipenv shell 26 | python3 -m pipenv sync 27 | 28 | python3 send_validator_logs.py --help 29 | OR 30 | python3 request_chain_info.py --help 31 | 32 | python3 -m unittest tests.send_validator_logs_test 33 | ``` 34 | -------------------------------------------------------------------------------- /pytest/debug_scripts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/pytest/debug_scripts/__init__.py -------------------------------------------------------------------------------- /pytest/debug_scripts/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/pytest/debug_scripts/tests/__init__.py -------------------------------------------------------------------------------- /pytest/debug_scripts/tests/send_validator_logs_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import datetime 3 | import io 4 | import sys 5 | from send_validator_logs import filter_log_file 6 | 7 | 8 | class test_validator_log_filtering(unittest.TestCase): 9 | 10 | def test_time_filtering(self): 11 | start_time = datetime.datetime(2024, 4, 4, 23, 42, 0, 0) 12 | end_time = datetime.datetime(2024, 4, 4, 23, 49, 0, 0) 13 | output_file_obj = filter_log_file("./tests/data/node0.logs", 14 | start_time=start_time, 15 | end_time=end_time) 16 | self.assertIsInstance( 17 | output_file_obj, list, 18 | "Parsed file object should be of type io.BytesIO") 19 | self.assertEqual(len(output_file_obj), 48, 20 | "Filtered log should have 48 lines") 21 | 22 | 23 | if __name__ == '__main__': 24 | unittest.main() 25 | -------------------------------------------------------------------------------- /pytest/endtoend/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/pytest/endtoend/__init__.py -------------------------------------------------------------------------------- /pytest/lib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/pytest/lib/__init__.py -------------------------------------------------------------------------------- /pytest/lib/messages/__init__.py: -------------------------------------------------------------------------------- 1 | from .block import block_schema 2 | from .bridge import bridge_schema 3 | from .crypto import crypto_schema 4 | from .network import network_schema 5 | from .shard import shard_schema 6 | from .tx import tx_schema 7 | 8 | schema = dict(block_schema + bridge_schema + crypto_schema + network_schema + 9 | shard_schema + tx_schema) 10 | -------------------------------------------------------------------------------- /pytest/lib/messages/bridge.py: -------------------------------------------------------------------------------- 1 | class Proof: 2 | pass 3 | 4 | 5 | bridge_schema = [[ 6 | Proof, { 7 | 'kind': 8 | 'struct', 9 | 'fields': [ 10 | ['log_index', 'u64'], 11 | ['log_entry_data', ['u8']], 12 | ['receipt_index', 'u64'], 13 | ['receipt_data', ['u8']], 14 | ['header_data', ['u8']], 15 | ['proof', [['u8']]], 16 | ] 17 | } 18 | ]] 19 | -------------------------------------------------------------------------------- /pytest/lib/messages/shard.py: -------------------------------------------------------------------------------- 1 | class StateRootNode: 2 | pass 3 | 4 | 5 | shard_schema = [[ 6 | StateRootNode, { 7 | 'kind': 'struct', 8 | 'fields': [['data', ['u8']], ['memory_usage', 'u64']] 9 | } 10 | ]] 11 | -------------------------------------------------------------------------------- /pytest/lib/populate.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | from os.path import join 3 | from shutil import copy2, rmtree 4 | 5 | 6 | def genesis_populate(unc_root, additional_accounts, node_dir): 7 | subprocess.check_call( 8 | (join(unc_root, 'genesis-populate'), '--additional-accounts-num', 9 | str(additional_accounts), '--home', node_dir)) 10 | rmtree(join(node_dir, 'data'), ignore_errors=True) 11 | 12 | 13 | def copy_genesis(node_dir_source, node_dir_target): 14 | for file_name in ['genesis.json', 'genesis_roots', 'state_dump']: 15 | source_file = join(node_dir_source, file_name) 16 | target_file = join(node_dir_target, file_name) 17 | copy2(source_file, target_file) 18 | 19 | 20 | def genesis_populate_all(unc_root, additional_accounts, node_dirs): 21 | genesis_populate(unc_root, additional_accounts, node_dirs[0]) 22 | for node_dir in node_dirs[1:]: 23 | copy_genesis(node_dirs[0], node_dir) 24 | rmtree(join(node_dir, 'data'), ignore_errors=True) 25 | -------------------------------------------------------------------------------- /pytest/remote.json: -------------------------------------------------------------------------------- 1 | { 2 | "local": true, 3 | "unc_root": "../target/debug/", 4 | "remote": { 5 | "instance_name": "unc-pytest", 6 | "binary": "unc-node", 7 | "zones": [ 8 | "" 9 | ] 10 | } 11 | } -------------------------------------------------------------------------------- /pytest/requirements.txt: -------------------------------------------------------------------------------- 1 | PyGithub 2 | base58 3 | cython 4 | deepdiff 5 | ed25519==1.3 6 | numpy 7 | prometheus-client 8 | psutil 9 | pynacl 10 | python-rc==0.3.9 11 | requests 12 | retrying 13 | scikit-learn 14 | scipy 15 | semver 16 | toml 17 | tqdm 18 | urllib3<2 19 | boto3 20 | locust 21 | -------------------------------------------------------------------------------- /pytest/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/pytest/tests/__init__.py -------------------------------------------------------------------------------- /pytest/tests/loadtest/contract/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "loadtest-contract" 3 | version = "0.1.0" 4 | authors = ["Hello Inc "] 5 | edition = "2018" 6 | 7 | [lints] 8 | 9 | [workspace] 10 | members = [] 11 | 12 | 13 | [lib] 14 | crate-type = ["cdylib", "rlib"] 15 | 16 | [dependencies] 17 | unc-sdk = "0.7.4" 18 | 19 | [dev-dependencies] 20 | borsh = { version = "1.4.0"} 21 | 22 | [profile.release] 23 | codegen-units = 1 24 | # Tell `rustc` to optimize for small code size. 25 | opt-level = "z" 26 | lto = true 27 | debug = false 28 | panic = "abort" 29 | # Opt into extra safety checks on arithmetic operations https://stackoverflow.com/a/64136471/249801 30 | overflow-checks = true 31 | -------------------------------------------------------------------------------- /pytest/tests/loadtest/contract/build.sh: -------------------------------------------------------------------------------- 1 | cargo build --target wasm32-unknown-unknown --release 2 | -------------------------------------------------------------------------------- /pytest/tests/loadtest/locust/res/congestion.wasm: -------------------------------------------------------------------------------- 1 | ../../../../../runtime/near-test-contracts/res/backwards_compatible_rs_contract.wasm -------------------------------------------------------------------------------- /pytest/tests/loadtest/locust/res/fungible_token.wasm: -------------------------------------------------------------------------------- 1 | ../../../../../runtime/near-test-contracts/res/fungible_token.wasm -------------------------------------------------------------------------------- /pytest/tests/loadtest/locust/res/social_db.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/pytest/tests/loadtest/locust/res/social_db.wasm -------------------------------------------------------------------------------- /pytest/tools/mirror/contract/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "addkey-contract" 3 | version = "0.1.0" 4 | authors = ["Hello Inc "] 5 | edition = "2018" 6 | 7 | [workspace] 8 | members = [] 9 | 10 | 11 | [lib] 12 | crate-type = ["cdylib", "rlib"] 13 | 14 | [dependencies] 15 | unc-sdk = "0.7.4" 16 | 17 | [dev-dependencies] 18 | borsh = { version = "1.4.0"} 19 | 20 | [profile.release] 21 | codegen-units = 1 22 | # Tell `rustc` to optimize for small code size. 23 | opt-level = "z" 24 | lto = true 25 | debug = false 26 | panic = "abort" 27 | # Opt into extra safety checks on arithmetic operations https://stackoverflow.com/a/64136471/249801 28 | overflow-checks = true 29 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/.gitignore: -------------------------------------------------------------------------------- 1 | unc-sdk-rs/ 2 | core-contracts/ 3 | test-contract/res/stable_* 4 | test-contract/res/nightly_* 5 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/compiler.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ./setup.sh 4 | 5 | VMKIND="wasmer2" 6 | features="required" 7 | 8 | if [ "$1" == "wasmtime" ]; then 9 | VMKIND="$1"; 10 | features="$features" 11 | fi 12 | if [ "$1" == "lightbeam" ]; then 13 | VMKIND="wasmtime" 14 | features="$features,lightbeam" 15 | fi 16 | 17 | 18 | 19 | set -ex 20 | 21 | cargo build --release --package runtime-params-estimator --features $features 22 | ./emu-cost/counter_plugin/qemu-x86_64 -cpu Westmere-v1 -plugin file=./emu-cost/counter_plugin/libcounter.so ../../target/release/runtime-params-estimator --vm-kind "$VMKIND" 23 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/emu-cost/Dockerfile: -------------------------------------------------------------------------------- 1 | # our local base image 2 | FROM rust:1.78.0 3 | 4 | LABEL description="Container for builds" 5 | 6 | RUN rustup target add wasm32-unknown-unknown 7 | 8 | # install build dependencies for QEMU 9 | RUN apt-get update && apt-get install -y g++ rsync zip openssh-server \ 10 | make apt-utils git sudo pkg-config libglib2.0-dev curl clang gdb llvm-dev cmake 11 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/emu-cost/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | docker build -t rust-emu . 3 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/emu-cost/counter_plugin/libcounter.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/runtime/runtime-params-estimator/emu-cost/counter_plugin/libcounter.so -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/emu-cost/counter_plugin/qemu-x86_64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/runtime/runtime-params-estimator/emu-cost/counter_plugin/qemu-x86_64 -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/emu-cost/data_builder.py: -------------------------------------------------------------------------------- 1 | import re 2 | import sys 3 | 4 | re1 = re.compile(r'Using (\d+) accounts') 5 | re2 = re.compile(r'executed (\d+) instructions; (\d+) bytes read; (\d+) bytes written') 6 | 7 | accounts = 0 8 | interesting = [ 1000000 ] 9 | 10 | for line in sys.stdin: 11 | m = re1.match(line) 12 | if m: 13 | accounts = int(m.group(1)) 14 | m = re2.match(line) 15 | if m and accounts in interesting: 16 | insn = m.group(1) 17 | read = m.group(2) 18 | written = m.group(3) 19 | print(insn, "r"+str(accounts), read) 20 | print(insn, "w"+str(accounts), written) 21 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/emu-cost/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | docker run \ 4 | --rm --mount type=bind,source=$HOST_DIR,target=/host \ 5 | --cap-add=SYS_PTRACE --security-opt seccomp=unconfined \ 6 | -i -t rust-emu \ 7 | /usr/bin/env bash 8 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/estimator-warehouse/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/estimator-warehouse/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "estimator-warehouse" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | anyhow.workspace = true 16 | chrono.workspace = true 17 | clap.workspace = true 18 | nix.workspace = true 19 | reqwest.workspace = true 20 | rusqlite.workspace = true 21 | serde.workspace = true 22 | serde_json.workspace = true 23 | tempfile.workspace = true 24 | xshell.workspace = true 25 | 26 | [dev-dependencies] 27 | insta.workspace = true 28 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/estimator-warehouse/src/snapshots/estimator_warehouse__check__tests__check_command-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/estimator-warehouse/src/check.rs 3 | expression: report.to_string() 4 | --- 5 | ## Report 6 | *Status: Warn* 7 | *Current commit: 0000b* 8 | *Compared to: 0004a* 9 | ### Relative gas estimation changes above threshold: 2 10 | ``` 11 | LogBase 5.00 Ggas ➜ 6.00 Ggas (+20.00%) 12 | LogByte 1.01 Ggas ➜ 7.00 Ggas (+594.44%) 13 | ``` 14 | ### Gas estimator uncertain estimations: 2 15 | ``` 16 | UncertainTest HIGH-VARIANCE ➜ None 17 | UncertainTest2 None ➜ BLOCK-MEASUREMENT-OVERHEAD 18 | ``` 19 | 20 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/estimator-warehouse/src/snapshots/estimator_warehouse__check__tests__check_command-3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/estimator-warehouse/src/check.rs 3 | expression: report.to_string() 4 | --- 5 | ## Report 6 | *Status: Warn* 7 | *Current commit: 0000b* 8 | *Compared to: 0004a* 9 | ### Relative gas estimation changes above threshold: 1 10 | ``` 11 | LogBase 5.00 Ggas ➜ 6.00 Ggas (+20.00%) 12 | ``` 13 | ### Gas estimator uncertain estimations: 0 14 | 15 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/estimator-warehouse/src/snapshots/estimator_warehouse__check__tests__check_command-4.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/estimator-warehouse/src/check.rs 3 | expression: report.to_string() 4 | --- 5 | ## Report 6 | *Status: Warn* 7 | *Current commit: 0000b* 8 | *Compared to: 0004a* 9 | ### Relative gas estimation changes above threshold: 2 10 | ``` 11 | AltBn128MultiExp 0 gas ➜ 10 gas (+inf%) 12 | LogByte 15.00 Mgas ➜ 20.00 Mgas (+33.33%) 13 | ``` 14 | ### Gas estimator uncertain estimations: 0 15 | 16 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/estimator-warehouse/src/snapshots/estimator_warehouse__check__tests__check_command.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/estimator-warehouse/src/check.rs 3 | expression: report.to_string() 4 | --- 5 | ## Report 6 | *Status: Warn* 7 | *Current commit: 0004a* 8 | *Compared to: 0003a* 9 | ### Relative gas estimation changes above threshold: 1 10 | ``` 11 | LogBase 4.00 Ggas ➜ 5.00 Ggas (+25.00%) 12 | ``` 13 | ### Gas estimator uncertain estimations: 1 14 | ``` 15 | UncertainTest NEGATIVE-COST ➜ HIGH-VARIANCE 16 | ``` 17 | 18 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/estimator-warehouse/src/snapshots/estimator_warehouse__tests__stats.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/estimator-warehouse/src/main.rs 3 | expression: generate_stats(&db).unwrap() 4 | --- 5 | 6 | ========================= Warehouse statistics ========================= 7 | 8 | metric records last updated 9 | ------ ------- ------------ 10 | icount 4 2015-05-15 11:22:33 11 | time 3 2015-05-15 11:22:33 12 | parameter 0 never 13 | 14 | ============================== END STATS =============================== 15 | 16 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/res/fungible_token.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/runtime/runtime-params-estimator/res/fungible_token.wasm -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/res/lockup_contract.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/runtime/runtime-params-estimator/res/lockup_contract.wasm -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/res/mission_control.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/runtime/runtime-params-estimator/res/mission_control.wasm -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/res/staking_pool.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/runtime/runtime-params-estimator/res/staking_pool.wasm -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/res/status_message.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/runtime/runtime-params-estimator/res/status_message.wasm -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/res/voting_contract.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/runtime/runtime-params-estimator/res/voting_contract.wasm -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/res/whitelist.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/runtime/runtime-params-estimator/res/whitelist.wasm -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cd test-binaries || exit 1; 4 | 5 | ensure_repo () { 6 | if [[ -e $1 ]]; then 7 | cd $1; 8 | git pull 9 | else 10 | git clone --depth=1 https://github.com/utnet-org/$1; 11 | fi 12 | } 13 | 14 | ensure_repo utility-sdk-rs; 15 | ensure_repo core-contracts; 16 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/src/snapshots/runtime_params_estimator__replay__tests__CacheStats-75220100-75220101.s0.io_trace.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/src/replay.rs 3 | expression: output 4 | --- 5 | top-level: 6 | GET 4 Block 4 BlockHeader 2 BlockHeight 4 BlockInfo 2 BlockMisc 2 ChunkExtra 2 Chunks 4 EpochInfo 2 IncomingReceipts 636 State 7 | DB GET 662 requests for a total of 2960023 B 8 | DB SET 0 requests for a total of 0 B 9 | STORAGE READ 18 requests for a total of 1745 B 10 | STORAGE WRITE 21 requests for a total of 1673 B 11 | TRIE NODES (guest) 751 / 4 / 187 (chunk-cache/shard-cache/DB) 12 | TRIE NODES (host) 761 / 445 (shard-cache/DB) 13 | SHARD CACHE 54.76% hit rate, 54.96% if removing 5 too large nodes from total 14 | CHUNK CACHE 79.72% hit rate 15 | 16 | 17 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/src/snapshots/runtime_params_estimator__replay__tests__CacheStats-75220100-75220101.s1.io_trace.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/src/replay.rs 3 | expression: output 4 | --- 5 | top-level: 6 | GET 4 Block 4 BlockHeader 2 BlockHeight 4 BlockInfo 2 BlockMisc 2 ChunkExtra 2 Chunks 4 EpochInfo 2 IncomingReceipts 4 State 7 | DB GET 30 requests for a total of 140837 B 8 | DB SET 0 requests for a total of 0 B 9 | STORAGE READ 0 requests for a total of 0 B 10 | STORAGE WRITE 0 requests for a total of 0 B 11 | TRIE NODES (guest) 0 / 0 / 0 (chunk-cache/shard-cache/DB) 12 | TRIE NODES (host) 22 / 4 (shard-cache/DB) 13 | SHARD CACHE 84.62% hit rate 14 | CHUNK CACHE not accessed 15 | 16 | 17 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/src/snapshots/runtime_params_estimator__replay__tests__CacheStats-75220100-75220101.s2.io_trace.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/src/replay.rs 3 | expression: output 4 | --- 5 | top-level: 6 | GET 4 Block 4 BlockHeader 2 BlockHeight 4 BlockInfo 2 BlockMisc 2 ChunkExtra 2 Chunks 4 EpochInfo 2 IncomingReceipts 242 State 7 | DB GET 268 requests for a total of 187304 B 8 | DB SET 0 requests for a total of 0 B 9 | STORAGE READ 0 requests for a total of 0 B 10 | STORAGE WRITE 0 requests for a total of 0 B 11 | TRIE NODES (guest) 0 / 0 / 0 (chunk-cache/shard-cache/DB) 12 | TRIE NODES (host) 469 / 238 (shard-cache/DB) 13 | SHARD CACHE 66.34% hit rate 14 | CHUNK CACHE not accessed 15 | 16 | 17 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/src/snapshots/runtime_params_estimator__replay__tests__CacheStats-75220100-75220101.s3.io_trace.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/src/replay.rs 3 | expression: output 4 | --- 5 | top-level: 6 | GET 4 Block 4 BlockHeader 2 BlockHeight 4 BlockInfo 2 BlockMisc 2 ChunkExtra 2 Chunks 4 EpochInfo 2 IncomingReceipts 678 State 7 | DB GET 704 requests for a total of 3288866 B 8 | DB SET 0 requests for a total of 0 B 9 | STORAGE READ 37 requests for a total of 1573 B 10 | STORAGE WRITE 35 requests for a total of 1557 B 11 | TRIE NODES (guest) 1058 / 15 / 231 (chunk-cache/shard-cache/DB) 12 | TRIE NODES (host) 991 / 443 (shard-cache/DB) 13 | SHARD CACHE 59.88% hit rate, 60.38% if removing 14 too large nodes from total 14 | CHUNK CACHE 81.13% hit rate 15 | 16 | 17 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/src/snapshots/runtime_params_estimator__replay__tests__ChunkDbStats-75220100-75220101.s0.io_trace.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/src/replay.rs 3 | expression: output 4 | --- 5 | apply_transactions shard_id=0 block=FhsQS1zgTLpZjYitRKevStmzJfUgweUTjQA1rUeNW6QR 6 | GET 287 State 7 | 8 | apply_transactions shard_id=0 block=2zB2oBqRj8dFECSaBeGP6hGGDs7KowYBVwcVfq8Ukjf9 9 | GET 345 State 10 | 11 | top-level: 12 | GET 4 Block 4 BlockHeader 2 BlockHeight 4 BlockInfo 2 BlockMisc 2 ChunkExtra 2 Chunks 4 EpochInfo 2 IncomingReceipts 4 State 13 | 14 | 15 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/src/snapshots/runtime_params_estimator__replay__tests__ChunkDbStats-75220100-75220101.s1.io_trace.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/src/replay.rs 3 | expression: output 4 | --- 5 | apply_transactions shard_id=1 block=FhsQS1zgTLpZjYitRKevStmzJfUgweUTjQA1rUeNW6QR 6 | GET 4 State 7 | 8 | apply_transactions shard_id=1 block=2zB2oBqRj8dFECSaBeGP6hGGDs7KowYBVwcVfq8Ukjf9 9 | top-level: 10 | 11 | 12 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/src/snapshots/runtime_params_estimator__replay__tests__ChunkDbStats-75220100-75220101.s2.io_trace.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/src/replay.rs 3 | expression: output 4 | --- 5 | apply_transactions shard_id=2 block=FhsQS1zgTLpZjYitRKevStmzJfUgweUTjQA1rUeNW6QR 6 | GET 94 State 7 | 8 | apply_transactions shard_id=2 block=2zB2oBqRj8dFECSaBeGP6hGGDs7KowYBVwcVfq8Ukjf9 9 | GET 144 State 10 | 11 | top-level: 12 | GET 4 Block 4 BlockHeader 2 BlockHeight 4 BlockInfo 2 BlockMisc 2 ChunkExtra 2 Chunks 4 EpochInfo 2 IncomingReceipts 4 State 13 | 14 | 15 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/src/snapshots/runtime_params_estimator__replay__tests__ChunkDbStats-75220100-75220101.s3.io_trace.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/src/replay.rs 3 | expression: output 4 | --- 5 | apply_transactions shard_id=3 block=FhsQS1zgTLpZjYitRKevStmzJfUgweUTjQA1rUeNW6QR 6 | GET 371 State 7 | 8 | apply_transactions shard_id=3 block=2zB2oBqRj8dFECSaBeGP6hGGDs7KowYBVwcVfq8Ukjf9 9 | GET 303 State 10 | 11 | top-level: 12 | GET 4 Block 4 BlockHeader 2 BlockHeight 4 BlockInfo 2 BlockMisc 2 ChunkExtra 2 Chunks 4 EpochInfo 2 IncomingReceipts 4 State 13 | 14 | 15 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/src/snapshots/runtime_params_estimator__replay__tests__GasCharges-75220100-75220101.s0.io_trace.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/src/replay.rs 3 | expression: output 4 | --- 5 | 475 free gets with total size of 2930417 6 | 187 charged gets with total size of 29606 7 | 71.75% of gets uncharged 8 | 99.00% of gets total size uncharged 9 | 10 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/src/snapshots/runtime_params_estimator__replay__tests__GasCharges-75220100-75220101.s1.io_trace.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/src/replay.rs 3 | expression: output 4 | --- 5 | 30 free gets with total size of 140837 6 | 0 charged gets with total size of 0 7 | 100.00% of gets uncharged 8 | 100.00% of gets total size uncharged 9 | 10 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/src/snapshots/runtime_params_estimator__replay__tests__GasCharges-75220100-75220101.s2.io_trace.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/src/replay.rs 3 | expression: output 4 | --- 5 | 268 free gets with total size of 187304 6 | 0 charged gets with total size of 0 7 | 100.00% of gets uncharged 8 | 100.00% of gets total size uncharged 9 | 10 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/src/snapshots/runtime_params_estimator__replay__tests__GasCharges-75220100-75220101.s3.io_trace.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/src/replay.rs 3 | expression: output 4 | --- 5 | 473 free gets with total size of 3233441 6 | 231 charged gets with total size of 55425 7 | 67.19% of gets uncharged 8 | 98.31% of gets total size uncharged 9 | 10 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/src/snapshots/runtime_params_estimator__replay__tests__ReceiptCacheStats-75220100-75220101.s1.io_trace.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/src/replay.rs 3 | expression: output 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/src/snapshots/runtime_params_estimator__replay__tests__ReceiptDbStats-75220100-75220101.s1.io_trace.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/src/replay.rs 3 | expression: output 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/src/snapshots/runtime_params_estimator__replay__tests__account_filter_CacheStats.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/src/replay.rs 3 | expression: output 4 | --- 5 | top-level: 6 | GET 4 State 7 | DB GET 4 requests for a total of 65 B 8 | DB SET 0 requests for a total of 0 B 9 | STORAGE READ 1 requests for a total of 1000 B 10 | STORAGE WRITE 0 requests for a total of 0 B 11 | TRIE NODES (guest) 1 / 19 / 1 (chunk-cache/shard-cache/DB) 12 | TRIE NODES (host) 27 / 3 (shard-cache/DB) 13 | SHARD CACHE 92.00% hit rate 14 | CHUNK CACHE 4.76% hit rate 15 | 16 | 17 | -------------------------------------------------------------------------------- /runtime/runtime-params-estimator/src/snapshots/runtime_params_estimator__replay__tests__account_filter_ReceiptDbStats.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: runtime/runtime-params-estimator/src/replay.rs 3 | expression: output 4 | --- 5 | process_receipt receiver=alice.unc receipt_id=id0 6 | GET 2 State 7 | 8 | process_receipt receiver=alice.unc receipt_id=id2 9 | GET 2 State 10 | 11 | process_receipt receiver=alice.unc receipt_id=id3 12 | 13 | 14 | -------------------------------------------------------------------------------- /runtime/unc-test-contracts/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-test-contracts" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | description = "A collection of smart-contract used in unc-infra.tests." 8 | repository.workspace = true 9 | license.workspace = true 10 | publish = false 11 | 12 | [lints] 13 | workspace = true 14 | 15 | [dependencies] 16 | once_cell.workspace = true 17 | wat.workspace = true 18 | wasm-encoder.workspace = true 19 | wasm-smith.workspace = true 20 | rand = { workspace = true, features = ["small_rng"] } 21 | arbitrary.workspace = true 22 | 23 | [features] 24 | nightly = [] 25 | -------------------------------------------------------------------------------- /runtime/unc-test-contracts/README.md: -------------------------------------------------------------------------------- 1 | A collection of smart-contract used in unc-infra.tests. 2 | 3 | Rust contracts are built via `build.rs`, the Assembly Script contract 4 | is build manually and committed to the git repository. 5 | `res/unc_evm.wasm` and `res/ZombieOwnership.bin` are taken from 6 | 7 | and it's for reproduce a performance issue encountered in EVM 8 | contracts. 9 | 10 | If you want to use a contract from rust core, add 11 | 12 | ```toml 13 | [dev-dependencies] 14 | unc-test-contracts = { path = "../unc-test-contracts" } 15 | ``` 16 | 17 | to the Cargo.toml and use `unc_test_contract::rs_contract()`. 18 | 19 | If you want to use a contract from an integration test, you can read 20 | the wasm file directly from the `./res` directory. To populate 21 | `./res`, you need to make sure that this crate was compiled. 22 | -------------------------------------------------------------------------------- /runtime/unc-test-contracts/contract-for-fuzzing-rs/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "contract-for-fuzzing-rs" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /runtime/unc-test-contracts/contract-for-fuzzing-rs/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "contract-for-fuzzing-rs" 3 | version = "0.1.0" 4 | authors = ["Hello Inc "] 5 | publish = false 6 | edition = "2018" 7 | 8 | [lib] 9 | crate-type = ["cdylib"] 10 | 11 | [profile.release] 12 | codegen-units = 1 13 | # Tell `rustc` to optimize for small code size. 14 | opt-level = "z" 15 | strip = true 16 | lto = true 17 | debug = false 18 | panic = "abort" 19 | rpath = false 20 | debug-assertions = false 21 | incremental = false 22 | 23 | [workspace] 24 | members = [] 25 | -------------------------------------------------------------------------------- /runtime/unc-test-contracts/estimator-contract/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "estimator-contract" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /runtime/unc-test-contracts/estimator-contract/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "estimator-contract" 3 | version = "0.1.0" 4 | authors = ["Hello Inc "] 5 | publish = false 6 | edition = "2021" 7 | 8 | [lib] 9 | crate-type = ["cdylib"] 10 | 11 | [profile.release] 12 | codegen-units = 1 13 | # Tell `rustc` to optimize for small code size. 14 | opt-level = "z" 15 | strip = true 16 | lto = true 17 | debug = false 18 | panic = "abort" 19 | 20 | [workspace] 21 | members = [] 22 | 23 | [features] 24 | nightly = [] 25 | -------------------------------------------------------------------------------- /runtime/unc-test-contracts/res/.gitignore: -------------------------------------------------------------------------------- 1 | *.wasm 2 | !test_contract_ts.wasm 3 | !unc_evm.wasm 4 | -------------------------------------------------------------------------------- /runtime/unc-test-contracts/res/test_contract_ts.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/runtime/unc-test-contracts/res/test_contract_ts.wasm -------------------------------------------------------------------------------- /runtime/unc-test-contracts/res/unc_evm.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/runtime/unc-test-contracts/res/unc_evm.wasm -------------------------------------------------------------------------------- /runtime/unc-test-contracts/test-contract-rs/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "test-contract-rs" 3 | version = "0.1.0" 4 | authors = ["Hello Inc "] 5 | publish = false 6 | edition = "2021" 7 | 8 | [lib] 9 | crate-type = ["cdylib"] 10 | 11 | [dependencies] 12 | base64 = "0.21" 13 | serde_json = "1" 14 | 15 | [profile.release] 16 | codegen-units = 1 17 | # Tell `rustc` to optimize for small code size. 18 | opt-level = "z" 19 | strip = true 20 | lto = true 21 | debug = false 22 | panic = "abort" 23 | rpath = false 24 | debug-assertions = false 25 | incremental = false 26 | 27 | [workspace] 28 | members = [] 29 | 30 | [features] 31 | nightly = [] 32 | latest_protocol = [] 33 | -------------------------------------------------------------------------------- /runtime/unc-vm-runner/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2 -------------------------------------------------------------------------------- /runtime/unc-vm-runner/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /runtime/unc-vm-runner/fuzz/.gitignore: -------------------------------------------------------------------------------- 1 | corpus 2 | artifacts 3 | -------------------------------------------------------------------------------- /runtime/unc-vm-runner/fuzz/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-vm-runner-fuzz" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [package.metadata] 12 | cargo-fuzz = true 13 | 14 | [lints] 15 | workspace = true 16 | 17 | [dependencies] 18 | arbitrary.workspace = true 19 | libfuzzer-sys.workspace = true 20 | wasm-smith.workspace = true 21 | wasmprinter.workspace = true 22 | 23 | unc-parameters.workspace = true 24 | unc-primitives.workspace = true 25 | unc-test-contracts.workspace = true 26 | unc-vm-runner.workspace = true 27 | 28 | [[bin]] 29 | name = "runner" 30 | path = "fuzz_targets/runner.rs" 31 | test = false 32 | doc = false 33 | 34 | [[bin]] 35 | name = "diffrunner" 36 | path = "fuzz_targets/diffrunner.rs" 37 | test = false 38 | doc = false 39 | -------------------------------------------------------------------------------- /runtime/unc-vm-runner/src/code.rs: -------------------------------------------------------------------------------- 1 | use unc_primitives_core::hash::{hash as sha256, CryptoHash}; 2 | 3 | pub struct ContractCode { 4 | code: Vec, 5 | hash: CryptoHash, 6 | } 7 | 8 | impl ContractCode { 9 | pub fn new(code: Vec, hash: Option) -> ContractCode { 10 | let hash = hash.unwrap_or_else(|| sha256(&code)); 11 | debug_assert_eq!(hash, sha256(&code)); 12 | 13 | ContractCode { code, hash } 14 | } 15 | 16 | pub fn code(&self) -> &[u8] { 17 | self.code.as_slice() 18 | } 19 | 20 | pub fn into_code(self) -> Vec { 21 | self.code 22 | } 23 | 24 | pub fn hash(&self) -> &CryptoHash { 25 | &self.hash 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /runtime/unc-vm-runner/src/errors.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, PartialEq)] 2 | pub enum ContractPrecompilatonResult { 3 | ContractCompiled, 4 | ContractAlreadyInCache, 5 | CacheNotAvailable, 6 | } 7 | -------------------------------------------------------------------------------- /runtime/unc-vm-runner/src/instrument.rs: -------------------------------------------------------------------------------- 1 | //! Instrumentation of wasm code for gas metering and stack limiting. 2 | //! 3 | //! The code in this module was originally vendored from MIT/Apache wasm-utils 4 | //! crate from the parity ecosystem: 5 | //! 6 | //! 7 | //! 8 | //! 9 | //! As every little detail of instrumentation matters for the semantics of our 10 | //! protocol, we want to maintain the implementation ourselves. 11 | //! 12 | //! At the moment, the implementation is a direct copy, but we don't intend to 13 | //! keep the code aligned with the upstream, feel free to refactor if you find 14 | //! something odd!. 15 | pub(crate) mod gas; 16 | pub(crate) mod rules; 17 | pub(crate) mod stack_height; 18 | -------------------------------------------------------------------------------- /runtime/unc-vm-runner/src/logic/mocks/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mock_external; 2 | pub mod mock_memory; 3 | -------------------------------------------------------------------------------- /runtime/unc-vm-runner/src/logic/tests/mod.rs: -------------------------------------------------------------------------------- 1 | mod alt_bn128; 2 | mod context; 3 | mod ed25519_verify; 4 | mod gas_counter; 5 | pub(crate) mod helpers; 6 | mod iterators; 7 | mod logs; 8 | mod miscs; 9 | mod promises; 10 | mod registers; 11 | mod storage_read_write; 12 | mod storage_usage; 13 | mod view_method; 14 | mod vm_logic_builder; 15 | 16 | use vm_logic_builder::TestVMLogic; 17 | -------------------------------------------------------------------------------- /runtime/unc-vm-runner/src/utils.rs: -------------------------------------------------------------------------------- 1 | use std::hash::{Hash, Hasher}; 2 | 3 | // This method is not used on macOS so it's fine to allow it to be unused. 4 | #[allow(dead_code)] 5 | pub(crate) fn stable_hash(value: T) -> u64 { 6 | // This is ported over from the previous uses, that relied on unc-stable-hasher. 7 | // The need for stability here can certainly be discussed, and it could probably be replaced with DefaultHasher. 8 | // Not doing it in this refactor as it’s not the core of the issue and using SipHasher is an easy alternative. 9 | #[allow(deprecated)] 10 | let mut hasher = std::hash::SipHasher::new(); 11 | value.hash(&mut hasher); 12 | hasher.finish() 13 | } 14 | -------------------------------------------------------------------------------- /runtime/unc-vm/.gitignore: -------------------------------------------------------------------------------- 1 | **/target 2 | **/*.rs.bk 3 | .DS_Store 4 | .idea 5 | .gdb_history 6 | **/.vscode 7 | api-docs-repo/ 8 | /.cargo_home/ 9 | /package/ 10 | /dist/ 11 | /wapm-cli/ 12 | /src/windows-installer/WasmerInstaller.exe 13 | /lib/c-api/wasmer.h 14 | 15 | # Generated by tests on Android 16 | /avd 17 | /core 18 | -------------------------------------------------------------------------------- /runtime/unc-vm/compiler-singlepass/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../../LICENSE-GPL2 -------------------------------------------------------------------------------- /runtime/unc-vm/compiler-singlepass/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /runtime/unc-vm/compiler-singlepass/src/address_map.rs: -------------------------------------------------------------------------------- 1 | use unc_vm_compiler::{FunctionAddressMap, FunctionBodyData, InstructionAddressMap, SourceLoc}; 2 | 3 | pub fn get_function_address_map<'data>( 4 | instructions: Vec, 5 | data: &FunctionBodyData<'data>, 6 | body_len: usize, 7 | ) -> FunctionAddressMap { 8 | // Generate source loc for a function start/end to identify boundary within module. 9 | // It will wrap around if byte code is larger than 4 GB. 10 | let start_srcloc = SourceLoc::new(data.module_offset as u32); 11 | let end_srcloc = SourceLoc::new((data.module_offset + data.data.len()) as u32); 12 | 13 | FunctionAddressMap { instructions, start_srcloc, end_srcloc, body_offset: 0, body_len } 14 | } 15 | -------------------------------------------------------------------------------- /runtime/unc-vm/compiler-singlepass/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! A WebAssembly `Compiler` implementation using Singlepass. 2 | //! 3 | //! Singlepass is a super-fast assembly generator that generates 4 | //! assembly code in just one pass. This is useful for different applications 5 | //! including Blockchains and Edge computing where quick compilation 6 | //! times are a must, and JIT bombs should never happen. 7 | //! 8 | //! Compared to Cranelift and LLVM, Singlepass compiles much faster but has worse 9 | //! runtime performance. 10 | 11 | mod address_map; 12 | mod codegen_x64; 13 | mod compiler; 14 | mod config; 15 | mod emitter_x64; 16 | mod machine; 17 | mod x64_decl; 18 | 19 | pub use crate::compiler::SinglepassCompiler; 20 | pub use crate::config::Singlepass; 21 | -------------------------------------------------------------------------------- /runtime/unc-vm/compiler-test-derive/Cargo.toml: -------------------------------------------------------------------------------- 1 | [lib] 2 | proc-macro = true 3 | 4 | [package] 5 | name = "unc-vm-compiler-test-derive" 6 | version.workspace = true 7 | authors = ["Wasmer Engineering Team ", "Hello Inc "] 8 | edition = "2021" 9 | license = "GPL-2.0-or-later" 10 | description = "A macro to generate easily tests across compilers and engines" 11 | keywords = ["unsafe", "body", "fn", "safety", "hygiene"] 12 | categories = ["rust-patterns"] 13 | publish = false 14 | 15 | [lints] 16 | workspace = true 17 | 18 | [dependencies] 19 | proc-macro2.workspace = true 20 | quote.workspace = true 21 | syn.workspace = true 22 | 23 | [features] 24 | 25 | [dev-dependencies] 26 | pretty_assertions.workspace = true 27 | trybuild.workspace = true 28 | -------------------------------------------------------------------------------- /runtime/unc-vm/compiler-test-derive/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | if let Ok(os) = std::env::var("CARGO_CFG_TARGET_OS") { 3 | println!("cargo:rustc-env=CFG_TARGET_OS={}", os); 4 | } 5 | if let Ok(os) = std::env::var("CARGO_CFG_TARGET_ARCH") { 6 | println!("cargo:rustc-env=CFG_TARGET_ARCH={}", os); 7 | } 8 | if let Ok(os) = std::env::var("CARGO_CFG_TARGET_ENV") { 9 | println!("cargo:rustc-env=CFG_TARGET_ENV={}", os); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /runtime/unc-vm/compiler/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../../LICENSE-GPL2 -------------------------------------------------------------------------------- /runtime/unc-vm/compiler/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /runtime/unc-vm/compiler/src/translator/mod.rs: -------------------------------------------------------------------------------- 1 | //! This module defines the parser and translator from wasmparser 2 | //! to a common structure `ModuleInfo`. 3 | //! 4 | //! It's derived from [cranelift-wasm] but architected for multiple 5 | //! compilers rather than just Cranelift. 6 | //! 7 | //! [cranelift-wasm]: https://crates.io/crates/cranelift-wasm/ 8 | mod environ; 9 | mod module; 10 | mod state; 11 | #[macro_use] 12 | mod error; 13 | mod sections; 14 | 15 | pub use self::environ::{FunctionBodyData, FunctionReader, ModuleEnvironment}; 16 | pub use self::module::translate_module; 17 | pub use self::sections::wptype_to_type; 18 | pub use self::state::ModuleTranslationState; 19 | -------------------------------------------------------------------------------- /runtime/unc-vm/compiler/src/trap.rs: -------------------------------------------------------------------------------- 1 | use crate::CodeOffset; 2 | use unc_vm_vm::TrapCode; 3 | 4 | /// Information about trap. 5 | #[derive(rkyv::Serialize, rkyv::Deserialize, rkyv::Archive, Clone, Debug, PartialEq, Eq)] 6 | pub struct TrapInformation { 7 | /// The offset of the trapping instruction in native code. It is relative to the beginning of the function. 8 | pub code_offset: CodeOffset, 9 | /// Code of the trap. 10 | pub trap_code: TrapCode, 11 | } 12 | -------------------------------------------------------------------------------- /runtime/unc-vm/engine/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../../LICENSE-GPL2 -------------------------------------------------------------------------------- /runtime/unc-vm/engine/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /runtime/unc-vm/engine/README.md: -------------------------------------------------------------------------------- 1 | # `unc-vm-engine` 2 | 3 | This crate is a fork of `wasmer-engine`. A significant number of things changed, but the documentation is not up-to-date yet. 4 | 5 | This crate is the general abstraction for creating Engines in Wasmer. 6 | 7 | Wasmer Engines are mainly responsible for two things: 8 | 9 | * Transform the compilation code (from any Wasmer Compiler) to 10 | **create** an `Artifact`, 11 | * **Load** an`Artifact` so it can be used by the user (normally, 12 | pushing the code into executable memory and so on). 13 | 14 | ### Acknowledgments 15 | 16 | This project borrowed some of the code of the trap implementation from 17 | the [`wasmtime-api`], the code since then has evolved significantly. 18 | 19 | Please check [Wasmer `ATTRIBUTIONS`] to further see licenses and other 20 | attributions of the project. 21 | 22 | [`wasmtime-api`]: https://crates.io/crates/wasmtime 23 | [Wasmer `ATTRIBUTIONS`]: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md 24 | -------------------------------------------------------------------------------- /runtime/unc-vm/engine/src/engine.rs: -------------------------------------------------------------------------------- 1 | //! Engine trait and associated types. 2 | 3 | use std::sync::atomic::{AtomicUsize, Ordering::SeqCst}; 4 | 5 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord)] 6 | #[repr(transparent)] 7 | /// A unique identifier for an Engine. 8 | pub struct EngineId { 9 | id: usize, 10 | } 11 | 12 | impl EngineId { 13 | /// Format this identifier as a string. 14 | pub fn id(&self) -> String { 15 | format!("{}", &self.id) 16 | } 17 | } 18 | 19 | impl Clone for EngineId { 20 | fn clone(&self) -> Self { 21 | Self::default() 22 | } 23 | } 24 | 25 | impl Default for EngineId { 26 | fn default() -> Self { 27 | static NEXT_ID: AtomicUsize = AtomicUsize::new(0); 28 | Self { id: NEXT_ID.fetch_add(1, SeqCst) } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /runtime/unc-vm/engine/src/export.rs: -------------------------------------------------------------------------------- 1 | use std::sync::Arc; 2 | use unc_vm_vm::{ImportInitializerFuncPtr, VMExtern, VMFunction, VMGlobal, VMMemory, VMTable}; 3 | 4 | -------------------------------------------------------------------------------- /runtime/unc-vm/engine/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! Generic Engine abstraction for Wasmer Engines. 2 | 3 | #![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] 4 | #![warn(unused_import_braces)] 5 | #![allow(clippy::new_without_default)] 6 | #![warn( 7 | clippy::float_arithmetic, 8 | clippy::mut_mut, 9 | clippy::nonminimal_bool, 10 | clippy::map_unwrap_or, 11 | clippy::print_stdout, 12 | clippy::unicode_not_nfc, 13 | clippy::use_self 14 | )] 15 | 16 | mod engine; 17 | mod error; 18 | mod resolver; 19 | mod trap; 20 | 21 | /// Universal engine 22 | pub mod universal; 23 | 24 | pub use crate::engine::EngineId; 25 | pub use crate::error::{DeserializeError, ImportError, InstantiationError, LinkError}; 26 | pub use crate::resolver::resolve_imports; 27 | pub use crate::trap::*; 28 | 29 | /// Version number of this crate. 30 | pub const VERSION: &str = env!("CARGO_PKG_VERSION"); 31 | -------------------------------------------------------------------------------- /runtime/unc-vm/engine/src/trap/mod.rs: -------------------------------------------------------------------------------- 1 | mod error; 2 | mod frame_info; 3 | pub use error::RuntimeError; 4 | pub use frame_info::{FrameInfo, GlobalFrameInfoRegistration}; 5 | -------------------------------------------------------------------------------- /runtime/unc-vm/engine/src/universal/mod.rs: -------------------------------------------------------------------------------- 1 | mod artifact; 2 | mod builder; 3 | mod code_memory; 4 | mod engine; 5 | mod executable; 6 | mod link; 7 | 8 | pub use self::artifact::UniversalArtifact; 9 | pub use self::builder::Universal; 10 | pub use self::code_memory::{CodeMemory, LimitedMemoryPool}; 11 | pub use self::engine::UniversalEngine; 12 | pub use self::executable::{UniversalExecutable, UniversalExecutableRef}; 13 | pub use self::link::link_module; 14 | -------------------------------------------------------------------------------- /runtime/unc-vm/test-api/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![cfg(target_arch = "x86_64")] 2 | 3 | mod sys; 4 | pub use sys::*; 5 | -------------------------------------------------------------------------------- /runtime/unc-vm/test-generator/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-vm-test-generator" 3 | version.workspace = true 4 | edition = "2021" 5 | authors = ["Wasmer Engineering Team ", "Hello Inc "] 6 | publish = false 7 | license = "Apache-2.0 WITH LLVM-exception" 8 | 9 | [lints] 10 | workspace = true 11 | 12 | [dependencies] 13 | anyhow.workspace = true 14 | target-lexicon.workspace = true 15 | 16 | [features] 17 | test-dylib = [] 18 | test-universal = [] 19 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/compilers/main.rs: -------------------------------------------------------------------------------- 1 | #![cfg(target_arch = "x86_64")] 2 | //! This test suite does all the tests that involve any compiler 3 | //! implementation, such as: singlepass. 4 | #[macro_use] 5 | extern crate unc_vm_compiler_test_derive; 6 | 7 | mod config; 8 | mod deterministic; 9 | mod imports; 10 | mod issues; 11 | // mod multi_value_imports; 12 | mod compilation; 13 | mod native_functions; 14 | mod serialize; 15 | mod stack_limiter; 16 | mod traps; 17 | mod wast; 18 | 19 | pub use crate::config::{Compiler, Config, Engine}; 20 | pub use crate::wast::run_wast; 21 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/deprecated.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/deprecated/README.md: -------------------------------------------------------------------------------- 1 | # Tests: Deprecated 2 | 3 | In this folder we will test deprecated APIs to verify that they 4 | still work the way it should, so users of Wasmer are happy while 5 | transitioning to newer APIs. 6 | 7 | As time passes and adoption of new APIs rises, tests on this folder 8 | should start tending towards 0. 9 | 10 | Therefore, deprecated tests are intended to be deleted on the long 11 | term. 12 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/examples/add.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (func (export "add") (param $x i64) (param $y i64) (result i64) (i64.add (local.get $x) (local.get $y))) 3 | ) -------------------------------------------------------------------------------- /runtime/unc-vm/tests/examples/call_indirect.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (type $multiply_signature (func (param i32 i32) (result i32))) 3 | (table 1 1 anyfunc) 4 | (elem (i32.const 0) $multiply) 5 | (memory $0 1) 6 | (export "memory" (memory $0)) 7 | (export "dispatch" (func $dispatch)) 8 | (export "multiply" (func $multiply)) 9 | (export "main" (func $main)) 10 | (func $dispatch (; 0 ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) 11 | (call_indirect (type $multiply_signature) 12 | (local.get $1) 13 | (local.get $2) 14 | (local.get $0) 15 | ) 16 | ) 17 | (func $multiply (; 1 ;) (type $multiply_signature) (param $0 i32) (param $1 i32) (result i32) 18 | (i32.mul 19 | (local.get $1) 20 | (local.get $0) 21 | ) 22 | ) 23 | (func $main (; 2 ;) (result i32) 24 | (call $dispatch 25 | (i32.const 0) 26 | (i32.const 20) 27 | (i32.const 30) 28 | ) 29 | ) 30 | ) 31 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/examples/fib.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (func $main (result i32) 3 | (call $fib (i32.const 40)) 4 | ) 5 | 6 | (func $fib (param $n i32) (result i32) 7 | (if (i32.eq (local.get $n) (i32.const 0)) 8 | (then (return (i32.const 1))) 9 | ) 10 | (if (i32.eq (local.get $n) (i32.const 1)) 11 | (then (return (i32.const 1))) 12 | ) 13 | (i32.add 14 | (call $fib (i32.sub (local.get $n) (i32.const 1))) 15 | (call $fib (i32.sub (local.get $n) (i32.const 2))) 16 | ) 17 | ) 18 | 19 | (export "_start" (func $main)) 20 | ) 21 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/examples/global.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (global $xxx (mut i32) (i32.const 42)) 3 | (func $main (result i32) 4 | (global.set $xxx (i32.const 0)) 5 | (i32.const 1) 6 | ) 7 | (export "_start" (func $main)) 8 | ) 9 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/examples/invalid.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (func (export "sqrt") (param f32) (result f32) 3 | f32.sqrt 4 | ) 5 | ) 6 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/examples/no_start.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (type (;0;) (func (param f64) (result i32))) 3 | (func (;0;) (type 0) (param f64) (result i32) 4 | unreachable)) 5 | 6 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/examples/trap.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (func $main (export "_start") (result i32) 3 | (i32.div_s (i32.const 0) (i32.const 0)) 4 | ) 5 | ) 6 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/wast/README.md: -------------------------------------------------------------------------------- 1 | # WebAssembly testsuite 2 | 3 | Here is where all the `.wast` tests live. 4 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/wast/spec/.gitignore: -------------------------------------------------------------------------------- 1 | /commit_message 2 | /repos/ 3 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/wast/spec/Contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing to WebAssembly 2 | 3 | Interested in participating? Please follow 4 | [the same contributing guidelines as the design repository][]. 5 | 6 | [the same contributing guidelines as the design repository]: https://github.com/WebAssembly/design/blob/master/Contributing.md 7 | 8 | Also, please be sure to read [the README.md](README.md) for this repository. 9 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/wast/spec/README.md: -------------------------------------------------------------------------------- 1 | Amalgamated WebAssembly Test Suite 2 | ================================== 3 | 4 | This repository holds a mirror of the WebAssembly core testsuite which is 5 | maintained [here](https://github.com/WebAssembly/spec/tree/master/test/core), 6 | as well as the tests from the various [proposals 7 | repositories](https://github.com/WebAssembly/proposals/blob/master/README.md). 8 | 9 | In addition it also contains tests from various proposals which are currently 10 | forks of the primary spec repo. 11 | 12 | To add new tests or report problems in existing tests, please file issues and 13 | PRs within the spec or individual proposal repositories rather than within this 14 | mirror repository. 15 | 16 | To update the tests in this repo from their upstream sources: 17 | 18 | 1. Run `update-tests.sh` 19 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/wast/spec/extract-parts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | set -u 4 | set -o pipefail 5 | 6 | # This script extracts the modules from the testsuite test files into 7 | # individual files in the following directories: 8 | # - valid - valid wasm modules 9 | # - invalid - wasm modules that fail to validate 10 | # - malformed - wasm text tests that fail to parse 11 | 12 | wabt="../wabt" 13 | wabtbin="$wabt/bin" 14 | 15 | mkdir -p valid invalid malformed 16 | rm -f valid/*.wasm 17 | rm -f invalid/*.wasm 18 | rm -f malformed/*.wat 19 | 20 | for wast in *.wast; do 21 | base="${wast##*/}" 22 | json="invalid/${base%.wast}.json" 23 | "$wabtbin/wast2json" "$wast" -o "$json" 24 | rm "$json" 25 | done 26 | 27 | mv invalid/*.wat malformed 28 | 29 | for wasm in invalid/*.wasm; do 30 | if "$wabtbin/wasm2wat" "$wasm" -o invalid/t.wat 2>/dev/null && \ 31 | "$wabtbin/wat2wasm" invalid/t.wat -o /dev/null 2>/dev/null ; then 32 | mv "$wasm" valid 33 | fi 34 | done 35 | rm invalid/t.wat 36 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/wast/spec/forward.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func $even (export "even") (param $n i32) (result i32) 3 | (if (result i32) (i32.eq (local.get $n) (i32.const 0)) 4 | (then (i32.const 1)) 5 | (else (call $odd (i32.sub (local.get $n) (i32.const 1)))) 6 | ) 7 | ) 8 | 9 | (func $odd (export "odd") (param $n i32) (result i32) 10 | (if (result i32) (i32.eq (local.get $n) (i32.const 0)) 11 | (then (i32.const 0)) 12 | (else (call $even (i32.sub (local.get $n) (i32.const 1)))) 13 | ) 14 | ) 15 | ) 16 | 17 | (assert_return (invoke "even" (i32.const 13)) (i32.const 0)) 18 | (assert_return (invoke "even" (i32.const 20)) (i32.const 1)) 19 | (assert_return (invoke "odd" (i32.const 13)) (i32.const 1)) 20 | (assert_return (invoke "odd" (i32.const 20)) (i32.const 0)) 21 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/wast/spec/inline-module.wast: -------------------------------------------------------------------------------- 1 | (func) (memory 0) (func (export "f")) 2 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/wast/spec/proposals/gc/ref_null.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $t (func)) 3 | (func (export "externref") (result externref) (ref.null extern)) 4 | (func (export "funcref") (result funcref) (ref.null func)) 5 | (func (export "ref") (result (ref null $t)) (ref.null $t)) 6 | 7 | (global externref (ref.null extern)) 8 | (global funcref (ref.null func)) 9 | (global (ref null $t) (ref.null $t)) 10 | ) 11 | 12 | (assert_return (invoke "externref") (ref.null extern)) 13 | (assert_return (invoke "funcref") (ref.null func)) 14 | (assert_return (invoke "ref") (ref.null)) 15 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/wast/spec/proposals/gc/table-sub.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $t (func)) 3 | (table $t1 10 (ref null func)) 4 | (table $t2 10 (ref null $t)) 5 | (elem $el funcref) 6 | (func $f 7 | (table.init $t1 $el (i32.const 0) (i32.const 1) (i32.const 2)) 8 | (table.copy $t1 $t2 (i32.const 0) (i32.const 1) (i32.const 2)) 9 | ) 10 | ) 11 | 12 | (assert_invalid 13 | (module 14 | (table $t1 10 funcref) 15 | (table $t2 10 externref) 16 | (func $f 17 | (table.copy $t1 $t2 (i32.const 0) (i32.const 1) (i32.const 2)) 18 | ) 19 | ) 20 | "type mismatch" 21 | ) 22 | 23 | (assert_invalid 24 | (module 25 | (table $t 10 funcref) 26 | (elem $el externref) 27 | (func $f 28 | (table.init $t $el (i32.const 0) (i32.const 1) (i32.const 2)) 29 | ) 30 | ) 31 | "type mismatch" 32 | ) 33 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/wast/spec/proposals/reference-types/ref_null.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func (export "anyref") (result anyref) (ref.null)) 3 | (func (export "funcref") (result funcref) (ref.null)) 4 | (func (export "nullref") (result nullref) (ref.null)) 5 | 6 | (global anyref (ref.null)) 7 | (global funcref (ref.null)) 8 | (global nullref (ref.null)) 9 | ) 10 | 11 | (assert_return (invoke "anyref") (ref.null)) 12 | (assert_return (invoke "funcref") (ref.null)) 13 | (assert_return (invoke "nullref") (ref.null)) 14 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/wast/spec/proposals/reference-types/table-sub.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (table $t1 10 anyref) 3 | (table $t2 10 funcref) 4 | (elem $el funcref) 5 | (func $f 6 | (table.init $t1 $el (i32.const 0) (i32.const 1) (i32.const 2)) 7 | (table.copy $t1 $t2 (i32.const 0) (i32.const 1) (i32.const 2)) 8 | ) 9 | ) 10 | 11 | (assert_invalid 12 | (module 13 | (table $t1 10 funcref) 14 | (table $t2 10 anyref) 15 | (func $f 16 | (table.copy $t1 $t2 (i32.const 0) (i32.const 1) (i32.const 2)) 17 | ) 18 | ) 19 | "type mismatch" 20 | ) 21 | 22 | (assert_invalid 23 | (module 24 | (table $t 10 funcref) 25 | (elem $el anyref) 26 | (func $f 27 | (table.init $t $el (i32.const 0) (i32.const 1) (i32.const 2)) 28 | ) 29 | ) 30 | "type mismatch" 31 | ) 32 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/wast/spec/ref_null.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func (export "externref") (result externref) (ref.null extern)) 3 | (func (export "funcref") (result funcref) (ref.null func)) 4 | 5 | (global externref (ref.null extern)) 6 | (global funcref (ref.null func)) 7 | ) 8 | 9 | (assert_return (invoke "externref") (ref.null extern)) 10 | (assert_return (invoke "funcref") (ref.null func)) 11 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/wast/spec/table-sub.wast: -------------------------------------------------------------------------------- 1 | (assert_invalid 2 | (module 3 | (table $t1 10 funcref) 4 | (table $t2 10 externref) 5 | (func $f 6 | (table.copy $t1 $t2 (i32.const 0) (i32.const 1) (i32.const 2)) 7 | ) 8 | ) 9 | "type mismatch" 10 | ) 11 | 12 | (assert_invalid 13 | (module 14 | (table $t 10 funcref) 15 | (elem $el externref) 16 | (func $f 17 | (table.init $t $el (i32.const 0) (i32.const 1) (i32.const 2)) 18 | ) 19 | ) 20 | "type mismatch" 21 | ) 22 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/wast/spec/token.wast: -------------------------------------------------------------------------------- 1 | ;; Test tokenization 2 | 3 | (assert_malformed 4 | (module quote "(func (drop (i32.const0)))") 5 | "unknown operator" 6 | ) 7 | (assert_malformed 8 | (module quote "(func br 0drop)") 9 | "unknown operator" 10 | ) 11 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/wast/wasmer/max_size_of_memory.wast: -------------------------------------------------------------------------------- 1 | (module (memory 65536)) 2 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/wast/wasmer/multiple-traps.wast: -------------------------------------------------------------------------------- 1 | ;; We assert that we can call a function that traps repeatedly 2 | 3 | (module 4 | (func (export "throw_trap") 5 | unreachable 6 | )) 7 | 8 | (assert_trap (invoke "throw_trap") "unreachable") 9 | (assert_trap (invoke "throw_trap") "unreachable") 10 | (assert_trap (invoke "throw_trap") "unreachable") 11 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/wast/wasmer/nan-canonicalization-issue-2159.wast: -------------------------------------------------------------------------------- 1 | ;; https://github.com/wasmerio/wasmer/issues/2159 2 | (module 3 | (func (export "_start") (result f64) 4 | f64.const 0x0p+0 (;=0;) 5 | f64.const 0x0p+0 (;=0;) 6 | f64.const 0x0p+0 (;=0;) 7 | f64.div 8 | f64.copysign 9 | ) 10 | ) -------------------------------------------------------------------------------- /runtime/unc-vm/tests/wast/wasmer/nan-canonicalization-issue-2347.wast: -------------------------------------------------------------------------------- 1 | ;; https://github.com/wasmerio/wasmer/issues/2347 2 | (module 3 | (type (;0;) (func (param f64) (result i32))) 4 | (func (;0;) (type 0) (param f64) (result i32) 5 | unreachable) 6 | (func (;1;) (type 0) (param f64) (result i32) 7 | i32.const -16579585 8 | f64.convert_i32_s 9 | f64.ceil 10 | f64.ceil 11 | local.get 0 12 | f64.copysign 13 | unreachable)) 14 | -------------------------------------------------------------------------------- /runtime/unc-vm/tests/wast/wasmer/stack-overflow.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type (;0;) (func)) 3 | (func (;0;) (type 0) 4 | i32.const 0 5 | call_indirect (type 0)) 6 | (table (;0;) 1 anyfunc) 7 | (export "stack-overflow" (func 0)) 8 | (elem (;0;) (i32.const 0) 0)) 9 | 10 | (assert_exhaustion (invoke "stack-overflow") "call stack exhausted") 11 | -------------------------------------------------------------------------------- /runtime/unc-vm/types/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-vm-types" 3 | version.workspace = true 4 | description = "unc VM Common Types" 5 | categories = ["wasm", "data-structures"] 6 | keywords = ["wasm", "webassembly", "types"] 7 | authors = ["Wasmer Engineering Team ", "Hello Inc "] 8 | repository.workspace = true 9 | license = "GPL-2.0-or-later" 10 | readme = "README.md" 11 | edition = "2021" 12 | publish = true 13 | 14 | [lints] 15 | workspace = true 16 | 17 | [dependencies] 18 | thiserror.workspace = true 19 | indexmap.workspace = true 20 | num-traits.workspace = true 21 | rkyv.workspace = true 22 | 23 | [dev-dependencies] 24 | bolero.workspace = true 25 | 26 | [[test]] 27 | name = "partial-sum-map" 28 | -------------------------------------------------------------------------------- /runtime/unc-vm/types/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../../LICENSE-GPL2 -------------------------------------------------------------------------------- /runtime/unc-vm/types/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /runtime/unc-vm/types/tests/partial-sum-map/corpus/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/runtime/unc-vm/types/tests/partial-sum-map/corpus/.gitkeep -------------------------------------------------------------------------------- /runtime/unc-vm/types/tests/partial-sum-map/crashes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/runtime/unc-vm/types/tests/partial-sum-map/crashes/.gitkeep -------------------------------------------------------------------------------- /runtime/unc-vm/vm/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../../LICENSE-GPL2 -------------------------------------------------------------------------------- /runtime/unc-vm/vm/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /runtime/unc-vm/vm/build.rs: -------------------------------------------------------------------------------- 1 | //! Runtime build script compiles C code using setjmp for trap handling. 2 | 3 | use std::env; 4 | 5 | fn main() { 6 | println!("cargo:rerun-if-changed=src/trap/handlers.c"); 7 | 8 | cc::Build::new() 9 | .warnings(true) 10 | .define( 11 | &format!("CFG_TARGET_OS_{}", env::var("CARGO_CFG_TARGET_OS").unwrap().to_uppercase()), 12 | None, 13 | ) 14 | .file("src/trap/handlers.c") 15 | .compile("handlers"); 16 | } 17 | -------------------------------------------------------------------------------- /runtime/unc-vm/vm/src/trap/mod.rs: -------------------------------------------------------------------------------- 1 | // This file contains code from external sources. 2 | // Attributions: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md 3 | 4 | //! This is the module that facilitates the usage of Traps 5 | //! in Wasmer Runtime 6 | mod trapcode; 7 | pub mod traphandlers; 8 | 9 | pub use trapcode::TrapCode; 10 | pub use traphandlers::resume_panic; 11 | pub use traphandlers::{ 12 | catch_traps, catch_traps_with_result, raise_lib_trap, raise_user_trap, unc_vm_call_trampoline, 13 | TlsRestore, Trap, 14 | }; 15 | -------------------------------------------------------------------------------- /runtime/unc-vm/wast/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-vm-wast" 3 | version.workspace = true 4 | authors = ["Wasmer Engineering Team ", "Hello Inc "] 5 | description = "wast testing support for wasmer" 6 | license = "GPL-2.0-or-later" 7 | categories = ["wasm"] 8 | keywords = ["wasm", "webassembly"] 9 | repository.workspace = true 10 | readme = "README.md" 11 | edition = "2021" 12 | publish = false 13 | 14 | [lints] 15 | workspace = true 16 | 17 | [dependencies] 18 | anyhow.workspace = true 19 | unc-vm-test-api.workspace = true 20 | wast.workspace = true 21 | tempfile.workspace = true 22 | thiserror.workspace = true 23 | 24 | [features] 25 | default = ["wat"] 26 | wat = ["unc-vm-test-api/wat"] 27 | 28 | [badges] 29 | maintenance = { status = "actively-developed" } 30 | -------------------------------------------------------------------------------- /runtime/unc-vm/wast/README.md: -------------------------------------------------------------------------------- 1 | This is the `wasmer-wast` crate, which contains an implementation of WebAssembly's 2 | "wast" test scripting language, which is used in the 3 | [WebAssembly spec testsuite], using wasmer for execution. 4 | 5 | [WebAssembly spec testsuite]: https://github.com/WebAssembly/testsuite 6 | 7 | > Note: this project started as a fork of [this crate](https://crates.io/crates/wasmtime-wast). 8 | -------------------------------------------------------------------------------- /runtime/unc-vm/wast/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! Implementation of the WAST text format for wasmer. 2 | #![cfg(target_arch = "x86_64")] 3 | #![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] 4 | #![warn(unused_import_braces)] 5 | #![deny(unstable_features)] 6 | #![allow(clippy::new_without_default)] 7 | #![warn( 8 | clippy::float_arithmetic, 9 | clippy::mut_mut, 10 | clippy::nonminimal_bool, 11 | clippy::map_unwrap_or, 12 | clippy::print_stdout, 13 | clippy::unicode_not_nfc, 14 | clippy::use_self 15 | )] 16 | 17 | mod error; 18 | mod spectest; 19 | mod wast; 20 | 21 | pub use crate::error::{DirectiveError, DirectiveErrors}; 22 | pub use crate::spectest::spectest_importobject; 23 | pub use crate::wast::Wast; 24 | 25 | /// Version number of this crate. 26 | pub const VERSION: &str = env!("CARGO_PKG_VERSION"); 27 | -------------------------------------------------------------------------------- /runtime/unc-wallet-contract/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-wallet-contract" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | description = "Builds and exposes Wallet Contract code." 8 | repository.workspace = true 9 | license.workspace = true 10 | publish = false 11 | 12 | [lints] 13 | workspace = true 14 | 15 | [dependencies] 16 | unc-vm-runner.workspace = true 17 | 18 | [dev-dependencies] 19 | unc-primitives-core.workspace = true 20 | 21 | [build-dependencies] 22 | anyhow.workspace = true 23 | 24 | [features] 25 | nightly_protocol = [ 26 | "unc-vm-runner/nightly_protocol", 27 | ] 28 | nightly = [ 29 | "nightly_protocol", 30 | "unc-vm-runner/nightly", 31 | ] 32 | -------------------------------------------------------------------------------- /runtime/unc-wallet-contract/README.md: -------------------------------------------------------------------------------- 1 | A temporary (placeholder) implementation of the `Wallet Contract`. 2 | 3 | Must not use in production! 4 | 5 | Currently, the contract can only be used in nightly build. 6 | The `build.rs` generates WASM file and saves it to the `./res` directory. 7 | 8 | If you want to use the contract from unc-infra. add this crate as a dependency 9 | to the Cargo.toml and use `unc_wallet_contract::wallet_contract()`. 10 | 11 | In order to review changes to the WASM file, rebuild the wallet contract locally 12 | (remove it beforehand to make sure it was rebuilt later) and check the hashes 13 | by running `check_wallet_contract` and `check_wallet_contract_magic_bytes` tests in `src/lib.rs`. 14 | -------------------------------------------------------------------------------- /runtime/unc-wallet-contract/res/.gitignore: -------------------------------------------------------------------------------- 1 | *.wasm 2 | -------------------------------------------------------------------------------- /runtime/unc-wallet-contract/wallet-contract/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "wallet-contract" 3 | version = "0.1.0" 4 | publish = false 5 | edition = "2021" 6 | 7 | [lib] 8 | crate-type = ["cdylib"] 9 | 10 | [dependencies] 11 | hex = "0.4.2" 12 | serde_json = "1.0.68" 13 | unc-sdk = "0.7.4" 14 | rlp = "0.4.6" 15 | 16 | [dev-dependencies] 17 | borsh = { version = "1.4.0"} 18 | 19 | [profile.release] 20 | codegen-units = 1 21 | # Tell `rustc` to optimize for small code size. 22 | opt-level = "z" 23 | strip = true 24 | lto = true 25 | debug = false 26 | panic = "abort" 27 | rpath = false 28 | debug-assertions = false 29 | incremental = false 30 | overflow-checks = true 31 | 32 | [workspace] 33 | members = [] 34 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | # This specifies the version of Rust we use to build. 3 | # Individual crates in the workspace may support a lower version, as indicated by `rust-version` field in each crate's `Cargo.toml`. 4 | # The version specified below, should be at least as high as the maximum `rust-version` within the workspace. 5 | channel = "1.78.0" 6 | components = [ "rustfmt", "clippy" ] 7 | targets = [ "wasm32-unknown-unknown" ] 8 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | use_small_heuristics = "Max" 2 | reorder_imports = true 3 | edition = "2021" 4 | # This option will merge imports, however it's only available in +nightly. 5 | # imports_granularity = "Module" 6 | # fn_args_density = "Compressed" 7 | # overflow_delimited_expr = "true" 8 | -------------------------------------------------------------------------------- /scripts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utnet-org/utility/cedcc29826cbee5ef22708a2690db45a38867883/scripts/__init__.py -------------------------------------------------------------------------------- /scripts/binaries/build_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export ENGINE="${ENGINE:-docker}" 3 | export ARCH="${ARCH:-x64}" 4 | export ZIP="true" 5 | 6 | for distro in ubuntu-2004 ubuntu-2204 ubuntu-2404 debian-11 debian-12 arch; do 7 | DISTRO=${distro} ./scripts/binaries/build.sh 8 | done 9 | -------------------------------------------------------------------------------- /scripts/binaries/x86_64/arch.Dockerfile: -------------------------------------------------------------------------------- 1 | # This is the first stage. Here we install all the dependencies that we need in order to build the Ternoa binary. 2 | FROM registry.hub.docker.com/archlinux/archlinux:latest as builder 3 | 4 | # This installs all dependencies that we need (besides Rust). 5 | RUN pacman -Syu --noconfirm git clang curl cmake make protobuf -y 6 | 7 | # This installs Rust 8 | RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rust_install.sh && chmod u+x rust_install.sh && ./rust_install.sh -y 9 | 10 | ADD . ./workdir 11 | WORKDIR "/workdir" 12 | 13 | # This install the right toolchain 14 | RUN $HOME/.cargo/bin/rustup show 15 | 16 | # This builds the binary. 17 | RUN $HOME/.cargo/bin/cargo build --locked --release -p unc-node 18 | 19 | # Create output folder 20 | RUN mkdir -p output 21 | 22 | VOLUME ["/output"] 23 | CMD cp ./target/release/unc-node /output 24 | -------------------------------------------------------------------------------- /scripts/binaries/x86_64/debian-11.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:11.9-slim as builder 2 | 3 | # This installs all dependencies that we need (besides Rust). 4 | RUN apt update -y && \ 5 | apt install build-essential git clang curl libssl-dev llvm libudev-dev make cmake protobuf-compiler -y 6 | 7 | # This installs Rust 8 | RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rust_install.sh && chmod u+x rust_install.sh && ./rust_install.sh -y 9 | 10 | ADD . ./workdir 11 | WORKDIR "/workdir" 12 | 13 | # This installs the right toolchain 14 | RUN $HOME/.cargo/bin/rustup show 15 | 16 | # This builds the binary. 17 | RUN $HOME/.cargo/bin/cargo build --locked --release -p unc-node 18 | 19 | # Create output folder 20 | RUN mkdir -p output 21 | 22 | VOLUME ["/output"] 23 | CMD cp ./target/release/unc-node /output 24 | -------------------------------------------------------------------------------- /scripts/binaries/x86_64/debian-12.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:12.5-slim as builder 2 | 3 | # This installs all dependencies that we need (besides Rust). 4 | RUN apt update -y && \ 5 | apt install build-essential git clang curl libssl-dev llvm libudev-dev make cmake protobuf-compiler -y 6 | 7 | # This installs Rust 8 | RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rust_install.sh && chmod u+x rust_install.sh && ./rust_install.sh -y 9 | 10 | ADD . ./workdir 11 | WORKDIR "/workdir" 12 | 13 | # This installs the right toolchain 14 | RUN $HOME/.cargo/bin/rustup show 15 | 16 | # This builds the binary. 17 | RUN $HOME/.cargo/bin/cargo build --locked --release -p unc-node 18 | 19 | # Create output folder 20 | RUN mkdir -p output 21 | 22 | VOLUME ["/output"] 23 | CMD cp ./target/release/unc-node /output 24 | -------------------------------------------------------------------------------- /scripts/binaries/x86_64/shared.dockerignore: -------------------------------------------------------------------------------- 1 | # Ignore everything 2 | * 3 | 4 | # Allow files and directories 5 | !/chain 6 | !/core 7 | !/infra 8 | !/runtime 9 | !/node 10 | !/utils 11 | !/tools 12 | !/integration-tests 13 | !/test-utils 14 | !/genesis-tools 15 | !Cargo.toml 16 | !Cargo.lock 17 | !rust-toolchain.toml 18 | !rustfmt.toml 19 | !.git 20 | -------------------------------------------------------------------------------- /scripts/binaries/x86_64/ubuntu-2004.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 as builder 2 | 3 | ARG DEBIAN_FRONTEND=noninteractive 4 | ENV TZ=Etc/UTC 5 | 6 | # This installs all dependencies that we need (besides Rust). 7 | RUN apt update -y && \ 8 | apt install build-essential git clang curl libssl-dev llvm libudev-dev make cmake protobuf-compiler -y 9 | 10 | # This installs Rust 11 | RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rust_install.sh && chmod u+x rust_install.sh && ./rust_install.sh -y 12 | 13 | ADD . ./workdir 14 | WORKDIR "/workdir" 15 | 16 | # This installs the right toolchain 17 | RUN $HOME/.cargo/bin/rustup show 18 | 19 | # This builds the binary. 20 | RUN $HOME/.cargo/bin/cargo build --locked --release -p unc-node 21 | 22 | # Create output folder 23 | RUN mkdir -p output 24 | 25 | VOLUME ["/output"] 26 | CMD cp ./target/release/unc-node /output 27 | -------------------------------------------------------------------------------- /scripts/binaries/x86_64/ubuntu-2204.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:22.04 as builder 2 | 3 | # This installs all dependencies that we need (besides Rust). 4 | RUN apt update -y && \ 5 | apt install build-essential git clang curl libssl-dev llvm libudev-dev make cmake protobuf-compiler -y 6 | 7 | # This installs Rust 8 | RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rust_install.sh && chmod u+x rust_install.sh && ./rust_install.sh -y 9 | 10 | ADD . ./workdir 11 | WORKDIR "/workdir" 12 | 13 | # This installs the right toolchain 14 | RUN $HOME/.cargo/bin/rustup show 15 | 16 | # This builds the binary. 17 | RUN $HOME/.cargo/bin/cargo build --locked --release -p unc-node 18 | 19 | # Create output folder 20 | RUN mkdir -p output 21 | 22 | VOLUME ["/output"] 23 | CMD cp ./target/release/unc-node /output 24 | -------------------------------------------------------------------------------- /scripts/binaries/x86_64/ubuntu-2404.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:24.04 as builder 2 | 3 | # This installs all dependencies that we need (besides Rust). 4 | RUN apt update -y && \ 5 | apt install build-essential git clang curl libssl-dev llvm libudev-dev make cmake protobuf-compiler -y 6 | 7 | # This installs Rust 8 | RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rust_install.sh && chmod u+x rust_install.sh && ./rust_install.sh -y 9 | 10 | ADD . ./workdir 11 | WORKDIR "/workdir" 12 | 13 | # This installs the right toolchain 14 | RUN $HOME/.cargo/bin/rustup show 15 | 16 | # This builds the binary. 17 | RUN $HOME/.cargo/bin/cargo build --locked --release -p unc-node 18 | 19 | # Create output folder 20 | RUN mkdir -p output 21 | 22 | VOLUME ["/output"] 23 | CMD cp ./target/release/unc-node /output 24 | -------------------------------------------------------------------------------- /scripts/coverage-wrapper-rustc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## When collecting coverage we want to instrument only the crates in our workspace, and not the 4 | ## external dependencies (there is no value in doing so – we don’t run tests for our dependencies 5 | ## anyway.) Furthermore, instrumenting the crates like these run a risk of significant performance 6 | ## regressions, such as seen in #10201 7 | 8 | RUSTC="$1"; shift 9 | exec "$RUSTC" -Cinstrument-coverage --cfg=coverage "$@" 10 | -------------------------------------------------------------------------------- /scripts/install_precommit.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "Copying rustfmt.toml into ~/.config/rustfmt/" 4 | mkdir -p "${HOME}"/.config/rustfmt 5 | cp $(dirname "${0}")/../rustfmt.toml "${HOME}"/.config/rustfmt/ 6 | 7 | if [[ ! -f "${HOME}/.local/bin/pre-commit" ]]; then 8 | echo "installing pre-commit program" 9 | if [[ ! -z "$(command -v pip3)" ]]; then 10 | pip3 install pre-commit 11 | elif [[ ! -z "$(command -v pip)" ]]; then 12 | pip install pre-commit 13 | else 14 | echo "Please install pip3 or pip and rerun this script" 15 | exit 1 16 | fi 17 | fi 18 | 19 | "${HOME}"/.local/bin/pre-commit install 20 | -------------------------------------------------------------------------------- /scripts/requirements_check.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | npm --version 6 | # if that's the issue use 7 | # yarn config set ignore-engines true 8 | npm current node -v 9 | yarn --version 10 | python3 --version 11 | cargo --version 12 | 13 | 14 | if [[ $(yarn --version) != "1."* ]]; then 15 | echo "You version of yarn is too old $(yarn --version) < 1.0" 16 | echo "Install with npm install --global yarn" 17 | exit 1 18 | fi 19 | 20 | -------------------------------------------------------------------------------- /scripts/run_docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | UNC_HOME=${UNC_HOME:-/srv/unc} 5 | export UNC_HOME 6 | 7 | if [ -n "$INIT" ]; then 8 | unc-node init --download-genesis --download-config ${CHAIN_ID:+--chain-id="$CHAIN_ID"} \ 9 | ${ACCOUNT_ID:+--account-id="$ACCOUNT_ID"} 10 | fi 11 | 12 | if [ -n "$NODE_KEY" ]; then 13 | cat << EOF > "$UNC_HOME/node_key.json" 14 | {"account_id": "", "public_key": "", "private_key": "$NODE_KEY"} 15 | EOF 16 | fi 17 | 18 | ulimit -c unlimited 19 | 20 | echo "Telemetry: ${TELEMETRY_URL}" 21 | echo "Bootnodes: ${BOOT_NODES}" 22 | 23 | exec unc-node run ${TELEMETRY_URL:+--telemetry-url="$TELEMETRY_URL"} \ 24 | ${BOOT_NODES:+--boot-nodes="$BOOT_NODES"} "$@" 25 | -------------------------------------------------------------------------------- /scripts/setup_hooks.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" 3 | HOOK_DIR=$(git rev-parse --show-toplevel)/.git/hooks 4 | ln -s -f ${DIR}/pre-commit ${HOOK_DIR} 5 | -------------------------------------------------------------------------------- /scripts/state/split-genesis.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Splits given genesis.json into 2 files: 4 | # - genesis_config.json - that contains all fields except for the records 5 | # - genesis_records.json - that contains all records from the genesis.json 6 | # It keeps key order in the genesis config file. 7 | 8 | import json 9 | import os 10 | import sys 11 | from collections import OrderedDict 12 | 13 | filename = sys.argv[1] 14 | with open(filename) as fd: 15 | q = json.load(fd, object_pairs_hook=OrderedDict) 16 | 17 | records = q['records'] 18 | q['records'] = [] 19 | 20 | dirname = os.path.dirname(filename) 21 | with open(os.path.join(dirname, 'genesis_config.json'), 'w') as fd: 22 | json.dump(q, fd, indent=2) 23 | with open(os.path.join(dirname, '_genesis_records.json'), 'w') as fd: 24 | json.dump(records, fd, indent=2) 25 | -------------------------------------------------------------------------------- /test-utils/actix-test-utils/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-actix-test-utils" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | actix-rt.workspace = true 16 | futures.workspace = true 17 | once_cell.workspace = true 18 | 19 | unc-store.workspace = true 20 | 21 | [features] 22 | nightly = [ 23 | "nightly_protocol", 24 | "unc-store/nightly", 25 | ] 26 | nightly_protocol = [ 27 | "unc-store/nightly_protocol", 28 | ] 29 | -------------------------------------------------------------------------------- /test-utils/logger/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-logger-utils" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [dependencies] 12 | tracing.workspace = true 13 | unc-o11y.workspace = true 14 | -------------------------------------------------------------------------------- /test-utils/runtime-tester/fuzz/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | target 3 | corpus 4 | artifacts 5 | -------------------------------------------------------------------------------- /test-utils/runtime-tester/fuzz/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "runtime-tester-fuzz" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [package.metadata] 15 | cargo-fuzz = true 16 | 17 | [dependencies] 18 | libfuzzer-sys.workspace = true 19 | serde_json.workspace = true 20 | runtime-tester.workspace = true 21 | 22 | [[bin]] 23 | name = "runtime_fuzzer" 24 | path = "fuzz_targets_disabled/runtime_fuzzer.rs" 25 | test = false 26 | doc = false 27 | -------------------------------------------------------------------------------- /test-utils/store-validator/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "store-validator" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | clap.workspace = true 16 | yansi.workspace = true 17 | 18 | unc-epoch-manager.workspace = true 19 | unc-chain-configs.workspace = true 20 | unc-primitives.workspace = true 21 | unc-store.workspace = true 22 | unc-o11y.workspace = true 23 | unc-chain.workspace = true 24 | unc-infra.workspace = true 25 | 26 | [dev-dependencies] 27 | testlib.workspace = true 28 | serde_json.workspace = true 29 | unc-client.workspace = true 30 | -------------------------------------------------------------------------------- /test-utils/testlib/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod fees_utils; 2 | pub mod process_blocks; 3 | pub mod runtime_utils; 4 | -------------------------------------------------------------------------------- /tools/amend-genesis/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-amend-genesis" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | anyhow.workspace = true 16 | borsh.workspace = true 17 | clap.workspace = true 18 | num-rational.workspace = true 19 | serde.workspace = true 20 | serde_json.workspace = true 21 | tempfile.workspace = true 22 | tracing.workspace = true 23 | 24 | unc-chain.workspace = true 25 | unc-chain-configs.workspace = true 26 | unc-crypto.workspace = true 27 | unc-epoch-manager.workspace = true 28 | unc-network.workspace = true 29 | unc-primitives.workspace = true 30 | unc-primitives-core.workspace = true 31 | unc-store.workspace = true 32 | unc-test-contracts.workspace = true 33 | unc-infra.workspace = true 34 | node-runtime.workspace = true 35 | -------------------------------------------------------------------------------- /tools/chainsync-loadtest/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "chainsync-loadtest" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [[bin]] 15 | path = "src/main.rs" 16 | name = "chainsync-loadtest" 17 | 18 | [dependencies] 19 | actix.workspace = true 20 | anyhow.workspace = true 21 | async-trait.workspace = true 22 | clap.workspace = true 23 | dirs.workspace = true 24 | futures.workspace = true 25 | log.workspace = true 26 | openssl-probe.workspace = true 27 | parking_lot.workspace = true 28 | rand.workspace = true 29 | tokio.workspace = true 30 | 31 | unc-async.workspace = true 32 | unc-chain-configs.workspace = true 33 | unc-crypto.workspace = true 34 | unc-primitives.workspace = true 35 | unc-store.workspace = true 36 | unc-infra.workspace = true 37 | unc-network.workspace = true 38 | unc-o11y.workspace = true 39 | -------------------------------------------------------------------------------- /tools/chainsync-loadtest/src/concurrency/mod.rs: -------------------------------------------------------------------------------- 1 | mod once; 2 | mod rate_limiter; 3 | pub mod weak_map; 4 | 5 | pub use once::Once; 6 | pub use rate_limiter::RateLimiter; 7 | pub use weak_map::WeakMap; 8 | -------------------------------------------------------------------------------- /tools/cold-store/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cold-store-tool" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | anyhow.workspace = true 16 | borsh.workspace = true 17 | clap.workspace = true 18 | rand.workspace = true 19 | strum.workspace = true 20 | tracing.workspace = true 21 | 22 | unc-infra.workspace = true 23 | unc-chain-configs.workspace = true 24 | unc-epoch-manager.workspace = true 25 | unc-primitives.workspace = true 26 | unc-store.workspace = true 27 | -------------------------------------------------------------------------------- /tools/cold-store/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod cli; 2 | pub use cli::ColdStoreCommand; 3 | -------------------------------------------------------------------------------- /tools/crates-publish-checker/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "crates-publish-checker" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | description = "https://en.wikipedia.org/wiki/Checklist" 8 | repository.workspace = true 9 | license.workspace = true 10 | publish = false 11 | 12 | [lints] 13 | workspace = true 14 | 15 | [dependencies] 16 | toml.workspace = true 17 | serde.workspace = true 18 | anyhow.workspace = true 19 | semver.workspace = true 20 | cargo_metadata.workspace = true 21 | -------------------------------------------------------------------------------- /tools/database/src/compact.rs: -------------------------------------------------------------------------------- 1 | use crate::utils::{open_rocksdb, resolve_column}; 2 | use clap::Parser; 3 | use std::path::PathBuf; 4 | use unc_store::db::Database; 5 | 6 | #[derive(Parser)] 7 | pub(crate) struct RunCompactionCommand { 8 | /// If specified only this column will compacted 9 | #[arg(short, long)] 10 | column: Option, 11 | } 12 | 13 | impl RunCompactionCommand { 14 | pub(crate) fn run(&self, home: &PathBuf) -> anyhow::Result<()> { 15 | let db = open_rocksdb(home, unc_store::Mode::ReadWrite)?; 16 | if let Some(col_name) = &self.column { 17 | db.compact_column(resolve_column(col_name)?)?; 18 | } else { 19 | db.compact()?; 20 | } 21 | eprintln!("Compaction is finished!"); 22 | Ok(()) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tools/database/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod adjust_database; 2 | mod analyse_data_size_distribution; 3 | mod analyse_gas_usage; 4 | mod block_iterators; 5 | pub mod commands; 6 | mod compact; 7 | mod corrupt; 8 | mod make_snapshot; 9 | mod memtrie; 10 | mod run_migrations; 11 | mod state_perf; 12 | mod utils; 13 | -------------------------------------------------------------------------------- /tools/database/src/run_migrations.rs: -------------------------------------------------------------------------------- 1 | use std::path::Path; 2 | 3 | #[derive(clap::Args)] 4 | pub(crate) struct RunMigrationsCommand {} 5 | 6 | impl RunMigrationsCommand { 7 | pub(crate) fn run(&self, home_dir: &Path) -> anyhow::Result<()> { 8 | let mut unc_config = unc_infra::config::load_config( 9 | &home_dir, 10 | unc_chain_configs::GenesisValidationMode::UnsafeFast, 11 | ) 12 | .unwrap_or_else(|e| panic!("Error loading config: {:#}", e)); 13 | unc_infra::open_storage(home_dir, &mut unc_config)?; 14 | Ok(()) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tools/debug-ui/.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | build/ 3 | -------------------------------------------------------------------------------- /tools/debug-ui/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | browser: true 3 | es2021: true 4 | extends: 5 | - eslint:recommended 6 | - plugin:react/recommended 7 | - plugin:react/jsx-runtime 8 | - plugin:@typescript-eslint/recommended 9 | - plugin:import/recommended 10 | - plugin:import/typescript 11 | - prettier 12 | overrides: [] 13 | parser: '@typescript-eslint/parser' 14 | parserOptions: 15 | ecmaVersion: latest 16 | sourceType: module 17 | plugins: 18 | - react 19 | - '@typescript-eslint' 20 | rules: 21 | import/order: 22 | - error 23 | '@typescript-eslint/no-non-null-assertion': 24 | - off 25 | '@typescript-eslint/no-unused-vars': 26 | - error 27 | '@typescript-eslint/no-empty-function': 28 | - off 29 | settings: 30 | import/resolver: 31 | typescript: true 32 | node: true 33 | react: 34 | version: detect 35 | -------------------------------------------------------------------------------- /tools/debug-ui/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /tools/debug-ui/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100, 3 | "tabWidth": 4, 4 | "singleQuote": true, 5 | "bracketSameLine": true 6 | } -------------------------------------------------------------------------------- /tools/debug-ui/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:19-alpine AS build 2 | 3 | WORKDIR /build 4 | ADD package.json /build/package.json 5 | ADD package-lock.json /build/package-lock.json 6 | RUN npm install 7 | 8 | ADD src /build/src 9 | ADD public /build/public 10 | ADD tsconfig.json /build/tsconfig.json 11 | RUN npm run build 12 | 13 | # Serving does not require npm; simple nginx is good enough; it's just some 14 | # static files. 15 | FROM nginx:1.25.3-alpine 16 | COPY --from=build /build/build /var/www/html 17 | COPY nginx.conf /etc/nginx/conf.d/default.conf 18 | -------------------------------------------------------------------------------- /tools/debug-ui/nginx.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | root /var/www/html; 4 | 5 | location /static { 6 | alias /var/www/html/static; 7 | } 8 | 9 | location / { 10 | try_files $uri /index.html; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tools/debug-ui/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | React App 9 | 10 | 11 | 12 | 13 |
14 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /tools/debug-ui/src/App.scss: -------------------------------------------------------------------------------- 1 | .navbar { 2 | padding: 4px; 3 | background-color: #eee; 4 | border-bottom: 1px solid gray; 5 | 6 | .nav-link { 7 | margin: -4px 4px; 8 | padding: 4px 8px; 9 | text-decoration: none; 10 | color: black; 11 | 12 | &:first-child { 13 | margin-left: -4px; 14 | } 15 | 16 | &.active { 17 | background-color: rgb(53, 53, 159); 18 | color: white; 19 | } 20 | 21 | &:hover { 22 | background-color: rgb(93, 93, 217); 23 | color: white; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tools/debug-ui/src/BlocksView.scss: -------------------------------------------------------------------------------- 1 | .chain-and-chunk-blocks-view { 2 | .error { 3 | color: red; 4 | } 5 | } 6 | .chain-and-chunk-blocks-table { 7 | table { 8 | width: 100%; 9 | border-collapse: collapse; 10 | } 11 | 12 | table, 13 | th, 14 | td { 15 | border: 1px solid black; 16 | } 17 | 18 | td { 19 | text-align: left; 20 | vertical-align: top; 21 | padding: 8px; 22 | } 23 | 24 | th { 25 | text-align: center; 26 | vertical-align: center; 27 | padding: 8px; 28 | background-color: lightgrey; 29 | } 30 | 31 | tr.active { 32 | background-color: #eff8bf; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tools/debug-ui/src/ChainAndChunkInfoView.scss: -------------------------------------------------------------------------------- 1 | .chain-and-chunk-info-view { 2 | .error { 3 | color: red; 4 | } 5 | 6 | table { 7 | width: 100%; 8 | border-collapse: collapse; 9 | } 10 | 11 | table, 12 | th, 13 | td { 14 | border: 1px solid black; 15 | } 16 | 17 | td { 18 | text-align: left; 19 | vertical-align: top; 20 | padding: 8px; 21 | } 22 | 23 | th { 24 | text-align: center; 25 | vertical-align: center; 26 | padding: 8px; 27 | background-color: lightgrey; 28 | } 29 | 30 | tr.active { 31 | background-color: #eff8bf; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tools/debug-ui/src/ChainInfoSummaryView.scss: -------------------------------------------------------------------------------- 1 | .chain-info-summary-view { 2 | .error { 3 | color: red; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /tools/debug-ui/src/ClusterNodeView.scss: -------------------------------------------------------------------------------- 1 | .cluster-node-view { 2 | display: flex; 3 | align-items: center; 4 | 5 | &:hover { 6 | background-color: lightgray; 7 | } 8 | 9 | .addr { 10 | width: 150px; 11 | } 12 | 13 | .loading { 14 | color: gray; 15 | font-style: italic; 16 | } 17 | 18 | .height { 19 | width: 80px; 20 | margin: 0 10px; 21 | font-family: 'Courier New', Courier, monospace; 22 | text-align: center; 23 | } 24 | 25 | .account { 26 | width: 300px; 27 | margin: 0 10px; 28 | overflow: hidden; 29 | text-overflow: ellipsis; 30 | } 31 | 32 | .error { 33 | color: red; 34 | } 35 | 36 | .old-height { 37 | color: brown; 38 | background-color: #fcc; 39 | } 40 | 41 | a { 42 | text-decoration: none; 43 | } 44 | 45 | .sync-status { 46 | width: 200px; 47 | margin: 0 10px; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /tools/debug-ui/src/ClusterView.scss: -------------------------------------------------------------------------------- 1 | .cluster-view { 2 | padding: 10px; 3 | 4 | .title { 5 | font-weight: bold; 6 | margin-bottom: 10px; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tools/debug-ui/src/ConnectionStorageView.scss: -------------------------------------------------------------------------------- 1 | .connection-storage-table { 2 | margin: 10px; 3 | } 4 | -------------------------------------------------------------------------------- /tools/debug-ui/src/CurrentPeersView.scss: -------------------------------------------------------------------------------- 1 | .current-peers-view { 2 | padding: 10px; 3 | 4 | .peer_in_sync { 5 | background-color: green; 6 | color: white; 7 | } 8 | 9 | .peer_ahead { 10 | background-color: lightblue; 11 | } 12 | 13 | .peer_ahead_alot { 14 | background-color: blueviolet; 15 | color: white; 16 | } 17 | 18 | .peer_behind_a_little { 19 | background-color: yellowgreen; 20 | } 21 | 22 | .peer_behind { 23 | background-color: yellow; 24 | } 25 | 26 | .peer_far_behind { 27 | background-color: red; 28 | color: white; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tools/debug-ui/src/EpochInfoView.scss: -------------------------------------------------------------------------------- 1 | .epoch-info-view { 2 | .error { 3 | color: red; 4 | } 5 | 6 | table { 7 | width: 100%; 8 | border-collapse: collapse; 9 | } 10 | 11 | th, 12 | td { 13 | border: 1px solid #444; 14 | } 15 | 16 | td { 17 | text-align: left; 18 | vertical-align: top; 19 | padding: 8px; 20 | } 21 | 22 | th { 23 | text-align: center; 24 | vertical-align: center; 25 | padding: 8px; 26 | background-color: lightgrey; 27 | } 28 | 29 | .content { 30 | padding: 10px; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tools/debug-ui/src/FloatingChunksView.scss: -------------------------------------------------------------------------------- 1 | .floating-chunks-view { 2 | .error { 3 | color: red; 4 | } 5 | } 6 | .floating-chunks-table { 7 | table { 8 | width: 100%; 9 | border-collapse: collapse; 10 | } 11 | 12 | table, 13 | th, 14 | td { 15 | border: 1px solid black; 16 | } 17 | 18 | td { 19 | text-align: left; 20 | vertical-align: top; 21 | padding: 8px; 22 | } 23 | 24 | th { 25 | text-align: center; 26 | vertical-align: center; 27 | padding: 8px; 28 | background-color: lightgrey; 29 | } 30 | 31 | tr.active { 32 | background-color: #eff8bf; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tools/debug-ui/src/HeaderBar.scss: -------------------------------------------------------------------------------- 1 | .header-bar { 2 | width: 100%; 3 | display: flex; 4 | align-items: center; 5 | background-color: #eee; 6 | border-bottom: 1px solid gray; 7 | padding: 4px; 8 | box-sizing: border-box; 9 | 10 | .loading { 11 | color: gray; 12 | font-style: italic; 13 | } 14 | 15 | .error { 16 | color: red; 17 | } 18 | 19 | .label { 20 | margin: -4px 4px -4px 4px; 21 | padding: 4px 8px; 22 | border-left: 1px solid gray; 23 | border-right: 1px solid gray; 24 | background-color: #666; 25 | color: white; 26 | } 27 | 28 | .label:first-child { 29 | border-left: none; 30 | margin-left: -4px; 31 | } 32 | 33 | .value { 34 | margin-right: 20px; 35 | margin-left: 4px; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tools/debug-ui/src/LandingPage.scss: -------------------------------------------------------------------------------- 1 | .landing-page { 2 | padding: 10px; 3 | 4 | input { 5 | font-family: 'Courier New', Courier, monospace; 6 | } 7 | 8 | button { 9 | margin-left: 10px; 10 | } 11 | 12 | form { 13 | margin-top: 10px; 14 | display: flex; 15 | } 16 | 17 | h3 { 18 | font-size: 1.5em; 19 | font-weight: bold; 20 | } 21 | 22 | .spacer { 23 | height: 100px; 24 | } 25 | 26 | ul { 27 | list-style-type: initial; 28 | 29 | li { 30 | margin-left: 20px; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tools/debug-ui/src/NetworkInfoView.scss: -------------------------------------------------------------------------------- 1 | .network-info-view { 2 | .error { 3 | color: red; 4 | } 5 | 6 | table { 7 | width: 100%; 8 | border-collapse: collapse; 9 | } 10 | 11 | table, 12 | th, 13 | td { 14 | border: 1px solid black; 15 | } 16 | 17 | td { 18 | text-align: left; 19 | vertical-align: top; 20 | padding: 8px; 21 | } 22 | 23 | th { 24 | text-align: center; 25 | vertical-align: center; 26 | padding: 8px; 27 | background-color: lightgrey; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tools/debug-ui/src/PeerStorageView.scss: -------------------------------------------------------------------------------- 1 | .peer-storage-table { 2 | margin: 10px; 3 | } 4 | -------------------------------------------------------------------------------- /tools/debug-ui/src/RecentEpochsView.scss: -------------------------------------------------------------------------------- 1 | .recent-epochs-table { 2 | th:first-child { 3 | border: none; 4 | background-color: transparent; 5 | } 6 | 7 | td:first-child { 8 | border: none; 9 | background-color: none; 10 | text-align: right; 11 | white-space: nowrap; 12 | } 13 | 14 | tr.current-epoch { 15 | td:not(:first-child) { 16 | background-color: #c6f8bf; 17 | } 18 | 19 | td:first-child { 20 | color: #3bda26; 21 | } 22 | } 23 | 24 | tr.next-epoch { 25 | color: gray; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tools/debug-ui/src/RoutingTableView.scss: -------------------------------------------------------------------------------- 1 | .routing-table-view { 2 | margin: 10px; 3 | } 4 | -------------------------------------------------------------------------------- /tools/debug-ui/src/SnapshotHostsView.scss: -------------------------------------------------------------------------------- 1 | .snapshot-hosts-view { 2 | margin: 10px; 3 | } 4 | -------------------------------------------------------------------------------- /tools/debug-ui/src/Tier1View.scss: -------------------------------------------------------------------------------- 1 | .tier1-peers-view { 2 | padding: 10px; 3 | } 4 | -------------------------------------------------------------------------------- /tools/debug-ui/src/entity_debug/EntityDebugView.scss: -------------------------------------------------------------------------------- 1 | .entity-debug-view { 2 | display: flex; 3 | height: calc(100vh - 66px); 4 | align-items: stretch; 5 | 6 | .left-panel { 7 | border-right: 1px solid gray; 8 | display: flex; 9 | flex-direction: column; 10 | } 11 | 12 | .right-panel { 13 | flex: 1; 14 | display: flex; 15 | flex-direction: column; 16 | } 17 | 18 | .left-panel-query-list { 19 | flex: 1; 20 | display: flex; 21 | flex-direction: column; 22 | min-height: 0; 23 | } 24 | 25 | .right-panel-entity-tree { 26 | flex: 1; 27 | overflow: hidden; 28 | overflow-y: auto; 29 | display: flex; 30 | align-items: stretch; 31 | 32 | > * { 33 | flex: 1; 34 | } 35 | } 36 | 37 | .right-panel-pinned-keys { 38 | background-color: #eee; 39 | padding: 2px 10px; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tools/debug-ui/src/entity_debug/KeyInput.scss: -------------------------------------------------------------------------------- 1 | .key-editor { 2 | display: flex; 3 | gap: 6px; 4 | align-items: center; 5 | 6 | .key-value { 7 | width: 500px; 8 | border: 1px solid gray; 9 | 10 | &.key-value-invalid { 11 | border: 1px solid red; 12 | background-color: #ffe6e6; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tools/debug-ui/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 4 | 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | } 8 | 9 | code { 10 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; 11 | } 12 | -------------------------------------------------------------------------------- /tools/debug-ui/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /tools/debug-ui/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2015", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "preserve" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } -------------------------------------------------------------------------------- /tools/epoch-sync/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-epoch-sync-tool" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | anyhow.workspace = true 16 | clap.workspace = true 17 | tracing.workspace = true 18 | 19 | unc-infra = { workspace = true, features = ["new_epoch_sync"] } 20 | unc-chain.workspace = true 21 | unc-chain-configs.workspace = true 22 | unc-epoch-manager.workspace = true 23 | unc-primitives.workspace = true 24 | unc-store.workspace = true 25 | -------------------------------------------------------------------------------- /tools/epoch-sync/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod cli; 2 | pub use cli::EpochSyncCommand; 3 | -------------------------------------------------------------------------------- /tools/flat-storage/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-flat-storage" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | anyhow.workspace = true 16 | borsh.workspace = true 17 | clap.workspace = true 18 | rayon.workspace = true 19 | tqdm.workspace = true 20 | tracing.workspace = true 21 | 22 | unc-chain.workspace = true 23 | unc-chain-configs.workspace = true 24 | unc-epoch-manager.workspace = true 25 | unc-primitives.workspace = true 26 | unc-store.workspace = true 27 | unc-infra.workspace = true 28 | -------------------------------------------------------------------------------- /tools/flat-storage/README.md: -------------------------------------------------------------------------------- 1 | Set of tools for debugging and experimenting with flat storage. -------------------------------------------------------------------------------- /tools/flat-storage/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod commands; 2 | -------------------------------------------------------------------------------- /tools/fork-network/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod cli; 2 | mod single_shard_storage_mutator; 3 | mod storage_mutator; 4 | -------------------------------------------------------------------------------- /tools/indexer/example/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "indexer-example" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | actix.workspace = true 16 | anyhow.workspace = true 17 | clap.workspace = true 18 | openssl-probe.workspace = true 19 | serde_json.workspace = true 20 | tokio.workspace = true 21 | tracing.workspace = true 22 | 23 | unc-indexer.workspace = true 24 | unc-o11y.workspace = true 25 | -------------------------------------------------------------------------------- /tools/indexer/example/README.md: -------------------------------------------------------------------------------- 1 | Utility Indexer Simple Logger Example 2 | ================================== 3 | 4 | This is an example project featuring [Utility Indexer Framework](https://github.com/utnet-org/utility/tree/master/chain/indexer). This Indexer prints out all the blocks, chunks, transactions, receipts, execution outcomes, and state changes block by block immediately once it gets finalized in the network. 5 | 6 | Refer to the Utility Indexer Framework README to learn how to run this example. 7 | -------------------------------------------------------------------------------- /tools/mirror/src/metrics.rs: -------------------------------------------------------------------------------- 1 | use once_cell::sync::Lazy; 2 | use unc_o11y::metrics::{ 3 | try_create_int_counter, try_create_int_counter_vec, IntCounter, IntCounterVec, 4 | }; 5 | 6 | pub static TRANSACTIONS_SENT: Lazy = Lazy::new(|| { 7 | try_create_int_counter_vec( 8 | "unc_mirror_transactions_sent", 9 | "Total number of transactions sent", 10 | &["status"], 11 | ) 12 | .unwrap() 13 | }); 14 | 15 | pub static TRANSACTIONS_INCLUDED: Lazy = Lazy::new(|| { 16 | try_create_int_counter( 17 | "unc_mirror_transactions_included", 18 | "Total number of transactions sent that made it on-chain", 19 | ) 20 | .unwrap() 21 | }); 22 | -------------------------------------------------------------------------------- /tools/re-pledged/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "re-pledged" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | clap.workspace = true 16 | tokio.workspace = true 17 | 18 | unc-crypto.workspace = true 19 | unc-primitives.workspace = true 20 | unc-jsonrpc-client.workspace = true 21 | unc-infra.workspace = true 22 | unc-o11y.workspace = true 23 | 24 | integration-tests.workspace = true 25 | 26 | [features] 27 | test_features = ["integration-tests/test_features"] 28 | -------------------------------------------------------------------------------- /tools/rpctypegen/core/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-rpc-error-core" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | description = "This crate generates schema for Rust structs which can be used by TypeScript." 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = true 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | quote.workspace = true 16 | serde.workspace = true 17 | syn.workspace = true 18 | 19 | [dev-dependencies] 20 | serde_json = { workspace = true, features = ["preserve_order"] } 21 | 22 | [features] 23 | test = [] 24 | dump_errors_schema = [] 25 | -------------------------------------------------------------------------------- /tools/rpctypegen/core/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../../LICENSE-GPL2 -------------------------------------------------------------------------------- /tools/rpctypegen/core/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /tools/rpctypegen/macro/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-rpc-error-macro" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | description = "This crate generates schema for Rust structs which can be used by TypeScript." 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = true 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [lib] 15 | proc-macro = true 16 | 17 | [dependencies] 18 | serde.workspace = true 19 | serde_json = { workspace = true, optional = true, features = ["preserve_order"] } 20 | syn.workspace = true 21 | fs2.workspace = true 22 | 23 | unc-rpc-error-core.workspace = true 24 | 25 | [features] 26 | test = [] 27 | dump_errors_schema = ["unc-rpc-error-core/dump_errors_schema", "serde_json"] 28 | -------------------------------------------------------------------------------- /tools/rpctypegen/macro/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../../LICENSE-GPL2 -------------------------------------------------------------------------------- /tools/rpctypegen/macro/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /tools/speedy_sync/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "speedy_sync" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | unc-store.workspace = true 16 | unc-chain-primitives.workspace = true 17 | unc-primitives.workspace = true 18 | unc-infra.workspace = true 19 | unc-chain-configs.workspace = true 20 | unc-chain.workspace = true 21 | unc-epoch-manager.workspace = true 22 | 23 | borsh.workspace = true 24 | serde.workspace = true 25 | serde_json.workspace = true 26 | clap.workspace = true 27 | -------------------------------------------------------------------------------- /tools/state-parts-dump-check/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod cli; 2 | mod metrics; 3 | -------------------------------------------------------------------------------- /tools/state-viewer/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!("../README.md")] 2 | 3 | mod apply_chain_range; 4 | mod apply_chunk; 5 | pub mod cli; 6 | mod commands; 7 | mod contract_accounts; 8 | mod epoch_info; 9 | mod rocksdb_stats; 10 | mod scan_db; 11 | mod state_changes; 12 | mod state_dump; 13 | mod state_parts; 14 | mod trie_iteration_benchmark; 15 | mod tx_dump; 16 | 17 | pub use cli::StateViewerSubCommand; 18 | -------------------------------------------------------------------------------- /tools/storage-usage-delta-calculator/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "storage-usage-delta-calculator" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | anyhow.workspace = true 16 | serde_json.workspace = true 17 | tokio.workspace = true 18 | tracing.workspace = true 19 | 20 | unc-chain-configs.workspace = true 21 | unc-o11y.workspace = true 22 | unc-parameters.workspace = true 23 | unc-primitives.workspace = true 24 | unc-store.workspace = true 25 | node-runtime.workspace = true 26 | -------------------------------------------------------------------------------- /tools/storage-usage-delta-calculator/README.md: -------------------------------------------------------------------------------- 1 | # Storage delta calculator 2 | 3 | A small tool to compare the actual storage use with the one saved within the state. 4 | Useful as a sanity check if we do any updates (as storage has impact on the amount of tokens that we lock in people's accounts). 5 | 6 | WARNING: This was built as a one-time tool - to debug the issue during migration in May 2021 - and is no longer maintained. 7 | -------------------------------------------------------------------------------- /utils/config/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-config-utils" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | description = "This is an internal crate to provide utils for reading config files" 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = true 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | anyhow.workspace = true 16 | json_comments.workspace = true 17 | thiserror.workspace = true 18 | tracing.workspace = true 19 | 20 | -------------------------------------------------------------------------------- /utils/config/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2 -------------------------------------------------------------------------------- /utils/config/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /utils/fmt/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-fmt" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | description = "Helpers for pretty formatting." 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = true 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | unc-primitives-core.workspace = true 16 | 17 | [features] 18 | nightly = [ 19 | "nightly_protocol", 20 | "unc-primitives-core/nightly", 21 | ] 22 | nightly_protocol = [ 23 | "unc-primitives-core/nightly_protocol", 24 | ] 25 | -------------------------------------------------------------------------------- /utils/fmt/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2 -------------------------------------------------------------------------------- /utils/fmt/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /utils/fmt/README.md: -------------------------------------------------------------------------------- 1 | # Custom formatting for the unc-infra.code base 2 | 3 | This crate is a lightweight assembly of wrapper types that we use to pretty 4 | print values. 5 | 6 | Keep dependencies to an absolute minimum, since this crate is a dependency of 7 | `unc-primitives` which in turn is used by many unc related crates inside and 8 | outside the unc-infra.repository. 9 | -------------------------------------------------------------------------------- /utils/mainnet-res/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-mainnet-res" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | serde_json.workspace = true 16 | 17 | unc-account-id.workspace = true 18 | unc-chain-configs.workspace = true 19 | unc-primitives.workspace = true 20 | 21 | [features] 22 | nightly = [ 23 | "nightly_protocol", 24 | "unc-chain-configs/nightly", 25 | "unc-primitives/nightly", 26 | ] 27 | nightly_protocol = [ 28 | "unc-chain-configs/nightly_protocol", 29 | "unc-primitives/nightly_protocol", 30 | ] 31 | -------------------------------------------------------------------------------- /utils/mainnet-res/README.md: -------------------------------------------------------------------------------- 1 | ## Core Resource Files 2 | 3 | Stores resource data which is part of the protocol stable enough to be moved outside of the code. 4 | 5 | ### `mainnet_genesis.json` 6 | 7 | Stores genesis of mainnet. 8 | 9 | ### `mainnet_restored_receipts.json` 10 | 11 | Stores receipts restored after the fix of applying chunks. See [#4248](https://github.com/utnet-org/utility/pull/4248) for more details. 12 | 13 | ### `storage_usage_delta.json` 14 | 15 | Stores difference of storage usage applied to mainnet after observed bug related to delete key action. See [#3824](https://github.com/utnet-org/utility/issues/3824) for more details. 16 | -------------------------------------------------------------------------------- /utils/mainnet-res/src/lib.rs: -------------------------------------------------------------------------------- 1 | use unc_account_id::AccountId; 2 | use unc_chain_configs::Genesis; 3 | use unc_primitives::receipt::ReceiptResult; 4 | 5 | pub fn mainnet_restored_receipts() -> ReceiptResult { 6 | let data = include_bytes!("../res/mainnet_restored_receipts.json"); 7 | serde_json::from_slice(data) 8 | .expect("File with receipts restored after apply_chunks fix has to be correct") 9 | } 10 | 11 | pub fn mainnet_storage_usage_delta() -> Vec<(AccountId, u64)> { 12 | let data = include_bytes!("../res/storage_usage_delta.json"); 13 | serde_json::from_slice(data).expect("File with storage usage delta has to be correct") 14 | } 15 | 16 | pub fn mainnet_genesis() -> Genesis { 17 | let data = include_bytes!("../res/mainnet_genesis.json"); 18 | serde_json::from_slice(data).expect("Failed to deserialize mainnet genesis") 19 | } 20 | -------------------------------------------------------------------------------- /utils/mainnet-res/tests/load_genesis.rs: -------------------------------------------------------------------------------- 1 | use unc_chain_configs::{Genesis, GenesisValidationMode}; 2 | 3 | #[test] 4 | fn test_load_genesis() { 5 | Genesis::from_file("res/mainnet_genesis.json", GenesisValidationMode::Full).unwrap(); 6 | } 7 | -------------------------------------------------------------------------------- /utils/stdx/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-stdx" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | description = "This crate contains polyfills which should really be in std, but currently aren't for one reason or another." 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = true 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | # Absolutely must not depend on any crates from unc-infra.workspace, 16 | # and should have as few dependencies as possible otherwise. 17 | -------------------------------------------------------------------------------- /utils/stdx/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2 -------------------------------------------------------------------------------- /utils/stdx/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /utils/unc-cache/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-cache" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | description = "do not use this, new versions can stop being published at literally any time" 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = true 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | lru.workspace = true 16 | 17 | [dev-dependencies] 18 | bencher.workspace = true 19 | rand.workspace = true 20 | 21 | [[bench]] 22 | name = "cache" 23 | harness = false 24 | -------------------------------------------------------------------------------- /utils/unc-cache/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2 -------------------------------------------------------------------------------- /utils/unc-cache/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /utils/unc-cache/README.md: -------------------------------------------------------------------------------- 1 | # unc-cache 2 | 3 | Do not use this, new versions can stop being published on crates.io at literally any time 4 | -------------------------------------------------------------------------------- /utils/unc-cache/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod cell; 2 | mod sync; 3 | 4 | pub use crate::{cell::CellLruCache, sync::SyncLruCache}; 5 | -------------------------------------------------------------------------------- /utils/unc-performance-metrics-macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-performance-metrics-macros" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | quote.workspace = true 16 | syn.workspace = true 17 | 18 | [lib] 19 | proc-macro = true 20 | -------------------------------------------------------------------------------- /utils/unc-performance-metrics/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-performance-metrics" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = false 10 | 11 | [lints] 12 | workspace = true 13 | 14 | [dependencies] 15 | actix.workspace = true 16 | bitflags.workspace = true 17 | bytes.workspace = true 18 | bytesize = { workspace = true, optional = true } 19 | futures.workspace = true 20 | libc.workspace = true 21 | once_cell.workspace = true 22 | strum.workspace = true 23 | tokio.workspace = true 24 | tokio-util.workspace = true 25 | tracing.workspace = true 26 | 27 | [features] 28 | c_memory_stats = [] 29 | performance_stats = ["bytesize"] 30 | -------------------------------------------------------------------------------- /utils/unc-performance-metrics/src/actix_disabled.rs: -------------------------------------------------------------------------------- 1 | use std::time::Duration; 2 | 3 | pub fn spawn(_class_name: &'static str, f: F) 4 | where 5 | F: futures::Future + 'static, 6 | { 7 | actix::spawn(f); 8 | } 9 | 10 | pub fn run_later(ctx: &mut B, dur: Duration, f: F) -> actix::SpawnHandle 11 | where 12 | B: actix::AsyncContext, 13 | A: actix::Actor, 14 | F: FnOnce(&mut A, &mut A::Context) + 'static, 15 | { 16 | ctx.run_later(dur, f) 17 | } 18 | -------------------------------------------------------------------------------- /utils/unc-performance-metrics/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod actix_disabled; 2 | #[cfg(feature = "performance_stats")] 3 | pub mod actix_enabled; 4 | pub mod process; 5 | pub mod stats_disabled; 6 | #[cfg(feature = "performance_stats")] 7 | pub mod stats_enabled; 8 | 9 | #[cfg(not(feature = "performance_stats"))] 10 | pub use actix_disabled as actix; 11 | #[cfg(feature = "performance_stats")] 12 | pub use actix_enabled as actix; 13 | #[cfg(not(feature = "performance_stats"))] 14 | pub use stats_disabled as stats; 15 | #[cfg(feature = "performance_stats")] 16 | pub use stats_enabled as stats; 17 | -------------------------------------------------------------------------------- /utils/unc-performance-metrics/src/process.rs: -------------------------------------------------------------------------------- 1 | use crate::stats::print_performance_stats; 2 | use std::thread; 3 | use std::time::Duration; 4 | use tracing::{error, info}; 5 | 6 | pub fn schedule_printing_performance_stats(sleep_time: Duration) { 7 | if cfg!(feature = "performance_stats") { 8 | if sleep_time.is_zero() { 9 | info!("print_performance_stats: disabled"); 10 | return; 11 | } 12 | info!("print_performance_stats: enabled"); 13 | 14 | if let Err(err) = 15 | thread::Builder::new().name("PerformanceMetrics".to_string()).spawn(move || loop { 16 | print_performance_stats(sleep_time); 17 | thread::sleep(sleep_time); 18 | }) 19 | { 20 | error!("failed to spawn the thread: {}", err); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /utils/unc-performance-metrics/src/stats_disabled.rs: -------------------------------------------------------------------------------- 1 | use std::time::Duration; 2 | 3 | pub fn measure_performance( 4 | _class_name: &'static str, 5 | msg: Message, 6 | f: F, 7 | ) -> Result 8 | where 9 | F: FnOnce(Message) -> Result, 10 | { 11 | f(msg) 12 | } 13 | 14 | pub fn measure_performance_with_debug( 15 | _class_name: &'static str, 16 | msg: Message, 17 | f: F, 18 | ) -> Result 19 | where 20 | F: FnOnce(Message) -> Result, 21 | for<'a> &'a Message: Into<&'static str>, 22 | { 23 | f(msg) 24 | } 25 | 26 | pub fn print_performance_stats(_sleep_time: Duration) {} 27 | -------------------------------------------------------------------------------- /utils/unc-stable-hasher/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unc-stable-hasher" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | description = "`unc-stable-hasher` is a library that is essentially a wrapper around, now deprecated, `std::hash::SipHasher`." 7 | repository.workspace = true 8 | license.workspace = true 9 | publish = true 10 | 11 | [lints] 12 | workspace = true 13 | -------------------------------------------------------------------------------- /utils/unc-stable-hasher/LICENSE-GPL2: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2 -------------------------------------------------------------------------------- /utils/unc-stable-hasher/LICENSE-GPL2.1: -------------------------------------------------------------------------------- 1 | ../../LICENSE-GPL2.1 -------------------------------------------------------------------------------- /utils/unc-stable-hasher/README.md: -------------------------------------------------------------------------------- 1 | # `unc-stable-hasher` 2 | 3 | `unc-stable-hasher` is a library that is essentially a wrapper around, now deprecated, `std::hash::SipHasher`. 4 | Its purpose is to provide a stable hash function, which doesn't change depending on `rust_version`, `architecture`, `platform`, 5 | `time`, etc. 6 | 7 | In addition, note that `SipHasher` is deprecated since `Rust` `1.13.0`. 8 | Eventually `SipHasher` will be removed from `Rust`. 9 | We need to ensure, nothing breaks during this transition period. 10 | 11 | ## Structs 12 | 13 | This crate provides only one struct. See `StableHasher`. 14 | 15 | ### Example 16 | 17 | ```rust 18 | fn test_stable_hasher() { 19 | let mut sh = StableHasher::new(); 20 | 21 | sh.write(&[1, 2, 3, 4, 5]); 22 | let finish = sh.finish(); 23 | assert_eq!(finish, 12661990674860217757) 24 | } 25 | ``` 26 | --------------------------------------------------------------------------------