why only one node can sync blocks in my private eth chain? - ethereum

I have setup 4 nodes (named A, B, C, D) in a PC (windows 8.1) to build my private chain using geth v1.8.11.
A node is the first one to be created and have 1 account.
B node is the second one to be created and have 1 account.
A and B connected using admin.addPeer.
A and B mined 336 blocks. Their blocks are synced.
C node and D node were setup later.
C and D connected A using admin.addPeer. But C and D displayed the following info and the blocks can't be sync.
And eth.syncing shows:
eth.blockNumber shows: 0
B, C, D nodes start with the following command:
geth --datadir "H:\blockchain\eth\dataX" --networkid 15 --nodiscover --port="3030X" --ipcdisable --rpc --rpcapi "admin,debug,eth,miner,net,personal,shh,txpool,web3" --rpcaddr "0.0.0.0" --rpcport "31X00" --rpccorsdomain "*" --ws --wsport="31X01" --wsaddr="0.0.0.0" --wsorigins "*" console
So why C and D sync fail?
the block number is 0 but the startingBlock is 271, is it normal?

This issue may arise if the new node is not initiated using the same genesis file with which the base node is created.
Make sure of it.

Related

Cannot connect to a geth private network node with configured --ipcpath using Web3.IPCProvider

My OS is Windows. I have several running geth instances in my machine and, because of this, I must manually configure their ipcpath so that they would not have a conflict. I create a geth instance using the following command:
geth --datadir data --networkid 123 --ipcpath node5.ipc
I can attach to the instance via geth attach ipc:\\.\pipe\node5.ipc. But I cannot do the same using web3.py:
>>> from web3 import Web3
>>> w3 = Web3(Web3.IPCProvider('\\.\pipe\node5.ipc'))
>>> w3.isConnected()
False
What seems to be the problem here?

Ethereum geth reset the block to 0 again after i restarted my pc

Everything run well when i restarted running command "geth" for my local private network. but when i restarted my pc and run the geth command again, the block reset to 0 again.
Here is my code to init the geth from configuration in my genesis.json:
geth --datadir "/PATH_TO_NODE/" init /PATH_TO/genesis.json
And then i run my geth node with command:
geth --identity "node01" --http --http.port "8000" --http.corsdomain "*" --datadir "/PATH_TO_NODE/" --nodiscover --http.api "eth,net,web3,personal,miner,admin" --networkid 1900 --allow-insecure-unlock
when i rerun the command above there is no problem, it will continuing the block that already there. But it will be resetting to the 0 again when i restart my PC. Is it intended or not?
I believe this is because you've ran your geth node with a different network ID (--networkid 1900) rather than the default which is hardcoded as 1 and will have been used when you ran your first command (without the flag above). Every time you do this it resets the chain data. Also afaik, putting network ID in the genesis doesn't actually change anything. The only ways to change it are to a) hardcode it in the codebase or use the flag.

Unable to list accounts using geth console even though accounts exist

When I run the geth command to list all accounts, it works fine:
geth account list
INFO [04-09|15:47:35.967] Maximum peer count ETH=50 LES=0 total=50
INFO [04-09|15:47:35.967] Smartcard socket not found, disabling err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [04-09|15:47:35.968] Set global gas cap cap=25000000
Account #0: {<my_public_address>} keystore: <path_to_keystore>
But when I start it's console, I get undefined and an empty array while requesting balances/accounts:
> eth.getAccounts()
undefined
> eth.accounts
[]
However, if I specify my address in order to check the balance, it works fine:
> eth.getBalance("<my account address>")
3000000000000000000
I am running a local self-hosted Ethereum node on rinkeby network:
geth --rinkeby --rpc --rpcapi "eth,net,web3" --cache 2048
Try manually using the --keystore option, and adding the path to the folder that has your keystore. (in this case it's probably ~/.ethereum/rinkeby/keystore )

How do i connect to an Ethereum node?

I setup an Ethereum light node on a VPS using Geth, and i'm running it using:
nohup geth --syncmode "light" --rpc --rpcapi "eth,net,web3" --ws --rpccorsdomain '*' --rpcaddr 0.0.0.0 --rpcport 8080 &
Now from my local laptop i would like to use this node to perform web3 queries to the Etherum blockchain. I'm using python but i tried to do the same using Web3js too and the output is the same:
from web3 import Web3
w3 = Web3(Web3.HTTPProvider('http://MY-VPS-IP:8080'))
print(w3.isConnected())
Which gives me the following output:
False
Which means, i'm assuming, that the node is not accessible from outside the vps where i hosted it. How can i access it from outside? In theory the command i used should work, and i also made sure to have port 80 open. Any advice is appreciated
The command you write is old and not fully correct use this:
geth --syncmode "light" --ws --ws.addr "specific IP" --http --http.addr "specific IP"

I have a SysV init script on Fedora 18. How can I make it start after the network is ready?

I have a SysV init script on Fedora 18. Fedora 18 uses systemd (and apparently, there is no way to switch back to SysV).
My script requires the network to be ready. Currently, at the time the script runs, the network is not ready. How can I make sure that my SysV init script runs after the network is up?
The beginning of my script looks like this:
#!/bin/bash
#
# chkconfig: 345 99 01
# description: starts the xyz boot service
OK, after trying several things, I tried adding an LSB header:
### BEGIN INIT INFO
# Required-Start: $network $local_fs $named
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: Starts/stops the foo service
# Description: Starts/stops the foo service
### END INIT INFO
This worked! The script now runs after the network is initialized. I guess the systemd implementation reads the LSB header.
To run a script when the network is ready, in the [Unit] section of your systemd service file, add the following:
After=network-online.target
Wants=network-online.target
The network is defined as ready when the network management software considers the network is up (that generally means a IP address is configured and routable). For NetWorkManager, it queries dbus to get the information..
References
Running Services After the Network is up
systemd.unit(5) man page
nm-online source code, function check_online