concept node in category blockchain

This is an excerpt from Manning's book Blockchain in Action.

This is an excerpt from Manning's book Permissioned Blockchains in Action.
Figure 1.4 File downloads in the Torrent protocol. Notice how nodes with partial copies of files can still upload to other nodes. These shares are reported by each node independently using trackers.
![]()
Many clients were developed which incrementally reduced the downsides of the protocol. A side effect of the ease of file sharing was simplifying distribution of protected content, like movies and music. Naturally, regulators did not like that. They pressured Internet Service Providers to monitor torrent users and to threaten them with lawsuits. This highlighted another weakness in torrent: there is no user privacy or anonymity. You could easily find nodes through their IP addresses.
In the last chapter, we deployed our first multi-node network and talked a bit about consensus algorithms. We saw how nodes stay in sync over the data that has been put on the blockchain. And then we learned how to deploy a contract on to this network and how to send transactions to a deployed contract. However, we never really explained what a transaction is. We simply used it. In this chapter, we’ll get a better understanding of all they do and highlight their uses in DLT frameworks. While we are at it, we will look at the visibility of data in a DLT network to see what information transactions leak.
So, these four people decide to build a voting app on a blockchain so that everyone can verify that the votes were honestly tallied. They each spin up a node on their computers, start the consensus algorithm and deploy their voting contract. Every day they go to their terminal, type in their flavour choice and send a transaction. After everyone has voted, the contract picks the flavour with the most votes. Now, we want to avoid anyone voting twice so if we find two votes from one node, we invalidate both. Elegant system. They call this “Pizzaensus”.
Figure 6.5 Overview of the Pizzaensus system
![]()
This system works well. They pick their pizzas, check which had the most votes and then order the pizza. Until one day, Alice gets fired. Then, the company hires Emma to replace her. At this point, Dan, the system administrator, realizes that changing the nodes is quite difficult. He would have to learn these low level commands and then make sure that the ports aren’t misconfigured, etc. He decides it isn’t worth the bother and instead just gives Alice’s old computer to Emma which still has the old node running. Now Emma can participate in Pizzaensus with no change to any configuration. Problem solved.
Except Dan didn’t realize how angry Alice was at getting fired. She wants revenge. And so she wants to mess around with Pizzaensus. Before leaving the office, Alice made a copy of the private key of her node (which she had to have access to). Now, armed with this key, she can send transactions to the blockchain and the blockchain won’t be able to discern if it came from Alice or Emma. The key is the only identifier we have for nodes. You can see what happens next: Emma casts a vote and Alice maliciously casts a vote. The system sees two votes from the same key and disregards both. Emma doesn’t get a say. Poor Emma.
Figure 6.6 Alice’s attack on Pizzensus
![]()
The problem we’ve highlighted here is of course over-simplified but it touches upon a real problem that DLT systems have to deal with: employee churn. Employees leave, change positions or teams, get fired, get hired, die. In some sectors, such as retail, annual employee churn is over 100%! Clearly, if we are going to pitch DLTs as a technology for mass adoption then it needs to be able to deal with this fact of life. Adding or removing nodes is not an infrequent operation, its daily maintenance.
The permissioned blockchain community took a while to realize this fact. For example, until 2018, Hyperledger Burrow didn’t have a way to change the node configuration. You were stuck with the nodes you started off with. Even today, many mature frameworks have no (or very crude) support for reconfiguration. Interestingly enough, Burrow, having started off lagging in this domain, is now in our opinion the one with the most polished approach. While other frameworks make you go through config files and cryptic scripts, Burrow just hands you a nice admin transaction to use. Quorum, on the other hand, has a bit of a hybrid approach using both an admin transaction and some config files. We’ll take a look at this as soon as we do the first half of our coding assignment. Speaking of which:
Now comes the fun part. Open up the geth console on nodes 1 to 5 in separate terminal windows. If your console supports tabs then use those, it will make your life much simpler. If it doesn’t, then consider using a terminal multiplexer like tmux (https://github.com/tmux/tmux/). Terminal multiplexers allow you to create multiple terminals on a single screen. The ability to have multiple interactive console windows open and usable is crucial to working with distributed systems. You’ll be juggling back and forth between many windows representing multiple nodes and it becomes difficult to keep track of which window is which node without a neat tabbing/multiplexing solution. If you’re interested, Figure win shows how I have arranged my tabs for this exercise:
Figure 6.12 Using tabs to open multiple terminals on the same screen. Avoid juggling a bunch of windows if you can.
![]()
That deviation aside, let’s see how we can play this game. If you’ve opened the terminals as I have done, you should see the welcome message from the Geth console on 5 nodes. All of them should show that we are at block number 1. The first block was created in response to our contract deployment. Now, if you connect Remix to node1 then you will notice that the coinbase value shown by Geth is the same value as shown in Figure ident. A coinbase is simply the primary account used by a node. In the case of the 7-node example, every node has exactly one account, which by default is also its coinbase. This is in no way a necessity: it is possible, and indeed usual, for a single node to have multiple Ethereum accounts. We will learn how to deal with that arrangement in later chapters, for now, the 1 node = 1 account mental model is what we will work with.
Figure 6.13 The coinbase value shown in Geth is the account used in Remix. In this example, each node has only one account.
![]()
If you’ve been a good student and actually tested the contract in Remix when we asked you to then you know that to play the game, we first need to add the players’ accounts using the addPlayer function. For this, you need the account addresses of the four players. These, in the case of Quorum, are the coinbases of nodes 2-5. To call the addPlayer function from Geth console, we need to be in the node 1 terminal and execute the following commands:
web3.eth.defaultAccount = eth.accounts[0] var DealerContract = web3.eth.contract( <<Paste ABI here>> ) var Instance = DealerContract.at(" <<Contract address here>> “) Instance.addPlayer(“ <<Node 2 coinbase here>> “)Alternatively, you can also add players using the Remix interface functions as we have in the previous chapters. As for the commands here, the first statement is the only new piece: here we are explicitly setting our default account (the account used for all transactions) to the first account in the list of available accounts on this node. This needs to be done since the default account variable is sometimes undefined which can lead to errors when calling functions. Now, repeat the Instance.addPlayer command for nodes 3, 4 and 5 as well. Once that is done you are ready to let the players make their bets.
Navigate to the geth console on node 2 and execute the following commands:
web3.eth.defaultAccount = eth.accounts[0] var DealerContract = web3.eth.contract( <<Paste ABI here>> ) var Instance = DealerContract.at(" <<Contract address here>> “) Instance.makeBet(<<Bet value here>>)The first three commands are identical to the ones we executed on node 1, as you would expect. These are setting up “the environment” and that is identical for all nodes in this network. Do note that we have to make the bet for a particular player from its corresponding node: geth uses the private key associated with the account to sign the transaction. Thus, everyone on the network knows where a transaction came from. This is referred to as the provenance of the transaction.
The last command is the actual betting: the argument is the card you pick (a number between 1 and 13). Repeat the same set of commands on nodes 3, 4 and 5.