An Introduction to Geth and Running Ethereum Nodes — SitePoint


In this article, we’ll look at what Ethereum nodes are, and explore one of the most popular ones, called Geth.

In order to communicate with the blockchain, we must use a blockchain client. The client is a piece of software capable of establishing a p2p communication channel with other clients, signing and broadcasting transactions, mining, deploying and interacting with smart contracts, etc. The client is often referred to as a node.

The formal definition of the functionality an Ethereum node must follow is defined in the ethereum yellow paper. The yellow paper defines the required functions of nodes on the network, the mining algorithm, private/public key ECDSA parameters. It defines the entirety of features which make nodes fully compatible Ethereum clients.

Based on the yellow paper, anyone is able to create their own implementation of an Ethereum node in whatever language they see fit.

A full list of clients can be seen here.

The most popular clients so far are Geth and Parity. The implementations differ mostly by the programming language of choice — where Geth uses Golang and Parity uses Rust.

Since Geth is the most popular client implementation currently available, we’ll focus on it for now.

Types of Nodes

When you’re joining the Ethereum network, you have an option of running
various types of nodes. The options currently are:

  • Light node
  • Full node
  • Archive node

An archive node is a special case of a full node, so we won’t go into detail on it. One of the best summaries on the types of nodes I’ve found is on Stack Exchange:

In general, we can divide node software into two types: full nodes and light(weight) nodes. Full nodes verify block that is broadcast onto the network. That is, they ensure that the transactions contained in the blocks (and the blocks themselves) follow the rules defined in the Ethereum specifications. They maintain the current state of the network (as defined according to the Ethereum specifications).

Transactions and blocks that do not follow the rules are not used to determine the current state of the Ethereum network. For example, if A tries to send 100 ether to B but A has 0 ethers and a block includes this transaction, the full nodes will realize this does not follow the rules of Ethereum and reject that block as invalid. In particular, the execution of smart contracts is an example of a transaction. Whenever a smart contract is used in a transaction (e.g., sending ERC-20 tokens), all full nodes will have to run all the instructions to ensure that they arrive at the correct, agreed-upon next state of the blockchain.

There are multiple ways of arriving at the same state. For example, if A had 101 ether and gave a hundred of them to B in one transaction paying 1 ether for gas, the end result would be the same as if A sent 100 transactions of 1 ether each to B paying 0.01 ether per transaction (ignoring who received the transaction fees). To know if B is now allowed to send 100 ether, it is sufficient to know what B’s current balance is. Full nodes that preserve the entire history of transactions are known as full archiving nodes. These must exist on the network for it to be healthy.

Nodes may also opt to discard old data; if B wants to send 100 ether to C, it doesn’t matter how the ether was obtained, only that B’s account contains 100 ether. Light nodes, in contrast, do not verify every block or transaction and may not have a copy of the current blockchain state. They rely on full nodes to provide them with missing details (or simply lack particular functionality). The advantage of light nodes is that they can get up and running much more quickly, can run on more computationally/memory constrained devices, and don’t eat up nearly as much storage. On the downside, there is an element of trust in other nodes (it varies based on client and probabilistic methods/heuristics can be used to reduce risk). Some full clients include features to have faster syncs (e.g., Parity’s warp sync).

Installing Geth

The installation instructions for Geth on various platforms (Windows, macOS, Linux) can be found here. The list is quite comprehensive and kept up to date, so I won’t go over it in the article.

Running Geth

In order to spin up a Geth node, the only thing you need to do is go to your terminal window and run geth. When you do it, you should get an output similar to this:

