Data on Private Ethereum blockchain lost/disappears after couple of days - blockchain

I am deploying a private ethereum blockchain (geth) on a virtual machine on Azure. Upon deploying my Solidity contracts on the blockchain and launching my NodeJS application to it, I am able to add data normally through web apis of the nodejs Loopback App and everything is working fine and I can see the added data using the GET apis.
However, after 1-2-3 days (random) I am not able to retrieve the data I added through my GET apis, while am still able to add new data which confirms that Geth is running fine and wasn't interrupted.
I am running geth using:
geth --datadir ./myDataDir --rpc --networkid 1441 console 2>> myEth.log
myEth.log isn't showing anything wrong, nodejs logs are clean as well.
eth.syncing shows false which means the network is synced.
size of myDataDir folder is still increasing so logically data should be somewhere there but it's not showing.

This is not a private blockchain!
--networkid 1441
This only says that you communicate with clients that also run a network with ID 1441. It might be unlikely, but if someone else runs a network with ID 1441, this node will connect to your node just fine. And in case, the other network with the same ID has a longer (more "heavier") chain, this overwrites your local chain.
To avoid this, try a more random network ID, maybe 7-9 digits, and disable discovery with
--nodiscovery
Or just use the --dev preset.

Related

How Ethereum protocol works with geth

I am new to Ethereum and generally to blockchain. I learned that Ethereum blockchain works on Kademlia. The distributed hash table and its working was beautiful and nicely explained by Eleuth P2P.
Now I used geth to connect to the Ethereum Mainnet and it discovered 2 to 3 maximum peers in 5 to 6 minutes.
Now I know the algorithm but my concern is how the first peer is discovered? Because internet is just a big set of routers and different type of computers (server, computer, etc ) and if you broadcast the discovery like in ARP. The internet will be flooded with these peer discovery broadcast messages and this doesn't seems right. So how initially the connections are made? Also we cannot trust a single network for first time connection because this will make the system server and client based and not decentralised so how the initial connections and peer discovery happens?
Are the broadcast message like have TTL like to prevent the circular loop like in TCP I guess? But this also seems a horrible idea to me.
Please explain.
In order to get going initially, geth uses a set of bootstrap nodes whose endpoints are recorded in the source code.
Source: Geth docs
Here's the list of the bootstrap nodes hardcoded in the Geth source code: https://github.com/ethereum/go-ethereum/blob/v1.10.11/params/bootnodes.go#L23
The --bootnodes option allows you to overwrite this list with your own. Example from the above linked docs:
geth --bootnodes enode://pubkey1#ip1:port1,enode://pubkey2#ip2:port2,enode://pubkey3#ip3:port3

What keeps accessing Google Cloud metadata on my instance

I have a Google Cloud compute instance running with Ubuntu 18. We had wireshark running tracking another problem and we noticed that every minute something is accessing the meta data server. Three requests every minute:
GET /computeMetadata/v1/instance/virtual-clock/drift-token?alt=json&last_etag=XXXXXXXXXXXXXXXX&recursive=False&timeout_sec=60&wait_for_change=True
GET /computeMetadata/v1/instance/network-interfaces/?alt=json&last_etag=XXXXXXXXXXXXXXXX&recursive=True&timeout_sec=60&wait_for_change=True
GET /computeMetadata/v1/?alt=json&last_etag=XXXXXXXXXXXXXXXX&recursive=True&timeout_sec=77&wait_for_change=True
In call cases, the wireshark says the source is the IP of my instance, and the destination is the 169.254.169.254 which is the Google metadata server.
I don't have any code we have written that is accessing the server. The first one makes me think that this is some Google specific software that is accessing the meta data? But I haven't been able to prove that. What is worrisome is that the response for the third one contains ssh keys. Also, every minute seem excessive.
I see another post talking about scripts in /usr/share/google, but I don't have that directory. I do see that google-fluent is installed. I also see a installed snap for google-cloud-sdk. Could one of those be it? I don't recall installing them, AFAIK, I am not using it, so if that is it, what is the harm in uninstalling it?
You do not have a problem to worry about. The metadata server is private to your instance. The Google VM guest environment software and Stackdriver (fluentd) are making requests to the metadata server to get credentials, detect changes (new SSH keys), set the clock, etc.
The IP address 169.254.169.254 is an IPv4 Link Local Address. Only your VM has a route to that network.
Compute Engine Guest Environment
Do not attempt to uninstall the Guest Environment. You can remove Stackdriver, but I do not recommend that. Stackdriver provides logging and monitoring features that are very useful.

I need the capability of running a software locally remotelly and be able to acess it depending on whether I have internet connection or not

So I am an intern at a Startup company that's providing agricultural solutions to remote areas of our country. The project consists of a private network we run, covering the entire farm, so the farmer can operate quickly from within the farm. Now we're trying to transition into the cloud so that if the client has internet access on the farm, he can operate it remotely.
Because of this, we have the requirement of having a constantly running frontend/backend on the farm. The current solution we came up with was also running a server with frontend/backend on AWS, this software would then have to try and connect to the server running on the farm so the farmer could operate it remotely. But this seems extremely hacky, for example, if internet connection on the farm eventually dropped, the farmer would have to switch into the private network manually (many wouldn't know how to do this), and also, we would have to maintain two instances of the same frontend running in the cloud and locally, this totally seems like a hack..
We're completely out of ideas though and at a loss of how to proceed.

Difference of Geth or Ganache

Hi I am new to blockchain topic and I am trying to make an Ethereum smart contract. First step I installed truffle and when I try to migrate it throws an error because I have no ethereum client.
For solving this problem truffle develop, ganache, geth are recommended but I couldnt decide to which one is more suitable and I dont understand the difference of ganache and geth. Basically are they serving same thing or not? Here is error:
Could not connect to your Ethereum client with the following parameters:
- host > 127.0.0.1
- port > 7545
- network_id > *
Please check that your Ethereum client:
- is running
- is accepting RPC connections (i.e., "--rpc" option is used in geth)
- is accessible over the network
- is properly configured in your Truffle configuration file (truffle-config.js)
Truffle
As you already did, you migrated a contract. So Truffle can be used for contract compilation and migration. It aims for easy and fast migration.
Geth
Is an Ethereum-client, which means that you can run your own private blockchain with it. You can adjust your needs by defining for example the amount of threads you offer for mining.
Geth itself is a command line tool, which can run a full Ethereum node implemented in Go. It provides the command lines, a Json-rpc server and an interactive console, where you can run your own scripts written in javascript.
Ganache
If you want a GUI, where you can track all deployments and transactions on your blockchain, you can choose Ganache.
It allows you to create your own private blockchain mainly for testing purposes.
It is used for deployment-testing for example, because there are no real miners on a "ganache-blockchain", so you can test if your contracts work.
I would suggest you to use Geth and Truffle if you want to set up your own blockchain on your local node and then deploy some contracts on it.
There are plenty of manuals online on how to set up your own local node.
For example:
Create your own local node with geth
Setting up Ethereum development environment
After you created your node, you can deploy some contracts with truffle to it. I hope I could help you.
TLDR : start with Ganache and learn Geth along the way.
Truffle is a compiler and out of question.
But between Geth and Ganache :
Why Ganache ? Because it is easy !
Geth is a real deal , for a small local chain you have to run it's service first then create genesis block then you need to bring some miner to mine the transaction to the blockchain and generate some eath! then you can migrate smart contract to it but Ganache will do all of that for you!
Why use Geth? from here :
1- Geth is the official client software provided by the Ethereum
foundation.
2- Comes with a JavaScript console (run it with geth console).
3- Has an interoperable JavaScript client (web3js).
4- Built-in access to the Rinkeby test net (or build your own private
Ethereum network).
5- It is generally considered to be the reference implementation for
other Ethereum nodes.
From my experience at this time/date, Ganache cloud be buggy and will give you some errors irrelevant to your code , but if you need to migrate your code to a test nest like Rinkeby Testnet, eventually you need to learn Geth.

Ropsten Ethereum not showing transaction information

I am using geth 1.7.3-stable-4bb3c89d to sync with Ropsten network. I started synchronization with fast mode and restarted the service. When I type eth.syncing in geth console it always shows false but the new blocks are being imported.
eth.blockNumber in my node returns 4374961 but when I try to get one of the transaction info from that block then it returns null.
When will the transaction info of the blocks be downloaded in my node? I already removed the test database 3 times and started fresh with fast sync mode. I have 11 peers right now in my node. Do I need to change something to download block info?
I think I was on the different fork than the fork of https://ropsten.etherscan.io/blocks as stated here. I updated my geth server and started syncing with bootnodes available here. Now everything seems updated with Ropsten network.