- .github
- accounts
- build
- cmd
- common
- consensus
- console
- containers
- contracts
-
core
-
asm
-
bloombits
-
constellation-test-keys
-
forkid
-
mps
-
privatecache
-
rawdb
-
state
-
types
-
vm
- .gitignore
- bench_test.go
- block_validator.go
- block_validator_test.go
- blockchain.go
- blockchain_cache_provider_mps_test.go
- blockchain_cache_provider_test.go
- blockchain_insert.go
- blockchain_repair_test.go
- blockchain_sethead_test.go
- blockchain_snapshot_test.go
- blockchain_test.go
- blocks.go
- bloom_indexer.go
- call_helper.go
- chain_indexer.go
- chain_indexer_test.go
- chain_makers.go
- chain_makers_test.go
- config.go
- dao_test.go
- default_psm.go
- default_psm_test.go
- dual_state_test.go
- error.go
- events.go
- evm.go
- gaspool.go
- gen_genesis.go
- gen_genesis_account.go
- genesis.go
- genesis_alloc.go
- genesis_test.go
- headerchain.go
- headerchain_test.go
- mkalloc.go
- multiple_psm.go
- multiple_psm_test.go
- private_state_manager.go
- private_state_test.go
- rlp_test.go
- state_prefetcher.go
- state_prefetcher_private_test.go
- state_processor.go
- state_processor_test.go
- state_transition.go
- state_transition_pmh.go
- state_transition_pmh_test.go
- state_transition_test.go
- tx_cacher.go
- tx_journal.go
- tx_list.go
- tx_list_test.go
- tx_noncer.go
- tx_pool.go
- tx_pool_test.go
- types.go
- upgrade_db_test.go
-
asm
- crypto
- docs
-
eth
-
catalyst
-
downloader
-
ethconfig
-
fetcher
-
filters
-
gasprice
-
protocols
-
tracers
- api.go
- api_backend.go
- api_backend_test.go
- api_test.go
- backend.go
- bloombits.go
- config_test.go
- handler.go
- handler_eth.go
- handler_eth_test.go
- handler_qlight_client.go
- handler_qlight_server.go
- handler_snap.go
- handler_test.go
- peer.go
- peerset.go
- quorum_protocol.go
- state_accessor.go
- sync.go
- sync_test.go
-
catalyst
- ethclient
- ethdb
- ethstats
- event
- extension
- graphql
- internal
-
les
-
checkpointoracle
-
flowcontrol
-
utils
-
vflux
- api.go
- api_backend.go
- api_test.go
- benchmark.go
- bloombits.go
- client.go
- client_handler.go
- commons.go
- costtracker.go
- distributor.go
- distributor_test.go
- enr_entry.go
- fetcher.go
- fetcher_test.go
- handler_test.go
- metrics.go
- odr.go
- odr_requests.go
- odr_test.go
- peer.go
- peer_test.go
- protocol.go
- pruner.go
- pruner_test.go
- request_test.go
- retrieve.go
- server.go
- server_handler.go
- server_requests.go
- servingqueue.go
- state_accessor.go
- sync.go
- sync_test.go
- test_helper.go
- txrelay.go
- ulc.go
- ulc_test.go
-
checkpointoracle
- light
- log
-
metrics
-
exp
-
influxdb
-
librato
-
prometheus
- FORK.md
- LICENSE
- README.md
- config.go
- counter.go
- counter_test.go
- cpu.go
- cpu_disabled.go
- cpu_enabled.go
- cpu_syscall.go
- cpu_windows.go
- debug.go
- debug_test.go
- disk.go
- disk_linux.go
- disk_nop.go
- doc.go
- ewma.go
- ewma_test.go
- gauge.go
- gauge_float64.go
- gauge_float64_test.go
- gauge_test.go
- graphite.go
- graphite_test.go
- healthcheck.go
- histogram.go
- histogram_test.go
- init_test.go
- json.go
- json_test.go
- log.go
- memory.md
- meter.go
- meter_test.go
- metrics.go
- metrics_test.go
- opentsdb.go
- opentsdb_test.go
- registry.go
- registry_test.go
- resetting_sample.go
- resetting_timer.go
- resetting_timer_test.go
- runtime.go
- runtime_cgo.go
- runtime_gccpufraction.go
- runtime_no_cgo.go
- runtime_no_gccpufraction.go
- runtime_test.go
- sample.go
- sample_test.go
- syslog.go
- timer.go
- timer_test.go
- validate.sh
- writer.go
- writer_test.go
-
exp
- miner
- mobile
- multitenancy
- node
- p2p
- params
- permission
-
plugin
-
account
-
gen
-
helloworld
-
initializer
-
qlight
-
security
- api.go
- base.go
- central.go
- central_test.go
- downloader.go
- downloader_test.go
- local_verifier.go
- local_verifier_test.go
- online_verifier.go
- plugin_manager_mockery.go
- plugin_templates.go
- plugin_templates_mockery.go
- service.go
- service_test.go
- settings.go
- settings_test.go
- utils.go
- utils_test.go
- verifier.go
- verifier_test.go
-
account
- private
- qlight
- raft
- rlp
-
rpc
-
testdata
- client.go
- client_example_test.go
- client_test.go
- constants_unix.go
- constants_unix_nocgo.go
- context.go
- doc.go
- endpoints.go
- errors.go
- handler.go
- http.go
- http_test.go
- inproc.go
- ipc.go
- ipc_js.go
- ipc_unix.go
- ipc_windows.go
- json.go
- metrics.go
- security.go
- security_test.go
- server.go
- server_test.go
- service.go
- stdio.go
- subscription.go
- subscription_test.go
- testservice_test.go
- types.go
- types_test.go
- websocket.go
- websocket_test.go
-
testdata
- signer
- swarm
-
tests
-
fuzzers
-
solidity
-
testdata
- block_test.go
- block_test_util.go
- difficulty_test.go
- difficulty_test_util.go
- gen_btheader.go
- gen_difficultytest.go
- gen_stenv.go
- gen_sttransaction.go
- gen_vmexec.go
- init.go
- init_test.go
- rlp_test.go
- rlp_test_util.go
- state_test.go
- state_test_util.go
- transaction_test.go
- transaction_test_util.go
- vm_test.go
- vm_test_util.go
-
fuzzers
- trie
- .bintray.json
- .dockerignore
- .gitattributes
- .gitignore
- .gitmodules
- .golangci.yml
- .mailmap
- .travis.yml
- AUTHORS
- BUILDING.md
- COPYING
- COPYING.LESSER
- Dockerfile
- Dockerfile.alltools
- Makefile
- NOTES.md
- README.md
- SECURITY.md
- appveyor.yml
- circle.yml
- go.mod
- go.sum
- interfaces.go
- logo.png
- mkdocs.yml
- oss-fuzz.sh
Explanation
The code implements a command-line tool, bootnode
, which runs a bootstrap node for the Ethereum Discovery Protocol (EDP). EDP is used by nodes in the Ethereum network to discover each other and establish connections.
Key Components:
- Command-line Arguments:
-addr
: Defines the UDP address and port the bootnode listens on (default: :30301).-genkey
: Generates a new private key for the bootnode.-writeaddress
: Prints the public key of the node and exits (used to get the public key after generating a new key).-nodekey
: Specifies the file containing the private key.-nodekeyhex
: Specifies the private key as a hexadecimal string (for testing).-nat
: Specifies the NAT traversal mechanism for the node (e.g.,upnp
,pmp
).-netrestrict
: Restricts network communication to specific IP networks (CIDR masks).-v5
: Runs a v5 topic discovery bootnode (introduced in later Ethereum versions).-verbosity
: Sets the logging verbosity level (0-5).-vmodule
: Specifies a pattern for selective logging.- Key Management:
- Loads or generates a private key for the node, either from a file, a hex string, or by generating a new one.
- Networking:
- Resolves the provided listen address to a UDP address.
- Binds the UDP address to a UDP listener.
- Configures NAT traversal based on the
-nat
flag. - Discovery Protocol:
- Uses the
discover
package to set up the UDP listener and listen for EDP packets. - Creates a local node using the
enode
package, which represents the node’s information (public key, IP address, port). - Initializes the
discover.Config
struct with the private key and network restrictions (if provided). - Starts listening for EDP packets using either
discover.ListenUDP
(for older versions) ordiscover.ListenV5
(for v5 topic discovery). - Printing Information:
- Prints the bootnode’s URL, a warning that
bootnode
is a development tool, and a recommendation to use a regular node as a bootstrap node in production deployments.
Key Concepts:
- Bootstrap Node: A node in a network that provides initial information and connectivity for other nodes.
- Ethereum Discovery Protocol (EDP): A protocol that allows Ethereum nodes to find each other and establish connections.
- NAT Traversal: The process of allowing nodes behind NAT (Network Address Translation) devices to communicate with each other.
Overall Purpose:
The bootnode
tool provides a simple way to run a bootstrap node for the Ethereum network. It handles key management, network configuration, and EDP listening, allowing other nodes to easily discover and connect to the network.
Graph
The graph shows the usage of functions within the codebase.
Select a code symbol to view it's graph