➜  ~ geth
INFO [06-03|11:03:13] Maximum peer count                       ETH=25 LES=0 total=25
INFO [06-03|11:03:13] Starting peer-to-peer node               instance=Geth/v1.8.10-stable/darwin-amd64/go1.10.2
INFO [06-03|11:03:13] Allocated cache and file handles         database=/Users/mjvr/Library/Ethereum/geth/chaindata cache=768 handles=128
INFO [06-03|11:03:13] Writing default main-net genesis block
INFO [06-03|11:03:14] Persisted trie from memory database      nodes=12356 size=2.34mB time=48.31016ms gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [06-03|11:03:14] Initialised chain configuration          config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: <nil> Engine: ethash}"
INFO [06-03|11:03:14] Disk storage enabled for ethash caches   dir=/Users/mjvr/Library/Ethereum/geth/ethash count=3
INFO [06-03|11:03:14] Disk storage enabled for ethash DAGs     dir=/Users/mjvr/.ethash                      count=2
INFO [06-03|11:03:14] Initialising Ethereum protocol           versions="[63 62]" network=1
INFO [06-03|11:03:14] Loaded most recent local header          number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [06-03|11:03:14] Loaded most recent local full block      number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [06-03|11:03:14] Loaded most recent local fast block      number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [06-03|11:03:14] Regenerated local transaction journal    transactions=0 accounts=0
INFO [06-03|11:03:14] Starting P2P networking
INFO [06-03|11:03:16] UDP listener up                          self=enode://a4cb08519bc2bceecb8ad421871c624d5212888653bbaee309fda960f3c87ca7aa9855ee14684d521836ae88ad1986b8ca944348e976760d2bd1247ed3ca7628@[::]:30303
INFO [06-03|11:03:16] RLPx listener up                         self=enode://a4cb08519bc2bceecb8ad421871c624d5212888653bbaee309fda960f3c87ca7aa9855ee14684d521836ae88ad1986b8ca944348e976760d2bd1247ed3ca7628@[::]:30303
INFO [06-03|11:03:16] IPC endpoint opened                      url=/Users/mjvr/Library/Ethereum/geth.ipc

After this, you should see new lines appear periodically, where Geth says “Importing new state” or “Importing new block headers” or “Importing new receipts”. The state, block headers and transactions are part of Ethereum’s tree tries: they must be downloaded in order to synchronize your node with the Ethereum blockchain.

This is a process which can take a really long time, so one of the options you have is to run a light node like this;

geth --light

What Geth needs to do now is only pull the latest block headers and rely on other full nodes to validate transactions through the usage of merkle proofs.

Accessing a Geth Console

Now that you’ve created a node, you can access it by opening up a new tab in your terminal and running the following:

geth attach

This will connect a Geth console — which is a Javascript environment for communicating with the blockchain — to your running node. This can be done in both the full client mode and the light mode.

After you’ve opened the console, type this:

web3.eth.blockNumber

You should get an output as a number (e.g. 5631487) which represents the current block number of the Ethereum network.

Creating a New Account

In order to use the blockchain, you need to have an account. With Geth, you can do it by running the following in your terminal:

geth account new

After you’ve done that, it will ask you for the password, which you’ll need to protect your account. Make sure to use a secure password and to store it safely.

What Geth does when you run geth account new is update a file in the Geth data directory (a directory where Geth stores all the necessary data, including blocks and headers). The locations are (per platform):

  • macOS: ~/Library/Ethereum
  • Linux: ~/.ethereum
  • Windows: %APPDATA%Ethereum

Accessing Geth from Other Clients

When you start Geth, the client automatically starts an RPC server at port 8545. You can access the RPC server and its methods on this port by connecting to localhost:8545 with a library like web3js or web3j or call it manually with curl or wget.

To learn about connecting with external tools like those to a running Geth instance (either private when launching your own blockchain, or public as in the instructions above) see this post.

Conclusion

In this short introduction we covered Geth, the types of Ethereum nodes, and their purpose. You can now run a Geth node of your own, and enhance it with third-party tools. In future articles, we’ll cover running private networks (your own Ethereum blockchain with Geth) and much more.


Be the first to comment

Leave a Reply

Your email address will not be published.


*


Privacy Policy

WideBitcoin.com is committed to safeguarding your privacy. Contact us at if you have any questions or problems regarding the use of your Personal Data and we will gladly assist you.

By using this site or/and our services, you consent to the Processing of your Personal Data as described in this Privacy Policy.

Table of Contents

  1. Definitions used in this Policy
  2. Data protection principles we follow
  3. What rights do you have regarding your Personal Data
  4. What Personal Data we gather about you
  5. How we use your Personal Data
  6. Who else has access to your Personal Data
  7. How we secure your data
  8. Information about cookies
  9. Contact information

Definitions

Personal Data – any information relating to an identified or identifiable natural person.
Processing – any operation or set of operations which is performed on Personal Data or on sets of Personal Data.
Data subject – a natural person whose Personal Data is being Processed.
Child – a natural person under 16 years of age.
We/us (either capitalized or not)

