
How to create a private Ethereum network - osmode
https://omarmetwally.wordpress.com/2017/07/25/how-to-create-a-private-ethereum-network/
======
omarforgotpwd
A blockchain is secure because in order to "hack" into the database you need
to have 51% of the computational power on the network to create the longest
chain. In a large network like Bitcoin or Ethereum the massive computational
power of the network ensures generating 51% of the compute power of the
network is near impossibly expensive. How secure is a private blockchain? If
there are only a few servers the network could be destroyed by just unplugging
a few machines, or plugging in a few more.

~~~
ym705
I recommend reading this: [https://blog.ethereum.org/2015/08/07/on-public-and-
private-b...](https://blog.ethereum.org/2015/08/07/on-public-and-private-
blockchains/) . In a private blockchain the reading and writing permissions
are controlled, therefore only selected nodes can write to it.

"The validators are known, so any risk of a 51% attack arising from some miner
collusion in China does not apply."

I guess you could still have attack from authorized nodes in your own
organization?

~~~
omarforgotpwd
Well, if you only need to maintain transactions within your own organization
and there is full trust, why not just use a simple SQL database to record
transactions instead of a much more expensive and complex blockchain? If there
are multiple parties, what's to stop one of the nodes from, say, buying 1000
GPU instances on EC2 and massively increasing their hashing power. Even if you
have some type of network control settings that only allow certain nodes
access to the network, the proof of work could be distributed and you could
just proxy the answer back to the machine that has access to the network.

~~~
wmf
The case for private ledgers is coordination among a moderate number of non-
anonymous mostly-untrusted entities. (Whether this case ever exists is left as
an exercise for the reader.) They can't use a central database but they don't
need mining either; variants of BFT can be used that work as long as (n/2)+1
entities are honest.

~~~
eterm
If things are non-anonymous, you are far far better off having highly fungible
but also highly audited databases.

Make it easy to do but also easy to undo anything, while also having a very
large amount of transparency in the system so any "bad actor" can be dealt
with swiftly.

That seems to work for the banking system, where any malicious transactions
are easily "reversed" (often just reversed on one side actually, 'paid for' by
insurance / banks) and a large amount of auditing which makes it possible to
clamp down on the bad actors quickly.

Abusing the system then no longer becomes a technical challenge so it removes
the possibility that someone with the right technical prowess can "break" the
system. Robbing a bank is the easiest thing in the world, just walk in and ask
for money, it's getting away with it that's difficult.

~~~
askmike
> That seems to work for the banking system, where any malicious transactions
> are easily "reversed" (often just reversed on one side actually, 'paid for'
> by insurance / banks) and a large amount of auditing which makes it possible
> to clamp down on the bad actors quickly.

I work for a bank on blockchain projects. It's almost never this simple. You'd
be suprised how much banking is paper based right now for the simple reason
that no party wants a central solution controlled by any other party.

~~~
mercer
That's fascinating. Could you tell more about that, or maybe provide a link to
more information? I find the topic interesting, and as a geek am inclined to
find blockchain stuff cool and useful, but I know very little about the real-
world situation/concerns.

~~~
askmike
A lot of companies in all kinds of sectors (finance, healthcare, etc) are
looking into blockchain (or DLT) because it allows for a database model that
is not centralised. This is great in situations where you don't fully trust
other parties you are doing business with.

A lot of these companies are doing experiments using private blockchains (like
the private ethereum network linked in OP). However depending on how much you
trust the "other" parties allowed to mine (or sign blocks), you might still
have the risk where one or more conspire against you and 51% attack you.
Periodically putting a blockheader of your private chain into a public
blockchain would be a great solution to this, as pulling off a 51% attack on
bitcoin is rather hard.

~~~
mercer
Thanks for the info! Do you perhaps have some suggestions for what a good
'next step' is when it comes to understanding all this in more detail?

