├── .dockerignore ├── .editorconfig ├── .envrc ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ └── security-assessment-issue.md └── workflows │ ├── ci.yml │ ├── nightly_build.yml │ ├── pr_block.yml │ ├── release.yml │ └── unit-test-results.yml ├── .gitignore ├── .gitmodules ├── .nvmrc ├── .vscode └── tasks.json ├── AllTests-mainnet.md ├── CHANGELOG.md ├── ConsensusSpecPreset-mainnet.md ├── ConsensusSpecPreset-minimal.md ├── Dockerfile ├── LICENSE-APACHEv2 ├── LICENSE-MIT ├── Makefile ├── README.md ├── beacon_chain.nimble ├── beacon_chain ├── .editorconfig ├── .gitignore ├── beacon_chain_db.nim ├── beacon_chain_db_immutable.nim ├── beacon_chain_db_light_client.nim ├── beacon_chain_file.nim ├── beacon_clock.nim ├── beacon_node.nim ├── beacon_node_light_client.nim ├── beacon_node_status.nim ├── conf.nim ├── conf_common.nim ├── conf_light_client.nim ├── consensus_object_pools │ ├── README.md │ ├── attestation_pool.nim │ ├── blob_quarantine.nim │ ├── block_clearance.nim │ ├── block_dag.nim │ ├── block_pools_types.nim │ ├── block_pools_types_light_client.nim │ ├── block_quarantine.nim │ ├── blockchain_dag.nim │ ├── blockchain_dag_light_client.nim │ ├── blockchain_list.nim │ ├── common_tools.nim │ ├── consensus_manager.nim │ ├── data_column_quarantine.nim │ ├── light_client_pool.nim │ ├── spec_cache.nim │ ├── sync_committee_msg_pool.nim │ ├── validator_change_pool.nim │ └── vanity_logs │ │ ├── bellatrix │ │ ├── blink.ans │ │ ├── color.ans │ │ └── mono.txt │ │ ├── capella │ │ ├── blink.ans │ │ ├── color.ans │ │ └── mono.txt │ │ ├── deneb │ │ ├── color.ans │ │ └── mono.txt │ │ ├── electra │ │ ├── blink.ans │ │ ├── color.ans │ │ └── mono.txt │ │ └── vanity_logs.nim ├── db_limits.nim ├── deposits.nim ├── el │ ├── deposit_contract.nim │ ├── deposit_contract.nim.cfg │ ├── deposit_contract_code.txt │ ├── el_conf.nim │ ├── el_manager.nim │ ├── engine_api_conversions.nim │ ├── eth1_chain.nim │ └── merkle_minimal.nim ├── era_db.nim ├── extras.nim ├── filepath.nim ├── fork_choice │ ├── README.md │ ├── fork_choice.nim │ ├── fork_choice_types.nim │ └── proto_array.nim ├── gossip_processing │ ├── README.md │ ├── batch_validation.nim │ ├── block_processor.nim │ ├── eth2_processor.nim │ ├── gossip_validation.nim │ ├── light_client_processor.nim │ └── optimistic_processor.nim ├── libnimbus_lc │ ├── libnimbus_lc.h │ ├── libnimbus_lc.nim │ ├── test_files │ │ ├── bootstrap.ssz │ │ ├── config.yaml │ │ ├── executionBlockHeader.json │ │ ├── finUpdate.json │ │ ├── finUpdate.ssz │ │ ├── genesis.ssz │ │ ├── optUpdate.json │ │ ├── optUpdate.ssz │ │ ├── optimistic_update.ssz │ │ ├── receipts.json │ │ ├── transactions.json │ │ └── updates.ssz │ └── test_libnimbus_lc.c ├── light_client.nim ├── light_client_db.nim ├── networking │ ├── README.md │ ├── eth2_agents.nim │ ├── eth2_discovery.nim │ ├── eth2_network.nim │ ├── eth2_protocol_dsl.nim │ ├── libp2p_json_serialization.nim │ ├── network_metadata.nim │ ├── network_metadata_downloads.nim │ ├── network_metadata_gnosis.S │ ├── network_metadata_mainnet.S │ ├── peer_pool.nim │ ├── peer_protocol.nim │ ├── peer_scores.nim │ └── topic_params.nim ├── nim.cfg ├── nimbus_beacon_node.nim ├── nimbus_beacon_node.nim.cfg ├── nimbus_binary_common.nim ├── nimbus_light_client.nim ├── nimbus_light_client.nim.cfg ├── nimbus_signing_node.nim ├── nimbus_signing_node.nim.cfg ├── nimbus_validator_client.nim ├── nimbus_validator_client.nim.cfg ├── rpc │ ├── rest_api.nim │ ├── rest_beacon_api.nim │ ├── rest_builder_api.nim │ ├── rest_config_api.nim │ ├── rest_constants.nim │ ├── rest_debug_api.nim │ ├── rest_event_api.nim │ ├── rest_key_management_api.nim │ ├── rest_light_client_api.nim │ ├── rest_nimbus_api.nim │ ├── rest_node_api.nim │ ├── rest_rewards_api.nim │ ├── rest_utils.nim │ ├── rest_validator_api.nim │ └── state_ttl_cache.nim ├── spec │ ├── beacon_time.nim │ ├── beaconstate.nim │ ├── block_id.nim │ ├── crypto.nim │ ├── datatypes │ │ ├── altair.nim │ │ ├── base.nim │ │ ├── bellatrix.nim │ │ ├── capella.nim │ │ ├── constants.nim │ │ ├── deneb.nim │ │ ├── electra.nim │ │ ├── fulu.nim │ │ └── phase0.nim │ ├── deposit_snapshots.nim │ ├── digest.nim │ ├── engine_authentication.nim │ ├── english_word_list.txt │ ├── eth2_apis │ │ ├── dynamic_fee_recipients.nim │ │ ├── eth2_rest_serialization.nim │ │ ├── rest_beacon_calls.nim │ │ ├── rest_beacon_client.nim │ │ ├── rest_builder_calls.nim │ │ ├── rest_common.nim │ │ ├── rest_config_calls.nim │ │ ├── rest_debug_calls.nim │ │ ├── rest_event_calls.nim │ │ ├── rest_fork_config.nim │ │ ├── rest_keymanager_calls.nim │ │ ├── rest_keymanager_types.nim │ │ ├── rest_light_client_calls.nim │ │ ├── rest_nimbus_calls.nim │ │ ├── rest_node_calls.nim │ │ ├── rest_remote_signer_calls.nim │ │ ├── rest_types.nim │ │ └── rest_validator_calls.nim │ ├── eth2_merkleization.nim │ ├── eth2_ssz_serialization.nim │ ├── forks.nim │ ├── forks_light_client.nim │ ├── helpers.nim │ ├── helpers_el.nim │ ├── keystore.nim │ ├── light_client_sync.nim │ ├── mev │ │ ├── bellatrix_mev.nim │ │ ├── capella_mev.nim │ │ ├── deneb_mev.nim │ │ ├── electra_mev.nim │ │ ├── fulu_mev.nim │ │ ├── rest_deneb_mev_calls.nim │ │ ├── rest_electra_mev_calls.nim │ │ └── rest_fulu_mev_calls.nim │ ├── network.nim │ ├── peerdas_helpers.nim │ ├── presets.nim │ ├── presets │ │ ├── gnosis.nim │ │ ├── gnosis │ │ │ ├── altair_preset.nim │ │ │ ├── bellatrix_preset.nim │ │ │ ├── capella_preset.nim │ │ │ ├── deneb_preset.nim │ │ │ ├── electra_preset.nim │ │ │ └── phase0_preset.nim │ │ ├── mainnet.nim │ │ ├── mainnet │ │ │ ├── altair_preset.nim │ │ │ ├── bellatrix_preset.nim │ │ │ ├── capella_preset.nim │ │ │ ├── deneb_preset.nim │ │ │ ├── electra_preset.nim │ │ │ └── phase0_preset.nim │ │ ├── minimal.nim │ │ └── minimal │ │ │ ├── altair_preset.nim │ │ │ ├── bellatrix_preset.nim │ │ │ ├── capella_preset.nim │ │ │ ├── deneb_preset.nim │ │ │ ├── electra_preset.nim │ │ │ └── phase0_preset.nim │ ├── signatures.nim │ ├── signatures_batch.nim │ ├── ssz_codec.nim │ ├── state_transition.nim │ ├── state_transition_block.nim │ ├── state_transition_epoch.nim │ ├── validator.nim │ └── weak_subjectivity.nim ├── sszdump.nim ├── statediff.nim ├── statusbar.nim ├── sync │ ├── README.md │ ├── light_client_manager.nim │ ├── light_client_protocol.nim │ ├── light_client_sync_helpers.nim │ ├── request_manager.nim │ ├── sync_manager.nim │ ├── sync_overseer.nim │ ├── sync_protocol.nim │ ├── sync_queue.nim │ └── sync_types.nim ├── trusted_node_sync.nim ├── validator_bucket_sort.nim ├── validator_client │ ├── api.nim │ ├── attestation_service.nim │ ├── block_service.nim │ ├── common.nim │ ├── doppelganger_service.nim │ ├── duties_service.nim │ ├── fallback_service.nim │ ├── fork_service.nim │ ├── scoring.nim │ ├── selection_proofs.nim │ └── sync_committee_service.nim ├── validators │ ├── README.md │ ├── action_tracker.nim │ ├── activity_metrics.nim │ ├── beacon_validators.nim │ ├── keystore_management.nim │ ├── message_router.nim │ ├── message_router_mev.nim │ ├── slashing_protection.nim │ ├── slashing_protection_common.nim │ ├── slashing_protection_v2.nim │ ├── validator_duties.nim │ ├── validator_monitor.nim │ └── validator_pool.nim ├── version.nim ├── wallets.nim └── winservice.nim ├── benchmarks ├── rest_api_benchmark.nim └── rest_api_benchmark.nim.cfg ├── ci ├── Jenkinsfile ├── Jenkinsfile.benchmarks ├── Jenkinsfile.nix └── nix.Jenkinsfile ├── config.nims ├── docker ├── README.md └── dist │ ├── Dockerfile.amd64 │ ├── Dockerfile.amd64-opt │ ├── Dockerfile.arm │ ├── Dockerfile.arm64 │ ├── Dockerfile.macos │ ├── Dockerfile.macos-arm64 │ ├── Dockerfile.win64 │ ├── README-Windows.md.tpl │ ├── README.md.tpl │ ├── base_image │ ├── Dockerfile.amd64 │ ├── Dockerfile.arm │ ├── Dockerfile.arm64 │ ├── Dockerfile.macos │ ├── Dockerfile.win64 │ ├── Makefile │ ├── README.md │ ├── build_osxcross.sh │ └── make_base_image.sh │ ├── binaries │ ├── Dockerfile.bn.amd64 │ ├── Dockerfile.bn.arm │ ├── Dockerfile.bn.arm64 │ ├── Dockerfile.vc.amd64 │ ├── Dockerfile.vc.arm │ ├── Dockerfile.vc.arm64 │ ├── README.md │ ├── docker-compose-example1.yml │ ├── docker-compose-example2.yml │ └── docker-compose-example3.yml │ └── entry_point.sh ├── docs ├── .gitignore ├── Makefile ├── README.md ├── attestation_flow.dot ├── attestation_flow.md ├── attestation_flow.png ├── block_flow.dot ├── block_flow.md ├── block_flow.png ├── cpu_features.md ├── e2store.md ├── logging.md ├── nbc_audit_2020 │ ├── README.md │ ├── eth2_spec_core │ │ ├── attestation_processing_and_production.md │ │ ├── block_processing_and_production.md │ │ ├── block_synchronization.md │ │ ├── epoch_finalization_and_justification.md │ │ ├── eth1_data_processing.md │ │ ├── finalization.png │ │ ├── fork_choice_logic.md │ │ ├── peer_pool_management.md │ │ ├── reward_processing.md │ │ ├── schlesi_rewards.png │ │ ├── signature_verification.md │ │ ├── state_transition.png │ │ └── state_transition_logic.md │ ├── network_core │ │ ├── discovery_protocol_discv5.md │ │ ├── eth2_req_resp_protocol.md │ │ ├── publish_subscribe_gossipsub.md │ │ └── ssz_serialization_and_tree_hashing.md │ └── validator_core │ │ ├── account_management_and_key_storage.md │ │ ├── block_attestation_signing.md │ │ ├── command_line_interface_CLI.md │ │ ├── rpc_api.md │ │ └── slash_prevention_mechanisms.md ├── requirements.in ├── requirements.txt ├── the_auditors_handbook │ ├── .gitignore │ ├── book.toml │ └── src │ │ ├── 01_introduction.md │ │ ├── 02.1.1_operators_bit_manipulation.md │ │ ├── 02.1.2_pointer_manipulation.md │ │ ├── 02.1.3_emitting_raw_C_assembly_code.md │ │ ├── 02.1.4_closure_iterators.md │ │ ├── 02.10_Nim_FAQ.md │ │ ├── 02.1_nim_routines_proc_func_templates_macros.md │ │ ├── 02.2.1_builtin_types.md │ │ ├── 02.2.2_casting_and_low_level_memory_representation.md │ │ ├── 02.2.3_memory_management_gc.md │ │ ├── 02.2.4_generics_types_static_types.md │ │ ├── 02.2.5_arrays_openarrays_strings_cstring.md │ │ ├── 02.2.6_runtime_types_variants_oop.md │ │ ├── 02.2.7_compiletime_evaluation.md │ │ ├── 02.2_stack_ref_ptr_types.md │ │ ├── 02.3_correctness_distinct_mutability_effects_exceptions.md │ │ ├── 02.4_debugging_Nim_sanitizers_fuzzers.md │ │ ├── 02.5_foreign_lang_to_from_interop.md │ │ ├── 02.8_Nim_threat_model.md │ │ ├── 02.9_Nim_stdlib_use_in_nimbus.md │ │ ├── 02_the_Nim_programming_language.md │ │ ├── 03.2_build_system_and_dependencies.md │ │ ├── 03.5_the_threat_model.md │ │ ├── 03_nbc_nimbus_beacon_chain.md │ │ ├── 04_serialization.md │ │ ├── 05_async_with_chronos.md │ │ ├── 06_cryptography_and_rng.md │ │ ├── 07_nim-eth.md │ │ └── SUMMARY.md └── the_nimbus_book │ ├── .gitignore │ ├── CNAME │ ├── README.md │ ├── mkdocs.yml │ └── src │ ├── additional-validator.md │ ├── api.md │ ├── attestation-performance.md │ ├── audit.md │ ├── beacon-node-systemd.md │ ├── binaries.md │ ├── build.md │ ├── checksums.md │ ├── connect-eth2.md │ ├── contribute.md │ ├── data-dir.md │ ├── database-backup.md │ ├── deposit.md │ ├── developers.md │ ├── distribution_internals.md │ ├── docker.md │ ├── doppelganger-detection.md │ ├── el-light-client.md │ ├── email-notifications.md │ ├── era-store.md │ ├── eth1.md │ ├── execution-client.md │ ├── external-block-builder.md │ ├── faq.md │ ├── goerli-eth.md │ ├── graffiti.md │ ├── hardware.md │ ├── health.md │ ├── history.md │ ├── holesky.md │ ├── hoodi.md │ ├── img │ ├── RPi_imager1.png │ ├── RPi_imager2.png │ ├── RPi_imager3.png │ ├── RPi_imager4.png │ ├── RPi_imager5.png │ ├── beacon_node_example.PNG │ ├── connect_testnet.PNG │ ├── deposit-transaction-details.png │ ├── deposit_sent.PNG │ ├── developers_01.png │ ├── email_01.png │ ├── email_02.png │ ├── email_03.png │ ├── enter_private_key.PNG │ ├── export_pkey.PNG │ ├── health.png │ ├── metamask_export_private_1.png │ ├── metamask_export_private_2.png │ ├── metamask_export_private_3.png │ ├── metrics_01.png │ ├── metrics_02.png │ ├── metrics_03.png │ ├── metrics_04.png │ ├── metrics_05.png │ ├── metrics_06.png │ ├── metrics_07.png │ ├── metrics_08.png │ ├── metrics_09.png │ ├── metrics_10.png │ ├── metrics_11.png │ ├── metrics_12.png │ ├── metrics_13.png │ └── success.PNG │ ├── index.md │ ├── infura-guide.md │ ├── install.md │ ├── intro.md │ ├── keep-an-eye.md │ ├── keep-updated.md │ ├── keymanager-api.md │ ├── keys.md │ ├── light-client-data.md │ ├── log-levels.md │ ├── log-rotate.md │ ├── logging.md │ ├── merge.md │ ├── metrics-pretty-pictures.md │ ├── migration-options.md │ ├── migration.md │ ├── more-keys.md │ ├── networking.md │ ├── optimistic-sync.md │ ├── options.md │ ├── pi-guide.md │ ├── prater.md │ ├── preparation.md │ ├── profits.md │ ├── quick-start.md │ ├── resources.md │ ├── rest-api.md │ ├── run-a-validator.md │ ├── security_issues.md │ ├── start-syncing.md │ ├── stylesheets │ └── extra.css │ ├── suggested-fee-recipient.md │ ├── troubleshooting.md │ ├── trusted-node-sync.md │ ├── validator-client-options.md │ ├── validator-client.md │ ├── validator-monitor.md │ ├── voluntary-exit.md │ ├── web3signer.md │ └── withdrawals.md ├── env.sh ├── flake.lock ├── flake.nix ├── funding.json ├── grafana ├── README.md ├── beacon_nodes_Grafana_dashboard.json ├── img │ ├── grafana_01.png │ └── grafana_02.png ├── metrics.status.im.json └── prometheus.yml.example ├── installer ├── macos │ ├── .gitignore │ ├── README.md │ ├── nimbus-pkg.pkgproj │ ├── nimbus-pkg.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── nimbus-pkg.xcscheme │ └── nimbus-pkg │ │ ├── Base.lproj │ │ └── MyInstallerPane.xib │ │ ├── Info.plist │ │ ├── InstallerSections.plist │ │ ├── MyInstallerPane.h │ │ ├── MyInstallerPane.m │ │ ├── ReadMe.html │ │ ├── en.lproj │ │ ├── InfoPlist.strings │ │ └── Localizable.strings │ │ ├── launchservice.sh │ │ ├── license.html │ │ ├── nimbus.plist │ │ └── postinstall.sh └── windows │ ├── ConfigDlg.wxs │ ├── LICENSE-APACHEv2.rtf │ ├── Nimbus_InstallDir.wxs │ ├── Product.wxs │ └── README.md ├── kurtosis-network-params.yml ├── media ├── jenkins_artifacts.png └── monitoring.png ├── ncli ├── .gitignore ├── README.md ├── deposit_downloader.nim ├── download_mainnet_deposits.sh ├── e2store.nim ├── e2store.py ├── era.nim ├── ncli.nim ├── ncli_common.nim ├── ncli_db.nim ├── ncli_split_keystore.nim ├── ncli_testnet.nim ├── nim.cfg ├── nimquery.nim ├── requirements.txt ├── resttest-rules.json ├── resttest.nim ├── resttest.nim.cfg ├── validator_db_aggregator.nim └── validator_db_reports.ipynb ├── nfuzz ├── README.md ├── libnfuzz.h └── libnfuzz.nim ├── nix ├── README.md ├── checksums.nix ├── csources.nix ├── default.nix ├── nimble.nix ├── sat.nix ├── shell.nix ├── tools.nix └── version.nix ├── research ├── .gitignore ├── block_sim.nim ├── block_sim.nim.cfg ├── fakeee.nim ├── mev_mock.nim ├── nim.cfg ├── simutils.nim ├── stack_sizes.nim ├── timing.nim └── wss_sim.nim ├── run-holesky-beacon-node.sh ├── run-kurtosis-check.sh ├── run-mainnet-beacon-node.sh ├── run-sepolia-beacon-node.sh ├── scripts ├── .gitignore ├── bash_utils.sh ├── check_docs_help_msg.sh ├── compile_nim_program.sh ├── copyfile.sh ├── depositContract.v.py ├── detect_platform.sh ├── execution_genesis.json.template ├── find_unchanged_consensus_spec_files.sh ├── geth_binaries.sh ├── geth_vars.sh ├── launch_local_testnet.sh ├── mainnet-non-overriden-config.yaml ├── make_dist.sh ├── make_packages.sh ├── make_prometheus_config.sh ├── makedir.sh ├── minimal-non-overriden-config.yaml ├── nimbus_el_vars.sh ├── package_src │ ├── nimbus_beacon_node │ │ ├── after_install │ │ ├── after_remove │ │ ├── after_upgrade │ │ ├── before_remove │ │ ├── deb_after_purge │ │ ├── description │ │ └── image │ │ │ └── lib │ │ │ └── systemd │ │ │ └── system │ │ │ └── nimbus_beacon_node.service │ └── nimbus_validator_client │ │ ├── after_install │ │ ├── after_remove │ │ ├── after_upgrade │ │ ├── before_remove │ │ ├── deb_after_purge │ │ ├── description │ │ └── image │ │ └── lib │ │ └── systemd │ │ └── system │ │ └── nimbus_validator_client.service ├── print_version.nims ├── rotatelogs-compress.sh ├── run-beacon-node.sh ├── run-nimbus.sh ├── run_fuzzing_test.nims ├── run_ssz_fuzzing_test.nims ├── setup_scenarios.sh ├── signers │ ├── custom.sh │ ├── nimbus.sh │ └── web3signer.sh ├── slowlogs.py ├── start_geth_nodes.sh ├── start_nimbus_el_nodes.sh ├── time_module_builds.sh └── tmuxinator-el-cl-pair-in-devnet.yml ├── tests ├── all_tests.nim ├── consensus_spec │ ├── README.md │ ├── all_tests.nim │ ├── altair │ │ ├── all_altair_fixtures.nim │ │ ├── test_fixture_light_client_sync_protocol.nim │ │ ├── test_fixture_operations.nim │ │ ├── test_fixture_rewards.nim │ │ ├── test_fixture_ssz_consensus_objects.nim │ │ └── test_fixture_state_transition_epoch.nim │ ├── bellatrix │ │ ├── all_bellatrix_fixtures.nim │ │ ├── test_fixture_operations.nim │ │ ├── test_fixture_rewards.nim │ │ ├── test_fixture_ssz_consensus_objects.nim │ │ └── test_fixture_state_transition_epoch.nim │ ├── capella │ │ ├── all_capella_fixtures.nim │ │ ├── test_fixture_operations.nim │ │ ├── test_fixture_rewards.nim │ │ ├── test_fixture_ssz_consensus_objects.nim │ │ └── test_fixture_state_transition_epoch.nim │ ├── consensus_spec_tests_preset.nim │ ├── deneb │ │ ├── all_deneb_fixtures.nim │ │ ├── test_fixture_operations.nim │ │ ├── test_fixture_rewards.nim │ │ ├── test_fixture_ssz_consensus_objects.nim │ │ └── test_fixture_state_transition_epoch.nim │ ├── electra │ │ ├── all_electra_fixtures.nim │ │ ├── test_fixture_operations.nim │ │ ├── test_fixture_rewards.nim │ │ ├── test_fixture_ssz_consensus_objects.nim │ │ └── test_fixture_state_transition_epoch.nim │ ├── fixtures_utils.nim │ ├── fulu │ │ ├── all_fulu_fixtures.nim │ │ ├── test_fixture_operations.nim │ │ ├── test_fixture_rewards.nim │ │ ├── test_fixture_ssz_consensus_objects.nim │ │ └── test_fixture_state_transition_epoch.nim │ ├── os_ops.nim │ ├── phase0 │ │ ├── all_phase0_fixtures.nim │ │ ├── test_fixture_operations.nim │ │ ├── test_fixture_rewards.nim │ │ ├── test_fixture_ssz_consensus_objects.nim │ │ └── test_fixture_state_transition_epoch.nim │ ├── test_fixture_fork.nim │ ├── test_fixture_fork_choice.nim │ ├── test_fixture_kzg.nim │ ├── test_fixture_light_client_data_collection.nim │ ├── test_fixture_light_client_single_merkle_proof.nim │ ├── test_fixture_light_client_sync.nim │ ├── test_fixture_light_client_update_ranking.nim │ ├── test_fixture_merkle_proof.nim │ ├── test_fixture_networking.nim │ ├── test_fixture_sanity_blocks.nim │ ├── test_fixture_sanity_slots.nim │ ├── test_fixture_ssz_generic_types.nim │ └── test_fixture_transition.nim ├── fixtures │ └── bfdata-test.bin ├── fuzzing │ ├── .gitignore │ ├── beacon_node_cli │ │ ├── corpus │ │ │ ├── help.txt │ │ │ ├── spadina-deposits-data.txt │ │ │ ├── spadina.txt │ │ │ ├── version.txt │ │ │ ├── wallets-create.txt │ │ │ └── wallets-restore.txt │ │ └── fuzz_beacon_node_cli.nim │ ├── nim.cfg │ ├── ssz_decode_Attestation.nim │ ├── ssz_decode_AttesterSlashing.nim │ ├── ssz_decode_BeaconState.nim │ ├── ssz_decode_ProposerSlashing.nim │ ├── ssz_decode_SignedAggregateAndProof.nim │ ├── ssz_decode_SignedBeaconBlock.nim │ ├── ssz_decode_VoluntaryExit.nim │ ├── ssz_fuzzing.nim │ └── validator_client_cli │ │ ├── corpus │ │ ├── full.txt │ │ ├── help.txt │ │ ├── medalla.txt │ │ └── version.txt │ │ └── fuzz_validator_client_cli.nim ├── helpers │ ├── debug_state.nim │ └── digest_helpers.nim ├── media │ └── jwt.hex ├── mocking │ ├── mock_deposits.nim │ └── mock_genesis.nim ├── nim.cfg ├── simulation │ ├── .gitignore │ └── restapi.sh ├── slashing_protection │ ├── .gitignore │ ├── test_fixtures.nim │ └── test_slashing_protection_db.nim ├── test_action_tracker.nim ├── test_attestation_pool.nim ├── test_beacon_chain_db.nim ├── test_beacon_chain_file.nim ├── test_beacon_time.nim ├── test_beacon_validators.nim ├── test_block_dag.nim ├── test_block_processor.nim ├── test_block_quarantine.nim ├── test_blockchain_dag.nim ├── test_conf.nim ├── test_datatypes.nim ├── test_deposit_snapshots.nim ├── test_discovery.nim ├── test_el_conf.nim ├── test_el_manager.nim ├── test_engine_api_conversions.nim ├── test_engine_authentication.nim ├── test_eth2_ssz_serialization.nim ├── test_files │ └── SszLengthBounds_SignedBeaconBlockDeneb.txt ├── test_forks.nim ├── test_gossip_transition.nim ├── test_gossip_validation.nim ├── test_helpers.nim ├── test_honest_validator.nim ├── test_key_splitting.nim ├── test_keymanager_api.nim ├── test_keystore.nim ├── test_keystore_management.nim ├── test_light_client.nim ├── test_light_client_processor.nim ├── test_message_signatures.nim ├── test_mev_calls.nim ├── test_network_metadata.nim ├── test_peer_pool.nim ├── test_peerdas_helpers.nim ├── test_remote_keystore.nim ├── test_rest_json_serialization.nim ├── test_serialization.nim ├── test_signing_node.nim ├── test_spec.nim ├── test_statediff.nim ├── test_sync_committee_pool.nim ├── test_sync_manager.nim ├── test_toblindedblock.nim ├── test_validator_bucket_sort.nim ├── test_validator_change_pool.nim ├── test_validator_client.nim ├── test_validator_pool.nim ├── test_zero_signature.nim ├── testbcutil.nim ├── testblockutil.nim ├── testdbutil.nim ├── teststateutil.nim └── testutil.nim ├── tools └── generate_makefile.nim └── wasm ├── .gitignore ├── README.md ├── build_ncli.sh ├── index_ncli.html ├── ncli_shell.html └── nim.cfg /.dockerignore: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 Status Research & Development GmbH 2 | # Licensed under either of 3 | # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or 4 | # http://www.apache.org/licenses/LICENSE-2.0) 5 | # * MIT license ([LICENSE-MIT](LICENSE-MIT) or 6 | # http://opensource.org/licenses/MIT) 7 | # at your option. This file may not be copied, modified, or distributed except 8 | # according to those terms. 9 | vendor/* -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*.nim] 4 | indent_style = space 5 | indent_size = 2 6 | trim_trailing_whitespace = true 7 | insert_final_newline = false 8 | 9 | [*.sh] 10 | indent_style = space 11 | indent_size = 2 12 | 13 | [Makefile] 14 | ident_size = 2 15 | ident_style = tab -------------------------------------------------------------------------------- /.envrc: -------------------------------------------------------------------------------- 1 | NBS_ONLY_LOAD_ENV_VARS=1 source env.sh 2 | 3 | if ! has nix_direnv_version || ! nix_direnv_version 3.0.6; then 4 | source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.6/direnvrc" "sha256-RYcUJaRMf8oF5LznDrlCXbkOQrywm0HDv1VjYGaJGdM=" 5 | fi 6 | use flake 7 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Platform details (OS, architecture): '...' 16 | 2. Branch/commit used: '...' 17 | 3. Commands being executed: '...' 18 | 4. Relevant log lines: '...' 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Additional context** 24 | Add any other context about the problem here. 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/security-assessment-issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Security-assessment-issue 3 | about: File a Nimbus Security Assessment issue 4 | title: "[SEC]" 5 | labels: nbc-audit-2020-review :passport_control:, status:reviewed 6 | assignees: '' 7 | 8 | --- 9 | 10 | NOTE: before submitting, please attach appropriate tags: difficulty, severity, type 11 | 12 | ## Description 13 | briefly explain the issue and outline relevant specifics 14 | 15 | ## Exploit Scenario 16 | provide an example of how this issue can be used and the associated impact. 17 | 18 | ## Mitigation Recommendation 19 | If appropriate, provide a recommendation on how to resolve the issue. Bonus points for both short term and long term recommendations if appropriate. 20 | 21 | ## References 22 | provide any external resources referenced in the above content, as well as relevant affected code snippets. 23 | -------------------------------------------------------------------------------- /.github/workflows/pr_block.yml: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | name: PR block 9 | on: 10 | pull_request_target: 11 | branches: 12 | - stable 13 | 14 | jobs: 15 | close: 16 | name: "Close pull request" 17 | runs-on: ubuntu-latest 18 | if: github.actor != 'dependabot[bot]' 19 | steps: 20 | - name: Checkout 21 | uses: actions/checkout@v4 22 | 23 | - name: Close 24 | run: | 25 | gh pr close ${{ github.event.pull_request.number }} --comment \ 26 | 'Pull requests to the `stable` branch are not allowed. 27 | Please open your pull request against the `unstable` branch. 28 | See https://nimbus.guide/contribute.html#build-and-deploy' 29 | env: 30 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 31 | -------------------------------------------------------------------------------- /.github/workflows/unit-test-results.yml: -------------------------------------------------------------------------------- 1 | # https://github.com/EnricoMi/publish-unit-test-result-action 2 | name: Unit Test Results 3 | 4 | on: 5 | workflow_run: 6 | workflows: ["CI"] 7 | types: 8 | - completed 9 | 10 | jobs: 11 | unit-test-results: 12 | name: Unit Test Results 13 | runs-on: ubuntu-latest 14 | if: github.event.workflow_run.conclusion != 'skipped' 15 | 16 | steps: 17 | - name: Download and Extract Artifacts 18 | env: 19 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} 20 | run: | 21 | mkdir -p artifacts && cd artifacts 22 | 23 | artifacts_url=${{ github.event.workflow_run.artifacts_url }} 24 | 25 | gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact 26 | do 27 | IFS=$'\t' read name url <<< "$artifact" 28 | gh api $url > "$name.zip" 29 | unzip -d "$name" "$name.zip" 30 | done 31 | 32 | - name: Publish Unit Test Results 33 | uses: EnricoMi/publish-unit-test-result-action@v1 34 | with: 35 | commit: ${{ github.event.workflow_run.head_sha }} 36 | event_file: artifacts/Event File/event.json 37 | event_name: ${{ github.event.workflow_run.event }} 38 | files: "artifacts/**/*.xml" 39 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | v13.12.0 2 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "nim-beacon-chain build", 8 | "type": "shell", 9 | "command": "make", 10 | "group": { 11 | "kind": "build", 12 | "isDefault": true 13 | }, 14 | "problemMatcher": [ 15 | "$gcc" 16 | ] 17 | }, 18 | { 19 | "label": "nim-beacon-chain test", 20 | "type": "shell", 21 | "command": "make test", 22 | "group": { 23 | "kind": "build", 24 | "isDefault": true 25 | }, 26 | "problemMatcher": [ 27 | "$gcc" 28 | ] 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 Status Research & Development GmbH 2 | # Licensed under either of 3 | # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or 4 | # http://www.apache.org/licenses/LICENSE-2.0) 5 | # * MIT license ([LICENSE-MIT](LICENSE-MIT) or 6 | # http://opensource.org/licenses/MIT) 7 | # at your option. This file may not be copied, modified, or distributed except 8 | # according to those terms. 9 | 10 | FROM debian:testing-slim AS build 11 | 12 | SHELL ["/bin/bash", "-c"] 13 | 14 | RUN apt-get clean && apt update \ 15 | && apt -y install build-essential git-lfs 16 | 17 | RUN ldd --version ldd 18 | 19 | ADD . /root/nimbus-eth2 20 | 21 | RUN cd /root/nimbus-eth2 \ 22 | && make -j$(nproc) update \ 23 | && make -j$(nproc) V=1 NIMFLAGS="-d:const_preset=mainnet -d:disableMarchNative" LOG_LEVEL=TRACE nimbus_beacon_node 24 | 25 | 26 | # --------------------------------- # 27 | # Starting new image to reduce size # 28 | # --------------------------------- # 29 | FROM debian:testing-slim as deploy 30 | 31 | SHELL ["/bin/bash", "-c"] 32 | RUN apt-get clean && apt update \ 33 | && apt -y install build-essential 34 | RUN apt update && apt -y upgrade 35 | 36 | RUN ldd --version ldd 37 | 38 | RUN rm -rf /home/user/nimbus-eth2/build/nimbus_beacon_node 39 | 40 | # "COPY" creates new image layers, so we cram all we can into one command 41 | COPY --from=build /root/nimbus-eth2/build/nimbus_beacon_node /home/user/nimbus-eth2/build/nimbus_beacon_node 42 | 43 | ENV PATH="/home/user/nimbus-eth2/build:${PATH}" 44 | ENTRYPOINT ["nimbus_beacon_node"] 45 | WORKDIR /home/user/nimbus-eth2/build 46 | 47 | STOPSIGNAL SIGINT -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | beacon_chain is licensed under the MIT License 2 | Copyright (c) 2018 Status Research & Development GmbH 3 | ----------------------------------------------------- 4 | 5 | The MIT License (MIT) 6 | 7 | Copyright (c) 2018 Status Research & Development GmbH 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in all 17 | copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | SOFTWARE. 26 | -------------------------------------------------------------------------------- /beacon_chain/.editorconfig: -------------------------------------------------------------------------------- 1 | # https://EditorConfig.org 2 | root = true 3 | 4 | [*.nim] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [Makefile] 12 | indent_style = tab 13 | -------------------------------------------------------------------------------- /beacon_chain/.gitignore: -------------------------------------------------------------------------------- 1 | beacon_node 2 | nimbus_beacon_node 3 | nimbus_signing_process 4 | nimbus_validator_client 5 | 6 | -------------------------------------------------------------------------------- /beacon_chain/beacon_node_status.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2018-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | type 11 | # "state" is already taken by BeaconState 12 | BeaconNodeStatus* = enum 13 | Starting 14 | Running 15 | Stopping 16 | 17 | # this needs to be global, so it can be set in the Ctrl+C signal handler 18 | var bnStatus* = BeaconNodeStatus.Starting 19 | -------------------------------------------------------------------------------- /beacon_chain/db_limits.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2022-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import spec/datatypes/constants 11 | 12 | # No `uint64` support in Sqlite 13 | template isSupportedBySQLite*(slot: Slot): bool = 14 | slot <= int64.high.Slot 15 | template isSupportedBySQLite*(period: SyncCommitteePeriod): bool = 16 | period <= int64.high.SyncCommitteePeriod 17 | -------------------------------------------------------------------------------- /beacon_chain/el/deposit_contract.nim.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/beacon_chain/el/deposit_contract.nim.cfg -------------------------------------------------------------------------------- /beacon_chain/fork_choice/README.md: -------------------------------------------------------------------------------- 1 | # Fork choice implementations 2 | 3 | References: 4 | - https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/fork-choice.md 5 | - https://github.com/protolambda/lmd-ghost 6 | -------------------------------------------------------------------------------- /beacon_chain/libnimbus_lc/test_files/bootstrap.ssz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/beacon_chain/libnimbus_lc/test_files/bootstrap.ssz -------------------------------------------------------------------------------- /beacon_chain/libnimbus_lc/test_files/config.yaml: -------------------------------------------------------------------------------- 1 | ../../../vendor/mainnet/metadata/config.yaml -------------------------------------------------------------------------------- /beacon_chain/libnimbus_lc/test_files/finUpdate.ssz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/beacon_chain/libnimbus_lc/test_files/finUpdate.ssz -------------------------------------------------------------------------------- /beacon_chain/libnimbus_lc/test_files/genesis.ssz: -------------------------------------------------------------------------------- 1 | ../../../vendor/mainnet/metadata/genesis.ssz -------------------------------------------------------------------------------- /beacon_chain/libnimbus_lc/test_files/optUpdate.ssz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/beacon_chain/libnimbus_lc/test_files/optUpdate.ssz -------------------------------------------------------------------------------- /beacon_chain/libnimbus_lc/test_files/optimistic_update.ssz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/beacon_chain/libnimbus_lc/test_files/optimistic_update.ssz -------------------------------------------------------------------------------- /beacon_chain/libnimbus_lc/test_files/updates.ssz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/beacon_chain/libnimbus_lc/test_files/updates.ssz -------------------------------------------------------------------------------- /beacon_chain/networking/README.md: -------------------------------------------------------------------------------- 1 | # Networking 2 | 3 | These folders hold a collection of modules to: 4 | - configure the Eth2 P2P network 5 | - discover, connect, and maintain quality Eth2 peers 6 | 7 | Data received is handed over to the `../gossip_processing` modules for validation. 8 | 9 | ## Security concerns 10 | 11 | - Collusion: part of the peer selection must be kept random. This avoids peers bringing all their friends and colluding against a beacon node. 12 | - Denial-of-service: The beacon node must provide ways to handle burst of data that may come: 13 | - from malicious nodes trying to DOS us 14 | - from long periods of non-finality, creating lots of forks, attestations, forks 15 | -------------------------------------------------------------------------------- /beacon_chain/networking/libp2p_json_serialization.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2018-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import libp2p/[peerid, multiaddress], json_serialization 11 | export json_serialization 12 | 13 | proc writeValue*( 14 | writer: var JsonWriter, value: PeerId) {.raises: [IOError].} = 15 | writer.writeValue $value 16 | 17 | proc readValue*(reader: var JsonReader, value: var PeerId) {. 18 | raises: [IOError, SerializationError].} = 19 | let res = PeerId.init reader.readValue(string) 20 | if res.isOk: 21 | value = res.get() 22 | else: 23 | raiseUnexpectedValue(reader, $res.error) 24 | 25 | proc writeValue*( 26 | writer: var JsonWriter, value: MultiAddress) {.raises: [IOError].} = 27 | writer.writeValue $value 28 | 29 | proc readValue*(reader: var JsonReader, value: var MultiAddress) {. 30 | raises: [IOError, SerializationError].} = 31 | let res = MultiAddress.init reader.readValue(string) 32 | if res.isOk: 33 | value = res.value 34 | else: 35 | raiseUnexpectedValue(reader, $res.error) 36 | -------------------------------------------------------------------------------- /beacon_chain/nim.cfg: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2021-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | # Use only `secp256k1` public key cryptography as an identity in LibP2P. 9 | -d:"libp2p_pki_schemes=secp256k1" 10 | 11 | --styleCheck:usages 12 | --styleCheck:hint 13 | --hint[Processing]:off 14 | -------------------------------------------------------------------------------- /beacon_chain/nimbus_beacon_node.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:"chronicles_sinks=textlines[dynamic],json[dynamic]" 2 | -d:"chronicles_runtime_filtering=on" 3 | -d:"chronicles_disable_thread_id" 4 | 5 | @if release: 6 | -d:"chronicles_line_numbers:0" 7 | @end 8 | -------------------------------------------------------------------------------- /beacon_chain/nimbus_light_client.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:"chronicles_sinks=textlines[dynamic],json[dynamic]" 2 | -d:"chronicles_runtime_filtering=on" 3 | -d:"chronicles_disable_thread_id" 4 | 5 | @if release: 6 | -d:"chronicles_line_numbers:0" 7 | @end 8 | -------------------------------------------------------------------------------- /beacon_chain/nimbus_signing_node.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:"chronicles_sinks=textlines[dynamic],json[dynamic]" 2 | -d:"chronicles_runtime_filtering=on" 3 | -d:"chronicles_disable_thread_id" 4 | 5 | @if release: 6 | -d:"chronicles_line_numbers:0" 7 | @end 8 | -------------------------------------------------------------------------------- /beacon_chain/nimbus_validator_client.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:"chronicles_sinks=textlines[dynamic],json[dynamic]" 2 | -d:"chronicles_runtime_filtering=on" 3 | -d:"chronicles_disable_thread_id" 4 | 5 | @if release: 6 | -d:"chronicles_line_numbers:0" 7 | @end 8 | -------------------------------------------------------------------------------- /beacon_chain/rpc/rest_api.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2018-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | ## The `rest_api` module is a server implementation for the common REST API for 11 | ## Ethereum found at https://ethereum.github.io/beacon-APIs/ 12 | ## along with several Nimbus-specific extensions. It is used by the validator 13 | ## client as well as many community utilities. 14 | ## A corresponding client can be found in the 15 | ## `spec/eth2_apis/rest_beacon_client` module 16 | 17 | import 18 | "."/[ 19 | rest_utils, 20 | rest_beacon_api, rest_builder_api, rest_config_api, rest_debug_api, 21 | rest_event_api, rest_key_management_api, rest_light_client_api, 22 | rest_nimbus_api, rest_node_api, rest_validator_api, rest_rewards_api] 23 | 24 | export 25 | rest_utils, 26 | rest_beacon_api, rest_builder_api, rest_config_api, rest_debug_api, 27 | rest_event_api, rest_key_management_api, rest_light_client_api, 28 | rest_nimbus_api, rest_node_api, rest_validator_api, rest_rewards_api 29 | -------------------------------------------------------------------------------- /beacon_chain/spec/eth2_apis/rest_beacon_client.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2018-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import 11 | chronos, presto/client, 12 | "."/[ 13 | rest_beacon_calls, rest_builder_calls, rest_config_calls, rest_debug_calls, 14 | rest_keymanager_calls, rest_light_client_calls, 15 | rest_node_calls, rest_validator_calls, 16 | rest_nimbus_calls, rest_event_calls, rest_common, 17 | rest_fork_config 18 | ] 19 | 20 | export 21 | chronos, client, 22 | rest_beacon_calls, rest_builder_calls, rest_config_calls, rest_debug_calls, 23 | rest_keymanager_calls, rest_light_client_calls, 24 | rest_node_calls, rest_validator_calls, 25 | rest_nimbus_calls, rest_event_calls, rest_common, 26 | rest_fork_config 27 | -------------------------------------------------------------------------------- /beacon_chain/spec/eth2_apis/rest_builder_calls.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2023-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import 11 | presto/client, chronicles, 12 | ".."/[helpers, forks, eth2_ssz_serialization], 13 | "."/[rest_types, rest_common, eth2_rest_serialization] 14 | 15 | export client, rest_types, eth2_rest_serialization 16 | 17 | proc getNextWithdrawals*(state_id: StateIdent 18 | ): RestResponse[GetNextWithdrawalsResponse] {. 19 | rest, endpoint: "/eth/v1/builder/states/{state_id}/expected_withdrawals", 20 | meth: MethodGet.} 21 | ## https://ethereum.github.io/beacon-APIs/?urls.primaryName=v2.4.0#/Builder/getNextWithdrawals 22 | -------------------------------------------------------------------------------- /beacon_chain/spec/eth2_apis/rest_config_calls.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2018-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import 11 | presto/client, 12 | "."/[rest_types, eth2_rest_serialization] 13 | 14 | export client, rest_types, eth2_rest_serialization 15 | 16 | proc getForkSchedulePlain*(): RestPlainResponse {. 17 | rest, endpoint: "/eth/v1/config/fork_schedule", meth: MethodGet.} 18 | ## https://ethereum.github.io/beacon-APIs/#/Config/getForkSchedule 19 | 20 | proc getSpecVC*(): RestResponse[GetSpecVCResponse] {. 21 | rest, endpoint: "/eth/v1/config/spec", meth: MethodGet.} 22 | ## https://ethereum.github.io/beacon-APIs/#/Config/getSpec 23 | 24 | proc getDepositContract*(): RestResponse[GetDepositContractResponse] {. 25 | rest, endpoint: "/eth/v1/config/deposit_contract", meth: MethodGet.} 26 | ## https://ethereum.github.io/beacon-APIs/#/Config/getDepositContract 27 | -------------------------------------------------------------------------------- /beacon_chain/spec/eth2_apis/rest_event_calls.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2023-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import 11 | presto/client, 12 | "."/[rest_types, eth2_rest_serialization] 13 | 14 | proc subscribeEventStream*(topics: set[EventTopic]): RestHttpResponseRef {. 15 | rest, endpoint: "/eth/v1/events", accept: "text/event-stream", 16 | meth: MethodGet.} 17 | ## https://ethereum.github.io/beacon-APIs/#/Events/eventstream 18 | -------------------------------------------------------------------------------- /beacon_chain/spec/presets/gnosis.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2023-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import 11 | ./gnosis/[ 12 | phase0_preset, altair_preset, bellatrix_preset, capella_preset, 13 | deneb_preset, electra_preset] 14 | 15 | export 16 | phase0_preset, altair_preset, bellatrix_preset, capella_preset, 17 | deneb_preset, electra_preset 18 | -------------------------------------------------------------------------------- /beacon_chain/spec/presets/gnosis/altair_preset.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2023-2025 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | # Gnosis preset - Altair 11 | # https://github.com/gnosischain/specs/blob/1648fc86cef7bc148d74cb21921d2d12ca9442ac/consensus/preset/gnosis/altair.yaml 12 | const 13 | # Updated penalty values 14 | # --------------------------------------------------------------- 15 | # 3 * 2**24 (= 50,331,648) 16 | INACTIVITY_PENALTY_QUOTIENT_ALTAIR*: uint64 = 50331648 17 | # 2**6 (= 64) 18 | MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR*: uint64 = 64 19 | # 2 20 | PROPORTIONAL_SLASHING_MULTIPLIER_ALTAIR*: uint64 = 2 21 | 22 | 23 | # Sync committee 24 | # --------------------------------------------------------------- 25 | # 2**9 (= 512) 26 | SYNC_COMMITTEE_SIZE* = 512 27 | # 2**9 (= 512) 28 | EPOCHS_PER_SYNC_COMMITTEE_PERIOD* {.intdefine.}: uint64 = 512 29 | 30 | 31 | # Sync protocol 32 | # --------------------------------------------------------------- 33 | # 1 34 | MIN_SYNC_COMMITTEE_PARTICIPANTS* = 1 35 | # SLOTS_PER_EPOCH * EPOCHS_PER_SYNC_COMMITTEE_PERIOD (= 32 * 256) 36 | UPDATE_TIMEOUT*: uint64 = 8192 37 | -------------------------------------------------------------------------------- /beacon_chain/spec/presets/gnosis/bellatrix_preset.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2023 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | # Gnosis preset - Bellatrix 9 | # https://github.com/gnosischain/specs/blob/1648fc86cef7bc148d74cb21921d2d12ca9442ac/consensus/preset/gnosis/bellatrix.yaml 10 | const 11 | # Updated penalty values 12 | # --------------------------------------------------------------- 13 | # 2**24 (= 16,777,216) 14 | INACTIVITY_PENALTY_QUOTIENT_BELLATRIX*: uint64 = 16777216 15 | # 2**5 (= 32) 16 | MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX*: uint64 = 32 17 | # 3 18 | PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX*: uint64 = 3 19 | 20 | 21 | # Execution 22 | # --------------------------------------------------------------- 23 | # 2**30 (= 1,073,741,824) 24 | MAX_BYTES_PER_TRANSACTION* = 1073741824 25 | # 2**20 (= 1,048,576) 26 | MAX_TRANSACTIONS_PER_PAYLOAD* = 1048576 27 | # 2**8 (= 256) 28 | BYTES_PER_LOGS_BLOOM* = 256 29 | # 2**5 (= 32) 30 | MAX_EXTRA_DATA_BYTES* = 32 31 | -------------------------------------------------------------------------------- /beacon_chain/spec/presets/gnosis/capella_preset.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2023 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | # Gnosis preset - Capella 9 | # https://github.com/gnosischain/specs/blob/1648fc86cef7bc148d74cb21921d2d12ca9442ac/consensus/preset/gnosis/capella.yaml 10 | const 11 | # Max operations per block 12 | # --------------------------------------------------------------- 13 | # 2**4 (= 16) 14 | MAX_BLS_TO_EXECUTION_CHANGES* = 16 15 | 16 | 17 | # Execution 18 | # --------------------------------------------------------------- 19 | # 2**3 (= 8) withdrawals 20 | MAX_WITHDRAWALS_PER_PAYLOAD* = 8 21 | 22 | 23 | # Withdrawals processing 24 | # --------------------------------------------------------------- 25 | # 2**13 (= 8192) validators 26 | MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP* = 8192 27 | -------------------------------------------------------------------------------- /beacon_chain/spec/presets/gnosis/deneb_preset.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2023-2025 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | # Gnosis preset - Deneb 11 | # https://github.com/gnosischain/specs/blob/31f87ac73d271762ac35b3649e7639d00c73c66d/consensus/preset/gnosis/deneb.yaml 12 | const 13 | # `uint64(4096)` 14 | FIELD_ELEMENTS_PER_BLOB*: uint64 = 4096 15 | # `uint64(2**12)` (= 4096) 16 | MAX_BLOB_COMMITMENTS_PER_BLOCK*: uint64 = 4096 17 | # `floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) + 1 + ceillog2(MAX_BLOB_COMMITMENTS_PER_BLOCK)` = 4 + 1 + 12 = 17 18 | KZG_COMMITMENT_INCLUSION_PROOF_DEPTH* = 17 19 | -------------------------------------------------------------------------------- /beacon_chain/spec/presets/mainnet.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2019-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import 11 | ./mainnet/[ 12 | phase0_preset, altair_preset, bellatrix_preset, capella_preset, 13 | deneb_preset, electra_preset] 14 | 15 | export 16 | phase0_preset, altair_preset, bellatrix_preset, capella_preset, 17 | deneb_preset, electra_preset 18 | -------------------------------------------------------------------------------- /beacon_chain/spec/presets/mainnet/altair_preset.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2021-2025 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | # Mainnet preset - Altair 11 | # https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.5/presets/mainnet/altair.yaml 12 | const 13 | # Updated penalty values 14 | # --------------------------------------------------------------- 15 | # 3 * 2**24 (= 50,331,648) 16 | INACTIVITY_PENALTY_QUOTIENT_ALTAIR*: uint64 = 50331648 17 | # 2**6 (= 64) 18 | MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR*: uint64 = 64 19 | # 2 20 | PROPORTIONAL_SLASHING_MULTIPLIER_ALTAIR*: uint64 = 2 21 | 22 | 23 | # Sync committee 24 | # --------------------------------------------------------------- 25 | # 2**9 (= 512) 26 | SYNC_COMMITTEE_SIZE* = 512 27 | # 2**8 (= 256) 28 | EPOCHS_PER_SYNC_COMMITTEE_PERIOD* {.intdefine.}: uint64 = 256 29 | 30 | 31 | # Sync protocol 32 | # --------------------------------------------------------------- 33 | # 1 34 | MIN_SYNC_COMMITTEE_PARTICIPANTS* = 1 35 | # SLOTS_PER_EPOCH * EPOCHS_PER_SYNC_COMMITTEE_PERIOD (= 32 * 256) 36 | UPDATE_TIMEOUT*: uint64 = 8192 37 | -------------------------------------------------------------------------------- /beacon_chain/spec/presets/mainnet/bellatrix_preset.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2022-2025 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | # Mainnet preset - Bellatrix 11 | # https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.5/presets/mainnet/bellatrix.yaml 12 | const 13 | # Updated penalty values 14 | # --------------------------------------------------------------- 15 | # 2**24 (= 16,777,216) 16 | INACTIVITY_PENALTY_QUOTIENT_BELLATRIX*: uint64 = 16777216 17 | # 2**5 (= 32) 18 | MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX*: uint64 = 32 19 | # 3 20 | PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX*: uint64 = 3 21 | 22 | 23 | # Execution 24 | # --------------------------------------------------------------- 25 | # 2**30 (= 1,073,741,824) 26 | MAX_BYTES_PER_TRANSACTION* = 1073741824 27 | # 2**20 (= 1,048,576) 28 | MAX_TRANSACTIONS_PER_PAYLOAD* = 1048576 29 | # 2**8 (= 256) 30 | BYTES_PER_LOGS_BLOOM* = 256 31 | # 2**5 (= 32) 32 | MAX_EXTRA_DATA_BYTES* = 32 33 | -------------------------------------------------------------------------------- /beacon_chain/spec/presets/mainnet/capella_preset.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2022-2025 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | # Mainnet preset - Capella 11 | # https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.5/presets/mainnet/capella.yaml 12 | const 13 | # Max operations per block 14 | # --------------------------------------------------------------- 15 | # 2**4 (= 16) 16 | MAX_BLS_TO_EXECUTION_CHANGES* = 16 17 | 18 | 19 | # Execution 20 | # --------------------------------------------------------------- 21 | # 2**4 (= 16) withdrawals 22 | MAX_WITHDRAWALS_PER_PAYLOAD* = 16 23 | 24 | 25 | # Withdrawals processing 26 | # --------------------------------------------------------------- 27 | # 2**14 (= 16384) validators 28 | MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP* = 16384 29 | -------------------------------------------------------------------------------- /beacon_chain/spec/presets/mainnet/deneb_preset.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2023-2025 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | # Mainnet preset - Deneb 11 | # https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.5/presets/mainnet/deneb.yaml 12 | const 13 | # `uint64(4096)` 14 | FIELD_ELEMENTS_PER_BLOB*: uint64 = 4096 15 | # `uint64(2**12)` (= 4096) 16 | MAX_BLOB_COMMITMENTS_PER_BLOCK*: uint64 = 4096 17 | # `floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) + 1 + ceillog2(MAX_BLOB_COMMITMENTS_PER_BLOCK)` = 4 + 1 + 12 = 17 18 | KZG_COMMITMENT_INCLUSION_PROOF_DEPTH* = 17 19 | -------------------------------------------------------------------------------- /beacon_chain/spec/presets/minimal.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2019-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import 11 | ./minimal/[ 12 | phase0_preset, altair_preset, bellatrix_preset, capella_preset, 13 | deneb_preset, electra_preset] 14 | 15 | export 16 | phase0_preset, altair_preset, bellatrix_preset, capella_preset, 17 | deneb_preset, electra_preset 18 | -------------------------------------------------------------------------------- /beacon_chain/spec/presets/minimal/altair_preset.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2021-2025 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | # Minimal preset - Altair 11 | # https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.5/presets/minimal/altair.yaml 12 | const 13 | # Updated penalty values 14 | # --------------------------------------------------------------- 15 | # 3 * 2**24 (= 50,331,648) 16 | INACTIVITY_PENALTY_QUOTIENT_ALTAIR*: uint64 = 50331648 17 | # 2**6 (= 64) 18 | MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR*: uint64 = 64 19 | # 2 20 | PROPORTIONAL_SLASHING_MULTIPLIER_ALTAIR*: uint64 = 2 21 | 22 | 23 | # Sync committee 24 | # --------------------------------------------------------------- 25 | # [customized] 26 | SYNC_COMMITTEE_SIZE* = 32 27 | # [customized] 28 | EPOCHS_PER_SYNC_COMMITTEE_PERIOD* {.intdefine.}: uint64 = 8 29 | 30 | 31 | # Sync protocol 32 | # --------------------------------------------------------------- 33 | # 1 34 | MIN_SYNC_COMMITTEE_PARTICIPANTS* = 1 35 | # SLOTS_PER_EPOCH * EPOCHS_PER_SYNC_COMMITTEE_PERIOD (= 8 * 8) 36 | UPDATE_TIMEOUT*: uint64 = 64 37 | -------------------------------------------------------------------------------- /beacon_chain/spec/presets/minimal/bellatrix_preset.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2022-2025 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | # Minimal preset - Bellatrix 11 | # https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.5/presets/minimal/bellatrix.yaml 12 | const 13 | # Updated penalty values 14 | # --------------------------------------------------------------- 15 | # 2**24 (= 16,777,216) 16 | INACTIVITY_PENALTY_QUOTIENT_BELLATRIX*: uint64 = 16777216 17 | # 2**5 (= 32) 18 | MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX*: uint64 = 32 19 | # 3 20 | PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX*: uint64 = 3 21 | 22 | 23 | # Execution 24 | # --------------------------------------------------------------- 25 | # 2**30 (= 1,073,741,824) 26 | MAX_BYTES_PER_TRANSACTION* = 1073741824 27 | # 2**20 (= 1,048,576) 28 | MAX_TRANSACTIONS_PER_PAYLOAD* = 1048576 29 | # 2**8 (= 256) 30 | BYTES_PER_LOGS_BLOOM* = 256 31 | # 2**5 (= 32) 32 | MAX_EXTRA_DATA_BYTES* = 32 33 | -------------------------------------------------------------------------------- /beacon_chain/spec/presets/minimal/capella_preset.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2022-2025 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | # Minimal preset - Capella 11 | # https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.5/presets/minimal/capella.yaml 12 | const 13 | # Max operations per block 14 | # --------------------------------------------------------------- 15 | # 2**4 (= 16) 16 | MAX_BLS_TO_EXECUTION_CHANGES* = 16 17 | 18 | 19 | # Execution 20 | # --------------------------------------------------------------- 21 | # [customized] 2**2 (= 4) 22 | MAX_WITHDRAWALS_PER_PAYLOAD* = 4 23 | 24 | 25 | # Withdrawals processing 26 | # --------------------------------------------------------------- 27 | # [customized] 2**4 (= 16) validators 28 | MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP* = 16 29 | -------------------------------------------------------------------------------- /beacon_chain/spec/presets/minimal/deneb_preset.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2023-2025 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | # Minimal preset - Deneb 11 | # https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.5/presets/minimal/deneb.yaml 12 | const 13 | # `uint64(4096)` 14 | FIELD_ELEMENTS_PER_BLOB*: uint64 = 4096 15 | # [customized] 16 | MAX_BLOB_COMMITMENTS_PER_BLOCK*: uint64 = 32 17 | # [customized] `floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) + 1 + ceillog2(MAX_BLOB_COMMITMENTS_PER_BLOCK)` = 4 + 1 + 5 = 10 18 | KZG_COMMITMENT_INCLUSION_PROOF_DEPTH* = 10 19 | -------------------------------------------------------------------------------- /beacon_chain/validators/README.md: -------------------------------------------------------------------------------- 1 | # Validators 2 | 3 | This folder holds all modules related to a Beacon Chain Validator besides the binaries they interact directly with (nimbus_validator_client and nimbus_signing_process): 4 | - Validator keystore 5 | - Validator slashing protection 6 | - Validator duties 7 | - Validator pool 8 | -------------------------------------------------------------------------------- /beacon_chain/validators/activity_metrics.nim: -------------------------------------------------------------------------------- 1 | import metrics 2 | export metrics 3 | 4 | const delayBuckets = [-Inf, -4.0, -2.0, -1.0, -0.5, -0.1, -0.05, 5 | 0.05, 0.1, 0.5, 1.0, 2.0, 4.0, 8.0, Inf] 6 | 7 | # The "sent" counters capture messages that were sent via this beacon node 8 | # regardless if they were produced internally or received via the REST API. 9 | # 10 | # Counters and histograms for timing-sensitive messages, only counters for 11 | # the rest (aggregates don't affect rewards, so timing is less important) 12 | 13 | declarePublicCounter beacon_attestations_sent, 14 | "Number of attestations sent by the node" 15 | 16 | declarePublicCounter beacon_aggregates_sent, 17 | "Number of beacon chain attestations sent by the node" 18 | 19 | declarePublicHistogram beacon_attestation_sent_delay, 20 | "Time(s) between expected and actual attestation send moment", 21 | buckets = delayBuckets 22 | 23 | declarePublicCounter beacon_blocks_sent, 24 | "Number of beacon blocks sent by this node" 25 | 26 | declarePublicHistogram beacon_blocks_sent_delay, 27 | "Time(s) between expected and actual block send moment", 28 | buckets = delayBuckets 29 | 30 | declarePublicCounter beacon_sync_committee_messages_sent, 31 | "Number of sync committee messages sent by the node" 32 | 33 | declarePublicHistogram beacon_sync_committee_message_sent_delay, 34 | "Time(s) between expected and actual sync committee message send moment", 35 | buckets = delayBuckets 36 | 37 | declarePublicCounter beacon_sync_committee_contributions_sent, 38 | "Number of sync committee contributions sent by the node" 39 | -------------------------------------------------------------------------------- /benchmarks/rest_api_benchmark.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:"chronicles_runtime_filtering=on" 2 | -d:"chronicles_disable_thread_id" 3 | -------------------------------------------------------------------------------- /ci/Jenkinsfile.nix: -------------------------------------------------------------------------------- 1 | nix.Jenkinsfile -------------------------------------------------------------------------------- /docker/README.md: -------------------------------------------------------------------------------- 1 | ## directory layout 2 | 3 | ### dist/base_image/ 4 | 5 | Base Docker images for building distributable binaries. Uploaded to 6 | Docker Hub (we need them to reproduce officially released builds). 7 | 8 | ### dist/ 9 | 10 | Dockerfiles used to build local Docker images based on the base images 11 | described above. Only used for generating distributable binaries. Not uploaded 12 | to Docker Hub. 13 | 14 | ### dist/binaries/ 15 | 16 | Docker images for end-users, obtained by copying distributable binaries inside 17 | official Debian images. Uploaded to Docker Hub as part of the CI release process. 18 | 19 | Also contains some example `docker-compose` configuration files. 20 | 21 | ## more details 22 | 23 | See the ["Binary distribution internals"](https://nimbus.guide/distribution_internals.html) page of the Nimbus book. 24 | -------------------------------------------------------------------------------- /docker/dist/Dockerfile.amd64: -------------------------------------------------------------------------------- 1 | # The build is reproducible only if this base image stays the same. 2 | FROM statusteam/nimbus_beacon_node:dist_base_20201103201341@sha256:25510b42e7573450bd0a2bbfa4c331e3345b80bee8b96a7e60621949b6154f7f 3 | 4 | SHELL ["/bin/bash", "-c"] 5 | 6 | ARG USER_ID 7 | ARG GROUP_ID 8 | 9 | ENV BUILD_TOOLS=${BUILD_TOOLS} 10 | 11 | RUN echo "BUILD_TOOLS=${BUILD_TOOLS}" 12 | RUN addgroup --gid ${GROUP_ID} user; \ 13 | adduser --disabled-password --gecos '' --uid ${USER_ID} --gid ${GROUP_ID} user; 14 | 15 | USER user 16 | 17 | STOPSIGNAL SIGINT 18 | 19 | COPY "entry_point.sh" "/home/user/" 20 | ENTRYPOINT ["/home/user/entry_point.sh", "Linux_amd64"] 21 | 22 | 23 | -------------------------------------------------------------------------------- /docker/dist/Dockerfile.amd64-opt: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2023 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | # The build is reproducible only if this base image stays the same. 9 | FROM statusteam/nimbus_beacon_node:dist_base_20201103201341@sha256:25510b42e7573450bd0a2bbfa4c331e3345b80bee8b96a7e60621949b6154f7f 10 | 11 | SHELL ["/bin/bash", "-c"] 12 | 13 | ARG USER_ID 14 | ARG GROUP_ID 15 | 16 | ENV BUILD_TOOLS=${BUILD_TOOLS} 17 | 18 | RUN echo "BUILD_TOOLS=${BUILD_TOOLS}" 19 | RUN addgroup --gid ${GROUP_ID} user; \ 20 | adduser --disabled-password --gecos '' --uid ${USER_ID} --gid ${GROUP_ID} user; 21 | 22 | USER user 23 | 24 | STOPSIGNAL SIGINT 25 | 26 | COPY "entry_point.sh" "/home/user/" 27 | ENTRYPOINT ["/home/user/entry_point.sh", "Linux_amd64_opt"] 28 | 29 | 30 | -------------------------------------------------------------------------------- /docker/dist/Dockerfile.arm: -------------------------------------------------------------------------------- 1 | # The build is reproducible only if this base image stays the same. 2 | FROM statusteam/nimbus_beacon_node:dist_base_20210310012752_arm_v2@sha256:65919842dc7e17386399ae12b175e9996f5ef038ad6e228000392a1ff6465082 3 | 4 | SHELL ["/bin/bash", "-c"] 5 | 6 | ARG USER_ID 7 | ARG GROUP_ID 8 | 9 | ENV BUILD_TOOLS=${BUILD_TOOLS} 10 | 11 | RUN addgroup --gid ${GROUP_ID} user; \ 12 | adduser --disabled-password --gecos '' --uid ${USER_ID} --gid ${GROUP_ID} user; 13 | 14 | USER user 15 | 16 | STOPSIGNAL SIGINT 17 | 18 | COPY "entry_point.sh" "/home/user/" 19 | ENTRYPOINT ["/home/user/entry_point.sh", "Linux_arm32v7"] 20 | 21 | -------------------------------------------------------------------------------- /docker/dist/Dockerfile.arm64: -------------------------------------------------------------------------------- 1 | # The build is reproducible only if this base image stays the same. 2 | FROM statusteam/nimbus_beacon_node:dist_base_20211001175744_arm64_v4@sha256:558c34dcac4beaa6ca5256c6301b4768f206afeb9dea44d185e42295d5123e61 3 | 4 | SHELL ["/bin/bash", "-c"] 5 | 6 | ARG USER_ID 7 | ARG GROUP_ID 8 | 9 | ENV BUILD_TOOLS=${BUILD_TOOLS} 10 | 11 | RUN addgroup --gid ${GROUP_ID} user; \ 12 | adduser --disabled-password --gecos '' --uid ${USER_ID} --gid ${GROUP_ID} user; 13 | 14 | USER user 15 | 16 | STOPSIGNAL SIGINT 17 | 18 | COPY "entry_point.sh" "/home/user/" 19 | ENTRYPOINT ["/home/user/entry_point.sh", "Linux_arm64v8"] 20 | 21 | -------------------------------------------------------------------------------- /docker/dist/Dockerfile.macos: -------------------------------------------------------------------------------- 1 | # The build is reproducible only if this base image stays the same. 2 | FROM statusteam/nimbus_beacon_node:dist_base_20210513160553_macos@sha256:eef4aff594307c0ff615160aa7184b3660648ce929bb670a409428fc32bd04ed 3 | 4 | SHELL ["/bin/bash", "-c"] 5 | 6 | ARG USER_ID 7 | ARG GROUP_ID 8 | 9 | ENV BUILD_TOOLS=${BUILD_TOOLS} 10 | 11 | RUN addgroup --gid ${GROUP_ID} user; \ 12 | adduser --disabled-password --gecos '' --uid ${USER_ID} --gid ${GROUP_ID} user; 13 | 14 | USER user 15 | 16 | STOPSIGNAL SIGINT 17 | 18 | COPY "entry_point.sh" "/home/user/" 19 | ENTRYPOINT ["/home/user/entry_point.sh", "macOS_amd64"] 20 | 21 | -------------------------------------------------------------------------------- /docker/dist/Dockerfile.macos-arm64: -------------------------------------------------------------------------------- 1 | # The build is reproducible only if this base image stays the same. 2 | FROM statusteam/nimbus_beacon_node:dist_base_20210513160553_macos@sha256:eef4aff594307c0ff615160aa7184b3660648ce929bb670a409428fc32bd04ed 3 | 4 | SHELL ["/bin/bash", "-c"] 5 | 6 | ARG USER_ID 7 | ARG GROUP_ID 8 | 9 | ENV BUILD_TOOLS=${BUILD_TOOLS} 10 | 11 | RUN addgroup --gid ${GROUP_ID} user; \ 12 | adduser --disabled-password --gecos '' --uid ${USER_ID} --gid ${GROUP_ID} user; 13 | 14 | USER user 15 | 16 | STOPSIGNAL SIGINT 17 | 18 | COPY "entry_point.sh" "/home/user/" 19 | ENTRYPOINT ["/home/user/entry_point.sh", "macOS_arm64"] 20 | 21 | -------------------------------------------------------------------------------- /docker/dist/Dockerfile.win64: -------------------------------------------------------------------------------- 1 | # The build is reproducible only if this base image stays the same. 2 | FROM statusteam/nimbus_beacon_node:dist_base_20220327205458_win64_v2@sha256:a5bda8cbef9973c2feb94003d6812004bb9f6dfd6b0b817d85dfa1118034273a 3 | 4 | SHELL ["/bin/bash", "-c"] 5 | 6 | ARG USER_ID 7 | ARG GROUP_ID 8 | 9 | ENV BUILD_TOOLS=${BUILD_TOOLS} 10 | 11 | RUN addgroup --gid ${GROUP_ID} user; \ 12 | adduser --disabled-password --gecos '' --uid ${USER_ID} --gid ${GROUP_ID} user; 13 | 14 | USER user 15 | 16 | STOPSIGNAL SIGINT 17 | 18 | COPY "entry_point.sh" "/home/user/" 19 | ENTRYPOINT ["/home/user/entry_point.sh", "Windows_amd64"] 20 | 21 | -------------------------------------------------------------------------------- /docker/dist/README-Windows.md.tpl: -------------------------------------------------------------------------------- 1 | # Windows-specific requirements 2 | 3 | Run the wrapper scripts from a [Git for Windows](https://gitforwindows.org/) Bash shell. 4 | 5 | If you run the beacon node binary directly, prefix it with "winpty -- ". It 6 | will increase the chance of Ctrl+C working inside that "mintty" terminal emulator. 7 | 8 | -------------------------------------------------------------------------------- /docker/dist/base_image/Dockerfile.amd64: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2021-2023 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | # This Docker image can change from one build to another, because the upstream 9 | # Debian/Ubuntu package index is continuously updated and we have to run 10 | # `apt-get update` in here. 11 | # 12 | # The only way to make this a part of our reproducible build system is to build 13 | # it once, upload it to Docker Hub and make sure it's being pulled regularly so 14 | # it's not deleted after 6 months of inactivity. 15 | 16 | FROM ubuntu:20.04 17 | 18 | SHELL ["/bin/bash", "-c"] 19 | 20 | ENV DEBIAN_FRONTEND=noninteractive TZ="Etc/UTC" 21 | RUN apt-get -qq update \ 22 | && apt-get -qq -y install build-essential git-lfs &>/dev/null \ 23 | && apt-get -qq clean \ 24 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 25 | 26 | -------------------------------------------------------------------------------- /docker/dist/base_image/Dockerfile.arm: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2021-2023 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | # This Docker image can change from one build to another, because the upstream 9 | # Debian/Ubuntu package index is continuously updated and we have to run 10 | # `apt-get update` in here. 11 | # 12 | # The only way to make this a part of our reproducible build system is to build 13 | # it once, upload it to Docker Hub and make sure it's being pulled regularly so 14 | # it's not deleted after 6 months of inactivity. 15 | 16 | FROM ubuntu:20.04 17 | 18 | SHELL ["/bin/bash", "-c"] 19 | 20 | ENV DEBIAN_FRONTEND=noninteractive TZ="Etc/UTC" 21 | RUN apt-get -qq update \ 22 | && apt-get -qq -y install build-essential git-lfs \ 23 | libc6-armhf-armel-cross libc6-dev-armel-armhf-cross binutils-arm-linux-gnueabihf gcc-arm-linux-gnueabihf &>/dev/null \ 24 | && apt-get -qq clean \ 25 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 26 | 27 | -------------------------------------------------------------------------------- /docker/dist/base_image/Dockerfile.arm64: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2021-2023 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | # This Docker image can change from one build to another, because the upstream 9 | # Debian/Ubuntu package index is continuously updated and we have to run 10 | # `apt-get update` in here. 11 | # 12 | # The only way to make this a part of our reproducible build system is to build 13 | # it once, upload it to Docker Hub and make sure it's being pulled regularly so 14 | # it's not deleted after 6 months of inactivity. 15 | 16 | # We use an older Debian version so we can support Raspbian's glibc-2.28: 17 | # https://github.com/status-im/nimbus-eth2/issues/2583 18 | FROM debian:10.10 19 | 20 | SHELL ["/bin/bash", "-c"] 21 | 22 | ENV DEBIAN_FRONTEND=noninteractive TZ="Etc/UTC" 23 | RUN apt-get -qq update \ 24 | && apt-get -qq -y install build-essential git-lfs \ 25 | binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu &>/dev/null \ 26 | && apt-get -qq clean \ 27 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 28 | 29 | -------------------------------------------------------------------------------- /docker/dist/base_image/Dockerfile.macos: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2021-2025 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | # This Docker image can change from one build to another, because the upstream 9 | # Debian/Ubuntu package index is continuously updated and we have to run 10 | # `apt-get update` in here. 11 | # 12 | # The only way to make this a part of our reproducible build system is to build 13 | # it once, upload it to Docker Hub and make sure it's being pulled regularly so 14 | # it's not deleted after 6 months of inactivity. 15 | # 16 | # Mar 2025: CMake is no longer needed, removable when base image is updated 17 | 18 | FROM ubuntu:20.04 19 | 20 | SHELL ["/bin/bash", "-c"] 21 | 22 | ENV DEBIAN_FRONTEND=noninteractive TZ="Etc/UTC" 23 | RUN apt-get -qq update \ 24 | && apt-get -qq -y install build-essential git-lfs clang-11 llvm-11-dev cmake curl libssl-dev lzma-dev libxml2-dev &>/dev/null \ 25 | && update-alternatives --install /usr/bin/clang clang /usr/bin/clang-11 100 \ 26 | && update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-11 100 \ 27 | && apt-get -qq clean \ 28 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 29 | 30 | COPY "build_osxcross.sh" "/root/" 31 | RUN cd /root \ 32 | && ./build_osxcross.sh 33 | -------------------------------------------------------------------------------- /docker/dist/base_image/Makefile: -------------------------------------------------------------------------------- 1 | SHELL := bash 2 | 3 | IMAGE_TAG := dist_base_$(shell date --utc +"%Y%m%d%H%M%S") 4 | IMAGE_NAME := statusteam/nimbus_beacon_node:$(IMAGE_TAG) 5 | 6 | .PHONY: \ 7 | build-amd64 \ 8 | build-arm64 \ 9 | build-arm \ 10 | build-win64 \ 11 | build-macos \ 12 | push-amd64 \ 13 | push-arm64 \ 14 | push-arm \ 15 | push-win64 \ 16 | push-macos 17 | 18 | build-amd64: 19 | $(CURDIR)/make_base_image.sh amd64 "$(IMAGE_NAME)" 20 | 21 | build-arm64: 22 | $(CURDIR)/make_base_image.sh arm64 "$(IMAGE_NAME)_arm64_v4" 23 | 24 | build-arm: 25 | $(CURDIR)/make_base_image.sh arm "$(IMAGE_NAME)_arm_v2" 26 | 27 | build-win64: 28 | $(CURDIR)/make_base_image.sh win64 "$(IMAGE_NAME)_win64_v2" 29 | 30 | build-macos: 31 | $(CURDIR)/make_base_image.sh macos "$(IMAGE_NAME)_macos" 32 | 33 | # You probably don't want to recreate and push these base images to Docker Hub, 34 | # because when older images expire and get deleted, it will no longer be possible 35 | # to reproduce old releases. 36 | # 37 | # When you really have to, change the Docker tags by appending "_v2", "_v3", etc. to them. 38 | # This way you won't overwrite the old image. 39 | 40 | #push-amd64: build-amd64 41 | # docker push $(IMAGE_NAME) 42 | 43 | #push-arm64: build-arm64 44 | # docker push $(IMAGE_NAME)_arm64_v4 45 | 46 | #push-arm: build-arm 47 | # docker push $(IMAGE_NAME)_arm_v2 48 | 49 | #push-win64: build-win64 50 | # docker push $(IMAGE_NAME)_win64_v2 51 | 52 | #push-macos: build-macos 53 | #docker push $(IMAGE_NAME)_macos 54 | 55 | -------------------------------------------------------------------------------- /docker/dist/base_image/README.md: -------------------------------------------------------------------------------- 1 | You probably don't want to re-create and push these base images to Docker Hub, 2 | because when older images expire and get deleted, it will no longer be possible 3 | to reproduce old releases. 4 | 5 | -------------------------------------------------------------------------------- /docker/dist/base_image/build_osxcross.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | 6 | git clone https://github.com/tpoechtrager/osxcross.git 7 | 8 | # macOS SDK 9 | cd osxcross/tarballs 10 | MACOS_SDK_VER="11.3" 11 | MACOS_SDK_TARBALL="MacOSX${MACOS_SDK_VER}.sdk.tar.xz" 12 | curl -OLsS https://github.com/phracker/MacOSX-SDKs/releases/download/${MACOS_SDK_VER}/${MACOS_SDK_TARBALL} 13 | cd .. 14 | 15 | # build OSXCross toolchain 16 | export TARGET_DIR="/opt/osxcross" 17 | UNATTENDED=1 ./build.sh 18 | # "tools/osxcross_conf.sh" ignores TARGET_DIR and uses "target" instead, so do a symlink 19 | ln -s ${TARGET_DIR} target 20 | ./build_llvm_dsymutil.sh 21 | # ridiculous amount of uncompressed man pages 22 | rm -rf ${TARGET_DIR}/SDK/MacOSX${MACOS_SDK_VER}.sdk/usr/share 23 | 24 | # cleanup 25 | cd .. 26 | rm -rf osxcross 27 | 28 | -------------------------------------------------------------------------------- /docker/dist/base_image/make_base_image.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2020-2021 Status Research & Development GmbH. Licensed under 4 | # either of: 5 | # - Apache License, version 2.0 6 | # - MIT license 7 | # at your option. This file may not be copied, modified, or distributed except 8 | # according to those terms. 9 | 10 | # Build base Docker images for making distributable binaries. 11 | # Should be used from "build-*" Make targets, passing the target architecture's 12 | # name and Docker image tag as parameters. 13 | 14 | set -e 15 | 16 | cd "$(dirname "${BASH_SOURCE[0]}")" 17 | 18 | if [[ -z "${2}" ]]; then 19 | echo "Usage: $(basename ${0}) ARCH DOCKER_TAG" 20 | exit 1 21 | fi 22 | ARCH="${1}" 23 | DOCKER_TAG="${2}" 24 | 25 | DOCKER_BUILDKIT=1 \ 26 | docker build \ 27 | -t ${DOCKER_TAG} \ 28 | --progress=plain \ 29 | -f Dockerfile.${ARCH} . 30 | 31 | -------------------------------------------------------------------------------- /docker/dist/binaries/Dockerfile.bn.amd64: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2024 Status Research & Development GmbH. Licensed under 2 | # either of: 3 | # - Apache License, version 2.0 4 | # - MIT license 5 | # at your option. This file may not be copied, modified, or distributed except 6 | # according to those terms. 7 | 8 | FROM debian:bookworm-slim 9 | 10 | SHELL ["/bin/bash", "-c"] 11 | 12 | # Likely to match the first regular user:group created on the host. 13 | RUN addgroup --gid 1000 user; \ 14 | adduser --disabled-password --gecos '' --uid 1000 --gid 1000 user; \ 15 | chmod a+rx /home/user; 16 | 17 | USER user 18 | 19 | STOPSIGNAL SIGINT 20 | 21 | COPY "nimbus-eth2/build/nimbus_beacon_node" "/home/user/nimbus_beacon_node" 22 | 23 | RUN mkdir -p /home/user/nimbus-eth2/build && \ 24 | ln -s /home/user/nimbus_beacon_node /home/user/nimbus-eth2/build/nimbus_beacon_node && \ 25 | chown -R user:user /home/user/nimbus-eth2/build 26 | 27 | WORKDIR "/home/user/" 28 | ENTRYPOINT ["/home/user/nimbus_beacon_node"] 29 | -------------------------------------------------------------------------------- /docker/dist/binaries/Dockerfile.bn.arm: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2024 Status Research & Development GmbH. Licensed under 2 | # either of: 3 | # - Apache License, version 2.0 4 | # - MIT license 5 | # at your option. This file may not be copied, modified, or distributed except 6 | # according to those terms. 7 | 8 | FROM --platform=linux/arm/v7 debian:bookworm-slim 9 | 10 | SHELL ["/bin/bash", "-c"] 11 | 12 | # We need the host's registered binfmt_misc "interpreter" inside the container, 13 | # for that transparent virtualisation to work. 14 | COPY "qemu-arm-static" "/usr/bin/" 15 | 16 | # Likely to match the first regular user:group created on the host. 17 | RUN addgroup --gid 1000 user; \ 18 | adduser --disabled-password --gecos '' --uid 1000 --gid 1000 user; \ 19 | chmod a+rx /home/user; 20 | 21 | USER user 22 | 23 | STOPSIGNAL SIGINT 24 | 25 | COPY "nimbus-eth2/build/nimbus_beacon_node" "/home/user/nimbus_beacon_node" 26 | 27 | RUN mkdir -p /home/user/nimbus-eth2/build && \ 28 | ln -s /home/user/nimbus_beacon_node /home/user/nimbus-eth2/build/nimbus_beacon_node && \ 29 | chown -R user:user /home/user/nimbus-eth2/build 30 | 31 | WORKDIR "/home/user/" 32 | ENTRYPOINT ["/home/user/nimbus_beacon_node"] 33 | -------------------------------------------------------------------------------- /docker/dist/binaries/Dockerfile.bn.arm64: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2024 Status Research & Development GmbH. Licensed under 2 | # either of: 3 | # - Apache License, version 2.0 4 | # - MIT license 5 | # at your option. This file may not be copied, modified, or distributed except 6 | # according to those terms. 7 | 8 | FROM --platform=linux/arm64/v8 debian:bookworm-slim 9 | 10 | SHELL ["/bin/bash", "-c"] 11 | 12 | # We need the host's registered binfmt_misc "interpreter" inside the container, 13 | # for that transparent virtualisation to work. 14 | COPY "qemu-aarch64-static" "/usr/bin/" 15 | 16 | # Likely to match the first regular user:group created on the host. 17 | RUN addgroup --gid 1000 user; \ 18 | adduser --disabled-password --gecos '' --uid 1000 --gid 1000 user; \ 19 | chmod a+rx /home/user; 20 | 21 | USER user 22 | 23 | STOPSIGNAL SIGINT 24 | 25 | COPY "nimbus-eth2/build/nimbus_beacon_node" "/home/user/nimbus_beacon_node" 26 | 27 | RUN mkdir -p /home/user/nimbus-eth2/build && \ 28 | ln -s /home/user/nimbus_beacon_node /home/user/nimbus-eth2/build/nimbus_beacon_node && \ 29 | chown -R user:user /home/user/nimbus-eth2/build 30 | 31 | WORKDIR "/home/user/" 32 | ENTRYPOINT ["/home/user/nimbus_beacon_node"] 33 | -------------------------------------------------------------------------------- /docker/dist/binaries/Dockerfile.vc.amd64: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2024 Status Research & Development GmbH. Licensed under 2 | # either of: 3 | # - Apache License, version 2.0 4 | # - MIT license 5 | # at your option. This file may not be copied, modified, or distributed except 6 | # according to those terms. 7 | 8 | FROM debian:bookworm-slim 9 | 10 | SHELL ["/bin/bash", "-c"] 11 | 12 | # Likely to match the first regular user:group created on the host. 13 | RUN addgroup --gid 1000 user; \ 14 | adduser --disabled-password --gecos '' --uid 1000 --gid 1000 user; \ 15 | chmod a+rx /home/user; 16 | 17 | USER user 18 | 19 | STOPSIGNAL SIGINT 20 | 21 | COPY "nimbus-eth2/build/nimbus_validator_client" "/home/user/nimbus_validator_client" 22 | WORKDIR "/home/user/" 23 | ENTRYPOINT ["/home/user/nimbus_validator_client"] 24 | -------------------------------------------------------------------------------- /docker/dist/binaries/Dockerfile.vc.arm: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2024 Status Research & Development GmbH. Licensed under 2 | # either of: 3 | # - Apache License, version 2.0 4 | # - MIT license 5 | # at your option. This file may not be copied, modified, or distributed except 6 | # according to those terms. 7 | 8 | FROM --platform=linux/arm/v7 debian:bookworm-slim 9 | 10 | SHELL ["/bin/bash", "-c"] 11 | 12 | # We need the host's registered binfmt_misc "interpreter" inside the container, 13 | # for that transparent virtualisation to work. 14 | COPY "qemu-arm-static" "/usr/bin/" 15 | 16 | # Likely to match the first regular user:group created on the host. 17 | RUN addgroup --gid 1000 user; \ 18 | adduser --disabled-password --gecos '' --uid 1000 --gid 1000 user; \ 19 | chmod a+rx /home/user; 20 | 21 | USER user 22 | 23 | STOPSIGNAL SIGINT 24 | 25 | COPY "nimbus-eth2/build/nimbus_validator_client" "/home/user/nimbus_validator_client" 26 | WORKDIR "/home/user/" 27 | ENTRYPOINT ["/home/user/nimbus_validator_client"] 28 | -------------------------------------------------------------------------------- /docker/dist/binaries/Dockerfile.vc.arm64: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2024 Status Research & Development GmbH. Licensed under 2 | # either of: 3 | # - Apache License, version 2.0 4 | # - MIT license 5 | # at your option. This file may not be copied, modified, or distributed except 6 | # according to those terms. 7 | 8 | FROM --platform=linux/arm64/v8 debian:bookworm-slim 9 | 10 | SHELL ["/bin/bash", "-c"] 11 | 12 | # We need the host's registered binfmt_misc "interpreter" inside the container, 13 | # for that transparent virtualisation to work. 14 | COPY "qemu-aarch64-static" "/usr/bin/" 15 | 16 | # Likely to match the first regular user:group created on the host. 17 | RUN addgroup --gid 1000 user; \ 18 | adduser --disabled-password --gecos '' --uid 1000 --gid 1000 user; \ 19 | chmod a+rx /home/user; 20 | 21 | USER user 22 | 23 | STOPSIGNAL SIGINT 24 | 25 | COPY "nimbus-eth2/build/nimbus_validator_client" "/home/user/nimbus_validator_client" 26 | WORKDIR "/home/user/" 27 | ENTRYPOINT ["/home/user/nimbus_validator_client"] 28 | 29 | -------------------------------------------------------------------------------- /docker/dist/binaries/README.md: -------------------------------------------------------------------------------- 1 | Simple Docker image with the contents of a release tarball inside it. 2 | It's being built and published to Docker Hub from a GitHub action, in CI. 3 | 4 | Suitable for end users. Example `docker-compose` configuration files included. 5 | 6 | -------------------------------------------------------------------------------- /docker/dist/binaries/docker-compose-example1.yml: -------------------------------------------------------------------------------- 1 | # Using the default entry point, which is the "nimbus_beacon_chain" binary. 2 | # 3 | # Example usage: 4 | # 5 | # mkdir data 6 | # docker-compose -f docker-compose-example1.yml up --quiet-pull --no-color --detach 7 | 8 | version: "2.4" 9 | services: 10 | nimbus_beacon_node: 11 | image: statusim/nimbus-eth2:amd64-latest 12 | container_name: nimbus-eth2-amd64-latest 13 | restart: unless-stopped 14 | stop_grace_period: 1m 15 | ports: 16 | - 9000:9000/tcp 17 | - 9000:9000/udp 18 | - 127.0.0.1:5052:5052/tcp 19 | - 127.0.0.1:8008:8008/tcp 20 | volumes: 21 | - ./data:/home/user/nimbus-eth2/build/data 22 | # you need to make sure that port 9000 is accesible from outside; no automagic port forwarding here 23 | command: >- 24 | --network=hoodi 25 | --data-dir=/home/user/nimbus-eth2/build/data/shared_hoodi_0 26 | --web3-url=wss://hoodi.infura.io/ws/v3/YOUR_TOKEN 27 | --nat=extip:YOUR_EXTERNAL_IP 28 | --log-level=info 29 | --tcp-port=9000 30 | --udp-port=9000 31 | --rest 32 | --rest-address=0.0.0.0 33 | --rest-port=5052 34 | --metrics 35 | --metrics-address=0.0.0.0 36 | --metrics-port=8008 37 | -------------------------------------------------------------------------------- /docker/dist/binaries/docker-compose-example2.yml: -------------------------------------------------------------------------------- 1 | # Using a wrapper script as the entry point. 2 | # 3 | # Example usage: 4 | # 5 | # mkdir data 6 | # docker-compose -f docker-compose-example2.yml up --quiet-pull --no-color --detach 7 | 8 | version: "2.4" 9 | services: 10 | nimbus_beacon_node: 11 | image: statusim/nimbus-eth2:amd64-latest 12 | container_name: nimbus-eth2-amd64-latest 13 | restart: unless-stopped 14 | stop_grace_period: 1m 15 | ports: 16 | - 9000:9000/tcp 17 | - 9000:9000/udp 18 | - 127.0.0.1:5052:5052/tcp 19 | - 127.0.0.1:8008:8008/tcp 20 | volumes: 21 | - ./data:/home/user/nimbus-eth2/build/data 22 | entrypoint: /home/user/nimbus-eth2/run-holesky-beacon-node.sh 23 | environment: 24 | WEB3_URL: wss://holesky.infura.io/ws/v3/YOUR_TOKEN 25 | # you need to make sure that port 9000 is accesible from outside; no automagic port forwarding here 26 | command: >- 27 | --nat=extip:YOUR_EXTERNAL_IP 28 | --rest 29 | --rest-address=0.0.0.0 30 | --metrics 31 | --metrics-address=0.0.0.0 32 | -------------------------------------------------------------------------------- /docker/dist/binaries/docker-compose-example3.yml: -------------------------------------------------------------------------------- 1 | # Using the host's network, so we can talk with a UPnP-enabled router to 2 | # redirect ports and get the external IP. 3 | # 4 | # Example usage: 5 | # 6 | # mkdir data 7 | # docker-compose -f docker-compose-example3.yml up --quiet-pull --no-color --detach 8 | 9 | version: "2.4" 10 | services: 11 | nimbus_beacon_node: 12 | image: statusim/nimbus-eth2:amd64-latest 13 | container_name: nimbus-eth2-amd64-latest 14 | restart: unless-stopped 15 | stop_grace_period: 1m 16 | network_mode: host 17 | volumes: 18 | - ./data:/home/user/nimbus-eth2/build/data 19 | entrypoint: /home/user/nimbus-eth2/run-holesky-beacon-node.sh 20 | environment: 21 | WEB3_URL: wss://holesky.infura.io/ws/v3/YOUR_TOKEN 22 | #command: >- 23 | #--nat=any 24 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | mkdocs 2 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | mkdocs: mkdocs/bin/mkdocs 2 | 3 | mkdocs/bin/mkdocs: 4 | test -d mkdocs || python3 -m venv mkdocs 5 | . mkdocs/bin/activate; pip install -r requirements.txt 6 | 7 | compile: 8 | . mkdocs/bin/activate; pip-compile requirements.in 9 | 10 | sync: 11 | . mkdocs/bin/activate; pip-sync requirements.txt 12 | 13 | serve: mkdocs 14 | . mkdocs/bin/activate; cd the_nimbus_book; mkdocs serve 15 | 16 | book: mkdocs 17 | . mkdocs/bin/activate; cd the_nimbus_book; mkdocs build 18 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Documentation 2 | 3 | ## material for mkdocs 4 | 5 | The Nimbus guide is generated using [Material for mkdocs](https://squidfunk.github.io/mkdocs-material/), and installed using a python VENV (see Makefile). 6 | 7 | ## mdbook 8 | 9 | Some books in this folder were produced using [mdBook](https://github.com/rust-lang/mdBook) - see installation guide. 10 | 11 | ```bash 12 | # Install or update tooling (make sure you add "~/.cargo/bin" to PATH): 13 | cargo install mdbook --version 0.4.36 14 | cargo install mdbook-toc --version 0.14.1 15 | cargo install mdbook-open-on-gh --version 2.4.1 16 | cargo install mdbook-admonish --version 1.14.0 17 | 18 | # Work on the book locally - open "http://localhost:4000" for live version 19 | cd docs/the_auditors_handbook 20 | mdbook serve -p 4000 21 | 22 | # Create a local copy of the book 23 | make book 24 | 25 | # Publish book using makefile (in the top-level dir) 26 | make publish-book 27 | ``` 28 | -------------------------------------------------------------------------------- /docs/attestation_flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/attestation_flow.png -------------------------------------------------------------------------------- /docs/block_flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/block_flow.png -------------------------------------------------------------------------------- /docs/nbc_audit_2020/eth2_spec_core/block_processing_and_production.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Block Processing & production" 3 | code_owner: "(tersec) and Mamy André-Ratsimbazafy (mratsim)" 4 | round: "Audit round 3" 5 | category: "Validator Core Audit" 6 | repositories: "nim-beacon-chain" 7 | --- 8 | 9 | See [attestation_processing_and_production.md](./attestation_processing_and_production.md) 10 | -------------------------------------------------------------------------------- /docs/nbc_audit_2020/eth2_spec_core/block_synchronization.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Block synchronization" 3 | code_owner: "Eugene Kabanov (cheatfate)" 4 | round: "Audit round 2" 5 | category: "ETH2 Specification Core Audit" 6 | repositories: "nim-beacon-chain" 7 | --- 8 | 9 | **Note:** Currently there is an issue where ingoing block sync is slow on Medalla testnet and being investigated. There are many changes being made. 10 | 11 | Spec: TODO 12 | 13 | # Ingoing Sync algorithms 14 | 15 | *syncing from remote peers* 16 | 17 | We have 2 kinds of ingoing sync, forward sync and backward sync 18 | 19 | forward sync: 20 | 21 | [https://github.com/status-im/nim-beacon-chain/blob/devel/beacon_chain/sync_manager.nim](https://github.com/status-im/nim-beacon-chain/blob/devel/beacon_chain/sync_protocol.nim) 22 | 23 | backward sync: 24 | 25 | [https://github.com/status-im/nim-beacon-chain/blob/devel/beacon_chain/request_manager.nim](https://github.com/status-im/nim-beacon-chain/blob/devel/beacon_chain/request_manager.nim) 26 | 27 | # Outgoing Sync algorithms 28 | 29 | *remote peers sync from us* 30 | 31 | [https://github.com/status-im/nim-beacon-chain/blob/devel/beacon_chain/sync_protocol.nim](https://github.com/status-im/nim-beacon-chain/blob/devel/beacon_chain/sync_protocol.nim) 32 | -------------------------------------------------------------------------------- /docs/nbc_audit_2020/eth2_spec_core/epoch_finalization_and_justification.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Epoch finalization and justification" 3 | code_owner: "Mamy André-Ratsimbazafy (mratsim)" 4 | round: "Audit round 2" 5 | category: "ETH2 Specification Core Audit" 6 | repositories: "nim-beacon-chain" 7 | --- 8 | 9 | Spec: [https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/beacon-chain.md#justification-and-finalization](https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/beacon-chain.md#justification-and-finalization) 10 | 11 | Visual depiction: [https://github.com/protolambda/eth2-docs#justification-and-finalization](https://github.com/protolambda/eth2-docs#justification-and-finalization) 12 | 13 | ![finalization.png](./finalization.png) 14 | 15 | Implementation: [https://github.com/status-im/nim-beacon-chain/blob/543cbdfc6b9bc16f0331df2797422b7dc4d61eeb/beacon_chain/spec/state_transition_epoch.nim#L102-L240](https://github.com/status-im/nim-beacon-chain/blob/543cbdfc6b9bc16f0331df2797422b7dc4d61eeb/beacon_chain/spec/state_transition_epoch.nim#L102-L240) 16 | 17 | Self-test: [https://github.com/status-im/nim-beacon-chain/blob/master/tests/spec_epoch_processing/test_process_justification_and_finalization.nim](https://github.com/status-im/nim-beacon-chain/blob/master/tests/spec_epoch_processing/test_process_justification_and_finalization.nim) 18 | 19 | EF test vectors: [https://github.com/status-im/nim-beacon-chain/blob/543cbdfc/tests/official/test_fixture_state_transition_epoch.nim#L57-L58](https://github.com/status-im/nim-beacon-chain/blob/543cbdfc6b9bc16f0331df2797422b7dc4d61eeb/tests/official/test_fixture_state_transition_epoch.nim#L57-L58) 20 | -------------------------------------------------------------------------------- /docs/nbc_audit_2020/eth2_spec_core/eth1_data_processing.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "ETH1 data processing" 3 | code_owner: "" 4 | round: "Audit round 2" 5 | category: "ETH2 Specification Core Audit" 6 | repositories: "nim-beacon-chain, nim-web3" 7 | --- 8 | 9 | ETH2 validators are added by locking ETH on a designated ETH1 contract. 10 | 11 | Monitoring the ETH1 deposit contract is done via the mainchain_monitor service 12 | which connects to a ETH1 Web3 provider (Geth or Infura): 13 | - [https://github.com/status-im/nim-beacon-chain/blob/master/beacon_chain/mainchain_monitor.nim](https://github.com/status-im/nim-beacon-chain/blob/master/beacon_chain/mainchain_monitor.nim) 14 | - Spec of the deposit contract (for reference): [https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/deposit-contract.md](https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/deposit-contract.md) 15 | 16 | nim-web3 scope is significantly larger (and unimplemented) that the audit of nim-beacon-chain. The subset in scope is the one used by mainchain_monitor namely: 17 | 18 | - The types Web3, Sender, Subscription 19 | 20 | - The procedures 21 | 22 | - eth_getBlockByHash, eth_getBlockByNumber 23 | 24 | Processing the new entrants is done in the following state_transition function: 25 | - [https://github.com/status-im/nim-beacon-chain/blob/master/beacon_chain/spec/state_transition_block.nim#L125-L130](https://github.com/status-im/nim-beacon-chain/blob/master/beacon_chain/spec/state_transition_block.nim#L125-L130) 26 | - Specced at [https://github.com/ethereum/eth2.0-specs/blob/v0.12.2/specs/phase0/beacon-chain.md#eth1-data](https://github.com/ethereum/eth2.0-specs/blob/v0.12.2/specs/phase0/beacon-chain.md#eth1-data) 27 | -------------------------------------------------------------------------------- /docs/nbc_audit_2020/eth2_spec_core/finalization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/nbc_audit_2020/eth2_spec_core/finalization.png -------------------------------------------------------------------------------- /docs/nbc_audit_2020/eth2_spec_core/peer_pool_management.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Peer pool management" 3 | code_owner: "Eugene Kabanov (cheatfate)" 4 | round: "Audit round 2" 5 | category: "ETH2 Specification Core Audit" 6 | repositories: "nim-beacon-chain" 7 | --- 8 | 9 | Note: no spec 10 | 11 | location: 12 | 13 | - [https://github.com/status-im/nim-beacon-chain/blob/devel/beacon_chain/peer_pool.nim](https://github.com/status-im/nim-beacon-chain/blob/master/beacon_chain/peer_pool.nim) 14 | 15 | Created Issues from round 1: 16 | 17 | - [https://github.com/status-im/nim-beacon-chain/issues/1365](https://github.com/status-im/nim-beacon-chain/issues/1365) 18 | - [https://github.com/status-im/nim-beacon-chain/issues/1364](https://github.com/status-im/nim-beacon-chain/issues/1364) 19 | - [https://github.com/status-im/nim-beacon-chain/issues/1362](https://github.com/status-im/nim-beacon-chain/issues/1362) 20 | -------------------------------------------------------------------------------- /docs/nbc_audit_2020/eth2_spec_core/schlesi_rewards.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/nbc_audit_2020/eth2_spec_core/schlesi_rewards.png -------------------------------------------------------------------------------- /docs/nbc_audit_2020/eth2_spec_core/signature_verification.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Signature verification" 3 | code_owner: "Mamy André-Ratsimbazafy (mratsim)" 4 | round: "Audit round 2" 5 | category: "ETH2 Specification Core Audit" 6 | repositories: "nim-beacon-chain, nim-blscurve" 7 | --- 8 | 9 | # Description 10 | 11 | Verify that cryptographic primitives (Miracl and BLST) are properly used at a high-level. 12 | We assume that they are correctly implemented in the backend. 13 | 14 | Specs: 15 | - [https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/beacon-chain.md#bls-signatures](https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/beacon-chain.md#bls-signatures) 16 | 17 | For information, evaluation of backends: [https://notes.status.im/nim-bls-curve-backends](https://notes.status.im/nim-bls-curve-backends) 18 | 19 | # Links 20 | 21 | Links to the repositories and more information 22 | 23 | - [https://github.com/status-im/nim-blscurve](https://github.com/status-im/nim-blscurve) (low-level wrapper over crypto primitives, 2 backends) 24 | - [https://github.com/status-im/nim-beacon-chain/blob/master/beacon_chain/spec/crypto.nim](https://github.com/status-im/nim-beacon-chain/blob/master/beacon_chain/spec/crypto.nim) (high-level BLS signature types and serialization) 25 | - [https://github.com/status-im/nim-beacon-chain/blob/devel/beacon_chain/spec/signatures.nim](https://github.com/status-im/nim-beacon-chain/blob/devel/beacon_chain/spec/signatures.nim) (abstraction over signing and verification of consensus objects) 26 | -------------------------------------------------------------------------------- /docs/nbc_audit_2020/eth2_spec_core/state_transition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/nbc_audit_2020/eth2_spec_core/state_transition.png -------------------------------------------------------------------------------- /docs/nbc_audit_2020/network_core/discovery_protocol_discv5.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Discovery Protocol (discv5)" 3 | code_owner: "" 4 | round: "Audit round 1" 5 | category: "Network Core Audit" 6 | repositories: "nim-eth" 7 | --- 8 | 9 | ## Discovery “discv5” 10 | 11 | - Protocol specification: [https://github.com/ethereum/devp2p/tree/master/discv5](https://github.com/ethereum/devp2p/tree/master/discv5) 12 | - Note: the wire format might change ([https://github.com/ethereum/devp2p/issues/152](https://github.com/ethereum/devp2p/issues/152)) 13 | - Part of `nim-eth` repository that holds the discovery v5 code: [https://github.com/status-im/nim-eth/tree/master/eth/p2p/discoveryv5](https://github.com/status-im/nim-eth/tree/master/eth/p2p/discoveryv5) 14 | - In scope: 15 | - All of `discoveryv5` directory 16 | - All other modules in the `nim-eth` repository that the discoveryv5 code depends on, namely: `keys`, `rlp`, `async_utils`. It currently is also depending on and `trie/db` but as this is to be replaced, it can be considered out-of-scope. 17 | - For additional information see also the [readme](https://github.com/status-im/nim-eth/blob/master/doc/discv5.md). 18 | - [Open issues](https://github.com/status-im/nim-eth/issues?q=is%3Aissue+is%3Aopen+label%3Adiscoveryv5) and those that are likely to have [security implications](https://github.com/status-im/nim-eth/issues?q=is%3Aissue+is%3Aopen+label%3Adiscoveryv5+label%3Asecurity). 19 | -------------------------------------------------------------------------------- /docs/requirements.in: -------------------------------------------------------------------------------- 1 | pip-tools 2 | pyyaml >= 6.0.1 3 | mkdocs-material 4 | -------------------------------------------------------------------------------- /docs/the_auditors_handbook/.gitignore: -------------------------------------------------------------------------------- 1 | book 2 | -------------------------------------------------------------------------------- /docs/the_auditors_handbook/book.toml: -------------------------------------------------------------------------------- 1 | [book] 2 | authors = ["Mamy André-Ratsimbazafy"] 3 | language = "en" 4 | multilingual = false 5 | src = "src" 6 | title = "The Auditors Handbook to Nimbus Beacon Chain" 7 | -------------------------------------------------------------------------------- /docs/the_auditors_handbook/src/01_introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | !!! warning 4 | This auditors' handbook is frozen and obsolete; the [Nim language manual](https://nim-lang.org/docs/manual.html) alongside [other Nim documentation](https://nim-lang.org/documentation.html), [Status Nim style guide](https://status-im.github.io/nim-style-guide/), [Chronos guides](https://github.com/status-im/nim-chronos/blob/master/docs/src/SUMMARY.md), and [Nim by Example](https://nim-by-example.github.io/getting_started/) supercede it. 5 | 6 | The Nimbus Nim-Beacon-Chain (NBC) project is an implementation of the [Ethereum 2 Beacon Chain specification](https://github.com/ethereum/consensus-specs) in the [Nim programming language](https://nim-lang.org/). 7 | 8 | The Auditors' Handbook aims to be provide a comprehensive introduction to: 9 | - The Nim programming language, as used in the project. 10 | - The NBC project. 11 | - The dependencies of the project. 12 | 13 | A particular focus will be given to features related to safety, correctness, error handling, testing, fuzzing, or inspecting Nim code. 14 | 15 | One of the major highlights of Nim is that it compiles to C or C++ before compiling to native code. All techniques available to audit C code can be used to audit Nim. 16 | 17 | The dependencies NBC rely on are detailed per audit phase in the [build system and dependencies](03.2_build_system_and_dependencies.md) section. 18 | -------------------------------------------------------------------------------- /docs/the_auditors_handbook/src/02.1.2_pointer_manipulation.md: -------------------------------------------------------------------------------- 1 | # Pointer manipulation 2 | 3 | !!! warning 4 | This auditors' handbook is frozen and obsolete; the [Nim language manual](https://nim-lang.org/docs/manual.html) alongside [other Nim documentation](https://nim-lang.org/documentation.html), [Status Nim style guide](https://status-im.github.io/nim-style-guide/), [Chronos guides](https://github.com/status-im/nim-chronos/blob/master/docs/src/SUMMARY.md), and [Nim by Example](https://nim-by-example.github.io/getting_started/) supercede it. 5 | 6 | https://github.com/status-im/nim-stew/blob/master/stew/ptrops.nim 7 | -------------------------------------------------------------------------------- /docs/the_auditors_handbook/src/02.1.3_emitting_raw_C_assembly_code.md: -------------------------------------------------------------------------------- 1 | # Emitting raw C or Assembly code 2 | 3 | TODO 4 | -------------------------------------------------------------------------------- /docs/the_auditors_handbook/src/02.1.4_closure_iterators.md: -------------------------------------------------------------------------------- 1 | # Closures and closures iterators 2 | 3 | !!! warning 4 | This auditors' handbook is frozen and obsolete; the [Nim language manual](https://nim-lang.org/docs/manual.html) alongside [other Nim documentation](https://nim-lang.org/documentation.html), [Status Nim style guide](https://status-im.github.io/nim-style-guide/), [Chronos guides](https://github.com/status-im/nim-chronos/blob/master/docs/src/SUMMARY.md), and [Nim by Example](https://nim-by-example.github.io/getting_started/) supercede it. 5 | 6 | TODO 7 | 8 | ## At a low-level 9 | 10 | Closures and closures iterators are implemented via 11 | a pointer + an environment that stores the captured state necessary 12 | to execute the function. 13 | 14 | The Nim compiler has a limited form of borrow checking and prevents 15 | capturing mutable variable or openArray (pointer+length pair). 16 | 17 | It otherwise copies the capture variables in case of objects with value semantics 18 | or increment the reference count in case of ref object. 19 | 20 | The Chronos library needs to generate a closure iterator for all async proc instantiated 21 | which may lead to long-lived ref objects and unreclaimable memory. 22 | 23 | This may also extend to other resources like socket connections or file descriptors and 24 | a significant effort is underway to track memory usage and detect such scenarios: 25 | 26 | - [https://github.com/status-im/nim-libp2p/issues/145](https://github.com/status-im/nim-libp2p/issues/145) 27 | - [https://github.com/status-im/nim-libp2p/issues/207](https://github.com/status-im/nim-libp2p/issues/207) 28 | -------------------------------------------------------------------------------- /docs/the_auditors_handbook/src/02.10_Nim_FAQ.md: -------------------------------------------------------------------------------- 1 | # Nim FAQ 2 | -------------------------------------------------------------------------------- /docs/the_auditors_handbook/src/02.2.1_builtin_types.md: -------------------------------------------------------------------------------- 1 | # Builtin types 2 | 3 | TODO 4 | -------------------------------------------------------------------------------- /docs/the_auditors_handbook/src/02.2.2_casting_and_low_level_memory_representation.md: -------------------------------------------------------------------------------- 1 | # Casting and low-level memory representation 2 | 3 | !!! warning 4 | This auditors' handbook is frozen and obsolete; the [Nim language manual](https://nim-lang.org/docs/manual.html) alongside [other Nim documentation](https://nim-lang.org/documentation.html), [Status Nim style guide](https://status-im.github.io/nim-style-guide/), [Chronos guides](https://github.com/status-im/nim-chronos/blob/master/docs/src/SUMMARY.md), and [Nim by Example](https://nim-by-example.github.io/getting_started/) supercede it. 5 | 6 | ## Conversions 7 | 8 | Casting to a signed integer will lead to a range check. 9 | Conversion to an unsigned integer even from a negative signed integer will NOT lead to a range check (https://github.com/nim-lang/RFCs/issues/175) 10 | https://nim-lang.org/docs/manual.html#statements-and-expressions-type-conversions 11 | 12 | ## Casting integers 13 | 14 | Unsigned integer casts behave like C. 15 | 16 | Upcasting will lead to zero extension 17 | Downcasting will lead to truncation 18 | 19 | Signed integer ranges will not be checked with a cast. 20 | 21 | ## Casting to/from other types 22 | 23 | Casting to or from any other types will be done through: 24 | 25 | - union casts by default 26 | - or C conversion if the type is a pointer. 27 | 28 | In practice this means that the bit-pattern will be reinterpreted as the new type, similar to C++ reinterpret cast. 29 | -------------------------------------------------------------------------------- /docs/the_auditors_handbook/src/02.2.3_memory_management_gc.md: -------------------------------------------------------------------------------- 1 | # Nim memory management 2 | 3 | !!! warning 4 | This auditors' handbook is frozen and obsolete; the [Nim language manual](https://nim-lang.org/docs/manual.html) alongside [other Nim documentation](https://nim-lang.org/documentation.html), [Status Nim style guide](https://status-im.github.io/nim-style-guide/), [Chronos guides](https://github.com/status-im/nim-chronos/blob/master/docs/src/SUMMARY.md), and [Nim by Example](https://nim-by-example.github.io/getting_started/) supercede it. 5 | 6 | Nim memory management is on a per-type basis. 7 | 8 | Plain objects and char and numerical types are allocated on the stack. 9 | 10 | Sequences and strings are allocated on the heap but have value semantics. 11 | They are copied on assignment 12 | 13 | Ref types are allocated on the heap and have reference semantics, i.e. an unique instance 14 | can be held by multiple variables and only when all those variables go out-of-scope is 15 | the ref type discarded. 16 | 17 | By default Nim uses a deferred reference counting GC. Additionally, if the type can lead 18 | to cycles, Nim will add "mark-and-sweep" passes to collect them. 19 | 20 | ## Destructors 21 | 22 | TODO 23 | 24 | ## Nim allocator 25 | 26 | Nim GCs are backed by a TLSF allocator which allows Nim to provide soft real-time guarantees if needed. 27 | 28 | ## Analyzing memory leaks 29 | 30 | Nim can be compiled with `-d:useMalloc` to bypass the TLSF allocator and directly use malloc/free 31 | 32 | ## References 33 | 34 | - [https://nim-lang.org/docs/gc.html](https://nim-lang.org/docs/gc.html) 35 | 36 | - [http://www.gii.upv.es/tlsf/](http://www.gii.upv.es/tlsf/) 37 | -------------------------------------------------------------------------------- /docs/the_auditors_handbook/src/02.2.4_generics_types_static_types.md: -------------------------------------------------------------------------------- 1 | # Generics and Static types 2 | 3 | !!! warning 4 | This auditors' handbook is frozen and obsolete; the [Nim language manual](https://nim-lang.org/docs/manual.html) alongside [other Nim documentation](https://nim-lang.org/documentation.html), [Status Nim style guide](https://status-im.github.io/nim-style-guide/), [Chronos guides](https://github.com/status-im/nim-chronos/blob/master/docs/src/SUMMARY.md), and [Nim by Example](https://nim-by-example.github.io/getting_started/) supercede it. 5 | 6 | Nim types can be parametrized by types (generics) or compile-time values (static) 7 | 8 | For example 9 | 10 | ```Nim 11 | type 12 | MySeq[T] = object 13 | len, reserved: int 14 | data: ptr UncheckedArray[T] 15 | ``` 16 | 17 | The generics can be restricted 18 | 19 | ```Nim 20 | type 21 | MySeq[T: int32 or int64] = object 22 | len, reserved: int 23 | data: ptr UncheckedArray[T] 24 | ``` 25 | 26 | With static types 27 | 28 | ```Nim 29 | type 30 | SmallSeq[MaxLen: static int, T] = object 31 | len: int 32 | data: array[MaxLen, T] 33 | ``` 34 | -------------------------------------------------------------------------------- /docs/the_auditors_handbook/src/02.2.5_arrays_openarrays_strings_cstring.md: -------------------------------------------------------------------------------- 1 | # Arrays, openarrays, varargs 2 | 3 | !!! warning 4 | This auditors' handbook is frozen and obsolete; the [Nim language manual](https://nim-lang.org/docs/manual.html) alongside [other Nim documentation](https://nim-lang.org/documentation.html), [Status Nim style guide](https://status-im.github.io/nim-style-guide/), [Chronos guides](https://github.com/status-im/nim-chronos/blob/master/docs/src/SUMMARY.md), and [Nim by Example](https://nim-by-example.github.io/getting_started/) supercede it. 5 | 6 | ## Arrays 7 | 8 | TODO 9 | 10 | ## Openarrays 11 | 12 | Openarray are a parameter-only type that represent a (pointer, length) pair. 13 | In other languages they are also known as slices, ranges, views, spans. 14 | 15 | _The name openArray is inherited from Pascal, Oberon and Modula 2_ 16 | 17 | Arrays and sequences are implictily converted to openArray. 18 | 19 | The compiler has a limited form of escape analysis to prevent capturing openarrays in closures 20 | or returning them. 21 | 22 | ## UncheckedArrays 23 | 24 | TODO 25 | -------------------------------------------------------------------------------- /docs/the_auditors_handbook/src/02.2.6_runtime_types_variants_oop.md: -------------------------------------------------------------------------------- 1 | # Runtime types, variants, object-oriented programming 2 | TODO 3 | -------------------------------------------------------------------------------- /docs/the_auditors_handbook/src/02.2.7_compiletime_evaluation.md: -------------------------------------------------------------------------------- 1 | # Compile-time evaluation 2 | TODO 3 | -------------------------------------------------------------------------------- /docs/the_auditors_handbook/src/02.8_Nim_threat_model.md: -------------------------------------------------------------------------------- 1 | # Nim threat model 2 | 3 | !!! warning 4 | This auditors' handbook is frozen and obsolete; the [Nim language manual](https://nim-lang.org/docs/manual.html) alongside [other Nim documentation](https://nim-lang.org/documentation.html), [Status Nim style guide](https://status-im.github.io/nim-style-guide/), [Chronos guides](https://github.com/status-im/nim-chronos/blob/master/docs/src/SUMMARY.md), and [Nim by Example](https://nim-by-example.github.io/getting_started/) supercede it. 5 | 6 | Nim and its standard library are not the focus of the audits. 7 | 8 | In particular the codebase intentionally limits reliance on the standard library 9 | so that it is not tied to Nim release schedule, instead of the standard library 10 | we use `stew` most of the time: [https://github.com/status-im/nim-stew](https://github.com/status-im/nim-stew). 11 | 12 | Nim standard library is implemented here: 13 | - [https://github.com/nim-lang/Nim/tree/v1.2.4/lib](https://github.com/nim-lang/Nim/tree/v1.2.4/lib) 14 | 15 | We target Nim v1.2.2 16 | -------------------------------------------------------------------------------- /docs/the_auditors_handbook/src/02.9_Nim_stdlib_use_in_nimbus.md: -------------------------------------------------------------------------------- 1 | # Nim standard library use in Nimbus 2 | -------------------------------------------------------------------------------- /docs/the_auditors_handbook/src/04_serialization.md: -------------------------------------------------------------------------------- 1 | # Serialization 2 | 3 | -------------------------------------------------------------------------------- /docs/the_auditors_handbook/src/05_async_with_chronos.md: -------------------------------------------------------------------------------- 1 | # Async/Await with the Chronos library 2 | -------------------------------------------------------------------------------- /docs/the_auditors_handbook/src/06_cryptography_and_rng.md: -------------------------------------------------------------------------------- 1 | # Cryptography 2 | -------------------------------------------------------------------------------- /docs/the_auditors_handbook/src/07_nim-eth.md: -------------------------------------------------------------------------------- 1 | # Ethereum Networking 2 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/.gitignore: -------------------------------------------------------------------------------- 1 | book 2 | site 3 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/CNAME: -------------------------------------------------------------------------------- 1 | nimbus.guide 2 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/README.md: -------------------------------------------------------------------------------- 1 | The Nimbus Guide is written using markdown and [material for mkdocs](https://squidfunk.github.io/mkdocs-material/). 2 | 3 | See the `Makefile` for setup. 4 | 5 | The guide is divided into several sections - broadly: 6 | 7 | * Guides - walk-throughs that allow the user to get started with a specific area of the client 8 | * How-to:s - short pages that show the user how to solve a specific problem or perform a specific task 9 | * Reference - pages describing how specific parts of Nimbus work, reference-style 10 | * "Other" - explanations of concepts, background etc. 11 | 12 | ## Resources 13 | 14 | * [material for mkdocs](https://squidfunk.github.io/mkdocs-material/) - doc generator 15 | * [divio](https://documentation.divio.com/introduction.html) - useful resource diving into the above section structure 16 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/additional-validator.md: -------------------------------------------------------------------------------- 1 | # Add an additional validator 2 | 3 | 4 | 5 | To add an additional validator, [generate a new key](./more-keys.md) then follow [the same steps](./run-a-validator.md#2-import-your-validator-keys) as you did when adding your other keys. 6 | 7 | You'll have to [restart](./run-a-validator.md#3-start-validating) the beacon node for the changes to take effect. 8 | 9 | !!! tip 10 | A single Nimbus instance is able to handle multiple validators. 11 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/build.md: -------------------------------------------------------------------------------- 1 | # Build from source 2 | 3 | Building Nimbus from source ensures that all hardware-specific optimizations are turned on. 4 | The build process itself is simple and fully automated, but may take a few minutes. 5 | 6 | !!! note "Nim" 7 | Nimbus is written in the [Nim](https://nim-lang.org) programming language. 8 | The correct version will automatically be downloaded as part of the build process! 9 | 10 | ## Prerequisites 11 | 12 | Make sure you have all needed [build prerequisites](./install.md#build-prerequisites). 13 | 14 | ## Building the node 15 | 16 | ### 1. Clone the `nimbus-eth2` repository 17 | 18 | ```sh 19 | git clone https://github.com/status-im/nimbus-eth2 20 | cd nimbus-eth2 21 | ``` 22 | 23 | ### 2. Run the beacon node build process 24 | 25 | To build the Nimbus beacon node and its dependencies, run: 26 | 27 | ```sh 28 | make -j4 nimbus_beacon_node 29 | ``` 30 | 31 | !!! tip 32 | Omit `-j4` on systems with 4GB of memory or less. 33 | 34 | This step can take several minutes. 35 | After it has finished, you can check if the installation was successful by running: 36 | 37 | ```sh 38 | build/nimbus_beacon_node --help 39 | ``` 40 | 41 | If you see the command-line options, your installation was successful! 42 | Otherwise, don't hesitate to reach out to us in the `#helpdesk` channel of [our discord](https://discord.gg/j3nYBUeEad). 43 | 44 | 45 | 46 | ## Keeping Nimbus updated 47 | 48 | When you decide to upgrade Nimbus to a newer version, make sure to follow the [keeping updated guide](./keep-updated.md). -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/connect-eth2.md: -------------------------------------------------------------------------------- 1 | This page has been removed. 2 | 3 | Follow our [validating guide](./run-a-validator.md). 4 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/database-backup.md: -------------------------------------------------------------------------------- 1 | # Back up your database 2 | 3 | 4 | The best way to do this is to use `.backup` sqlite command: 5 | 6 | 1. Navigate to either `build/data/shared_mainnet_0/db/` (if you're running Hoodi: `shared_hoodi_0`) or the directory you supplied to the `--data-dir` argument when you launched Nimbus. 7 | 8 | 2. Run the following command: 9 | ``` 10 | sqlite3 nbc.sqlite3 ".backup 'backup_nbc.sqlite3'" 11 | ``` 12 | Make sure to correctly type both single and double quotes, as written above. 13 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/deposit.md: -------------------------------------------------------------------------------- 1 | This page has been removed. 2 | 3 | Follow our [validating guide](./run-a-validator.md). 4 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/doppelganger-detection.md: -------------------------------------------------------------------------------- 1 | # Doppelganger detection 2 | 3 | Doppelganger detection is a safety feature for preventing slashing in the event that two setups are using the same validator keys, for example after a migration of keys from one setup to another. 4 | 5 | Doppelganger detection works by monitoring network activity for a short period for each validator while preventing duties from being performed. 6 | 7 | If any activity is detected, the node shuts down with exit code 129. 8 | 9 | Because detection depends on network detection, there are cases where it may fail to find duplicate validators even though they are live. 10 | You should never use it as a mechanism for running redundant setups! 11 | 12 | ## Command line 13 | 14 | Doppelganger detection is turned on by default - disable it with: 15 | 16 | === "Beacon node" 17 | 18 | ```sh 19 | # Disable doppelganger detection 20 | ./run-mainnet-beacon-node.sh --doppelganger-detection=off ... 21 | ``` 22 | 23 | === "Validator client" 24 | 25 | ```sh 26 | # Disable doppelganger detection 27 | build/nimbus_validator_client --doppelganger-detection=off ... 28 | ``` 29 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/email-notifications.md: -------------------------------------------------------------------------------- 1 | # Email notifications 2 | 3 | You can create an account on [beaconcha.in](https://beaconcha.in/) to set up email notifications in case your validator loses balance (goes offline), or gets slashed. 4 | 5 | !!! tip 6 | If your validator loses balance for two epochs in a row, you may want to investigate. 7 | It's a strong signal that it may be offline. 8 | 9 | ### 1. Sign up at [beaconcha.in/register](https://beaconcha.in/register) 10 | 11 | ### 2. Type your validator's public key into the search bar 12 | 13 | ![](./img/email_01.png) 14 | 15 | ### 3. Click on the bookmark icon 16 | 17 | ![](./img/email_02.png) 18 | 19 | ### 4. Tick the boxes and select *Add To Watchlist* 20 | 21 | ![](./img/email_03.png) 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/goerli-eth.md: -------------------------------------------------------------------------------- 1 | This page has been removed. 2 | 3 | Use the [Hoodi testnet](./hoodi.md). 4 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/graffiti.md: -------------------------------------------------------------------------------- 1 | # Set up Graffiti 2 | 3 | You can use your node's graffiti flag to include a short text in the blocks that your node creates. 4 | You will be able to see it using the block explorer. 5 | 6 | The graffiti can be either a string or, if you want to specify raw bytes, you can use 0x-prefixed hex value. 7 | 8 | ## Command line 9 | 10 | === "Mainnet" 11 | ```sh 12 | ./run-mainnet-beacon-node.sh \ 13 | --graffiti="" 14 | ``` 15 | 16 | === "Hoodi" 17 | ```sh 18 | build/nimbus_beacon_node \ 19 | --network=hoodi \ 20 | --data-dir=build/data/shared_hoodi_0 \ 21 | --graffiti="" 22 | ``` 23 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/hardware.md: -------------------------------------------------------------------------------- 1 | # System requirements 2 | 3 | The recommended system requirements for running the Nimbus beacon node are: 4 | 5 | | What | Recommended | 6 | | ---------- | ------ | 7 | | Operating system | Linux [64-bit](https://en.wikipedia.org/wiki/64-bit_computing), Windows 64-bit, macOS 11+ | 8 | | Memory | 4GB (running) or 8GB (building) | 9 | | Disk space | 200GB | 10 | | Network | Reliable broadband | 11 | 12 | !!! note 13 | While the consensus client will work with a classic, spinning, hard disks, if you plan to run an execution client make sure you use an SSD, either SATA or NVMe. 14 | 15 | 16 | ### Execution client 17 | 18 | In addition to the beacon node, you will need to run an [execution client](./eth1.md). 19 | Check the documentation of the client of choice and add them to the above requirements. 20 | 21 | Broadly, to run both an execution and a consensus client on the same machine, we recommend a **2 TB** SSD and **16 GB RAM**. 22 | 23 | 24 | ### Minimal requirements 25 | 26 | Nimbus has been optimized to also run well on hardware significantly less powerful than the recommended system requirements — the more validators you run on the same node, the more hardware resources and network bandwidth will it will use. 27 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/holesky.md: -------------------------------------------------------------------------------- 1 | This page has been removed. 2 | 3 | Use the [Hoodi testnet](./hoodi.md). 4 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/RPi_imager1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/RPi_imager1.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/RPi_imager2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/RPi_imager2.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/RPi_imager3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/RPi_imager3.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/RPi_imager4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/RPi_imager4.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/RPi_imager5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/RPi_imager5.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/beacon_node_example.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/beacon_node_example.PNG -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/connect_testnet.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/connect_testnet.PNG -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/deposit-transaction-details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/deposit-transaction-details.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/deposit_sent.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/deposit_sent.PNG -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/developers_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/developers_01.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/email_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/email_01.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/email_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/email_02.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/email_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/email_03.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/enter_private_key.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/enter_private_key.PNG -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/export_pkey.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/export_pkey.PNG -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/health.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/health.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/metamask_export_private_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/metamask_export_private_1.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/metamask_export_private_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/metamask_export_private_2.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/metamask_export_private_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/metamask_export_private_3.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/metrics_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/metrics_01.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/metrics_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/metrics_02.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/metrics_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/metrics_03.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/metrics_04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/metrics_04.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/metrics_05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/metrics_05.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/metrics_06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/metrics_06.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/metrics_07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/metrics_07.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/metrics_08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/metrics_08.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/metrics_09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/metrics_09.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/metrics_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/metrics_10.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/metrics_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/metrics_11.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/metrics_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/metrics_12.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/metrics_13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/metrics_13.png -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/img/success.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/docs/the_nimbus_book/src/img/success.PNG -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/infura-guide.md: -------------------------------------------------------------------------------- 1 | This page has been removed - following the merge it is no longer possible to use Infura for validation duties. 2 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/intro.md: -------------------------------------------------------------------------------- 1 | [Moved](./index.md) 2 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/keymanager-api.md: -------------------------------------------------------------------------------- 1 | # Keymanager API 2 | 3 | The standardized [Keymanager API](https://ethereum.github.io/keymanager-APIs/) can be used to add, remove, or [migrate](./migration.md) validators on the fly while the beacon node is running. 4 | 5 | ## Configuration 6 | 7 | By default, we disable the Keymanager API. 8 | To enable it, start the beacon node with the `--keymanager` option enabled: 9 | 10 | ``` 11 | build/nimbus_beacon_node \ 12 | --network=hoodi \ 13 | --data-dir=build/data/shared_hoodi_0 \ 14 | --keymanager 15 | ``` 16 | 17 | Once the node is running, you'll be able to access the API from [http://localhost:5052/](http://localhost:5052/). 18 | 19 | ### Authorization: Bearer scheme 20 | 21 | All requests must be authorized through the `Authorization: Bearer` scheme with a token matching the contents of a file provided at the start of the node through the `--keymanager-token-file` parameter. 22 | 23 | ### Enabling connections from outside machines 24 | 25 | By default, only connections from the same machine are entertained. 26 | If you wish to change this you can configure the port and listening address with the `--keymanager-port` and `--keymanager-address` options respectively. 27 | 28 | !!! warning 29 | The Keymanager API port should only be exposed through a secure channel (e.g. HTTPS, an SSH tunnel, a VPN, etc.) 30 | 31 | ## Specification 32 | 33 | The specification is documented [here](https://ethereum.github.io/keymanager-APIs/). 34 | The README is also extremely useful and is documented [here](https://github.com/ethereum/keymanager-APIs/). 35 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/keys.md: -------------------------------------------------------------------------------- 1 | This page has been removed. 2 | 3 | Follow our [validating guide](./run-a-validator.md). 4 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/log-levels.md: -------------------------------------------------------------------------------- 1 | This information has moved to [logging](./logging.md). 2 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/logging.md: -------------------------------------------------------------------------------- 1 | # Logging 2 | 3 | Nimbus offers several options for logging. 4 | By default, logs are written to stdout using the [chronicles](https://github.com/status-im/nim-chronicles#introduction) `textlines` format which is convenient to read and can be used with tooling for [heroku/logfmt](https://brandur.org/logfmt). 5 | 6 | ## Change log level 7 | 8 | You can customise Nimbus' verbosity with the `--log-level` option. 9 | 10 | For example: 11 | 12 | ``` 13 | ./run-mainnet-beacon-node.sh --log-level=WARN 14 | ``` 15 | 16 | The default value is `INFO`. 17 | 18 | Possible values (in order of decreasing verbosity) are: 19 | 20 | ``` 21 | TRACE 22 | DEBUG 23 | INFO 24 | NOTICE 25 | WARN 26 | ERROR 27 | FATAL 28 | NONE 29 | ``` 30 | 31 | ## Change logging style 32 | 33 | Nimbus supports three log formats: `colors`, `nocolors` and `json`. 34 | In `auto` mode, logs will be printed using either `colors` or `nocolors`. 35 | 36 | You can choose a log format with the `--log-format` option, which also understands `auto` and `none`: 37 | 38 | ``` 39 | ./run-mainnet-beacon-node.sh --log-format=none # disable logging to std out 40 | ./run-mainnet-beacon-node.sh --log-format=json # print json logs, one line per item 41 | ``` 42 | 43 | ## Logging to a file 44 | 45 | To send logs to a file, you can redirect the stdout logs: 46 | 47 | ``` 48 | # log json to filename.jsonl 49 | ./run-mainnet-beacon-node.sh --log-format=json > filename.jsonl 50 | ``` 51 | 52 | We recommend keeping an eye on the growth of this file with a [log rotator](./log-rotate.md). 53 | Logs are written in the "JSON Lines" format - one `json` entry per line. 54 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/merge.md: -------------------------------------------------------------------------------- 1 | This page has been removed; all Ethereum Foundation-affiliated Ethereum networks have merged. 2 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/optimistic-sync.md: -------------------------------------------------------------------------------- 1 | # Optimistic sync 2 | 3 | Optimistic sync is the process of syncing an execution and consensus client concurrently, without having the consensus client wait for the execution client. 4 | 5 | During optimistic sync, the consensus client quickly syncs up to the latest consensus but delays verifying block execution payloads: it continuously informs the execution client of the latest consensus head, allowing the execution client to perform a snapshot sync directly to the latest state. 6 | 7 | Once the execution client has caught up, the consensus and execution clients work in lock-step each validating the block. 8 | 9 | Both execution and consensus clients must be fully synced to perform validation duties: while optimistically synced, validator duties (attestation, sync committee and block production work) are skipped. 10 | 11 | !!! info "Running without execution client" 12 | Nimbus continues to sync optimistically when the execution client is not available thanks to its built-in execution payload verifier. 13 | 14 | ## Identifying optimistic sync 15 | 16 | An optimistically synced node can be identified by examining the "Slot start" log message. 17 | When optimistically synced, the `sync` key will have a `/opt` suffix, indicating that it's waiting for the execution client to catch up: 18 | 19 | ``` 20 | INF 2022-10-26 18:57:35.000+02:00 Slot start topics="beacnde" slot=4998286 epoch=156196 sync=synced/opt peers=29 head=f21d399e:4998285 finalized=156194:91e2ebaf delay=467us953ns 21 | ``` 22 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/prater.md: -------------------------------------------------------------------------------- 1 | This page has been removed. 2 | 3 | Use the [Hoodi testnet](./hoodi.md). 4 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/preparation.md: -------------------------------------------------------------------------------- 1 | # Mainnet checklist 2 | 3 | ## Latest software 4 | 5 | Please check that you are running the latest stable [Nimbus software release](https://github.com/status-im/nimbus-eth2/releases). 6 | 7 | !!! tip 8 | In order to stay on top of new releases you should subscribe to [our mailing list](https://subscribe.nimbus.team/). 9 | 10 | ## More than 15 peers 11 | 12 | Please check that your node has at least 15 peers. 13 | To monitor your peer count, pay attention to the [`Slot start` messages in your logs](keep-an-eye.md#keep-track-of-your-syncing-progress). 14 | See the [networking page](networking.md) for more tips. 15 | 16 | ## Validator attached 17 | 18 | Please check that your [validator is attached](keep-an-eye.md#make-sure-your-validator-is-attached) to your node. 19 | 20 | ## Systemd 21 | 22 | We recommend [setting up a systemd service](beacon-node-systemd.md) with an autorestart on boot. 23 | Should you experience an unexpected power outage, this will ensure your validator restarts correctly. 24 | 25 | Systemd will also ensure your validator keeps running when you exit your ssh session (`Ctrl-C`) and/or switch off your laptop. 26 | 27 | ## Ethereum Foundation's Checklist 28 | 29 | As a final check, we recommend you also go through the EF'S [staker checklist](https://launchpad.ethereum.org/en/checklist). 30 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/resources.md: -------------------------------------------------------------------------------- 1 | # Resources 2 | 3 | - [ethstaker discord](https://discord.com/invite/e84CFep): great place for tips and discussions 4 | 5 | - [Validator launchpad](https://launchpad.ethereum.org): to send deposits 6 | 7 | - [Beacon chain explorer](https://beaconcha.in/): to monitor network health 8 | 9 | - [Nimbus discord](https://discord.com/invite/XRxWahP): best place to ask questions and to stay up-to-date with critical updates 10 | 11 | - [Ethereum on ARM: Raspberry Pi 4 image + tutorial](https://www.reddit.com/r/ethereum/comments/gf3nhg/ethereum_on_arm_raspberry_pi_4_images_release/): turn your Raspberry Pi 4 into an eth1 or eth2 node just by flashing the MicroSD card 12 | 13 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/security_issues.md: -------------------------------------------------------------------------------- 1 | ## Security related issues 2 | 3 | **For any security related issues, follow responsible disclosure standards. 4 | Do not file public issues.** 5 | 6 | Please file a report at the [Ethereum bug bounty program](https://ethereum.org/en/bug-bounty/) in order to receive a reward for your findings. 7 | 8 | When in doubt, please send an encrypted email to security@status.im and ask ([gpg key](https://github.com/status-im/status-security/blob/master/pgp-keys/security%40status.im.asc)). 9 | 10 | Security related issues are (sufficient but not necessary criteria): 11 | 12 | - Soundness of protocols (consensus model, p2p protocols): consensus liveness and integrity. 13 | - Errors and failures in the cryptographic primitives 14 | - RCE vulnerabilities 15 | - Any issues causing consensus splits from the rest of the network 16 | - Denial of service (DOS) vectors 17 | - Broken Access Control 18 | - Memory Errors 19 | - Security Misconfiguration 20 | - Vulnerable Dependencies 21 | - Authentication Failures 22 | - Data Integrity Failures 23 | - Logging and Monitoring Vulnerabilities 24 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/stylesheets/extra.css: -------------------------------------------------------------------------------- 1 | [data-md-color-scheme="slate"] { 2 | --md-hue: 180; 3 | --md-default-bg-color: hsla(var(--md-hue), 0%, 0%, 1); 4 | --md-footer-bg-color: hsla(var(--md-hue), 0%, 0%, 1); 5 | --md-footer-bg-color--dark: hsla(var(--md-hue), 0%, 0%, 1); 6 | } 7 | -------------------------------------------------------------------------------- /docs/the_nimbus_book/src/voluntary-exit.md: -------------------------------------------------------------------------------- 1 | # Perform a voluntary exit 2 | 3 | Voluntary exits allow validators to permanently stop performing their duties, and eventually recover the deposit. 4 | 5 | Exits are subject to a wait period that depends on the length of the exit queue. 6 | While a validator is exiting, it still must perform its duties in order not to lose funds to inactivity penalities. 7 | 8 | !!! warning 9 | Voluntary exits are **irreversible**. 10 | You won't be able to validate again with the same key. 11 | 12 | !!! note 13 | Voluntary exits won't be processed if the chain isn't finalizing. 14 | 15 | To perform a voluntary exit, make sure your beacon node is running with the `--rest` option enabled (e.g. `./run-mainnet-beacon-node.sh --rest`), then run: 16 | 17 | build/nimbus_beacon_node deposits exit --validator= 18 | 19 | !!! note 20 | In the command above, you must replace `` with the file-system path of an Ethereum [ERC-2335 Keystore](https://eips.ethereum.org/EIPS/eip-2335) created by a tool such as [staking-deposit-cli](https://github.com/ethereum/staking-deposit-cli) or [ethdo](https://github.com/wealdtech/ethdo). 21 | 22 | !!! tip 23 | You can perform multiple voluntary exits at once by supplying the `--validator` option multiple times on the command-line. This is typically more convenient when the provided keystores share the same password - you'll be asked to enter it only once. 24 | 25 | ## `rest-url` parameter 26 | 27 | The `--rest-url` parameter can be used to point the exit command to a specific node for publishing the request, as long as it's compatible with the [REST API](./rest-api.md). 28 | 29 | -------------------------------------------------------------------------------- /env.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # beacon_chain 3 | # Copyright (c) 2020-2024 Status Research & Development GmbH 4 | # Licensed and distributed under either of 5 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 6 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 7 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 8 | 9 | # We use ${BASH_SOURCE[0]} instead of $0 to allow sourcing this file 10 | # and we fall back to a Zsh-specific special var to also support Zsh. 11 | REL_PATH="$(dirname ${BASH_SOURCE[0]:-${(%):-%x}})" 12 | ABS_PATH="$(cd "${REL_PATH}"; pwd)" 13 | 14 | # Activate nvm only when this file is sourced without arguments: 15 | if [ -z "$*" ]; then 16 | if ! command -v ganache-cli > /dev/null; then 17 | if command -v nvm > /dev/null; then 18 | nvm use 19 | npm install -g ganache-cli 20 | else 21 | echo < 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /installer/macos/nimbus-pkg.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /installer/macos/nimbus-pkg.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /installer/macos/nimbus-pkg/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | InstallerSectionTitle 22 | Configure 23 | NSMainNibFile 24 | MyInstallerPane 25 | NSPrincipalClass 26 | InstallerSection 27 | 28 | 29 | -------------------------------------------------------------------------------- /installer/macos/nimbus-pkg/InstallerSections.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SectionOrder 6 | 7 | Introduction 8 | ReadMe 9 | License 10 | nimbus-pkg.bundle 11 | Target 12 | PackageSelection 13 | Install 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /installer/macos/nimbus-pkg/MyInstallerPane.h: -------------------------------------------------------------------------------- 1 | // 2 | // MyInstallerPane.h 3 | // nimbus-pkg 4 | // 5 | // Created by zahary on 16.08.21. 6 | // 7 | 8 | #import 9 | 10 | @interface MyInstallerPane : InstallerPane 11 | @property BOOL EthValid; 12 | @property BOOL NetworkChosen; 13 | @property int ChosenNetwork; 14 | @property (weak) IBOutlet NSComboBoxCell *comboBox; 15 | @property (weak) IBOutlet NSTextField *EthField; 16 | @property (weak) IBOutlet NSTextField *descriptionField; 17 | @property (weak) IBOutlet NSButton *startServiceCheckbox; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /installer/macos/nimbus-pkg/ReadMe.html: -------------------------------------------------------------------------------- 1 | Nimbus-eth2 is a extremely efficient Beacon Chain client for participating in the Ethereum Proof of Stake protocol. It performs well on embedded systems, resource-restricted devices -- including Raspberry Pis and mobile devices -- the low resource usage also makes it an excellet choice for running together with an Ethereum client on a server or a desktop where it simply takes up less resources. 2 | -------------------------------------------------------------------------------- /installer/macos/nimbus-pkg/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | InstallerSectionTitle = "Configure"; 2 | 3 | -------------------------------------------------------------------------------- /installer/macos/nimbus-pkg/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | "PaneTitle" = "Configure"; 4 | -------------------------------------------------------------------------------- /installer/macos/nimbus-pkg/launchservice.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Scripts/Nimbus:/Library/Scripts/Nimbus:scripts 3 | 4 | source /etc/nimbus.config 5 | 6 | cd "/Library/Scripts/Nimbus" 7 | 8 | /Library/Scripts/Nimbus/nimbus_beacon_node --web3-url="${WEB3_URL}" --network="${NETWORK}" 9 | -------------------------------------------------------------------------------- /installer/macos/nimbus-pkg/nimbus.plist: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | UserName 7 | nimbus 8 | Label 9 | Nimbus 10 | ServiceDescription 11 | Nimbus Beacon Node 12 | Program 13 | /Library/Scripts/Nimbus/launchservice.sh 14 | ProgramArguments 15 | 16 | /Library/Scripts/Nimbus/launchservice.sh 17 | 18 | StandardOutPath 19 | /tmp/nimbus.stdout 20 | StandardErrorPath 21 | /tmp/nimbus.stderr 22 | 23 | 24 | -------------------------------------------------------------------------------- /installer/macos/nimbus-pkg/postinstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | NIMBUS_SERVER="$(cat /tmp/nimbus.server.config)" 4 | NIMBUS_ETH="$(cat /tmp/nimbus.eth.config)" 5 | NIMBUS_LAUNCH="$(cat /tmp/nimbus.launch.config)" 6 | 7 | echo "NETWORK=\"$NIMBUS_SERVER\"" > /etc/nimbus.config 8 | echo "WEB3_URL=\"$NIMBUS_ETH\"" >> /etc/nimbus.config 9 | echo "DATA_DIR=/var/lib/nimbus" >> /etc/nimbus.config 10 | mkdir "/var/lib/nimbus" 11 | 12 | sudo dscl . -create /Users/nimbus 13 | sudo dscl . -create /Users/nimbus UserShell /bin/bash 14 | sudo dscl . -create /Users/nimbus RealName "Nimbus" 15 | 16 | sudo dscl . -create /Users/nimbus UniqueID "1012" 17 | sudo dscl . -create /Users/nimbus PrimaryGroupID 80 18 | sudo dscl . -append /Groups/admin GroupMembership nimbus 19 | 20 | sudo chown nimbus /var/lib/nimbus 21 | 22 | sudo -u nimbus chmod u+rw,g,rw,o=r /var/lib/nimbus 23 | 24 | launchctl load /Library/LaunchDaemons/nimbus.plist 25 | 26 | if [ NIMBUS_LAUNCH == 1 ]; then 27 | sudo launchctl start Nimbus 28 | fi 29 | 30 | exit 0 31 | -------------------------------------------------------------------------------- /installer/windows/README.md: -------------------------------------------------------------------------------- 1 | This directory contains a set of files used for building a MSI Windows 2 | installation package for the Nimbus beacon node. 3 | 4 | To build the package, you'll need WiX Toolset (V3.11.2 or later): 5 | https://wixtoolset.org/releases/ 6 | 7 | Make sure the WiX build tools are in your PATH and run `make nimbus-msi` 8 | from the root of this repo. 9 | 10 | WixEdit is recommended for editing the installer dialogs: 11 | https://wixedit.github.io/ 12 | -------------------------------------------------------------------------------- /kurtosis-network-params.yml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 Status Research & Development GmbH 2 | # Licensed under either of 3 | # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or 4 | # http://www.apache.org/licenses/LICENSE-2.0) 5 | # * MIT license ([LICENSE-MIT](LICENSE-MIT) or 6 | # http://opensource.org/licenses/MIT) 7 | # at your option. This file may not be copied, modified, or distributed except 8 | # according to those terms. 9 | 10 | participants_matrix: 11 | el: 12 | - el_type: geth 13 | - el_type: nethermind 14 | - el_type: erigon 15 | cl: 16 | - cl_type: nimbus 17 | cl_image: 18 | - cl_type: lighthouse 19 | - cl_type: prysm 20 | additional_services: 21 | - tx_spammer 22 | - assertoor 23 | - beacon_metrics_gazer 24 | mev_type: null 25 | assertoor_params: 26 | image: "ethpandaops/assertoor:master" 27 | run_stability_check: true 28 | run_block_proposal_check: true 29 | run_transaction_test: true 30 | run_blob_transaction_test: true 31 | run_opcodes_transaction_test: true -------------------------------------------------------------------------------- /media/jenkins_artifacts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/media/jenkins_artifacts.png -------------------------------------------------------------------------------- /media/monitoring.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/media/monitoring.png -------------------------------------------------------------------------------- /ncli/.gitignore: -------------------------------------------------------------------------------- 1 | ncli_pretty 2 | ncli_hash_tree_root 3 | ncli_transition 4 | deposit_downloader 5 | -------------------------------------------------------------------------------- /ncli/README.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | `ncli` is a set of low level / debugging tools to interact with the nimbus [beacon chain specification](https://github.com/ethereum/consensus-specs/tree/dev/specs) implementation, similar to [zcli](https://github.com/protolambda/zcli). With it, you explore SSZ, make state transitions and compute hash tree roots. 4 | 5 | # Tools 6 | 7 | * transition: Perform state transition given a pre-state and a block to apply (both in SSZ format) 8 | * hash_tree_root: Print tree root of an SSZ object 9 | * pretty: Pretty-print SSZ object as JSON 10 | 11 | # Building 12 | 13 | Follow the instructions from [nimbus-eth2](../README.md) 14 | 15 | ```bash 16 | git clone https://github.com/status-im/nimbus-eth2.git 17 | cd nimbus-eth2 18 | make 19 | ``` 20 | 21 | # Usage 22 | 23 | ``` 24 | # Build with minimal config 25 | ../env.sh nim c -d:const_preset=minimal ncli_transition 26 | # Build with mainnet config 27 | ../env.sh nim c -d:const_preset=mainnet ncli_transition 28 | 29 | # Run.. 30 | ./ncli_transition --help 31 | ``` 32 | -------------------------------------------------------------------------------- /ncli/download_mainnet_deposits.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eu 4 | 5 | cd "$(dirname "$0")" 6 | 7 | WEB3_URL=wss://mainnet.infura.io/ws/v3/809a18497dd74102b5f37d25aae3c85a 8 | 9 | ../env.sh nim c -r deposit_downloader.nim \ 10 | --web3-url="$WEB3_URL" \ 11 | --deposit-contract=0x00000000219ab540356cBB839Cbe05303d7705Fa \ 12 | --start-block=11052984 13 | 14 | -------------------------------------------------------------------------------- /ncli/nim.cfg: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2019-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | -u:metrics 9 | 10 | -d:"libp2p_pki_schemes=secp256k1" 11 | 12 | --styleCheck:usages 13 | --styleCheck:hint 14 | --hint[Processing]:off 15 | -------------------------------------------------------------------------------- /ncli/resttest.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:chronicles_colors:off 2 | -------------------------------------------------------------------------------- /nfuzz/README.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | `libnfuzz` is a wrapper library that exports to C, a set of fuzzing test cases 4 | written in Nim and making use of nimbus-eth2. 5 | 6 | 7 | # Building 8 | 9 | To build the wrapper library (for more details follow first the instructions from 10 | [nimbus-eth2](../README.md)): 11 | 12 | ```bash 13 | git clone https://github.com/status-im/nimbus-eth2.git 14 | cd nimbus-eth2 15 | make 16 | # static library 17 | make libnfuzz.a 18 | # dynamic loaded library 19 | make libnfuzz.so 20 | ``` 21 | 22 | Default, the library is build with the `minimal` config. To select a specific config you can instead run: 23 | ```bash 24 | # build with mainnet config 25 | make libnfuzz.a NIMFLAGS="-d:const_preset=mainnet" 26 | ``` 27 | 28 | For the library to be useful for fuzzing with libFuzzer (e.g. for 29 | integration with [beacon-fuzz](https://github.com/sigp/beacon-fuzz)) we can pass 30 | additional Nim arguments, e.g.: 31 | 32 | ```bash 33 | make libnfuzz.a NIMFLAGS="--cc:clang --passC:'-fsanitize=fuzzer-no-link' --passL='-fsanitize=fuzzer'" 34 | ``` 35 | 36 | Other useful options might include: `--clang.path:`, `--clang.exe:`, `--clang.linkerexe:`, `-d:const_preset=mainnet` 37 | 38 | It might also deem useful to lower the log level, e.g. by adding `-d:chronicles_log_level=fatal`. 39 | 40 | # Usage 41 | There is a `libnfuzz.h` file provided for easy including in C or C++ projects. 42 | 43 | It is most important that before any of the exported tests are called, the 44 | `NimMain()` call is done first. Additionally, all following library calls need 45 | to be done from the same thread as from where the original `NimMain()` call was 46 | done. 47 | -------------------------------------------------------------------------------- /nfuzz/libnfuzz.h: -------------------------------------------------------------------------------- 1 | #ifndef __LIBNFUZZ_H__ 2 | #define __LIBNFUZZ_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | /** Initialize Nim & Garbage Collector. Must be called before anything else 9 | * of the API. Also, all following calls must come from the same thread as from 10 | * which this call was done. 11 | */ 12 | void NimMain(); 13 | 14 | /** Supported fuzzing tests */ 15 | bool nfuzz_attestation(uint8_t* input_ptr, size_t input_size, 16 | uint8_t* output_ptr, size_t* output_size, bool disable_bls); 17 | bool nfuzz_attester_slashing(uint8_t* input_ptr, size_t input_size, 18 | uint8_t* output_ptr, size_t* output_size, bool disable_bls); 19 | bool nfuzz_block(uint8_t* input_ptr, size_t input_size, 20 | uint8_t* output_ptr, size_t* output_size, bool disable_bls); 21 | bool nfuzz_block_header(uint8_t* input_ptr, size_t input_size, 22 | uint8_t* output_ptr, size_t* output_size, bool disable_bls); 23 | bool nfuzz_deposit(uint8_t* input_ptr, size_t input_size, 24 | uint8_t* output_ptr, size_t* output_size, bool disable_bls); 25 | bool nfuzz_proposer_slashing(uint8_t* input_ptr, size_t input_size, 26 | uint8_t* output_ptr, size_t* output_size, bool disable_bls); 27 | bool nfuzz_shuffle(uint8_t* seed_ptr, uint64_t* output_ptr, size_t output_size); 28 | bool nfuzz_voluntary_exit(uint8_t* input_ptr, size_t input_size, 29 | uint8_t* output_ptr, size_t* output_size, bool disable_bls); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif //__LIBNFUZZ_H__ 36 | -------------------------------------------------------------------------------- /nix/README.md: -------------------------------------------------------------------------------- 1 | # Usage 2 | 3 | ## Shell 4 | 5 | A development shell can be started using: 6 | ```sh 7 | nix develop 8 | ``` 9 | 10 | ## Building 11 | 12 | To build a beacon node you can use: 13 | ```sh 14 | nix build '.?submodules=1#beacon_node' 15 | ``` 16 | The `?submodules=1` part should eventually not be necessary. 17 | For more details see: 18 | https://github.com/NixOS/nix/issues/4423 19 | 20 | It can be also done without even cloning the repo: 21 | ```sh 22 | nix build 'github:status-im/nimbus-eth2?submodules=1#' 23 | ``` 24 | The trailing `#` is required due to [URI parsing bug in Nix](https://github.com/NixOS/nix/issues/6633). 25 | 26 | ## Running 27 | 28 | ```sh 29 | nix run 'github:status-im/nimbus-eth2?submodules=1#' 30 | ``` 31 | -------------------------------------------------------------------------------- /nix/checksums.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | 3 | let 4 | tools = pkgs.callPackage ./tools.nix {}; 5 | sourceFile = ../vendor/nimbus-build-system/vendor/Nim/koch.nim; 6 | in pkgs.fetchFromGitHub { 7 | owner = "nim-lang"; 8 | repo = "checksums"; 9 | rev = tools.findKeyValue "^ +ChecksumsStableCommit = \"([a-f0-9]+)\"$" sourceFile; 10 | # WARNING: Requires manual updates when Nim compiler version changes. 11 | hash = "sha256-Bm5iJoT2kAvcTexiLMFBa9oU5gf7d4rWjo3OiN7obWQ="; 12 | } 13 | -------------------------------------------------------------------------------- /nix/csources.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | 3 | let 4 | tools = pkgs.callPackage ./tools.nix {}; 5 | sourceFile = ../vendor/nimbus-build-system/vendor/Nim/config/build_config.txt; 6 | in pkgs.fetchFromGitHub { 7 | owner = "nim-lang"; 8 | repo = "csources_v2"; 9 | rev = tools.findKeyValue "^nim_csourcesHash=([a-f0-9]+)$" sourceFile; 10 | # WARNING: Requires manual updates when Nim compiler version changes. 11 | hash = "sha256-UCLtoxOcGYjBdvHx7A47x6FjLMi6VZqpSs65MN7fpBs="; 12 | } 13 | -------------------------------------------------------------------------------- /nix/nimble.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | 3 | let 4 | tools = pkgs.callPackage ./tools.nix {}; 5 | sourceFile = ../vendor/nimbus-build-system/vendor/Nim/koch.nim; 6 | in pkgs.fetchFromGitHub { 7 | owner = "nim-lang"; 8 | repo = "nimble"; 9 | fetchSubmodules = true; 10 | rev = tools.findKeyValue "^ +NimbleStableCommit = \"([a-f0-9]+)\".+" sourceFile; 11 | # WARNING: Requires manual updates when Nim compiler version changes. 12 | hash = "sha256-Rz48sGUKZEAp+UySla+MlsOfsERekuGKw69Tm11fDz8="; 13 | } 14 | -------------------------------------------------------------------------------- /nix/sat.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | 3 | let 4 | tools = pkgs.callPackage ./tools.nix {}; 5 | sourceFile = ../vendor/nimbus-build-system/vendor/Nim/koch.nim; 6 | in pkgs.fetchFromGitHub { 7 | owner = "nim-lang"; 8 | repo = "sat"; 9 | rev = tools.findKeyValue "^ +SatStableCommit = \"([a-f0-9]+)\"$" sourceFile; 10 | # WARNING: Requires manual updates when Nim compiler version changes. 11 | hash = "sha256-JFrrSV+mehG0gP7NiQ8hYthL0cjh44HNbXfuxQNhq7c="; 12 | } 13 | -------------------------------------------------------------------------------- /nix/shell.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import {}}: 2 | 3 | let 4 | mkdocs-packages = ps: with ps; [ 5 | mkdocs 6 | mkdocs-material 7 | mkdocs-material-extensions 8 | pymdown-extensions 9 | ]; 10 | mkdocs-python = pkgs.python3.withPackages mkdocs-packages; 11 | in pkgs.mkShell { 12 | 13 | buildInputs = with pkgs; [ 14 | figlet 15 | git 16 | git-lfs 17 | gnumake 18 | getopt 19 | 20 | # For the local simulation 21 | openssl # for generating the JWT file 22 | lsof # for killing processes by port 23 | killall # for killing processes manually 24 | curl # for working with the node APIs 25 | jq # for parsing beacon API for LC start 26 | openjdk # for running web3signer 27 | 28 | mkdocs-python 29 | ] ++ lib.optionals (!stdenv.isDarwin) [ 30 | lsb-release 31 | ]; 32 | 33 | shellHook = '' 34 | # By default, the Nix wrapper scripts for executing the system compilers 35 | # will erase `-march=native` because this introduces impurity in the build. 36 | # For the purposes of compiling Nimbus, this behavior is not desired: 37 | export NIX_ENFORCE_NO_NATIVE=0 38 | export USE_SYSTEM_GETOPT=1 39 | export MAKEFLAGS="-j$NIX_BUILD_CORES" 40 | 41 | figlet "Welcome to Nimbus-eth2" 42 | ''; 43 | } 44 | -------------------------------------------------------------------------------- /nix/tools.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | 3 | let 4 | 5 | inherit (pkgs.lib) fileContents last splitString flatten remove; 6 | inherit (builtins) map match; 7 | in { 8 | findKeyValue = regex: sourceFile: 9 | let 10 | linesFrom = file: splitString "\n" (fileContents file); 11 | matching = regex: lines: map (line: match regex line) lines; 12 | extractMatch = matches: last (flatten (remove null matches)); 13 | in 14 | extractMatch (matching regex (linesFrom sourceFile)); 15 | } 16 | -------------------------------------------------------------------------------- /nix/version.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | 3 | let 4 | tools = pkgs.callPackage ./tools.nix {}; 5 | source = ../beacon_chain/version.nim; 6 | 7 | major = tools.findKeyValue " versionMajor\\* = ([0-9]+)$" source; 8 | minor = tools.findKeyValue " versionMinor\\* = ([0-9]+)$" source; 9 | build = tools.findKeyValue " versionBuild\\* = ([0-9]+)$" source; 10 | in 11 | "${major}.${minor}.${build}" 12 | -------------------------------------------------------------------------------- /research/.gitignore: -------------------------------------------------------------------------------- 1 | *.dSYM/ 2 | *.json 3 | block_sim 4 | stack_sizes 5 | state_sim 6 | wss_sim 7 | -------------------------------------------------------------------------------- /research/block_sim.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:"chronicles_sinks=json[file(block_sim.log)]" 2 | -------------------------------------------------------------------------------- /research/nim.cfg: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2022-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | -u:metrics 9 | 10 | -d:"libp2p_pki_schemes=secp256k1" 11 | 12 | --styleCheck:usages 13 | --styleCheck:hint 14 | --hint[Processing]:off 15 | -------------------------------------------------------------------------------- /research/stack_sizes.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2020-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import ../beacon_chain/spec/datatypes/phase0 11 | 12 | import std/[typetraits, strformat, strutils] 13 | 14 | proc print(t: auto, n: string, indent: int) = 15 | try: 16 | echo fmt"{sizeof(t):>8} {spaces(indent)}{n}: {typeof(t).name}" 17 | except ValueError: 18 | # https://github.com/nim-lang/Nim/pull/23356 19 | raiseAssert "Arguments match the format string" 20 | 21 | when t is object|tuple: 22 | for n, p in t.fieldPairs: 23 | print(p, n, indent + 1) 24 | 25 | print((ref BeaconState)()[], "state", 0) 26 | 27 | echo "" 28 | 29 | print(SignedBeaconBlock(), "block", 0) 30 | 31 | echo "" 32 | 33 | print(Validator(), "validator", 0) 34 | 35 | echo "" 36 | 37 | print(Attestation(), "attestation", 0) 38 | -------------------------------------------------------------------------------- /research/timing.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2023-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import 11 | std/[times, stats] 12 | 13 | template withTimer*(stats: var RunningStat, body: untyped) = 14 | # TODO unify timing somehow 15 | let start = cpuTime() 16 | 17 | block: 18 | body 19 | 20 | let stop = cpuTime() 21 | stats.push stop - start 22 | 23 | template withTimerRet*(stats: var RunningStat, body: untyped): untyped = 24 | let start = cpuTime() 25 | let tmp = block: 26 | body 27 | let stop = cpuTime() 28 | stats.push stop - start 29 | 30 | tmp 31 | -------------------------------------------------------------------------------- /run-holesky-beacon-node.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (c) 2020-2024 Status Research & Development GmbH. Licensed under 4 | # either of: 5 | # - Apache License, version 2.0 6 | # - MIT license 7 | # at your option. This file may not be copied, modified, or distributed except 8 | # according to those terms. 9 | 10 | cd "$(dirname $0)" 11 | # Allow the binary to receive signals directly. 12 | exec scripts/run-beacon-node.sh nimbus_beacon_node holesky "$@" 13 | 14 | -------------------------------------------------------------------------------- /run-mainnet-beacon-node.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (c) 2020-2024 Status Research & Development GmbH. Licensed under 4 | # either of: 5 | # - Apache License, version 2.0 6 | # - MIT license 7 | # at your option. This file may not be copied, modified, or distributed except 8 | # according to those terms. 9 | 10 | cd "$(dirname $0)" 11 | # Allow the binary to receive signals directly. 12 | exec scripts/run-beacon-node.sh nimbus_beacon_node mainnet "$@" 13 | 14 | -------------------------------------------------------------------------------- /run-sepolia-beacon-node.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (c) 2024 Status Research & Development GmbH. Licensed under 4 | # either of: 5 | # - Apache License, version 2.0 6 | # - MIT license 7 | # at your option. This file may not be copied, modified, or distributed except 8 | # according to those terms. 9 | 10 | cd "$(dirname $0)" 11 | # Allow the binary to receive signals directly. 12 | exec scripts/run-beacon-node.sh nimbus_beacon_node sepolia "$@" 13 | -------------------------------------------------------------------------------- /scripts/.gitignore: -------------------------------------------------------------------------------- 1 | *.rpm 2 | *.deb 3 | package_image 4 | 5 | -------------------------------------------------------------------------------- /scripts/bash_utils.sh: -------------------------------------------------------------------------------- 1 | if [ -z "${BASH_UTILS_SOURCED:-}" ]; then 2 | BASH_UTILS_SOURCED=1 3 | 4 | VERBOSE="0" 5 | 6 | log() { 7 | if [[ "${VERBOSE}" -ge "1" ]]; then 8 | echo "${@}" 9 | fi 10 | } 11 | 12 | run() { 13 | echo Launching: $* 14 | $* 15 | } 16 | 17 | fi 18 | -------------------------------------------------------------------------------- /scripts/check_docs_help_msg.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (c) 2023-2024 Status Research & Development GmbH. 4 | # Licensed under either of: 5 | # - Apache License, version 2.0 6 | # - MIT license 7 | # at your option. This file may not be copied, modified, or distributed 8 | # except according to those terms. 9 | 10 | set -euo pipefail 11 | DOC_FILE='docs/the_nimbus_book/src/options.md' 12 | DOC_USAGE=$(sed -n '/Usage/,/^...$/ { /^...$/d; p; }' "${DOC_FILE}") 13 | BIN_USAGE=$( 14 | COLUMNS=200 build/nimbus_beacon_node --help | \ 15 | sed 's/\x1b\[[0-9;]*m//g' | \ 16 | sed -n '/Usage/,/Available sub-commands/ { /Available sub-commands/d; p; }' | \ 17 | sed 's/\\x1B\\[[0-9;]*[mG]//g' | \ 18 | sed 's/[[:space:]]*$//' 19 | ) 20 | if ! diff -u <(echo "${DOC_USAGE}") <(echo "${BIN_USAGE}"); then 21 | echo "Please update '${DOC_FILE}' to match 'COLUMNS=200 nimbus_beacon_node --help'" 22 | exit 1 23 | fi 24 | -------------------------------------------------------------------------------- /scripts/copyfile.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (c) 2018-2019 Status Research & Development GmbH. Licensed under 4 | # either of: 5 | # - Apache License, version 2.0 6 | # - MIT license 7 | # at your option. This file may not be copied, modified, or distributed except 8 | # according to those terms. 9 | 10 | if [[ $OS = "Windows_NT" ]]; then 11 | # Copy file. 12 | cp -a ${1} ${2}; 13 | if [ -f "$1" ]; then 14 | DST_FILE=$2 15 | if [ -d "$2" ]; then 16 | SRC_NAME="$(basename -- $1)" 17 | DST_FILE=$(realpath ${2})/$SRC_NAME 18 | fi 19 | # Single file was copied, so we setting file permissions only. 20 | icacls ${DST_FILE} /inheritance:r /grant:r $USERDOMAIN\\$USERNAME:\(F\); 21 | else 22 | if [ -d "$1" ]; then 23 | SRC_NAME="$(basename -- $1)" 24 | DST_DIR=$(realpath ${2})/$SRC_NAME 25 | DST_FILES=$(realpath ${DST_DIR})/\* 26 | # Directory was copied, so we update destination directory permissions. 27 | icacls ${DST_DIR} /inheritance:r /grant:r $USERDOMAIN\\$USERNAME:\(OI\)\(CI\)\(F\); 28 | # And update permissions for all files inside of destination directory. 29 | icacls ${DST_FILES} /inheritance:r /grant:r $USERDOMAIN\\$USERNAME:\(F\); 30 | fi 31 | fi 32 | else 33 | cp -a ${1} ${2}; 34 | fi 35 | -------------------------------------------------------------------------------- /scripts/detect_platform.sh: -------------------------------------------------------------------------------- 1 | if [ -z "${DETECT_PLATFORM_SOURCED:-}" ]; then 2 | DETECT_PLATFORM_SOURCED=1 3 | 4 | EXE_EXTENSION="" 5 | BAT_EXTENSION="" 6 | 7 | # OS detection 8 | OS="linux" 9 | if uname | grep -qi darwin; then 10 | OS="macos" 11 | elif uname | grep -qiE "mingw|msys"; then 12 | OS="windows" 13 | EXE_EXTENSION=".exe" 14 | BAT_EXTENSION=".bat" 15 | fi 16 | 17 | # Architecture detection 18 | ARCH="$(uname -m)" 19 | 20 | patchelf_when_on_nixos () { 21 | if [ -f /etc/NIXOS ]; then 22 | nix-shell \ 23 | -p stdenv.cc \ 24 | --command 'patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) "'$1'"' 25 | fi 26 | } 27 | 28 | fi 29 | -------------------------------------------------------------------------------- /scripts/geth_vars.sh: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2022 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | if [ -z "${GETH_VARS_SOURCED:-}" ]; then 9 | GETH_VARS_SOURCED=1 10 | 11 | GETH_NUM_NODES="${GETH_NUM_NODES:-4}" 12 | GETH_BASE_NET_PORT="${BASE_EL_NET_PORT:-30303}" 13 | GETH_BASE_RPC_PORT="${BASE_EL_RPC_PORT:-8545}" 14 | GETH_BASE_WS_PORT="${BASE_EL_WS_PORT:-8546}" 15 | GETH_BASE_AUTH_RPC_PORT="${BASE_EL_AUTH_RPC_PORT:-8551}" 16 | GETH_PORT_OFFSET="${EL_PORT_OFFSET:-20}" 17 | DISCOVER="--nodiscover" 18 | 19 | GETH_NET_PORTS=() 20 | GETH_AUTH_RPC_PORTS=() 21 | GETH_DATA_DIRS=() 22 | 23 | GETH_LAST_NODE_IDX=$((GETH_NUM_NODES - 1)) 24 | 25 | for GETH_NODE_IDX in $(seq 0 $GETH_LAST_NODE_IDX); do 26 | GETH_NET_PORTS+=($(( GETH_NODE_IDX * GETH_PORT_OFFSET + GETH_BASE_NET_PORT ))) 27 | GETH_RPC_PORTS+=($(( GETH_NODE_IDX * GETH_PORT_OFFSET + GETH_BASE_RPC_PORT ))) 28 | GETH_AUTH_RPC_PORTS+=($(( GETH_NODE_IDX * GETH_PORT_OFFSET + GETH_BASE_AUTH_RPC_PORT ))) 29 | GETH_DATA_DIRS+=("${DATA_DIR}/geth-${GETH_NODE_IDX}") 30 | done 31 | 32 | fi 33 | -------------------------------------------------------------------------------- /scripts/make_dist.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (c) 2020-2021 Status Research & Development GmbH. Licensed under 4 | # either of: 5 | # - Apache License, version 2.0 6 | # - MIT license 7 | # at your option. This file may not be copied, modified, or distributed except 8 | # according to those terms. 9 | 10 | # Build release binaries fit for public distribution, using Docker. 11 | # Should be used from "dist-*" Make targets, passing the target architecture's name as a parameter. 12 | 13 | set -e 14 | 15 | cd "$(dirname "${BASH_SOURCE[0]}")"/.. 16 | REPO_DIR="${PWD}" 17 | 18 | ARCH="${1:-amd64}" 19 | DOCKER_TAG="nimbus-eth2-dist-${ARCH}" 20 | 21 | docker rm ${DOCKER_TAG} &>/dev/null || true 22 | 23 | cd docker/dist 24 | 25 | BUILD_TOOLS_ENV="--env BUILD_TOOLS=${BUILD_TOOLS:-"0"}" 26 | 27 | echo "${BUILD_TOOLS_ENV}" 28 | 29 | 30 | DOCKER_BUILDKIT=1 \ 31 | docker build \ 32 | -t ${DOCKER_TAG} \ 33 | --progress=plain \ 34 | --build-arg USER_ID=$(id -u) \ 35 | --build-arg GROUP_ID=$(id -g) \ 36 | -f Dockerfile.${ARCH} . 37 | 38 | # seccomp can have some serious overhead, so we disable it with "--privileged" - https://pythonspeed.com/articles/docker-performance-overhead/ 39 | docker run --privileged ${BUILD_TOOLS_ENV} --rm --name ${DOCKER_TAG} -v ${REPO_DIR}:/home/user/nimbus-eth2 ${DOCKER_TAG} 40 | 41 | cd - &>/dev/null 42 | 43 | ls -l dist 44 | 45 | # We rebuild everything inside the container, so we need to clean up afterwards. 46 | ${MAKE} --no-print-directory clean 47 | 48 | -------------------------------------------------------------------------------- /scripts/makedir.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (c) 2018-2020 Status Research & Development GmbH. Licensed under 4 | # either of: 5 | # - Apache License, version 2.0 6 | # - MIT license 7 | # at your option. This file may not be copied, modified, or distributed except 8 | # according to those terms. 9 | 10 | [[ -z "$1" ]] && { echo "Usage: $(basename $0) path"; exit 1; } 11 | 12 | if uname | grep -qiE "mingw|msys"; then 13 | ON_WINDOWS=1 14 | else 15 | ON_WINDOWS=0 16 | fi 17 | 18 | if [[ "${ON_WINDOWS}" == "1" ]]; then 19 | if [[ ! -d "$1" ]]; then 20 | # Create full path. 21 | mkdir -p "$1"; 22 | # Remove all inherited access from path $1 ACL and grant full access rights 23 | # to current user only in $1 ACL. 24 | icacls "$1" /inheritance:r /grant:r $USERDOMAIN\\$USERNAME:\(OI\)\(CI\)\(F\)&>/dev/null; 25 | fi 26 | else 27 | # Create full path with proper permissions. 28 | mkdir -m 0700 -p $1 29 | fi 30 | 31 | -------------------------------------------------------------------------------- /scripts/nimbus_el_vars.sh: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2022 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | if [ -z "${NIMBUS_ETH1_VARS_SOURCED:-}" ]; then 9 | NIMBUS_ETH1_VARS_SOURCED=1 10 | 11 | NIMBUS_ETH1_NUM_NODES="${NIMBUS_ETH1_NUM_NODES:-4}" 12 | NIMBUS_ETH1_BASE_NET_PORT="${BASE_EL_NET_PORT:-40404}" 13 | NIMBUS_ETH1_BASE_RPC_PORT="${BASE_EL_RPC_PORT:-9545}" 14 | NIMBUS_ETH1_BASE_WS_PORT="${BASE_EL_WS_PORT:-9546}" 15 | NIMBUS_ETH1_BASE_AUTH_RPC_PORT="${BASE_EL_AUTH_RPC_PORT:-9551}" 16 | NIMBUS_ETH1_PORT_OFFSET="${EL_PORT_OFFSET:-10}" 17 | 18 | CURL_BINARY=${CURL_BINARY:-curl} 19 | JQ_BINARY=${JQ_BINARY:-jq} 20 | 21 | NIMBUS_ETH1_NET_PORTS=() 22 | NIMBUS_ETH1_RPC_PORTS=() 23 | NIMBUS_ETH1_AUTH_RPC_PORTS=() 24 | 25 | NIMBUS_ETH1_LAST_NODE_IDX=$((NIMBUS_ETH1_NUM_NODES - 1)) 26 | 27 | for NIMBUS_ETH1_NODE_IDX in $(seq 0 $NIMBUS_ETH1_LAST_NODE_IDX); do 28 | NIMBUS_ETH1_NET_PORTS+=($(( NIMBUS_ETH1_NODE_IDX * NIMBUS_ETH1_PORT_OFFSET + 1 + NIMBUS_ETH1_BASE_NET_PORT ))) 29 | NIMBUS_ETH1_RPC_PORTS+=($(( NIMBUS_ETH1_NODE_IDX * NIMBUS_ETH1_PORT_OFFSET + 1 + NIMBUS_ETH1_BASE_RPC_PORT ))) 30 | NIMBUS_ETH1_AUTH_RPC_PORTS+=($(( NIMBUS_ETH1_NODE_IDX * NIMBUS_ETH1_PORT_OFFSET + 1 + NIMBUS_ETH1_BASE_AUTH_RPC_PORT ))) 31 | done 32 | 33 | fi 34 | -------------------------------------------------------------------------------- /scripts/package_src/nimbus_beacon_node/after_install: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | DISTRO="UNKNOWN" 5 | if [ -r /etc/os-release ]; then 6 | . /etc/os-release 7 | DISTRO="${ID}" 8 | fi 9 | 10 | if ! id -u nimbus > /dev/null 2>&1; then 11 | case $DISTRO in 12 | Ubuntu|ubuntu|Debian|debian) 13 | # Debian uses `adduser` to create user... 14 | adduser --system --no-create-home --group nimbus 15 | ;; 16 | *) 17 | # ... while `useradd` is more standard 18 | useradd --system --no-create-home --user-group nimbus 19 | ;; 20 | esac 21 | fi 22 | 23 | mkdir -p /var/lib/nimbus 24 | chown nimbus:nimbus /var/lib/nimbus 25 | 26 | # Systems like docker containers do not have systemd. 27 | systemctl daemon-reload || echo "notice: systemd daemon not reloaded" >&2 28 | -------------------------------------------------------------------------------- /scripts/package_src/nimbus_beacon_node/after_remove: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # We don't do anything here since a normal "uninstall" should generally not 6 | # remove data - debian has "purge" to deal with this, others don't. 7 | -------------------------------------------------------------------------------- /scripts/package_src/nimbus_beacon_node/after_upgrade: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | ( systemctl is-active --quiet nimbus_beacon_node.service && \ 6 | echo "Nimbus has been upgraded, don't forget to restart with 'sudo systemctl restart nimbus_beacon_node.service'!" ) || true 7 | -------------------------------------------------------------------------------- /scripts/package_src/nimbus_beacon_node/before_remove: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | SERVICE_NAME="nimbus_beacon_node" 6 | 7 | if systemctl --all --type service | grep -q "$SERVICE_NAME"; then 8 | systemctl stop "$SERVICE_NAME" 9 | systemctl disable "$SERVICE_NAME" 10 | fi 11 | 12 | -------------------------------------------------------------------------------- /scripts/package_src/nimbus_beacon_node/deb_after_purge: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | rm -rf /var/lib/nimbus 6 | 7 | # https://wiki.debian.org/AccountHandlingInMaintainerScripts argues "mostly" 8 | # that users should not be removed, as do several debian bug debates that have 9 | # been ongoing since forever. Fedora is clear on the topic: don't remove 10 | # https://fedoraproject.org/wiki/Packaging:UsersAndGroups#Allocation_Strategies 11 | if id -u `nimbus` > /dev/null 2>&1; then 12 | echo User `nimbus` needs to be removed manually 13 | fi 14 | -------------------------------------------------------------------------------- /scripts/package_src/nimbus_beacon_node/description: -------------------------------------------------------------------------------- 1 | Nimbus Beacon Node / Ethereum Consensus client 2 | Nimbus is a client for the Ethereum network that is lightweight, 3 | secure and easy to use. 4 | . 5 | Its efficiency and low resource consumption allows it to perform well 6 | on all kinds of systems, ranging from Raspberry Pi's and mobile devices 7 | where it contributes to low power consumption and security 8 | -- to powerful servers where it leaves resources free to perform other tasks, 9 | such as running an execution node. 10 | . 11 | The beacon node connects to the beacon chain network, syncs historical data 12 | and provides API's to monitor and interact with the beacon chain. 13 | -------------------------------------------------------------------------------- /scripts/package_src/nimbus_validator_client/after_install: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | DISTRO="UNKNOWN" 6 | if [ -r /etc/os-release ]; then 7 | . /etc/os-release 8 | DISTRO="${ID}" 9 | fi 10 | 11 | if ! id -u nimbus > /dev/null 2>&1; then 12 | case $DISTRO in 13 | Ubuntu|ubuntu|Debian|debian) 14 | # Debian uses `adduser` to create user... 15 | adduser --system --no-create-home --group nimbus 16 | ;; 17 | *) 18 | # ... while `useradd` is more standard 19 | useradd --system --no-create-home --user-group nimbus 20 | ;; 21 | esac 22 | fi 23 | 24 | mkdir -p /var/lib/nimbus 25 | chown nimbus:nimbus /var/lib/nimbus 26 | 27 | # Systems like docker containers do not have systemd. 28 | systemctl daemon-reload || echo "notice: systemd daemon not reloaded" >&2 29 | -------------------------------------------------------------------------------- /scripts/package_src/nimbus_validator_client/after_remove: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # We don't do anything here since a normal "uninstall" should generally not 6 | # remove data - debian has "purge" to deal with this, others don't. 7 | -------------------------------------------------------------------------------- /scripts/package_src/nimbus_validator_client/after_upgrade: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | ( systemctl is-active --quiet nimbus_validator_client.service && \ 6 | echo "Nimbus has been upgraded, don't forget to restart with 'sudo systemctl restart nimbus_validator_client.service'!" ) || true 7 | -------------------------------------------------------------------------------- /scripts/package_src/nimbus_validator_client/before_remove: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | SERVICE_NAME="nimbus_validator_client" 6 | 7 | if systemctl --all --type service | grep -q "$SERVICE_NAME";then 8 | systemctl stop "$SERVICE_NAME" 9 | systemctl disable "$SERVICE_NAME" 10 | fi 11 | 12 | -------------------------------------------------------------------------------- /scripts/package_src/nimbus_validator_client/deb_after_purge: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # The data folder will be removed as part of uninstallin the beacon node - this 6 | # is not ideal, but otoh, the VC data folder is small. 7 | 8 | # https://wiki.debian.org/AccountHandlingInMaintainerScripts argues "mostly" 9 | # that users should not be removed, as do several debian bug debates that have 10 | # been ongoing since forever. Fedora is clear on the topic: don't remove 11 | # https://fedoraproject.org/wiki/Packaging:UsersAndGroups#Allocation_Strategies 12 | if id -u `nimbus` > /dev/null 2>&1; then 13 | echo User `nimbus` needs to be removed manually 14 | fi 15 | -------------------------------------------------------------------------------- /scripts/package_src/nimbus_validator_client/description: -------------------------------------------------------------------------------- 1 | Nimbus Validator Client for Ethereum 2 | Nimbus is a client for the Ethereum network that is lightweight, 3 | secure and easy to use. 4 | . 5 | Its efficiency and low resource consumption allows it to perform well 6 | on all kinds of systems, ranging from Raspberry Pi's and mobile devices 7 | where it contributes to low power consumption and security 8 | -- to powerful servers where it leaves resources free to perform other tasks, 9 | such as running an execution node. 10 | . 11 | The validator client allows advanced users to run validators in a separate 12 | process from the beacon node, allowing more flexible deployment strategies. 13 | -------------------------------------------------------------------------------- /scripts/print_version.nims: -------------------------------------------------------------------------------- 1 | import ../beacon_chain/version 2 | 3 | echo versionAsStr 4 | 5 | -------------------------------------------------------------------------------- /scripts/rotatelogs-compress.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Helper script for Apache rotatelogs to compress log files on rotation - `$2` contains the old log file name 4 | 5 | if [ -f "$2" ]; then 6 | # "nice" prevents hogging the CPU with this low-priority task 7 | nice gzip -9 "$2" 8 | fi 9 | 10 | -------------------------------------------------------------------------------- /scripts/run-nimbus.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | build/nimbus_beacon_node trustedNodeSync --config-file=config.toml 4 | 5 | #\ 6 | # --network:mainnet \ 7 | # --data-dir=build/mainnet/nimbus \ 8 | # --backfill=false \ 9 | # --trusted-node-url=http://testing.mainnet.beacon-api.nimbus.team/ 10 | 11 | if [ ! -f build/mainnet/jwtsecret ]; then 12 | openssl rand -hex 32 | tr -d "\n" > build/mainnet/jwtsecret 13 | fi 14 | 15 | # build/nimbus_beacon_node --non-interactive --udp-port=9123 --tcp-port=9123 --network=mainnet --log-level=DEBUG --data-dir=build/mainnet/nimbus --web3-url=http://localhost:9551/ --rest:on --metrics:on --doppelganger-detection=no --jwt-secret=build/mainnet/jwtsecret 16 | -------------------------------------------------------------------------------- /scripts/run_fuzzing_test.nims: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2020-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | import std/os except dirExists 9 | import 10 | std/[sequtils, strformat], 11 | confutils, testutils/fuzzing_engines 12 | 13 | const 14 | gitRoot = thisDir() / ".." 15 | fuzzingTestsDir = gitRoot / "tests" / "fuzzing" 16 | 17 | cli do (testname {.argument.}: string, 18 | fuzzer = defaultFuzzingEngine): 19 | 20 | let fuzzingTestDir = fuzzingTestsDir / testname 21 | 22 | if not dirExists(fuzzingTestDir): 23 | echo "Cannot find a fuzz test directory named '", testname, "' in ", fuzzingTestsDir 24 | quit 1 25 | 26 | let nimFiles = listFiles(fuzzingTestDir).filterIt(splitFile(it).ext == ".nim") 27 | if nimFiles.len != 1: 28 | echo "The fuzzing test dir '" & fuzzingTestDir & "' should contain exactly one Nim file" 29 | quit 1 30 | 31 | let 32 | corpusDir = fuzzingTestDir / "corpus" 33 | testProgram = nimFiles[0] 34 | 35 | exec &"""ntu fuzz --fuzzer={fuzzer} --corpus="{corpusDir}" "{testProgram}" """ 36 | -------------------------------------------------------------------------------- /scripts/setup_scenarios.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (c) 2018-2019 Status Research & Development GmbH. Licensed under 4 | # either of: 5 | # - Apache License, version 2.0 6 | # - MIT license 7 | # at your option. This file may not be copied, modified, or distributed except 8 | # according to those terms. 9 | 10 | set -e 11 | 12 | SUBREPO_DIR="vendor/nim-eth2-scenarios" 13 | # verbosity level 14 | [[ -z "$V" ]] && V=0 15 | [[ -z "$BUILD_MSG" ]] && BUILD_MSG="Downloading consensus spec test vectors" 16 | CACHE_DIR="$1" # optional parameter pointing to a CI cache dir. Without it, we just download the test vectors for a local `make test`. 17 | 18 | [[ -d "${SUBREPO_DIR}" ]] || { echo "This script should be run from the \"nimbus-eth2\" repo top dir."; exit 1; } 19 | 20 | # script output 21 | echo -e "$BUILD_MSG" 22 | [[ "$V" == "0" ]] && exec 3>&1 4>&2 &>/dev/null # save stdout and stderr before sending them into oblivion 23 | 24 | ############################################# 25 | # Main() 26 | 27 | if [[ -n "${CACHE_DIR}" ]]; then 28 | # delete old cache entries we no longer use (let this run for a month or so) 29 | rm -f "${CACHE_DIR}"/*.tar.xz 30 | 31 | # Ethereum Foundation test vectors 32 | mkdir -p "${CACHE_DIR}/tarballs" 33 | rm -rf "${SUBREPO_DIR}/tarballs" 34 | ln -s "$(pwd -P)/${CACHE_DIR}/tarballs" "${SUBREPO_DIR}" 35 | # (the dir symlink above also takes care of updating the cache) 36 | fi 37 | 38 | pushd "${SUBREPO_DIR}" 39 | ./download_test_vectors.sh 40 | ./download_slashing_interchange_tests.sh 41 | popd 42 | -------------------------------------------------------------------------------- /scripts/signers/nimbus.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (c) 2023 Status Research & Development GmbH. 4 | # Licensed under either of: 5 | # - Apache License, version 2.0 6 | # - MIT license 7 | # at your option. This file may not be copied, modified, or distributed 8 | # except according to those terms. 9 | 10 | SIGNING_NODE_IDX=$1 11 | 12 | ./build/nimbus_signing_node \ 13 | --log-level=DEBUG \ 14 | --validators-dir="${DATA_DIR}/validators_shares/$(( SIGNING_NODE_IDX + 1 ))" \ 15 | --secrets-dir="${DATA_DIR}/secrets_shares/$(( SIGNING_NODE_IDX + 1 ))" \ 16 | --bind-port=$(( BASE_REMOTE_SIGNER_PORT + SIGNING_NODE_IDX )) &> "${DATA_DIR}/logs/nimbus_signing_node.${SIGNING_NODE_IDX}.jsonl" & 17 | 18 | echo $! > "${DATA_DIR}/pids/nimbus_signing_node.${SIGNING_NODE_IDX}" 19 | -------------------------------------------------------------------------------- /scripts/slowlogs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Print logs that have gaps between them larger than the threshold - useful for 4 | # finding slowdowns in the code where the thread is busy for long periods of 5 | # time 6 | # usage: 7 | # tail -F logfile | python slowlogs.py 0.75 8 | 9 | import sys, re 10 | from datetime import datetime 11 | 12 | THRESHOLD = 0.75 13 | 14 | if len(sys.argv) > 0: 15 | THRESHOLD = float(sys.argv[1]) 16 | 17 | last = None 18 | prevline = None 19 | 20 | dt = re.compile(r"([0-9-]+ [0-9:.]+)") 21 | 22 | for line in sys.stdin: 23 | match = dt.search(line) 24 | 25 | if match: 26 | current = datetime.strptime(match.group(1), "%Y-%m-%d %H:%M:%S.%f") 27 | if last != None and (current - last).total_seconds() > THRESHOLD: 28 | print((current - last).total_seconds()) 29 | print(prevline, end="") 30 | print(line) 31 | last = current 32 | prevline = line 33 | -------------------------------------------------------------------------------- /scripts/time_module_builds.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -Eeo pipefail 3 | 4 | find beacon_chain/ ncli/ research/ tests/ -type f -name '*.nim' -print0 | shuf -z | xargs -0 -I{} bash -c "rm nimcache -rf && /usr/bin/time -f%e -- ./env.sh nim c -o:/dev/null --hints:off --warnings:off -d:release {} 2>&1 | tr -d '\n' && echo '' {}" 5 | -------------------------------------------------------------------------------- /scripts/tmuxinator-el-cl-pair-in-devnet.yml: -------------------------------------------------------------------------------- 1 | name: devnet 2 | root: . 3 | windows: 4 | - main: 5 | layout: main-horizontal 6 | # Synchronize all panes of this window, can be enabled before or after the pane commands run. 7 | # 'before' represents legacy functionality and will be deprecated in a future release, in favour of 'after' 8 | # synchronize: after 9 | panes: 10 | CL: ./scripts/run-<%= @settings["cl"] or "nimbus" %>-in-devnet.sh <%= @settings["network"] %> 11 | EL: ./scripts/run-<%= @settings["el"] or "geth" %>-in-devnet.sh <%= @settings["network"] %> 12 | -------------------------------------------------------------------------------- /tests/consensus_spec/README.md: -------------------------------------------------------------------------------- 1 | Tests based on scenarios generated from the [consensus spec](https://github.com/ethereum/consensus-spec-tests/). 2 | -------------------------------------------------------------------------------- /tests/consensus_spec/all_tests.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2018-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | {.used.} 10 | 11 | # BLS test vectors are covered by nim-blscurve: 12 | # https://github.com/status-im/nim-blscurve/blob/master/tests/eth2_vectors.nim 13 | 14 | # Tests that do not depend on `mainnet` vs `minimal` compile-time configuration 15 | 16 | import 17 | ./test_fixture_kzg, 18 | ./test_fixture_networking, 19 | ./test_fixture_ssz_generic_types 20 | -------------------------------------------------------------------------------- /tests/consensus_spec/altair/all_altair_fixtures.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2021-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | {.used.} 10 | 11 | import 12 | ./test_fixture_light_client_sync_protocol, 13 | ./test_fixture_operations, 14 | ./test_fixture_ssz_consensus_objects, 15 | ./test_fixture_state_transition_epoch 16 | -------------------------------------------------------------------------------- /tests/consensus_spec/bellatrix/all_bellatrix_fixtures.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2021-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | {.used.} 10 | 11 | import 12 | ./test_fixture_operations, 13 | ./test_fixture_ssz_consensus_objects, 14 | ./test_fixture_state_transition_epoch 15 | -------------------------------------------------------------------------------- /tests/consensus_spec/capella/all_capella_fixtures.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2022 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.used.} 9 | 10 | import 11 | ./test_fixture_operations, 12 | ./test_fixture_ssz_consensus_objects, 13 | ./test_fixture_state_transition_epoch 14 | -------------------------------------------------------------------------------- /tests/consensus_spec/consensus_spec_tests_preset.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2021-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import ../testutil 11 | 12 | # Tests that depend on `mainnet` vs `minimal` compile-time configuration 13 | 14 | import 15 | ./phase0/all_phase0_fixtures, 16 | ./altair/all_altair_fixtures, 17 | ./bellatrix/all_bellatrix_fixtures, 18 | ./capella/all_capella_fixtures, 19 | ./deneb/all_deneb_fixtures, 20 | ./electra/all_electra_fixtures, 21 | ./fulu/all_fulu_fixtures, 22 | ./test_fixture_fork, 23 | ./test_fixture_fork_choice, 24 | ./test_fixture_light_client_data_collection, 25 | ./test_fixture_light_client_single_merkle_proof, 26 | ./test_fixture_light_client_sync, 27 | ./test_fixture_light_client_update_ranking, 28 | ./test_fixture_merkle_proof, 29 | ./test_fixture_sanity_blocks, 30 | ./test_fixture_sanity_slots, 31 | ./test_fixture_transition 32 | 33 | summarizeLongTests("ConsensusSpecPreset") -------------------------------------------------------------------------------- /tests/consensus_spec/deneb/all_deneb_fixtures.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2022-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | {.used.} 10 | 11 | import 12 | ./test_fixture_operations, 13 | ./test_fixture_ssz_consensus_objects, 14 | ./test_fixture_state_transition_epoch 15 | -------------------------------------------------------------------------------- /tests/consensus_spec/electra/all_electra_fixtures.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | {.used.} 10 | 11 | import 12 | ./test_fixture_operations, 13 | ./test_fixture_ssz_consensus_objects, 14 | ./test_fixture_state_transition_epoch -------------------------------------------------------------------------------- /tests/consensus_spec/fulu/all_fulu_fixtures.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2022-2025 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | {.used.} 10 | 11 | import 12 | ./test_fixture_operations, 13 | ./test_fixture_ssz_consensus_objects, 14 | ./test_fixture_state_transition_epoch 15 | -------------------------------------------------------------------------------- /tests/consensus_spec/os_ops.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2023-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import std/os 11 | import stew/io2 12 | 13 | export walkDir, PathComponent, walkDirRec, walkPattern, `/`, relativePath, 14 | os.DirSep, os.splitPath 15 | export io2.readAllBytes 16 | 17 | proc fileExists*(path: string): bool = io2.isFile(path) 18 | 19 | proc dirExists*(path: string): bool = io2.isDir(path) 20 | 21 | proc readFile*(filename: string): string = 22 | let res = io2.readAllChars(filename) 23 | if res.isErr(): 24 | writeStackTrace() 25 | try: 26 | stderr.write "Could not load data from file \"", filename, "\"\n" 27 | stderr.write "(" & $int(res.error()) & ") ", ioErrorMsg(res.error()), "\n" 28 | except IOError: 29 | discard 30 | quit 1 31 | res.get() 32 | 33 | proc readFileChars*(path: string): string = 34 | readFile(path) 35 | 36 | proc readFileBytes*(path: string): seq[byte] = 37 | let res = io2.readAllBytes(path) 38 | if res.isErr(): 39 | writeStackTrace() 40 | try: 41 | stderr.write "Could not load data from file \"", path, "\"\n" 42 | stderr.write "(" & $int(res.error()) & ") ", ioErrorMsg(res.error()), "\n" 43 | except IOError: 44 | discard 45 | quit 1 46 | res.get() 47 | -------------------------------------------------------------------------------- /tests/consensus_spec/phase0/all_phase0_fixtures.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2021-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | {.used.} 10 | 11 | import 12 | ./test_fixture_operations, 13 | ./test_fixture_ssz_consensus_objects, 14 | ./test_fixture_state_transition_epoch 15 | -------------------------------------------------------------------------------- /tests/fixtures/bfdata-test.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status-im/nimbus-eth2/d2f23389ab657608261be9f4dcef1009d67fbc2d/tests/fixtures/bfdata-test.bin -------------------------------------------------------------------------------- /tests/fuzzing/.gitignore: -------------------------------------------------------------------------------- 1 | corpus/ 2 | 3 | -------------------------------------------------------------------------------- /tests/fuzzing/beacon_node_cli/corpus/help.txt: -------------------------------------------------------------------------------- 1 | --help 2 | -------------------------------------------------------------------------------- /tests/fuzzing/beacon_node_cli/corpus/spadina-deposits-data.txt: -------------------------------------------------------------------------------- 1 | deposits createTestnetDeposits --network=spadina --new-wallet-file=build/data/shared_spadina_0/wallet.json --out-validators-dir=build/data/shared_spadina_0/validators --out-secrets-dir=build/data/shared_spadina_0/secrets --out-deposits-file=spadina-deposits_data-20201001212925.json --count=1 2 | -------------------------------------------------------------------------------- /tests/fuzzing/beacon_node_cli/corpus/spadina.txt: -------------------------------------------------------------------------------- 1 | --network=spadina --log-level=INFO --log-file=build/data/shared_spadina_0/nbc_bn_20201001212647.log --data-dir=build/data/shared_spadina_0 --web3-url=wss://goerli.infura.io/ws/v3/809a18497dd74102b5f37d25aae3c85a --tcp-port=9000 --udp-port=9000 --metrics --metrics-port=8008 --rpc --rpc-port=9190 2 | -------------------------------------------------------------------------------- /tests/fuzzing/beacon_node_cli/corpus/version.txt: -------------------------------------------------------------------------------- 1 | --version 2 | -------------------------------------------------------------------------------- /tests/fuzzing/beacon_node_cli/corpus/wallets-create.txt: -------------------------------------------------------------------------------- 1 | wallets create --name:"my wallet" --next-account:10 --out:/tmp/wallet.json 2 | -------------------------------------------------------------------------------- /tests/fuzzing/beacon_node_cli/corpus/wallets-restore.txt: -------------------------------------------------------------------------------- 1 | wallets restore --name:"some wallet name" --deposits:10 --out:"some wallet name.json" 2 | -------------------------------------------------------------------------------- /tests/fuzzing/beacon_node_cli/fuzz_beacon_node_cli.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2020-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import 11 | # TODO These imports shouldn't be necessary here 12 | # (this is a variation of the sandwich problem) 13 | stew/shims/net, chronicles, 14 | 15 | confutils/cli_parsing_fuzzer, 16 | ../../../beacon_chain/conf, ../../../beacon_chain/spec/network 17 | 18 | fuzzCliParsing BeaconNodeConf 19 | -------------------------------------------------------------------------------- /tests/fuzzing/nim.cfg: -------------------------------------------------------------------------------- 1 | # clang complains that -flto=auto is not a supported option when creating libFuzzer builds 2 | -d:disableLTO 3 | -d:"const_preset=mainnet" 4 | -------------------------------------------------------------------------------- /tests/fuzzing/ssz_decode_Attestation.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2020-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import ./ssz_fuzzing 11 | 12 | sszFuzzingTest Attestation 13 | -------------------------------------------------------------------------------- /tests/fuzzing/ssz_decode_AttesterSlashing.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2020-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import ./ssz_fuzzing 11 | 12 | sszFuzzingTest AttesterSlashing 13 | -------------------------------------------------------------------------------- /tests/fuzzing/ssz_decode_BeaconState.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2020-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import ./ssz_fuzzing 11 | 12 | sszFuzzingTest BeaconState 13 | -------------------------------------------------------------------------------- /tests/fuzzing/ssz_decode_ProposerSlashing.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2020-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import ./ssz_fuzzing 11 | 12 | sszFuzzingTest ProposerSlashing 13 | -------------------------------------------------------------------------------- /tests/fuzzing/ssz_decode_SignedAggregateAndProof.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2020-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import ./ssz_fuzzing 11 | 12 | sszFuzzingTest SignedAggregateAndProof 13 | -------------------------------------------------------------------------------- /tests/fuzzing/ssz_decode_SignedBeaconBlock.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2020-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import ./ssz_fuzzing 11 | 12 | sszFuzzingTest SignedBeaconBlock 13 | -------------------------------------------------------------------------------- /tests/fuzzing/ssz_decode_VoluntaryExit.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2020-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import ./ssz_fuzzing 11 | 12 | sszFuzzingTest SignedVoluntaryExit 13 | -------------------------------------------------------------------------------- /tests/fuzzing/validator_client_cli/corpus/full.txt: -------------------------------------------------------------------------------- 1 | --log-level=TRACE --log-file:"foo/bar.log" --data-dir=/tmp/data --non-interactive --secrets-dir:secrets --graffiti:"some message" --graffiti:0xaa2311aa21 --stop-at-epoch:4 --rpc-port:10000 --rpc-address:127.0.0.1 --retry-delay:10 2 | -------------------------------------------------------------------------------- /tests/fuzzing/validator_client_cli/corpus/help.txt: -------------------------------------------------------------------------------- 1 | --help 2 | -------------------------------------------------------------------------------- /tests/fuzzing/validator_client_cli/corpus/medalla.txt: -------------------------------------------------------------------------------- 1 | build/nimbus_validator_client --log-level=INFO --log-file=build/data/shared_medalla_0/nbc_vc_20201009202103.log --data-dir=build/data/shared_medalla_0 --rpc-port=9190 2 | -------------------------------------------------------------------------------- /tests/fuzzing/validator_client_cli/corpus/version.txt: -------------------------------------------------------------------------------- 1 | --version 2 | -------------------------------------------------------------------------------- /tests/fuzzing/validator_client_cli/fuzz_validator_client_cli.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2020-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import 11 | # TODO These imports shouldn't be necessary here 12 | # (this is a variation of the sandwich problem) 13 | stew/shims/net, chronicles, ../../../beacon_chain/spec/network, 14 | 15 | confutils/cli_parsing_fuzzer, 16 | ../../../beacon_chain/conf 17 | 18 | fuzzCliParsing ValidatorClientConf 19 | -------------------------------------------------------------------------------- /tests/helpers/digest_helpers.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2018-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import 11 | ../../beacon_chain/spec/digest 12 | 13 | func `*`*(a: static array[1, byte], n: static int): static Eth2Digest = 14 | doAssert n == 32 15 | for mbyte in result.data.mitems: 16 | mbyte = a[0] 17 | -------------------------------------------------------------------------------- /tests/media/jwt.hex: -------------------------------------------------------------------------------- 1 | e59c86b378f1acd987a2598a53716082f6f2eb23b4ed4fcacc16d64e8dcb1884 -------------------------------------------------------------------------------- /tests/mocking/mock_genesis.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2018-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | # Mocking a genesis state 11 | # --------------------------------------------------------------- 12 | 13 | import 14 | # Specs 15 | ../../beacon_chain/spec/[beaconstate, forks, state_transition], 16 | # Mocking procs 17 | ./mock_deposits 18 | 19 | const mockEth1BlockHash* = 20 | Eth2Digest.fromHex("0x4242424242424242424242424242424242424242") 21 | 22 | proc initGenesisState*( 23 | num_validators = 8'u64 * SLOTS_PER_EPOCH, 24 | cfg = defaultRuntimeConfig): ref ForkedHashedBeaconState = 25 | let deposits = mockGenesisBalancedDeposits( 26 | validatorCount = num_validators, 27 | amountInEth = 32.Ether, # We create canonical validators with 32 Eth 28 | flags = {} 29 | ) 30 | 31 | result = (ref ForkedHashedBeaconState)( 32 | kind: ConsensusFork.Phase0, 33 | phase0Data: initialize_hashed_beacon_state_from_eth1( 34 | cfg, mockEth1BlockHash, 0, deposits, {})) 35 | 36 | var cache: StateCache 37 | maybeUpgradeState(cfg, result[], cache) 38 | 39 | when isMainModule: 40 | # Smoke test 41 | let state = initGenesisState(num_validators = SLOTS_PER_EPOCH) 42 | doAssert getStateField(state[], validators).lenu64 == SLOTS_PER_EPOCH 43 | -------------------------------------------------------------------------------- /tests/nim.cfg: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2019-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | # Use only `secp256k1` public key cryptography as an identity in LibP2P. 9 | -d:"libp2p_pki_schemes=secp256k1" 10 | -d:"chronicles_runtime_filtering=on" 11 | 12 | --styleCheck:usages 13 | --styleCheck:hint 14 | --hint[Processing]:off 15 | -------------------------------------------------------------------------------- /tests/simulation/.gitignore: -------------------------------------------------------------------------------- 1 | /data 2 | /validators 3 | /prometheus 4 | /secrets 5 | 6 | -------------------------------------------------------------------------------- /tests/slashing_protection/.gitignore: -------------------------------------------------------------------------------- 1 | *.json 2 | -------------------------------------------------------------------------------- /tests/test_datatypes.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2018-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | {.used.} 10 | 11 | import 12 | std/typetraits, 13 | unittest2, 14 | ../beacon_chain/spec/datatypes/base, 15 | ./testutil 16 | 17 | suite "Spec datatypes": 18 | test "Graffiti bytes": 19 | var 20 | g1 = GraffitiBytes.init "Hello" 21 | g2 = default(GraffitiBytes) 22 | g3 = g2 23 | 24 | distinctBase(g3)[2] = byte(6) 25 | 26 | check: 27 | $g1 == "Hello" 28 | $g2 == "" 29 | $g3 == "0x0000060000000000000000000000000000000000000000000000000000000000" 30 | 31 | g2 == GraffitiBytes.init("") 32 | g3 == GraffitiBytes.init($g3) 33 | -------------------------------------------------------------------------------- /tests/test_network_metadata.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2023-2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import 11 | unittest2, 12 | ../beacon_chain/networking/network_metadata, 13 | ../beacon_chain/spec/forks 14 | 15 | {.used.} 16 | 17 | template checkRoot(name, root) = 18 | let 19 | metadata = getMetadataForNetwork(name) 20 | cfg = metadata.cfg 21 | state = newClone(readSszForkedHashedBeaconState( 22 | metadata.cfg, metadata.genesis.bakedBytes)) 23 | 24 | check: 25 | $getStateRoot(state[]) == root 26 | 27 | suite "Network metadata": 28 | test "mainnet": 29 | checkRoot( 30 | "mainnet", 31 | "7e76880eb67bbdc86250aa578958e9d0675e64e714337855204fb5abaaf82c2b") 32 | 33 | test "sepolia": 34 | checkRoot( 35 | "sepolia", 36 | "fb9afe32150fa39f4b346be2519a67e2a4f5efcd50a1dc192c3f6b3d013d2798") -------------------------------------------------------------------------------- /tests/testbcutil.nim: -------------------------------------------------------------------------------- 1 | # beacon_chain 2 | # Copyright (c) 2024 Status Research & Development GmbH 3 | # Licensed and distributed under either of 4 | # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). 5 | # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). 6 | # at your option. This file may not be copied, modified, or distributed except according to those terms. 7 | 8 | {.push raises: [].} 9 | 10 | import results 11 | 12 | from ../beacon_chain/consensus_object_pools/block_clearance import 13 | addHeadBlockWithParent 14 | from ../beacon_chain/consensus_object_pools/block_dag import BlockRef 15 | from ../beacon_chain/consensus_object_pools/block_pools_types import 16 | ChainDAGRef, OnForkyBlockAdded, VerifierError 17 | from ../beacon_chain/spec/forks import ForkySignedBeaconBlock 18 | from ../beacon_chain/spec/signatures_batch import BatchVerifier 19 | 20 | proc addHeadBlock*( 21 | dag: ChainDAGRef, verifier: var BatchVerifier, 22 | signedBlock: ForkySignedBeaconBlock, 23 | onBlockAdded: OnForkyBlockAdded 24 | ): Result[BlockRef, VerifierError] = 25 | addHeadBlockWithParent( 26 | dag, verifier, signedBlock, ? dag.checkHeadBlock(signedBlock), 27 | executionValid = true, onBlockAdded) 28 | -------------------------------------------------------------------------------- /wasm/.gitignore: -------------------------------------------------------------------------------- 1 | state_sim 2 | 3 | -------------------------------------------------------------------------------- /wasm/README.md: -------------------------------------------------------------------------------- 1 | # Run nimbus ncli in a browser 2 | 3 | Simple runners for in-browser running of WASM versions of applications - based 4 | on emscripten-generated code. 5 | 6 | ``` 7 | # Make sure you have built nimbus-eth2 with make first! 8 | ./build_ncli.sh 9 | 10 | # Run a http server here (wasm + file:/// apparently don't mix) 11 | python -m SimpleHTTPServer 12 | 13 | # Open http://localhost:8000/index.html 14 | ``` 15 | -------------------------------------------------------------------------------- /wasm/build_ncli.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Simple build script to produce an Emscripten-based wasm version of the state 4 | # sim. 5 | # Assumes you have emcc latest-upstream in you PATH, per their install 6 | # instructions (https://emscripten.org/docs/getting_started/downloads.html) 7 | # 8 | # git clone https://github.com/emscripten-core/emsdk.git 9 | # cd emsdk 10 | # git pull 11 | # ./emsdk install latest-upstream 12 | # ./emsdk activate latest-upstream 13 | # source ./emsdk_env.sh 14 | 15 | # Clean build every time - we use wildcards below so this keeps it simple 16 | rm -rf ncli/nimcache 17 | 18 | # GC + emcc optimizer leads to crashes - for now, we disable the GC here 19 | ../env.sh nim c \ 20 | --cpu:i386 --os:linux --gc:none --threads:off \ 21 | -d:release -d:clang -d:emscripten -d:noSignalHandler -d:usemalloc \ 22 | --nimcache:ncli/nimcache \ 23 | -u:metrics \ 24 | -c ncli 25 | 26 | ../env.sh emcc \ 27 | -I ../vendor/nimbus-build-system/vendor/Nim/lib \ 28 | ncli/nimcache/*.c \ 29 | ../vendor/nim-blscurve/blscurve/csources/32/{big_384_29.c,ecp2_BLS381.c,rom_curve_BLS381.c,ecp_BLS381.c,fp2_BLS381.c,fp_BLS381.c,rom_field_BLS381.c,pair_BLS381.c,fp12_BLS381.c,fp4_BLS381.c} \ 30 | -s ERROR_ON_UNDEFINED_SYMBOLS=0 \ 31 | -s TOTAL_MEMORY=1073741824 \ 32 | -s EXTRA_EXPORTED_RUNTIME_METHODS=FS \ 33 | -s WASM=1 \ 34 | --shell-file ncli_shell.html \ 35 | -O3 \ 36 | -o ncli/ncli.html 37 | -------------------------------------------------------------------------------- /wasm/nim.cfg: -------------------------------------------------------------------------------- 1 | -u:metrics 2 | --------------------------------------------------------------------------------