How does Ethereum select peer nodes when it starts ? I guess there
should be a set of nodes hardcoded in geth that it tries to connect to
and then gets list of other nodes from them. How many of those nodes
is hardcoded into geth ?
There are 3 hard-coded bootnodes. See How many bootnodes are hardcoded into Ethereum clients?
Are they hardcoded by IP address or domain name ?
They're hardcoded as enode URLs, such as:
How would Ethereum network survive if all these nodes are shut down by
joint governments ban.
That's speculative. I'm assuming they'd create some more, and we'd enter an arms race of sorts.
Comparing Ethereum decentralization to Bitshares 101 nodes
centralization, if there are less than 101 hardcoded initial peers in
Ethereum, then it seems like it is not more decentralized than
Bitshares, but far slower. Is my understanding correct ?
The 3 hard-coded nodes are bootstrap nodes, whose purpose is to allow entry to the peer-to-peer network (and I think this is only for the first time a node enters the network - subsequent connections can use other nodes, mentioned in the answer to your final question). They don't serve all the data.
Ethereum uses a Kademlia-like system to discover further peers. The maximum number of peers is also configurable.
See How does Ethereum client select which peers to synchronise with?
If not done already, are there any plans to publish list of active
nodes on the blockchain so that next time geth starts it can try to
connect to latest list rather than hardcoded list.
This isn't quite handled the way you're suggesting at present, but there are more options than just connecting to the 3 hard-coded peers on each startup.
- "bootstrap" nodes: These are the 3 hard-coded nodes.
- "static" nodes: These can be explicitly added by the user.
- "trusted" nodes: These can also be configured, and are always connected to, even if the maximum (soft limit) number of peers has been reached.
Publishing a huge list, rather than letting the discovery protocol do its work, would possibly provide an attack surface for people wanting to publish their own, corrupt list.