Data Protection Principles

We promise to follow the following data protection principles:

  • Processing is lawful, fair, transparent. Our Processing activities have lawful grounds. We always consider your rights before Processing Personal Data. We will provide you information regarding Processing upon request.
  • Processing is limited to the purpose. Our Processing activities fit the purpose for which Personal Data was gathered.
  • Processing is done with minimal data. We only gather and Process the minimal amount of Personal Data required for any purpose.
  • Processing is limited with a time period. We will not store your personal data for longer than needed.
  • We will do our best to ensure the accuracy of data.
  • We will do our best to ensure the integrity and confidentiality of data.

Data Subject’s rights

The Data Subject has the following rights:

  1. Right to information – meaning you have to right to know whether your Personal Data is being processed; what data is gathered, from where it is obtained and why and by whom it is processed.
  2. Right to access – meaning you have the right to access the data collected from/about you. This includes your right to request and obtain a copy of your Personal Data gathered.
  3. Right to rectification – meaning you have the right to request rectification or erasure of your Personal Data that is inaccurate or incomplete.
  4. Right to erasure – meaning in certain circumstances you can request for your Personal Data to be erased from our records.
  5. Right to restrict processing – meaning where certain conditions apply, you have the right to restrict the Processing of your Personal Data.
  6. Right to object to processing – meaning in certain cases you have the right to object to Processing of your Personal Data, for example in the case of direct marketing.
  7. Right to object to automated Processing – meaning you have the right to object to automated Processing, including profiling; and not to be subject to a decision based solely on automated Processing. This right you can exercise whenever there is an outcome of the profiling that produces legal effects concerning or significantly affecting you.
  8. Right to data portability – you have the right to obtain your Personal Data in a machine-readable format or if it is feasible, as a direct transfer from one Processor to another.
  9. Right to lodge a complaint – in the event that we refuse your request under the Rights of Access, we will provide you with a reason as to why. If you are not satisfied with the way your request has been handled please contact us.
  10. Right for the help of supervisory authority – meaning you have the right for the help of a supervisory authority and the right for other legal remedies such as claiming damages.
  11. Right to withdraw consent – you have the right withdraw any given consent for Processing of your Personal Data.

Data we gather

Information you have provided us with
This might be your e-mail address, name, billing address, home address etc – mainly information that is necessary for delivering you a product/service or to enhance your customer experience with us. We save the information you provide us with in order for you to comment or perform other activities on the website. This information includes, for example, your name and e-mail address.

Information automatically collected about you
This includes information that is automatically stored by cookies and other session tools. For example, your shopping cart information, your IP address, your shopping history (if there is any) etc. This information is used to improve your customer experience. When you use our services or look at the contents of our website, your activities may be logged.

Information from our partners
We gather information from our trusted partners with confirmation that they have legal grounds to share that information with us. This is either information you have provided them directly with or that they have gathered about you on other legal grounds. See the list of our partners here.

Publicly available information
We might gather information about you that is publicly available.

How we use your Personal Data

We use your Personal Data in order to:

  • provide our service to you. This includes for example registering your account; providing you with other products and services that you have requested; providing you with promotional items at your request and communicating with you in relation to those products and services; communicating and interacting with you; and notifying you of changes to any services.
  • enhance your customer experience;
  • fulfil an obligation under law or contract;

We use your Personal Data on legitimate grounds and/or with your Consent.

On the grounds of entering into a contract or fulfilling contractual obligations, we Process your Personal Data for the following purposes:

  • to identify you;
  • to provide you a service or to send/offer you a product;
  • to communicate either for sales or invoicing;

On the ground of legitimate interest, we Process your Personal Data for the following purposes:

  • to send you personalized offers* (from us and/or our carefully selected partners);
  • to administer and analyse our client base (purchasing behaviour and history) in order to improve the quality, variety, and availability of products/ services offered/provided;
  • to conduct questionnaires concerning client satisfaction;

As long as you have not informed us otherwise, we consider offering you products/services that are similar or same to your purchasing history/browsing behaviour to be our legitimate interest.

With your consent we Process your Personal Data for the following purposes:

  • to send you newsletters and campaign offers (from us and/or our carefully selected partners);
  • for other purposes we have asked your consent for;

