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

In order to communicate with the blockchain, we must use a blockchain client. Clients are software that can establish P2P communication channels with other customers, sign and broadcast transactions, mine, deploy and interact with smart contracts, and so on. Clients are often referred to as nodes.

The formal definition of the functions that Ethereum nodes must follow is defined in the Ethereum Yellow Book. The Yellow Book defines the functions, mining algorithms, and private/public key ECDSA parameters required for nodes on the network. It defines all the functionality that makes nodes fully compatible with ethereum clients.

Based on the Ethereum Yellow Book, anyone can create their own Ethereum node implementation in any language they see fit.

You can see the full list of clients here.

By far the most popular customers are Geth and Parity. The difference in implementation is mainly in the programming language chosen: Geth uses Golang, while Parity uses Rust.

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

The node type

When you join the Ethereum network, you can choose to run various types of nodes. The current options are:

  • Light node
  • Full node
  • Archive nodes

The Archive node is a special case of the full node, so we won’t cover it in detail. One of the best summaries of node types I’ve found is on Stack Exchange:

In general, we can classify node software into two types: full nodes and light (weight) nodes. The full node validates the block broadcast to the network. That is, they ensure that the transactions contained in the block (and the block itself) follow the rules defined in the Ethereum specification. They maintain the current state of the network (as defined by the Ethereum specification).

Non-compliant transactions and blocks are not used to determine the current state of the Ethereum network. For example, if A tries to send 100 Aethers to B, but A has 0 Ethers, and A block contains this transaction, the full node will realize that this does not follow Ethereum’s rules and reject the block as invalid. In particular, the execution of smart contracts is an example of trading. Whenever a smart contract is used in a transaction (for example, erC-20 tokens are sent), all full nodes must run all instructions to ensure that they reach the correct, agreed-upon next state of the blockchain.

There are many ways to get to the same state. For example, if A has 101 aether and gives A hundred of them to B to pay gas for 1 Aether in A single transaction, the end result will be that if A sends 100 1-aether transactions to B, it pays 0.01 aether per transaction (regardless of who receives the transaction fee). Knowing whether B is now allowed to send 100 aether is enough to know what B’s current balance is. A complete node that retains the entire transaction history is called a complete archive node. These must exist on the web to remain healthy.

The node can also choose to discard old data. If B wants to send 100 ether to C, it doesn’t matter how it gets it, as long as B’s account contains 100 ether. In contrast, the light node does not validate every block or transaction and may not have a copy of the current blockchain state. They rely on complete nodes to provide them with missing details (or just a lack of specific functionality). The advantage of lightweight nodes is that they can get up and running faster, can run on more computing/memory constrained devices, and don’t take up nearly as much storage space. On the downside, the other nodes have a trust factor (which varies by client and probabilistic/heuristic methods and can be used to reduce risk). Some complete clients include features for faster synchronization (for example, Parity’s Warp Sync).

Install the Geth

Installation instructions for Geth on various platforms (Windows, macOS, Linux) can be found here. The list is comprehensive and up to date, so I won’t cover it in this article.

Run the Geth

To start the Geth node, all you need to do is go to the terminal window and run Geth. When you do this, you should get something like 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 The 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 The main -.net genesis block INFO [06-03 | 11:03:14] Persisted trie from memory database nodes = 12356 size = 2.34 mB time = 48.31016 ms Gcnodes = 0 gctime gcsize = 0.00 B = 0 s livenodes = 1 livesize = 0.00 B 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 recentlocal full block      number=0 hash= d4e567... cb8fa3 td=17179869184 INFO [06-03|11:03:14] Loaded most recentlocal fast block      number=0 hash= d4e567... cb8fa3 td=17179869184 INFO [06-03|11:03:14] Regeneratedlocaltransaction 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://a4cb08519bc2bceecb8ad421871c624d5212888653bbaee309fda960f3c87ca7aa9855ee14684d521836ae88ad1986b8ca944348e97 6760d2bd1247ed3ca7628@[::]:30303 INFO [06-03|11:03:16] RLPx listener up self=enode://a4cb08519bc2bceecb8ad421871c624d5212888653bbaee309fda960f3c87ca7aa9855ee14684d521836ae88ad1986b8ca944348e97 6760d2bd1247ed3ca7628@[::]:30303 INFO [06-03|11:03:16] IPC endpoint opened url=/Users/mjvr/Library/Ethereum/geth.ipcCopy the code