------
keorn
Proof of work is not the right tool for private networks since it is not sybil
resistant in this context. [https://github.com/paritytech/parity/wiki/Demo-
PoA-tutorial](https://github.com/paritytech/parity/wiki/Demo-PoA-tutorial) is
another tutorial that uses a Proof of Authority consensus for an Ethereum-like
chain.

~~~
decentralised
PoW is not often used in consortium networks because there is no need for the
excess power usage when the blockchain network is not in the public domain and
participation is limited by some form of authority or centralised management
structure.

I'm not sure what you mean with sybil resistance in this context though. Do
you mean to say that PoA reduces the "51% attack" vector?

~~~
keorn
The way people try to use PoW for consortium networks does not cause excess
power usage: low difficulty, low powered device/s.

Anyone malicious that connects to the network can easily overpower the
existing validators. Sybil resistance is only the case if validators compete
with computation due to economic incentives. In consortium network the native
tokens have likely no/low value.

With PoA there are rules according to which validators are added/removed and
limits on block issuance that ensure fault tolerance.

~~~
decentralised
I'm not sure I agree with you re: overpowering the existing validators.

On a public blockchain, you need a proof that all nodes are acting in the best
interest of the network because there is no way of stopping anyone from
joining. The economic incentives play a huge part here as you mention.

On a private chain, you'll have some form of registration or centralised auth
which prevents "unknown" nodes from joining in the first place. If mining is
centralised, that means that trust is established "off-chain" so an external
sybil attack would not be a real threat.

Regarding the power usage and difficulty increase over time, I guess you could
keep the resource usage low for some time, but you'd need to re-write the
client software to prevent and increase in proportion to the number of blocks
created, which could have a negative effect on the network synchronisation, or
rate of inflation (coin issuance) if there is a token involved.

~~~
keorn
What is the point of blockchain if there is no fault tolerance, under your
private PoW scenario as soon as a single node goes rogue the security
guarantees disappear and the chain is messed up.

With this PoA you can keep a well functioning chain and kick misbehaving nodes
(up to 50% of validators for this consensus engine) in due time.

~~~
decentralised
I'm not sure I can agree with you. To my mind with a private blockchain there
is always off-chain trust or contract limiting access to the network. (edit:
regardless of the consensus algorithm used).

In order to re-write historic transactions, an attacker would need to convince
other participants to accept the new chain as valid and drop the old one,
which is would be prevented by the off-chain trust model in the first place.

A powerful "rogue" node that starts producing blocks with different validation
rules would be automatically ignored by other validator nodes who would not
recognise the blocks as valid, so here again the risk of a successful sybil
attack is limited.

Fault tolerance seems to be a red herring here because but I would rather ask
you to expand on what you mean.

~~~
keorn
First you need to understand what is a fault in this case. If you make use of
PoW the chain is picked on the basis of total difficulty, this means that if
any validator (already admitted by a centralised party) is hacked, then they
can very quickly produce a chain which gets accepted by all others as
canonical (with higher difficulty). This reverses any existing transactions
and requires significant extra-protocol action to mitigate.

With PoA there is no such ability, since the canonicality is not abusable.
Furthermore addition and removal of nodes can be decentralised and determined
according to any rules (since validators can be specified in a contract). This
makes it possible to include validators based on something like majority
voting.

~~~
decentralised
I understand that if one node is compromised, it can then be used to generate
malicious txs and the attacker can try to add them to a block it generates,
but why would you say the other validators accept such block(s) or
transactions in the first place?

It seems to me that a successful attack on a private blockchain requires the
attacker gaining access to both a "pre-approved" node and having the hashrate
majority needed to ensure its blocks are generated faster than the rest of the
network combined.

Some background: [https://coinjournal.net/vitalik-buterin-on-misconceptions-
in...](https://coinjournal.net/vitalik-buterin-on-misconceptions-in-the-
private-vs-public-blockchain-debate/) and
[https://www.reddit.com/r/ethereum/comments/48m9n6/vitalik_bu...](https://www.reddit.com/r/ethereum/comments/48m9n6/vitalik_buterin_on_misconceptions_in_the_private/)

------
coinfantastic
Especially given all the warnings in the post, I'm wondering why one would
want to do this? I imagine the ostensible answer is security, but given the
many recent posts about Solidity's poor design and the many recent heists due
to (non-obvious) smart contract bugs, why would anyone want to run a private
Ethereum network?

Is there a better alternative?

~~~
modalduality
One common use is to test out your new contract code without using real
ethereum. You could even imagine a time where you could run a fuzzer on your
contract to try to find bugs.

Personally I don't think there's a real risk of exposing your real Ethereum
wallet by setting up a testnet, as long as you only let localhost connect to
it.

~~~
6nf
Doesn't ETH have a testnet like Bitcoin?

~~~
JohnJamesRambo
Yes.

------
decentralised
Pretty good, I'm really happy to see the added focus on Ethereum here :-)

Since you are building a private network, you may also add a small script so
your nodes only mine on demand (i.e., when there are new transactions) which
will reduce the power usage on your machine and avoids having the difficulty
increase too quickly.

Save the script below as mine.js (for instance) and then in your geth startup
command, include it as `geth --networkid <your_networ_id> ...other params...
js ./mine.js`

`var mining_threads = 1

function checkWork() { if (eth.pendingTransactions.length > 0) { if
(eth.mining) return; console.log("== Pending transactions! Mining...");
miner.start(mining_threads); } else { miner.stop(); console.log("== No
transactions! Mining stopped."); } }

eth.filter("latest", function(err, block) { checkWork(); });
eth.filter("pending", function(err, block) { checkWork(); });

checkWork();`

I picked up this "trick" from Embark framework
([https://github.com/iurimatias/embark-
framework](https://github.com/iurimatias/embark-framework))

------
modalduality
Good article. I found while doing the same thing a lot of the information
online was out of date (for example referencing geth's built-in solc) and
unusable.

One addition--Geth 1.6 released a very nice interactive tool called puppeth
that creates genesis blocks and provisions testnets, I've found it easier than
doing everything myself.

Although once again there really wasn't any tutorial or documentation about
puppeth for Ethereum beginners, the only reference I could find was a
Taiwanese Ethereum meetup blogpost, which was mostly in Chinese.

------
quickthrower2
This is appealing as a way for testing contracts without paying the
rediculously high gas price. However is there any advantage of this over the
test Etherium network?

~~~
albertgoeswoof
if you're testing there are several free test eth nets that can be used either
locally or disributed

------
ym705
Hello osmode, if you'd like you could say hello there:
[https://ethereumdev.io/contact/](https://ethereumdev.io/contact/) Loved your
articles and looking to write blockchain creation and more after finishing
Solidity tutorials..