We Process your Personal Data in order to fulfil obligation rising from law and/or use your Personal Data for options provided by law. We reserve the right to anonymise Personal Data gathered and to use any such data. We will use data outside the scope of this Policy only when it is anonymised. We save your billing information and other information gathered about you for as long as needed for accounting purposes or other obligations deriving from law, but not longer than 1 year.

We might process your Personal Data for additional purposes that are not mentioned here, but are compatible with the original purpose for which the data was gathered. To do this, we will ensure that:

  • the link between purposes, context and nature of Personal Data is suitable for further Processing;
  • the further Processing would not harm your interests and
  • there would be appropriate safeguard for Processing.

We will inform you of any further Processing and purposes.

Who else can access your Personal Data

We do not share your Personal Data with strangers. Personal Data about you is in some cases provided to our trusted partners in order to either make providing the service to you possible or to enhance your customer experience. We share your data with:

Our processing partners:

  • facebook.com
  • google.com
  • bing.com
  • twitter.com
  • pinterest.com

Our business partners:

  • facebook.com
  • google.com
  • bing.com
  • twitter.com
  • pinterest.com

Connected third parties:

  • facebook.com
  • google.com
  • bing.com
  • twitter.com
  • pinterest.com

We only work with Processing partners who are able to ensure adequate level of protection to your Personal Data. We disclose your Personal Data to third parties or public officials when we are legally obliged to do so. We might disclose your Personal Data to third parties if you have consented to it or if there are other legal grounds for it.

How we secure your data

We do our best to keep your Personal Data safe. We use safe protocols for communication and transferring data (such as HTTPS). We use anonymising and pseudonymising where suitable. We monitor our systems for possible vulnerabilities and attacks.

Even though we try our best we can not guarantee the security of information. However, we promise to notify suitable authorities of data breaches. We will also notify you if there is a threat to your rights or interests. We will do everything we reasonably can to prevent security breaches and to assist authorities should any breaches occur.

If you have an account with us, note that you have to keep your username and password secret.

Children

We do not intend to collect or knowingly collect information from children. We do not target children with our services.

Cookies and other technologies we use

We use cookies and/or similar technologies to analyse customer behaviour, administer the website, track users’ movements, and to collect information about users. This is done in order to personalize and enhance your experience with us.

A cookie is a tiny text file stored on your computer. Cookies store information that is used to help make sites work. Only we can access the cookies created by our website. You can control your cookies at the browser level. Choosing to disable cookies may hinder your use of certain functions.

We use cookies for the following purposes:

  • Necessary cookies – these cookies are required for you to be able to use some important features on our website, such as logging in. These cookies don’t collect any personal information.
  • Functionality cookies – these cookies provide functionality that makes using our service more convenient and makes providing more personalised features possible. For example, they might remember your name and e-mail in comment forms so you don’t have to re-enter this information next time when commenting.
  • Analytics cookies – these cookies are used to track the use and performance of our website and services
  • Advertising cookies – these cookies are used to deliver advertisements that are relevant to you and to your interests. In addition, they are used to limit the number of times you see an advertisement. They are usually placed to the website by advertising networks with the website operator’s permission. These cookies remember that you have visited a website and this information is shared with other organisations such as advertisers. Often targeting or advertising cookies will be linked to site functionality provided by the other organisation.

You can remove cookies stored in your computer via your browser settings. Alternatively, you can control some 3rd party cookies by using a privacy enhancement platform such as optout.aboutads.info or youronlinechoices.com. For more information about cookies, visit allaboutcookies.org.

We use Google Analytics to measure traffic on our website. Google has their own Privacy Policy which you can review here. If you’d like to opt out of tracking by Google Analytics, visit the Google Analytics opt-out page.

Read more about cookies on our Cookie Policy

Contact Information

email: contact@widebitcoin.com

Changes to this Privacy Policy

We reserve the right to make change to this Privacy Policy.

You can configure your Internet browser, by changing its options, to stop accepting cookies completely or to prompt you before accepting a cookie from the website you visit. If you do not accept cookies, however, you may not be able to use all portions of the WideBitcoin Websites or all functionality of the Services.

Please note that disabling these technologies may interfere with the performance and features of the Services.

You may also disable cookies on the WideBitcoin Sites by modifying your settings here:

Visitor comments may be checked through an automated spam detection service.

Last Update: May 25, 2018