After that, you should see new lines appear regularly, Geth says, “import new status” or “import new bulk” or “import new receipts.” States, sizes, and transactions are part of Ethereum’s Tree tries: they must be downloaded to synchronize your node with the Ethereum blockchain.

This process can take a long time, so you can choose to run such lightweight nodes.

geth --light
Copy the code

All Geth needs to do now is pull the latest bulk and rely on other full nodes to verify transactions using merkle proofs.

Access the Geth console

Now that you have created a node, you can access it by opening a new TAB in terminal and running the following command:

geth attach
Copy the code

This will connect the Geth console (a Javascript environment for communicating with the blockchain) to your running node. This can be done in full client mode or light mode.

After opening the console, type the following:

web3.eth.blockNumber
Copy the code

You should output a number (for example, 5631487) that represents the current block number of the Ethereum network.

Create a new account

To use blockchain, you need to have an account. With Geth, you can do this by running the following command in the terminal:

geth account new
Copy the code

When done, it will ask you for your password to protect your account. Make sure to use a secure password and store it securely.

When geth Account New is run, all geth does is update the files in the geth data directory (the directory where geth stores all necessary data, including block and bulk information). Directory location on each platform:

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

Access Geth from another client

When you start Geth, the client will automatically start the RPC server on port 8545. You can access the RPC server and its methods on this port by connecting to localhost:8545 using a library such as web3JS or web3j or manually calling it using curl or wGET.

See this article to learn how to connect to external tools that are running Geth instances that are private when you launch your own blockchain, or are exposed in the instructions above.

conclusion

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

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

Share some interactive online programming tutorials related to blockchain such as Ethereum, EOS and Bitcoin:

  • Java Ethereum development tutorial, mainly for Java and Android programmers for blockchain Ethereum development web3J details.
  • Python Ethereum is a detailed explanation of blockchain ethereum development by Python engineers using Web3.py.
  • PHP Ethereum, mainly introduces the use of PHP for smart contract development interaction, account creation, transactions, transfers, token development, filters and transactions and other content.
  • Ethereum introductory course, mainly introduces smart contract and DAPP application development, suitable for entry.
  • Ethereum development advanced tutorial, mainly introduces the use of Node.js, mongodb, blockchain, IPFS to achieve decentralized e-commerce DApp combat, suitable for advanced.
  • C# ethereum, mainly explains how to use C# based development. Net ethereum applications, including account management, status and transactions, smart contract development and interaction, filters and transactions, etc.
  • This course will help you get a quick start on the development of EOS blockchain decentralized applications. It covers core knowledge points such as EOS tool chain, account and wallet, issuing tokens, development and deployment of smart contracts, and interaction between codes and smart contracts. Finally, the development of a notepad DApp will be completed using all knowledge points comprehensively.
  • Java development tutorial COINS, this course for beginners, content covers the core concepts of COINS, such as block mechanism, key chain store, decentralized consensus and script, trading and UTXO etc, also explained how to integrate the currency support functions in Java code, such as creating address wallet, tectonic naked trading, management, Is a rare bitcoin development course for Java engineers.
  • PHP currency development tutorial, this course for beginners, content covers the core concepts of COINS, such as block mechanism, key chain store, decentralized consensus and script, trading and UTXO etc, also explained how to integrated the currency support functions in PHP code, such as creating address wallet, tectonic naked trading, management, This is a rare bitcoin development course for Php engineers.
  • Tendermint blockchain development in detail, this course is suitable for engineers who want to use Tendermint blockchain development, the course content includes the core concepts of tendermint application development model, such as ABCI interface, Merkle tree, multi-version state library, etc., also includes the rich practical code such as token issuance. It is the best choice for go language engineers to quickly start blockchain development.

Huizhi net original translation, reprint please indicate the source. Here is the original Geth introduction and how to run ethereum node