Tell me please. with whom does the first interaction occur when starting the client \ wallet? I'm trying to understand how the client works. Blockchain is a decentralized system, but if it needs to communicate with any server to find the first seed, it turns out that it is centralized. Please explain this to me. How does the network of blochchain work?
In case you are talking about very first run of your client.
Client will synchronise with a blockchain via peer2peer network.
There are 3 types of sync:
- "Full" Sync: Gets the block headers, the block bodies, and validates every element from genesis block.
- Fast Sync: Gets the block headers, the block bodies, it processes no transactions until current block - 1024. Then it gets a snapshot state and goes like a full synchronization.
- Light Sync: Gets only the current state. To verify elements, it needs to ask to full (archive) nodes for the corresponding tree leaves.
A simplified model of how the p2p algorithm works is the following:
you have nodes that are assumed to be always available/online (in Ethereum they are called bootstrap nodes)
bootstrap nodes maintain a list of all nodes that connected to them in a period of time (predefined temporal value, for example last 24
hours)- when peers (Ethereum client applications such as eth, geth, pyethapp, etc.) connect to the Ethreum network, they first connect to the bootstrap nodes which share the lists of peers that have connected to them in the last predefined time period
the connecting peers then synchronize with the peers and may prune the connections to the bootstrap nodes since they are no longer
essential in peer discovery (the peers can perform discovery on their own)the default bootstrap nodes are part of the wallet you download; you can override these values in
Geth
andParity
. You can even select a different node inMyEtherWallet
Different structures visualised
This is why blockchain is decentralized. There is no such thing as server.
Brilliant sources which helped me to answer this question:
1. Types of sync
2. P2p algorithm
3. Image from Blockgeeks article
-
1To add to this answer, the default bootstrap nodes are part of the wallet you download; you can override these values in
geth
and Parity. You can even select a different node in myetherwallet! – lungj Dec 21 '17 at 16:16 -