Introducing the Web Node — an in-browser Mina node that verifies blocks and transfers funds
It is always beneficial to decentralize a blockchain network across a multitude of nodes. Distributing control across multiple nodes improves the network’s ability to resist attackers.
Additional nodes provide critical redundancy for the network, ensuring it runs even if other nodes go offline. Each additional node further democratizes the blockchain and makes it even more transparent and fair, and by allowing more people to verify the blockchain state by themselves, the network becomes more efficient.
Why more people aren’t running blockchain nodes
However, most blockchain nodes capable of state verification require expensive hardware or lengthy setups that are often too complex for the majority of people to follow. We want to allow anyone to run a blockchain node, even those who are limited to slow-CPU and low-memory devices such as mobile phones, or those who lack technical knowledge.
The setup for a blockchain node can be challenging even for more experienced users, and it is especially difficult for those from a non-technical background. It often requires a very specific set of environments that could only be attained in certain distributions of Linux, or, barring that, by creating virtual environments in Docker or other programs.
If we want to ensure that Mina can be used by everyone, we need to make this installation process much simpler. Our ambition is to make it easy and reduce the hardware requirements to the point where anyone, even those from a non-technical background, can run their own node from virtually any kind of device.
A browser-based Mina node you can launch from any device
For that purpose, we have developed the Mina Web Node, a blockchain node that can be set up in a matter of seconds and configured through a standard internet browser such as Chrome or Firefox. The Web Node can be run on devices with slow CPUs and low memory. In fact, it has such low hardware requirements that you can even run it on your mobile phone.
The Mina Web Node presents a significant step towards further decentralization of the Mina blockchain’s network because it does not rely on the validity of data from any specific peer or group of peers, as it can verify the blockchain state by itself.
This is made possible because, unlike other blockchains, Mina nodes do not have to download and apply all of the blocks (starting from the genesis block) with their transactions to reconstruct the ledger, which is a very lengthy and resource-intensive process, requiring gigabytes of storage and taking hours or even days to complete. Additionally, in such blockchains, each node has to maintain all of the blocks so that new nodes can download them.
Over the P2P network, we receive a block along with a proof of the validity of all blocks in the blockchain, starting from the genesis block all the way up to the most recent block we’ve received. Unlike the case with other blockchains, we do not need to download and process the entire history of the blockchain to confirm the validity of the last block and its history (and therefore the validity of the entire blockchain).
Mina nodes can verify the blockchain state without reconstructing the ledger, but it’s still best for as many nodes as possible to maintain a copy of the ledger, so that we don’t run into data availability issues. Block producers need a copy of the ledger for producing blocks. Regardless, they don’t need to apply blocks since the genesis block.
Instead, for a Mina node to synchronize with the network, it queries its peers, reconstructs snapshots of the ledger, and then applies the most recent blocks on top to sync up with the most recent state. However, for the Web Node, we only need to maintain a partial ledger containing accounts that we are managing, which is really cheap to do.
The development of the Web Node is a major step forward in the decentralization of the Mina network. Without a Web Node, unless users are able to set up a block-producing node, then they had to query 3rd party nodes for information from the blockchain, with no way of verifying if this information is true.
Try out the Mina Web Node
Head over to the link below to test out the Berkley net (testnet) version of the Mina Web Node:
Wait until the Web Node has prepared loading inside your browser. The following steps need to be completed first:
1) Setting up browser for Web Node
The browser requires a specific environment for the Web Node to run, which is achieved by loading a Web Assembly (wasm) file. As mentioned previously, Web Assembly is a binary instruction format through which we can run code in a browser even if it’s written in languages other than javascript.
2) Getting ready to verify blocks
For verifying block SNARKs, we need to fetch a verifier index, which contains constants necessary for verifying a block for a given chain.
3) Connecting directly to Mina network
The Web Node has to connect directly to the Mina network via WebRTC, without using intermediaries.
4) Catching up with the network
The Web Node downloads the latest block and verifies it. In the demo version, this step also fetches the latest state of the demo account along with its Merkle proof from the peer’s ledger. Using the Merkle proof, we can verify that this account state is indeed part of the ledger with the hash that is part of a block we verified.
These four steps should take a total of 15 to 20 seconds. After the Web Node has finished loading, click on the blue button titled Continue.
Latest block
Once the Web Node has loaded, it will begin to automatically validate new blocks. In this part of the UI, you can see the number of the latest block verified by your Web Node, as well as the network on which it has been verified. Please note that the current demo version of the Web Node runs on the Berkeley Testnet, but a mainnet version is already in the works.
Account
Here are the details of your account, which you can also view in the Mina Explorer. In the current testnet version of the Web Node, you are assigned a random pre-funded account.
In the future mainnet version, users will be able to connect their own wallets, and we will strongly recommend that they use a Ledger hardware wallet for this purpose.
Latest Transaction
If you have already made a transaction, it will show up in this window after about 4 minutes, which is the time it takes for a block to be produced. You can also verify the confirmation of a transaction in the Mina Explorer.
To make your first transaction, click on the blue button titled Transfer funds found in the bottom-right corner of the Web Node’s UI.
This is the window in which you can input details for sending a transaction. Let’s take a closer look at each section:
Recipient
Here you enter the wallet address to which you want to send your tMINA funds.
Amount
Enter the amount of tMINA you want to send. Please note that the amount plus the fee cannot be higher than the balance of the account assigned to your Web Node.
Fee
The fee you wish to pay for the transaction to be processed. The higher the fee, the greater the priority with which your transaction will be processed.
Memo (optional)
If you want to, you can write a memo for your transaction. You can enter up to 32 characters.
Once all details have been inputted and checked, click on the blue Confirm transaction button to begin processing the transaction.
This will take you back to the transaction overview page of the Mina Web Node. In the Latest Transaction window, you can see the details of your pending transaction, including the recipient wallet’s address, the amount, the fee as well as the memo you wrote (if any). The transaction will also be allotted a unique Transaction hash.
All of these details can be also viewed on the Mina Explorer by clicking on the block Explorer button.
Wait some time (normally up to 4 minutes) until the status of the transaction changes to Applied.
Once the transaction’s status has been changed to Applied, your transaction has been successfully processed, which will reduce your tMINA balance by the sum you sent (plus the transaction fee) and credit the recipient’s wallet by that amount minus the transaction fee. You can confirm this by checking out the transaction in the Mina Explorer by clicking on the block Explorer link found in the upper right corner of the Latest Transaction window.
Currently, the Mina Web Node is limited to the Berkeley Testnet. We plan on developing a Mainnet implementation of the Web Node in the future. In the Mainnet version, users will be able to connect their own wallets. We also plan on improving support for smartphones, namely, optimizing the phone’s battery usage and reducing the amount of network IO that needs to be performed.
We are also paying close attention to user feedback from everyone who will try out the demo version of the Web Node. If you have any comments, suggestions or questions, feel free to contact me directly by email.
This is the first article about our work at OpenMina, and we hope that you are as excited as we are about the Mina Web Node! To read more about OpenMina and the Mina Web Node, subscribe to our Medium or visit our GitHub.