LoginSignup
4
2

More than 5 years have passed since last update.

イーサリアム1.8でプライベートネット作成したけど、難易度高すぎで掘れない対応

Last updated at Posted at 2018-02-26

[1.8] イーサリアムのプライベートネット作成したけど、難易度高すぎで掘れない対応

プライベートネットでイーサリアムを起動し、マイニングを実行していても、難易度が高すぎて一向に採掘ができない問題があった。(genesis.jsonの修正は試みた)

gethのコンソールで eth.getBlock(0) を実行してみた結果

eth.getBlock(0)
{
  difficulty: 17179869184,
  extraData: "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",

  ~ 省略 ~

  totalDifficulty: 17179869184,
  ~ 省略 ~
}

17179869184 !!??? difficulty高すぎワロたwww

デフォルト難易度を変えてしまえ!

go-ethereum(https://github.com/ethereum/go-ethereum)の
core/genesis.go の311行目に最初に生成するブロックの難易度を設定する箇所があったので強制的に変えて解決することにした。

修正前

// DefaultGenesisBlock returns the Ethereum main net genesis block.
func DefaultGenesisBlock() *Genesis {
    return &Genesis{
        Config:     params.MainnetChainConfig,
        Nonce:      66,
        ExtraData:  hexutil.MustDecode("0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa"),
        GasLimit:   5000,
        Difficulty: big.NewInt(17179869184),
        Alloc:      decodePrealloc(mainnetAllocData),
    }
}

ここの
Difficulty: big.NewInt(17179869184),

Difficulty: big.NewInt(1),

に変更する

修正後

// DefaultGenesisBlock returns the Ethereum main net genesis block.
func DefaultGenesisBlock() *Genesis {
    return &Genesis{
        Config:     params.MainnetChainConfig,
        Nonce:      66,
        ExtraData:  hexutil.MustDecode("0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa"),
        GasLimit:   5000,
        Difficulty: big.NewInt(1),
        Alloc:      decodePrealloc(mainnetAllocData),
    }
}

その後、 make all をして、build/bin/gethを用いて起動する (Go1.10を使用)

gethコンソール上で確認した結果

> miner.start()
null
> eth.blockNumber
13
> eth.blockNumber
13
> eth.blockNumber
15
> eth.blockNumber
70

できてる!!!

難易度も確認してみたら、マインングされていることが確認できました!

eth.getBlock(0)
{
  difficulty: 1,

  ~ 省略 ~

  totalDifficulty: 1,
  ~ 省略 ~
}

困った時は、ソースコードを直接かきかえような!!

おわり

4
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2