Skip to content

Instantly share code, notes, and snippets.

@tpmccallum
Last active January 31, 2018 07:20
Show Gist options
  • Save tpmccallum/818590856d070f2f18534d2490eb5570 to your computer and use it in GitHub Desktop.
Save tpmccallum/818590856d070f2f18534d2490eb5570 to your computer and use it in GitHub Desktop.
ethereum_private_network_housekeeping_go_git_geth

Housekeeping

To prepare the system type the following.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y build-essential

Installing Go

To get the Go package type the following.

cd ~

wget https://dl.google.com/go/go1.9.2.linux-amd64.tar.gz

Then verify the download by checking that the sha256sum results from the following command match that of the relevant sha256 checksum section on the < https://golang.org/dl/ > website.

sha256sum go1.9.2.linux-amd64.tar.gz To unpack the package, type the following (using sudo).

sudo tar -C /usr/local -xzf go1.9.2.linux-amd64.tar.gz

To ensure that the Go path is set for your user profile. Add the following line to the end of your ~/.profile file.

export PATH="$PATH:/usr/local/go/bin"

Log out and in (or reboot) to ensure the environment variables have taken. Test Go with the following command (confirm the version).

go version

The output should show the version.

go version go1.9.2 linux/amd64

Mining difficulty

As this will be a private network, we do not want the Ethereum installation to constantly increase the difficulty setting. We are just performing some testing, in a closed and private network, and as such want the quickest mining time available.

To set the difficulty at 1 statically, we need to open the following file in the source code (before compiling).

go-ethereum/consensus/ethash/consensus.go

Once we have this file open for editing, we need to go to the calcDifficulty function (currently on line 298).

https://github.com/ethereum/go-ethereum/blob/02aeb3d76652a4c0451e5c3734e6881aefe46249/consensus/ethash/consensus.go#L298

This function controls which difficulty adjustment function is called.

default Ethereum consensus file

In order to guarantee the lowest difficulty level (on an ongoing basis), we will need to strip out the case statement and simply return big.NewInt(1) for the entire function's execution.

return big.NewInt(1)

modified Ethereum consensus file

NOTE: Additional configuration and commands are required in relation to accounts, networks and configuration. Please hold off running any commands until reading the next few paragraphs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment