Remix provider connectivity issue with custom RPC - blockchain

I have setup Ethereum private site chain using geth with the following nodes and each node is running on a separate machine on aws.
abc.122.41.xyz admin(node1)
abc.73.38.xyz peer(node2)
abc.125.123.xyz RPC(node3)
This setup is working fine with these parameters in geth.
--http.vhosts '*'--http.corsdomain '*'
But, I want to restrict access to specific sites to use this RPC like REMIX and etc. Now, I run the below command in this way to restrict access and I read it from REMIX official site to pass parameters in this way. But, Remix is not going to connect to the RPC and throw this error.
Error while connecting to the provider, provider not connected
geth --datadir node01 --networkid 4444 --nat extip:xyz.31.2.xyz --port 30303 --mine --miner.gasprice 1000000 --miner.etherbase=0x35ef1cb0552cEfDEDc9cF1DA19199071274094Ab --keystore key01 --ethstats node01:s3cr3t#stats-localhost.batterychain.info:3000
geth --datadir node02 --networkid 4444 --port 30303 --mine --miner.gasprice 1000000 --keystore key02/ --ethstats Geth/v1.10.20-stable-8f2416a8/linux-amd64/go1.18.1:s3cr3t#stats-localhost.batterychain.info:3000
geth --datadir node03 --networkid 4444 --port 30303 --mine --miner.gasprice 1000000 --http --http.corsdomain 'https://remix.ethereum.org' --http.addr 0.0.0.0 --http.api personal,eth,net,web3 --keystore key03/ --ethstats Geth/v1.10.20-stable-8f2416a8/linux-amd64/go1.18.1:s3cr3t#stats-localhost.batterychain.info:3000
I try to explore this issue on the internet and found some solutions like changing the order of parameters, and also passing REMIX with HTTP instead of HTTPS like
http://remix.ethereum.org
But, each time I face the above same error.

Related

geth private network is which type of node?

I'm new to blockchain, I have setup on private node using geth.
Now I want to know, which kind of chain it is called PoA based chain or PoW?
below is my command to start private node:
geth --nodiscover --networkid 1111 --datadir node1 --unlock ADD --rpccorsdomain="" --mine --rpc --rpcapi "admin,debug,eth,miner,net,personal,txpool,web3,clique" --nousb --rpc --rpcaddr 0.0.0.0 --ws.api "eth,net,web3,debug,txpool" --ws --ws.addr 0.0.0.0 --ws.port 8546 --ws.origins "" --syncmode=full --gcmode=archive --rpcvhosts=* --allow-insecure-unlock console
It depends on your genesis.json config, not on the CLI params.
You're using Proof of Authority (PoA) if you have the clique defined in the config. If you don't have it, you're using Proof of Work (PoW).
For more info, see "Clique Example" in the docs.

which port I use when I want to connect remix to my local quorum network?

I want to deploy a smart contract on my local network.
I executed a local node via
PRIVATE_CONFIG=ignore nohup geth --datadir ./Node1/new-
node-1
--nodiscover --verbosity 5 --networkid 31337 --raft --
raftport 51001 --rpc --rpcaddr 0.0.0.0 --rpcport 22101 --
rpcapi
admin,db,eth,debug,miner,net,shh,txpool,personal,web3,
quorum,raft --emitcheckpoints --port 21101 2>>node1.log &
I have to use localhost:\127.0.0.1:21101 or 22101?
I want to know the difference betwwen the two ports and what are used for?
An other question if you don't mind:
When i use the port 21101, it fails to connect and when I consult the node log I find :
Failed RLPx handshake addr=[::1]:42552 conn=inbound
err="read tcp [::1]:21102->[::1]:42552: i/o timeout"
You need to use an RPC port number to connect the network.
For examples: http://localhost:22101
Difference between the Raft port and RPC port?
Quorum listens on port 50400 by default for the raft transport, but this is configurable with the --raftport flag.
You can start the HTTP JSON-RPC with the --rpc flag, to change the default port (8545) --rpcport <portnumber> If accessing the RPC from a browser, CORS will need to be enabled with the appropriate domain set. Otherwise, JavaScript calls are limit by the same-origin policy and requests will fail:
For examples: geth --rpc --rpccorsdomain "http://localhost:3000"
Try to use http://remix.ethereum.org/ for connecting local networks (unsecured networks). If Https certificate enabled then, you can use https://remix.ethereum.org/

Connecting two peers on different machines in a private network

