-
Notifications
You must be signed in to change notification settings - Fork 85
How to: Run a Grin node on Google Cloud for free
- Introduction
- Google Cloud Set up
- Provisioning an instance
- Building
- Syncing a floonet (testnet) Grin node
- Receiving some floonet grins
- Syncing a mainnet Grin node
- Future work
Thanks to Google Cloud's Always Free program, it's possible to create an instance on Cloud Compute that runs a full Grin node, 24/7, without it costing you anything. This is a cheap (free!) and fool-proof way to get a node up and running since it:
- Is not dependent on the compatibility of your computer or OS;
- Does not require you to open up ports on your network;
- Starts you off from a clean instance; and
- Allows you to follow instructions that are replicable.
The only requirement is that you are willing to sign up for a Google Cloud account and that you have a valid credit or debit card (which will not be charged).
NOTE: This is for testing purposes only. The node is free to run, but if you make mistakes in the configuration you may incur charges. Make sure you monitor your account and billing status regularly whilst running your instance to avoid any unpleasant surprises.
- Visit http://cloud.google.com and set up an account as an individual. This will require a debit or credit card, they do a $1 reserve charge on your card to ensure it's valid. As part of signing up you also get $300 in free trial credit to spend within 12 months.
- In order to qualify for Always Free you need to have an upgraded account. So ensure you upgrade. Note that this means that you will start to be charged automatically if your spend beyond the $300 in free trial credit. As you will not exceed the Always Free limits here, this point is moot, but keep it in mind for any other projects you use this account for.
- Launch a Cloud Shell console from your browser, or install the Google Cloud SDK to run Cloud Shell from your local terminal.
From the cloud shell, run the following command to create grin-node1
, an always free-compatible instance running Linux Debian 9:
gcloud beta compute instances create grin-node1 --zone=us-east1-b --machine-type=f1-micro --tags=grin-node --image=debian-9-stretch-v20180716 --image-project=debian-cloud --boot-disk-size=10GB --boot-disk-type=pd-standard --boot-disk-device-name=grin-disk1
Your newly created grin-node1
should now be visible in your list of Cloud Compute Instances. From there, open an SSH session in your browser by clicking the SSH
button, or SSH to the instance through your own terminal.
As always, first update your system:
sudo apt-get update
Install some tools:
- git
- pkg-config
- nano, a simple text editor
- tmux, which will allow you to run multiple terminal sessions and keep your node running on your instance once you disconnect remotely. See gentle intro and cheatsheet.
sudo apt-get install git nano tmux pkg-config
You can now enter a tmux session by tmux
and at any time you can close down your connection by CTRL+b
and then d
as in detach, and then return to it later by tmux a
as in attach.
Next install all dependencies:
- clang
- cmake
- ncurse
- zlibs
- openssl
sudo apt-get install clang cmake libncurses5-dev libncursesw5-dev zlib1g-dev libssl-dev
Install rust:
curl https://sh.rustup.rs -sSf | sh; source $HOME/.cargo/env
Clone grin and build a release version
git clone https://github.com/mimblewimble/grin.git
cd grin
cargo build --release
Building takes ~60 minutes on the grin-node1
instance. Slow, but it's free. Good time for a coffee break. Alternatively, you can skip the build process by downloading the latest Grin binary from here.
When the build has completed, create a new tmux
session and launch your Grin node in it:
tmux new -s floo
cd target/release
./grin --floonet
The node should automatically connect to peers and begin syncing. This might also take a while, so you might want to go for another break.
Once completed, the node should be at the same block height as https://floonet.grinscan.net/. We can now detach from the tmux session running the node by pressing ctrl+b
, then d
. This will allow us to continue interfacing with the gcloud instance command line, with the node running in the background. If you want to check in on the node at a later time, you can attach back into it's tmux session with tmux a -t floo
Have a fully synced node up and running? Congrats, you're a Grin user! Time to receive some grins.
On your physical machine, open a Cloud Shell console window, and set up a firewall rule to allow ingress tcp connections on port 13415 to grin-node1
so you can receive communication from other grin wallets:
gcloud compute firewall-rules create floo-wallet-port --direction=INGRESS --action=ALLOW --rules=tcp:13415 --target-tags=grin-node
Also obtain the internal and external IPs of your instance and write them down:
gcloud compute instances list
Now ssh back into grin-node1
. Initialize a wallet configuration, then edit grin-wallet.toml
to set api_listen_interface = "INTERNAL_IP"
where INTERNAL_IP
is the internal IP assigned to your instance by Google, which you obtained in the previous step.
cd ~/grin/target/release
./grin --floonet wallet init
cd ~/.grin/floo/
nano grin-wallet.toml
Edit, save, and exit grin-wallet.toml
, and then launch a grin wallet listener in a new tmux session:
cd ~/grin/target/release
tmux new -s floo-wl
./grin --floonet wallet listen
Detach from the wallet listener, and you're now ready to receive floonet grins. Try asking the GrinGod faucet for some. In a new terminal window on grin-node1
whilst your node and wallet listener are still running:
curl gringod.info
To check on the balance of your wallet, run:
./grin --floonet wallet info
And to view the transaction log:
./grin --floonet wallet txs
Now you can receive floonet grins from any other wallet on the network, simply give them your http://EXTERNAL_IP:13415
where EXTERNAL_IP is the external IP assigned to your instance by Google, which you obtained at the beginning of this section.
Note: Your external IP is ephemeral by default, so the moment you shut down or delete your instance, it will be released and you may not get the same assigned to you the next time you take an instance live. You can optionally choose to assign a static IP if you want to avoid, but that's beyond the scope of this document.
To sync and use a mainnet grin node and wallet, perform the above steps with the following modifications:
- omit the
--floonet
flag when running./grin
- substitute
floo
withmain
when navigating directories and managing tmux sessions - create a different firewall rule for the mainnet wallet port:
gcloud compute firewall-rules create main-wallet-port --direction=INGRESS --action=ALLOW --rules=tcp:3415 --target-tags=grin-node
- open up your node's p2p port so it can receive inbound connections
gcloud compute firewall-rules create main-p2p-port --direction=INGRESS --action=ALLOW --rules=tcp:3414 --target-tags=grin-node
- Updating your node
- Mining from your local set up to your Google Cloud node wallet
- Connecting to Grin-Pool
Basics
- Getting Started
- User Documentation
- MimbleWimble
- FAQ
- Planned releases (Roadmap)
- Code of Conduct
Contributing
- Contributing Guide
- Code Structure
- Code coverage and metrics
- Code Reviews and Audits
- Adding repos to /mimblewimble
Development
Mining
Infrastructure
Exchange integrations
R&D
Grin Community
Grin Governance
Risk Management
Grin Internals
- Block Header Data Structure
- Detailed validation logic
- P2P Protocol
Misc