5

I am trying to create my private Ethereum blockchain with homesteadBlock value that I want to assign. As I understand default homesteadBlock value is 1500000.

[Q] How could I assign homesteadBlock value to 0? And inside geth is it possible to check its value that it has been updated to 0? or how could I check that the homesteadBlock value is updated?

and more importantly how could I create my private Ethereum blockchain? I know there is many resources about this problem, but I could not find one for geth 1.4.17 version.

I am not sure if my private blockchain's homesteadBlock value is updated. Here is the way I have followed to create my private Ethereum blockchain from scratch:

First empty previous setup data:

[$] rm -rf ~/.ethash/* && rm -rf ~/.ethereum/*
[$] sudo rm -rf /home/miner/MyEthereumEbloc/  && mkdir /home/miner/MyEthereumEbloc/

Create an new account:

[$] sudo geth --datadir="/home/miner/MyEthereumEbloc/" account new

account new Address: {eda8c89a68f059c1659272076e85e4373717b0d8}

This address will be added into CustomGenesis.json file.

Setup CustomGenesis.json: This file should be same for all nodes that are connecting into the private ethereum network:

{
    "config": {
            "homesteadBlock": 0
    },
    "nonce": "0",
    "difficulty": "0x400",
    "mixhash": "0x00000000000000000000000000000000000000647572616c65787365646c6578",
    "coinbase": "0x0000000000000000000000000000000000000000",
    "timestamp": "0x00",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "0x",
    "gasLimit": "0x3B4A1B44",
    "alloc": {
        "0xeda8c89a68f059c1659272076e85e4373717b0d8":   //added line
        { "balance": "1000000000000000000000000000000" } //added line
    }
}

Blockchain Initialisation:

[$] sudo geth --datadir="/home/miner/MyEthereumEbloc/" init /home/CustomGenesis.json

Note, I can see updated balance, when I run:

sudo geth --datadir="/home/miner/MyEthereumEbloc/" console

primaryAddress = eth.accounts[0]
> web3.fromWei(eth.getBalance(primaryAddress), "ether")
1000000000000000000000000000000

To mine:

$ sudo ./geth --port 3000 --networkid 23422 --identity node1 --verbosity 3 
--nodiscover --nat none --datadir="/home/miner/MyEthereumEbloc" --mine
 --ipcpath /home/miner/MyEthereumEbloc/geth.ipc console

Thank you for your valuable help and time.

2 Answers 2

5

In order to change the Homestead block, you will need to recompile geth from source.

You can see the relevant line:

MainNetHomesteadBlock = big.NewInt(1150000)

Just change this to to

MainNetHomesteadBlock = big.NewInt(0)

and recompile using the instrutions

You can test that Homestead is enabled by compiling this contract:

contract TestHomestead{
    function test () constant returns(bool){
        return address(4).delegatecall(1);
    }
}

If you are in Homestead this will use very little gas (around 300) nod not return true. If you are in frontier, you will use all of the gas sent in the transaction and it will throw an exception.

0
1

This is part of the answer to How to call Library Function from a Contract? => [error] The contract code couldn't be stored, please check your gas amount. undefined.

I have set up my private blockchain with a custom homesteadBlock value using the following procedures:


1. Setup genesis.json

Wocket:ESE bok$ more genesis.json 
{
    "config": {
            "homesteadBlock": 10
    },
    "nonce": "0",
    "difficulty": "0x400",
    "mixhash": "0x00000000000000000000000000000000000000647572616c65787365646c6578",
    "coinbase": "0x0000000000000000000000000000000000000000",
    "timestamp": "0x00",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "0x",
    "gasLimit": "0x3B4A1B44",
    "alloc": {}
}


2. Password file

I created a password file testpassword containing my account password


3. Blockchain Initialisation Script

I created a script to initialise my blockchain:

Wocket:ESE bok$ more 02_runGethGenesisInit 
#!/bin/sh

geth --datadir /Users/bok/ESE/gethgenesis init /Users/bok/ESE/genesis.json
geth --datadir /Users/bok/ESE/gethgenesis --password testpassword account new

And I used chmod 700 02_runGethGenesisInit to set the executable bit.


4. Private Node Script

I created a script to start my private geth node in mining mode:

Wocket:ESE bok$ more 02_runGethGenesis 
#!/bin/sh

geth --datadir /Users/bok/ESE/gethgenesis --unlock 0 --password /Users/bok/ESE/testpassword --rpc --rpccorsdomain '*' --mine --minerthreads 1 console

And I used chmod 700 02_runGethGenesis to set the executable bit.


5. Browser Solidity

I downloaded Browser Solidity from https://github.com/ethereum/browser-solidity/tree/gh-pages.

I unzipped the files and loaded index.html into my web browser.


5. Start it all

I initialised my blockchain data using the following command:

Wocket:ESE bok$ ./02_runGethGenesisInit 

I started my node using the following command, and have been running it for a while:

Wocket:ESE bok$ ./02_runGethGenesis
...
I1015 09:56:14.364062 miner/worker.go:342] 🔨  Mined block (#5210 / f881b1be). Wait 5 blocks for confirmation
I1015 09:56:14.364333 miner/worker.go:539] commit new work on block 5211 with 0 txs & 0 uncles. Took 281.474µs
I1015 09:56:14.364360 miner/worker.go:435] 🔨 🔗  Mined 5 blocks back: block #5205
I1015 09:56:14.364492 miner/worker.go:539] commit new work on block 5211 with 0 txs & 0 uncles. Took 114.592µs
I1015 09:56:16.394886 miner/worker.go:342] 🔨  Mined block (#5211 / 420c7edc). Wait 5 blocks for confirmation
I1015 09:56:16.395189 miner/worker.go:539] commit new work on block 5212 with 0 txs & 0 uncles. Took 262.993µs
I1015 09:56:16.395222 miner/worker.go:435] 🔨 🔗  Mined 5 blocks back: block #5206


6. Testing For The Homestead Mode

I loaded the test script by @TjadenHess's answer to this question into Solidity Browser:

contract TestHomestead{
    function test () returns(bool){
        return address(4).delegatecall(1);
    }
}

I connected Solidity Browser to my local private node by clicking on the block icon and selecting Web3 Provider. I then clicked on Create to deploy the contract above to the blockchain. I clicked test and the message Transaction cost: 21657 gas. shows that my blockchain is in Homestead mode.

enter image description here

enter image description here

Note: If I alter the function to make it a constant function test () constant returns(bool){, I get the following results for a Homestead mode blockchain - true:

enter image description here

See section 7. below for the message displayed when the blockchain is in non-Homestead mode.


7. What Happens When My Node Is In Non-Homestead Mode

I connected Browser Solidity with a geth --dev blockchain:

geth --dev --datadir /Users/bok/ESE/gethdata --unlock 0 --password /Users/bok/ESE/testpassword --rpc --rpccorsdomain '*' --mine --minerthreads 1 console

I ran the same Homestead test code to produce the message Gas required exceeds limit: 50000000 showing that this --dev blockchain is in non-Homestead mode:

enter image description here

Note: If I alter the function to make it a constant function test () constant returns(bool){, I get the following results for a non-Homestead mode blockchain - false:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.