I am using geth to create a Private blockchain in my system which is connected to my office network.
I want to add another peer(different PC) to my blockchain network which is connected to the same network.
How can I do that??
Any suggestions on, creating an app which indeed does solve the above requirement.
The key change that would be needed is to start geth nodes on those machines using rpc mode
For example start geth node on Machine 1 and Machine 2 using the commands:
Machine 1 : geth --datadir "C:\ethereum\geth\data\01" --networkid 1234 --rpc --rpcport "8545" --rpcaddr "127.198.216.197" --rpccorsdomain "*"
Machine 2 : geth --datadir "C:\ethereum\geth\data\01" --networkid 1234 --rpc --rpcport "8545" --rpcaddr "127.198.216.198" --rpccorsdomain "*"
Now add Machine 2 as a peer to Machine 1 if you want to do it manually or use a Bootnode and start Geth using Bootnode. You can refer to the link if you want to use Boot nodes: https://github.com/ethereum/go-ethereum/wiki/Setting-up-private-network-or-local-cluster
Then you should be able to attach your console using the command: geth attach http://127.198.216.197:8545
One caveat: You need to open respective ports if they are blocked by your office network
When running the client daemon you can add the 'connect' parameter to specify the IP:Port of the computer you want to try to connect to when starting.
bitcoind --daemon -connect=127.0.0.1:9090
This usually has to be done when the ip's of nodes hard coded into your blockchain codebase have not been updated to the IP's where you have nodes running. Thus peers.dat does not know where to look for a connection to the blockchain.
You can also specify these in the config file with the addnode parameter. e.g.
server=1
rpcport=9090
rpcuser=bitcoinrpc
rpcpassword=3QtnxrB7P5y4EpBdad1MkCeB2RHmArvcarw7udgXsAce
addnode=10.0.0.2:8333

How to set up a Private network and connect peers in geth?

I am trying to setup a private network and trying to connect peers. Currently I'm trying it on my laptop and desktop (both of them are connected to different internet).
I run the below command in first terminal(in both systems (data dir is different in both systems)):
geth --rpc --rpcaddr "0.0.0.0" --rpcport "8545" --rpccorsdomain "http://localhost:5000, http://localhost:6000" --port "2403" --ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --rpcapi "db,eth,net,web3" --networkid 1001201 --datadir "E:\User\priv\data" init "E:\User\priv\genesis.json"
then I run:
geth --datadir "E:\User\priv\data"
Now, in the second terminal:
geth attach ipc:\\.\pipe\geth.ipc
I get the same enode value on both the systems when i run admin.nodeInfo.enode
then on 1st PC,
admin.addPeer("enode://e0c4960659b6ce4eda71c67b337055636f67660a711d157a81572b5eff1ed1b77931bef4bd079e2660baa661ac16d696b831e9394cb619378071a2593ecdf17a#[192.168.1.2]:30301");
on 2nd PC,
admin.addPeer("enode://e0c4960659b6ce4eda71c67b337055636f67660a711d157a81572b5eff1ed1b77931bef4bd079e2660baa661ac16d696b831e9394cb619378071a2593ecdf17a#[13.75.117.156]:30302");
both of them return true.
But admin.peerCount returns 0.
Can somebody please help me to setup a private geth network?
Step1
geth --identity "YourNodeName" --rpc --rpcport "8092" --datadir "DirectoryPathToStoreData" --port "30330" --nodiscover --rpcapi "db,eth,net,web3" --networkid 2010 init PathOfGenesisFile
The above command is to initialise a Genesis File.
Note: All Peers willing to connect to a network should have a same Genesis File.
Step2
geth --identity "YourNodeName" --rpc --rpcport "8092" --datadir "DirectoryPathToStoreData" --port "30330" --nodiscover --rpcapi "db,eth,net,web3" --networkid 2010 console
The above command opens a Geth JavaScript console.
Do the above 2 steps in other system also.
Step3
In the system where you want to add other system as peer type the following command admin.addPeer("Argument") where Argument is the enode value of other node which is obtained by typing admin.nodeInfo() in other system.
Eg:admin.nodeInfo
{
enode: "enode://965dc2b0f39e199d3a07871293015d8a4ad9349834fc27b7ee5e87bea89547e4fafda3ce7982ae07c14b8770c87a6c14e3fe2f91ef0d0ca717eb6ae56aa3e74b#[::]:30330?discport=0",
//////////
}
where 30330 is the network id of other system.
copy upto 30330.You need to give the ip address of other system in place of
[::]
It returns true if that node is capable of acting as a peer but not mean that it is added to our network, to know that type net.peerCount. It returns 1, if added.
You can follow the step3 for adding more peers.
You can create a private blockchain without creating a Genesis File.If you opt for that, follow this link.
As outlined here, your --port and --rpcport variables should be different. The resulting EnodeURLs should also be different.
Also, when you run geth the second time, I'd include everything you used in the first run before init.

Ethereum net status

I couldn't see my transactions on eth-netstats graph for my private network. Its listing out all other details like below. What am I missing, any pointers would be greatly appreciated.
I am running the application in:
- Node: 4.6.0
- NPM: 3.10.7
Geth command used to start the server:
geth --identity "nodeB" --rpc --rpcaddr "0.0.0.0" --rpcport "8001" --rpccorsdomain "*" --datadir "/home/node_b" --port "30304" --ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --rpcapi "db,eth,net,web3" --autodag --networkid 1900 --nat "any" console
Its resolved. The eth-netstats was not getting data from the eth-netstats intelligent api, restarting the eth-netstats-api resolved the issue.