github.com/isti4github/eth-ecc@v0.0.0-20201227085832-c337f2d99319/tutorial.md (about) 1 # Build private network and test 2 Project PI : Heung-No Lee 3 4 Email : heungno@gist.ac.kr 5 6 Writer : Hyoungsung Kim(김형성) 7 8 Email : hyoungsung@gist.ac.kr / rktkek456@gmail.com 9 10 Github for this example : https://github.com/cryptoecc/ETH-ECC 11 12 For more information : [INFONET](https://infonet.gist.ac.kr/) 13 14 - Eth-ECC is an Ethereum blockchain which INFONET has made public at github. The new characteristic of this blockchain is to enable ECCPoW a new protocol for time-varying proof-of-work generation system. 15 - This package is designed to run in Linux-environment. For this you need to download and install Linux-mint (see below). If you are Windows users, you need to install the Linux-mint first. If you are Linux users, you may skip this part. 16 - Under the assumption that you are in a Linux environment, you may follow this note to proceed. This note is to illustrate how to locate the Eth-ECC package at the github link, download, install, and run Eth-ECC in a local computer. 17 18 --- 19 20 Contents 21 22 1. [Environment](#1-environment) 23 1. [Download](#11-download) 24 2. [Install](#12-install) 25 2. [Run Eth-ECC in your local computer](#2-run-eth-ecc-in-your-local-computer) 26 1. [Configuration of Eth-ECC network options using puppeth](#21-configuration-of-eth-ecc-network-options-using-puppeth) 27 2. [Set the directory path for block data stroage](#22-set-the-directory-path-for-block-data-stroage) 28 3. [Run Eth-ECC](#23-run-eth-ecc) 29 3. [Test Eth-ECC](#3-test-eth-ecc) 30 1. [Basic tests](#31-basic-tests) 31 2. [Make a transaction for testing private network](#32-make-a-transaction-for-testing-private-network) 32 3. [(Appendix) Block generation time log](#33-appendix-block-generation-time-log) 33 34 --- 35 36 ## 1. Environment 37 For Windows, please visit [Windows instruciton](https://github.com/cryptoecc/ETH-ECC/blob/master/docs/eccpow%20windows%20instuction/Windows%20install%20instruction.md) before start. 38 Eth-ECC package uses the follow two environment 39 40 - Linux mint 19.1 or Linux manjaro 19.0.0 41 - Go (version 1.10 or later) develope language 42 43 You can follow two step below to download Eth-ECC and install(build) 44 45 ### 1.1 Download 46 47 Download can be done as follows 48 49 - First `clone` Eth-ECC repository to a directory that you want to locate Eth-ECC 50 - For `clone`, open terminal in the driectory and type command below 51 52 ``` 53 $ git clone https://github.com/cryptoecc/ETH-ECC.git 54 ``` 55 56 Then Eth-ECC will be downloaded. 57 58 ### 1.2 Installation of Eth-ECC 59 60 - Installation of Eth-ECC can be done as follows 61 62 After download is completed, move to `ETH-ECC` directory, open terminal and type this command 63 64 ``` 65 $ make all 66 ``` 67 68 If build is successful then you can see `geth` in /ETH-ECC/build/bin 69 70 ![you can see the geth in bin folder](./img/geth-directory.png) 71 72 ## 2. Run Eth-ECC in your local computer 73 74 In this chapter, we will follow three steps 75 76 - Configure Eth-ECC environment. 77 - In order to run Eth-ECC, you need to configure the network settings. They include chainID, network name, and consensus algorithm. This is done with `./puppeth` command. 78 - Set the directory path for block data stroage 79 - Run Eth-ECC 80 81 ### 2.1 Configuration of Eth-ECC environment 82 83 - For our network, we have to make a `genesis file` first 84 - `genesis file` includes network settings(chainID, network name and consensus algorithm) 85 - You need to find `puppet` which is located in same directory(/Eth-ECC/build/bin) with `geth` 86 87 Run `puppeth` and follow the steps below 88 89 ``` 90 ./puppeth 91 ``` 92 93 ``` 94 [hskim@hskim-pc bin]$ ./puppeth 95 +-----------------------------------------------------------+ 96 | Welcome to puppeth, your Ethereum private network manager | 97 | | 98 | This tool lets you create a new Ethereum network down to | 99 | the genesis block, bootnodes, miners and ethstats servers | 100 | without the hassle that it would normally entail. | 101 | | 102 | Puppeth uses SSH to dial in to remote servers, and builds | 103 | its network components out of Docker containers using the | 104 | docker-compose toolset. | 105 +-----------------------------------------------------------+ 106 107 Please specify a network name to administer (no spaces, hyphens or capital letters please) 108 > eccpow1 109 110 Sweet, you can set this via --network=eccpow1 next time! 111 112 INFO [02-14|21:21:23.414] Administering Ethereum network name=eccpow1 113 WARN [02-14|21:21:23.414] No previous configurations found path=/home/hskim/.puppeth/eccpow1 114 115 What would you like to do? (default = stats) 116 1. Show network stats 117 2. Configure new genesis 118 3. Track new remote server 119 4. Deploy network components 120 > 2 121 122 What would you like to do? (default = create) 123 1. Create new genesis from scratch 124 2. Import already existing genesis 125 > 1 126 127 Which consensus engine to use? (default = clique) 128 1. Ethash - proof-of-work 129 2. Clique - proof-of-authority 130 3. EccPoW - proof-of-work with LDPC 131 > 3 132 133 Which accounts should be pre-funded? (advisable at least one) 134 > 0x 135 136 Should the precompile-addresses (0x1 .. 0xff) be pre-funded with 1 wei? (advisable yes) 137 > 138 139 Specify your chain/network ID if you want an explicit one (default = random) 140 > 12345 141 INFO [02-14|21:21:58.917] Configured new genesis block 142 143 What would you like to do? (default = stats) 144 1. Show network stats 145 2. Manage existing genesis 146 3. Track new remote server 147 4. Deploy network components 148 > 2 149 150 1. Modify existing configurations 151 2. Export genesis configurations 152 3. Remove genesis configuration 153 > 2 154 155 Which folder to save the genesis specs into? (default = current) 156 Will create eccpow1.json, eccpow1-aleth.json, eccpow1-harmony.json, eccpow1-parity.json 157 > 158 INFO [02-14|21:22:02.800] Saved native genesis chain spec path=eccpow1.json 159 ERROR[02-14|21:22:02.800] Failed to create Aleth chain spec err="unsupported consensus engine" 160 ERROR[02-14|21:22:02.800] Failed to create Parity chain spec err="unsupported consensus engine" 161 INFO [02-14|21:22:02.803] Saved genesis chain spec client=harmony path=eccpow1-harmony.json 162 163 What would you like to do? (default = stats) 164 1. Show network stats 165 2. Manage existing genesis 166 3. Track new remote server 167 4. Deploy network components 168 > ^C 169 ``` 170 - `eccpow1` is name of genesis file 171 - you can see `eccpow1.json` in directory 172 - `chainID` is 12345. You can change it, but you have to avoid already defined `chainID` 173 - You can exit using `ctrl` + `c` 174 175 `chainID` is the most important part of this process. Because, geth can recognize a network using `chainID`. In ethereum network, There are already defined `chainIDs`. you can see more detail from [here](https://github.com/ethereumbook/ethereumbook/issues/110) 176 177 ``` 178 0: Olympic; Ethereum public pre-release testnet 179 1: Frontier; Homestead, Metropolis, the Ethereum public main network 180 1: Classic; The (un)forked public Ethereum Classic main network, chain ID 61 181 1: Expanse; An alternative Ethereum implementation, chain ID 2 182 2: Morden; The public Ethereum testnet, now Ethereum Classic testnet 183 3: Ropsten; The public cross-client Ethereum testnet 184 4: Rinkeby: The public Geth Ethereum testnet 185 42: Kovan; The public Parity Ethereum testnet 186 77: Sokol; The public POA testnet 187 99: POA; The public Proof of Authority Ethereum network 188 7762959: Musicoin; The music blockchain 189 ``` 190 191 Except these, you can use any `chainId` like 12345 what i did. 192 193 ### 2.2 Set the directory path for block data stroage 194 195 Now we have to make a directory to store information. I made `geth-test` folder. You can make it anywhere. my directory is `/home/hskim/Documents/geth-test` 196 197 Move to `/Eth-ECC/build/bin`, open terminal and follow it 198 199 ``` 200 $ ./geth --datadir your_own_storage init genesis_file_name.json 201 ``` 202 203 For example, in my case 204 205 ``` 206 (EXAMPLE) $ ./geth --datadir /home/hskim/Documents/geth-test init eccpow1.json 207 ``` 208 209 Once the above is initiated, the following terminal message shows up. 210 211 ``` 212 INFO [08-06|20:49:41.266] Bumping default cache on mainnet provided=1024 updated=4096 213 INFO [08-06|20:49:41.268] Maximum peer count ETH=50 LES=0 total=50 214 INFO [08-06|20:49:41.268] Smartcard socket not found, disabling err="stat /run/pcscd/pcscd.comm: no such file or directory" 215 INFO [08-06|20:49:41.271] Allocated cache and file handles database=/home/hskim/Documents/geth-test/geth/chaindata cache=16.00MiB handles=16 216 INFO [08-06|20:49:41.284] Writing custom genesis block 217 INFO [08-06|20:49:41.284] Persisted trie from memory database nodes=0 size=0.00B time=3.725µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B 218 INFO [08-06|20:49:41.285] Successfully wrote genesis state database=chaindata hash=ab944c…55600c 219 INFO [08-06|20:49:41.285] Allocated cache and file handles database=/home/hskim/Documents/geth-test/geth/lightchaindata cache=16.00MiB handles=16 220 INFO [08-06|20:49:41.302] Writing custom genesis block 221 INFO [08-06|20:49:41.302] Persisted trie from memory database nodes=0 size=0.00B time=3.632µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B 222 INFO [08-06|20:49:41.303] Successfully wrote genesis state database=lightchaindata hash=ab944c…55600c 223 ``` 224 225 After that, you can see geth and keystore folders in your storage folder: 226 227 ![geth-test folder](./img/geth-test.png) 228 229 ### 2.3 Run Eth-ECC 230 231 Open terminal in `/Eth-ECC/build/bin` and follow it 232 233 ``` 234 $ ./geth --datadir Your_own_storage --networkid YOUR_NETWORK_ID console 235 ``` 236 237 We set the `chainid` as 12345 when we make genesis file(In this example, genesis file name is `eccpow1.json`). Therefore our `networkid` is 12345 too 238 239 In my case, 240 241 ``` 242 (EXAMPLE) $ ./geth --datadir /home/hskim/Documents/geth-test --networkid 12345 console 243 ``` 244 245 Then you can see 246 247 ``` 248 INFO [08-06|21:27:43.867] Maximum peer count ETH=50 LES=0 total=50 249 INFO [08-06|21:27:43.867] Smartcard socket not found, disabling err="stat /run/pcscd/pcscd.comm: no such file or directory" 250 INFO [08-06|21:27:43.870] Starting peer-to-peer node instance=Geth/v1.9.2-unstable-aa6005b4-20190805/linux-amd64/go1.12.7 251 INFO [08-06|21:27:43.870] Allocated trie memory caches clean=256.00MiB dirty=256.00MiB 252 INFO [08-06|21:27:43.870] Allocated cache and file handles database=/home/hskim/Documents/geth-test/geth/chaindata cache=512.00MiB handles=524288 253 INFO [08-06|21:27:43.904] Opened ancient database database=/home/hskim/Documents/geth-test/geth/chaindata/ancient 254 INFO [08-06|21:27:43.904] Initialised chain configuration config="{ChainID: 12345 Homestead: 0 DAO: <nil> DAOSupport: false EIP150: <nil> EIP155: 0 EIP158: 0 Byzantium: <nil> Constantinople: <nil> Petersburg: <nil> Engine: unknown}" 255 INFO [08-06|21:27:43.904] Disk storage enabled for ethash caches dir=/home/hskim/Documents/geth-test/geth/ethash count=3 256 INFO [08-06|21:27:43.904] Disk storage enabled for ethash DAGs dir=/home/hskim/.ethash count=2 257 INFO [08-06|21:27:43.904] Initialising Ethereum protocol versions=[63] network=12345 dbversion=7 258 INFO [08-06|21:27:43.944] Loaded most recent local header number=0 hash=ab944c…55600c td=400 age=50y3mo3w 259 INFO [08-06|21:27:43.944] Loaded most recent local full block number=0 hash=ab944c…55600c td=400 age=50y3mo3w 260 INFO [08-06|21:27:43.944] Loaded most recent local fast block number=0 hash=ab944c…55600c td=400 age=50y3mo3w 261 INFO [08-06|21:27:43.945] Loaded local transaction journal transactions=0 dropped=0 262 INFO [08-06|21:27:43.945] Regenerated local transaction journal transactions=0 accounts=0 263 INFO [08-06|21:27:43.951] Allocated fast sync bloom size=512.00MiB 264 INFO [08-06|21:27:43.951] Initialized fast sync bloom items=0 errorrate=0.000 elapsed=37.353µs 265 INFO [08-06|21:27:43.997] New local node record seq=3 id=65c5b16ab4aa9e9f ip=127.0.0.1 udp=30303 tcp=30303 266 INFO [08-06|21:27:43.998] Started P2P networking self=enode://3e6e6cc9fd56954e02f3807813e086827ddf0576d0c969f67a915691ec3f879867332ba4911048fd513672856c63a2746063706005c6d777f670ae16c2c4a384@127.0.0.1:30303 267 INFO [08-06|21:27:43.999] IPC endpoint opened url=/home/hskim/Documents/geth-test/geth.ipc 268 WARN [08-06|21:27:44.088] Served eth_coinbase reqid=3 t=16.874µs err="etherbase must be explicitly specified" 269 Welcome to the Geth JavaScript console! 270 271 instance: Geth/v1.9.2-unstable-aa6005b4-20190805/linux-amd64/go1.12.7 272 at block: 0 (Thu, 01 Jan 1970 09:00:00 KST) 273 datadir: /home/hskim/Documents/geth-test 274 modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0 275 > 276 ``` 277 278 At last line, you can see console pointer(>). 279 280 There are some lines of the box above that we need to check 281 282 ``` 283 INFO [08-06|21:27:43.904] Initialised chain configuration config="{ChainID: 12345 Homestead: 0 DAO: <nil> DAOSupport: false EIP150: <nil> EIP155: 0 EIP158: 0 Byzantium: <nil> Constantinople: <nil> Petersburg: <nil> Engine: unknown}" 284 ``` 285 286 In this line, we can check ChainID is 12345. 287 288 Now our Eth-ECC network is running! 289 290 ## 3. Test Eth-ECC 291 292 1. Basic tests 293 - We will make an account, mine block and check result of mining 294 2. Make a transaction 295 3. (Appendix) Block generation time log 296 297 ### 3.1 Basic tests 298 299 In this test, we will follow 3 steps 300 301 - Generate account 302 - Check account's balance 303 - Mining 304 305 Now let's test our private network 306 307 ``` 308 > eth.blockNumber 309 0 310 > eth.accounts 311 [] 312 ``` 313 314 `eth.blockNumber` check the number of blocks. We just generate this network. Therefore there is 0 block. `eth.account` check accounts of network. There are no accounts. 315 316 #### Generate account 317 318 Let's generate account 319 320 ``` 321 > personal.newAccount("Alice") 322 INFO [08-06|21:33:36.241] Your new key was generated address=0xb8C941069cC2B71B1a00dB15E6E00A200d387039 323 WARN [08-06|21:33:36.241] Please backup your key file! path=/home/hskim/Documents/geth-test/keystore/UTC--2019-08-06T12-33-34.442823142Z--b8c941069cc2b71b1a00db15e6e00a200d387039 324 WARN [08-06|21:33:36.241] Please remember your password! 325 "0xb8c941069cc2b71b1a00db15e6e00a200d387039" 326 ``` 327 328 We just generated the address of Alice:`0xb8C941069cC2B71B1a00dB15E6E00A200d387039`. We can check using geth 329 330 ``` 331 > eth.accounts 332 ["0xb8c941069cc2b71b1a00db15e6e00a200d387039"] 333 ``` 334 335 we will use it as miner's address so block generation reward will be sent to Alice's address 336 337 #### Check account's balance 338 339 Before mining, let's check Alice's balance 340 341 ``` 342 > eth.getBalance("0xb8c941069cc2b71b1a00db15e6e00a200d387039") 343 0 344 > eth.getBalance(eth.accounts[0]) 345 0 346 ``` 347 348 There are 2 ways to check balance. 349 350 - First, using address directly 351 - Second, using random access of `eth.accounts`. Alice's account is first account of our network. so we can call it as `eth.account[0]` 352 353 I will use first one in this example to avoid confusion. 354 355 As we expect, there is no ether at all. Let's do mining. 356 357 #### Mining 358 359 First we have to set miner's address. For this, we will use 3 commands 360 361 - miner.setEtherbase(address) 362 - It sets miner's address. Mining reward will be sent to this account 363 - miner.start(number of threads) 364 - Start mining. You can set how many threads you will use. I will use 1 thread 365 - If your CPU has enough core, you can use higher number. It will work faster. 366 - miner.stop() 367 - Stop mining 368 369 ``` 370 > miner.setEtherbase("0xb8c941069cc2b71b1a00db15e6e00a200d387039") 371 true 372 > miner.start(1) 373 null 374 INFO [08-06|21:42:38.198] Updated mining threads threads=1 375 INFO [08-06|21:42:38.198] Transaction pool price threshold updated price=1000000000 376 null 377 > INFO [08-06|21:42:38.198] Commit new mining work number=1 sealhash=4bb421…3f463a uncles=0 txs=0 gas=0 fees=0 elapsed=325.066µs 378 INFO [08-06|21:42:40.752] Successfully sealed new block number=1 sealhash=4bb421…3f463a hash=4b2b78…4808f6 elapsed=2.554s 379 INFO [08-06|21:42:40.752] 🔨 mined potential block number=1 hash=4b2b78…4808f6 380 381 . 382 . 383 . 384 385 INFO [08-06|21:42:56.174] 🔨 mined potential block number=9 hash=2faebb…8be693 386 INFO [08-06|21:42:56.174] Commit new mining work number=10 sealhash=384aa6…cb0596 uncles=0 txs=0 gas=0 fees=0 elapsed=179.463µs 387 > miner.stop() 388 null 389 ``` 390 391 We finished mining. Now let's check it worked well. 392 393 ``` 394 > eth.blockNumber 395 9 396 ``` 397 398 In my case, I mined 9 blocks until I stop it. 399 400 ``` 401 > eth.getBalance("0xb8c941069cc2b71b1a00db15e6e00a200d387039") 402 45000000000000000000 403 ``` 404 405 Wow! we got a reward. Exactly `wei`, not `ether`. wei is small unit of ether like satoshi of bitcoin 406 407 ``` 408 1 ether = 10^18 wei 409 ``` 410 411 We can convert it to ether by command 412 413 ``` 414 > web3.fromWei(eth.getBalance("0xb8c941069cc2b71b1a00db15e6e00a200d387039"), "ether") 415 45 416 ``` 417 418 Yeah! we got 45 ether. But why 45 ether? To know it, we have to see the source code of geth(go-ethereum) 419 420 ```go 421 //go-ethereum/consensus/ethash/consensus.go 422 func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header *types.Header, uncles []*types.Header) { 423 // Select the correct block reward based on chain progression 424 blockReward := FrontierBlockReward 425 if config.IsByzantium(header.Number) { 426 blockReward = ByzantiumBlockReward 427 } 428 if config.IsConstantinople(header.Number) { 429 blockReward = ConstantinopleBlockReward 430 } 431 // Accumulate the rewards for the miner and any included uncles 432 reward := new(big.Int).Set(blockReward) 433 r := new(big.Int) 434 for _, uncle := range uncles { 435 r.Add(uncle.Number, big8) 436 r.Sub(r, header.Number) 437 r.Mul(r, blockReward) 438 r.Div(r, big8) 439 state.AddBalance(uncle.Coinbase, r) 440 441 r.Div(blockReward, big32) 442 reward.Add(reward, r) 443 } 444 state.AddBalance(header.Coinbase, reward) 445 } 446 ``` 447 448 In this function, `blockReward` is initialized as `FrontierBlockReward`. 449 450 Let's see what is `FrontierBlockReward` 451 452 ```go 453 //go-ethereum/consensus/ethash/consensus.go 454 var ( 455 FrontierBlockReward = big.NewInt(5e+18) // Block reward in wei for successfully mining a block 456 ByzantiumBlockReward = big.NewInt(3e+18) // Block reward in wei for successfully mining a block upward from Byzantium 457 ConstantinopleBlockReward = big.NewInt(2e+18) // Block reward in wei for successfully mining a block upward from Constantinople 458 maxUncles = 2 // Maximum number of uncles allowed in a single block 459 allowedFutureBlockTime = 15 * time.Second // Max time from current time allowed for blocks, before they're considered future blocks 460 . 461 . 462 . 463 ) 464 ``` 465 466 `FrontierBlockReward` is set as 5 * 10^18 and it is 5 ether. Alice generated 9 blocks and got 5 ether per generation. Therefore Alice got 45 ether. 467 468 ### 3.2 Make a transaction for testing private network 469 470 In this section, we want to generate transaction and send ether 471 472 - We will make a new account(Bob) and will send ether from miner(Alice) to new account(Bob) 473 474 Generate new account 475 476 ``` 477 > personal.newAccout("Bob") 478 INFO [08-06|22:00:23.416] Your new key was generated address=0xf39Cf42Cd233261cd2b45ADf8fb1E5A1e61A6f90 479 WARN [08-06|22:00:23.416] Please backup your key file! path=/home/hskim/Documents/geth-test/keystore/UTC--2019-08-06T13-00-21.621172635Z--f39cf42cd233261cd2b45adf8fb1e5a1e61a6f90 480 WARN [08-06|22:00:23.416] Please remember your password! 481 "0xf39cf42cd233261cd2b45adf8fb1e5a1e61a6f90" 482 483 > eth.getBalance("0xf39cf42cd233261cd2b45adf8fb1e5a1e61a6f90") 484 0 485 ``` 486 487 I got account of Bob:`0xf39cf42cd233261cd2b45adf8fb1e5a1e61a6f90` Alice will send ether to Bob's account 488 489 ``` 490 > eth.sendTransaction({from: "0xb8c941069cc2b71b1a00db15e6e00a200d387039", to: "0xf39cf42cd233261cd2b45adf8fb1e5a1e61a6f90", value: web3.toWei(5, "ether")}) 491 ``` 492 493 Let's send 5 ether to Bob's account 494 495 - Alice's account : `0xb8c941069cc2b71b1a00db15e6e00a200d387039` 496 - Bob's account : `0xf39cf42cd233261cd2b45adf8fb1e5a1e61a6f90` 497 498 Or we can initialize these using variable 499 500 ``` 501 > from = "0xb8c941069cc2b71b1a00db15e6e00a200d387039" 502 > to = "0xb8c941069cc2b71b1a00db15e6e00a200d387039" 503 > eth.sendTransaction({from: from, to: to, value: web3.toWei(5, "ether")}) 504 ``` 505 506 We have to unlock Alice's account. Let's see status of Alice's account. 507 508 ``` 509 > personal.listWallets[0].status 510 "Locked" 511 ``` 512 513 Yes It is locked. So we have to unlock it to send ether from Alice to Bob 514 515 ``` 516 > web3.personal.unlockAccount("0xb8c941069cc2b71b1a00db15e6e00a200d387039") 517 Unlock account 0xb8c941069cc2b71b1a00db15e6e00a200d387039 518 ``` 519 520 Alice's address is `0xb8c941069cc2b71b1a00db15e6e00a200d387039`. However we have to type a `Passphrase` of Alice. `passphrase` is `Alice` cause we generate this address using `Alice` 521 522 >Remember it! 523 > 524 >``` 525 >> personal.newAccount("Alice") 526 >``` 527 528 ``` 529 Passphrase: Alice 530 true 531 ``` 532 533 Now Alice's account is unlocked. Let's go back to transaction. We can see pending transactions 534 535 ``` 536 > eth.pendingTransactions 537 [] 538 ``` 539 540 Until now, there is not any transaction. We just unlocked Alice's account. Let's make a transaction again. 541 542 ``` 543 > eth.sendTransaction({from: "0xb8c941069cc2b71b1a00db15e6e00a200d387039", to: "0xf39cf42cd233261cd2b45adf8fb1e5a1e61a6f90", value: web3.toWei(5, "ether")}) 544 INFO [08-06|22:16:09.274] Setting new local account address=0xb8C941069cC2B71B1a00dB15E6E00A200d387039 545 INFO [08-06|22:16:09.275] Submitted transaction fullhash=0x926f1bb71d5b48a306e6cde2d45c01f8af2107febf94b166a7e5f8e025dc8adc recipient=0xf39Cf42Cd233261cd2b45ADf8fb1E5A1e61A6f90 546 "0x926f1bb71d5b48a306e6cde2d45c01f8af2107febf94b166a7e5f8e025dc8adc" 547 ``` 548 549 There is no error. Let's see a pending transactions 550 551 ``` 552 > eth.pendingTransactions 553 [{ 554 blockHash: null, 555 blockNumber: null, 556 from: "0xb8c941069cc2b71b1a00db15e6e00a200d387039", 557 gas: 21000, 558 gasPrice: 1000000000, 559 hash: "0x926f1bb71d5b48a306e6cde2d45c01f8af2107febf94b166a7e5f8e025dc8adc", 560 input: "0x", 561 nonce: 0, 562 r: "0x70484271bdc85f7233e715423d8d0be5c669a323385b5ec0ff080a52cf3c654c", 563 s: "0x1b55a792995f61128c10a48ce1e0869893c863d38489f574d84ae3a96b031cef", 564 to: "0xf39cf42cd233261cd2b45adf8fb1e5a1e61a6f90", 565 transactionIndex: null, 566 v: "0x42", 567 value: 5000000000000000000 568 }] 569 ``` 570 571 There is transaction. 572 573 ``` 574 > eth.getBalance("0xb8c941069cc2b71b1a00db15e6e00a200d387039") 575 45000000000000000000 576 > eth.getBalance("0xf39cf42cd233261cd2b45adf8fb1e5a1e61a6f90") 577 0 578 ``` 579 580 We didn't mine any block. so There is no change of balance yet. Let's mine again! 581 582 ``` 583 > miner.start(1) 584 INFO [08-06|22:19:53.061] Updated mining threads threads=1 585 INFO [08-06|22:19:53.061] Transaction pool price threshold updated price=1000000000 586 null 587 > INFO [08-06|22:19:53.062] Commit new mining work number=10 sealhash=f69cfb…273c0d uncles=0 txs=0 gas=0 fees=0 elapsed=265.557µs 588 INFO [08-06|22:19:53.062] Commit new mining work number=10 sealhash=a018f5…65f494 uncles=0 txs=1 gas=21000 fees=2.1e-05 elapsed=1.022ms 589 INFO [08-06|22:19:54.718] Successfully sealed new block number=10 sealhash=a018f5… 590 591 . 592 . 593 . 594 595 INFO [08-06|22:20:05.086] 🔨 mined potential block number=16 hash=e7688a…09ed64 596 INFO [08-06|22:20:05.086] Commit new mining work number=17 sealhash=6b297d…b76b19 uncles=0 txs=0 gas=0 fees=0 elapsed=252.945µs 597 > miner.stop() 598 null 599 ``` 600 601 ``` 602 > eth.blockNumber 603 16 604 ``` 605 606 Last time Alice mined 9 blocks and this time mined 7 blocks more. So We can expect Alice has 75 ether (80 ether block reward - 5 ether sent to Bob = 75 ether). Let's check. 607 608 First, 609 610 ``` 611 > eth.pendingTransactions 612 [] 613 ``` 614 615 There is no pending transaction. Alice and Bob's transaction is done! 616 617 Let's see balance of them 618 619 ``` 620 > eth.getBalance("0xb8c941069cc2b71b1a00db15e6e00a200d387039") 621 75000000000000000000 622 > eth.getBalance("0xf39cf42cd233261cd2b45adf8fb1e5a1e61a6f90") 623 5000000000000000000 624 ``` 625 626 As we expected, Alice has 75 ether, Bob has 5 ether. We did it! 627 628 ### 3.3 (Appendix) Block generation time log 629 630 When you want to record the log of block generation time of Eth-ECC, then follow step below 631 632 > I added few lines of source code in miner/worker.go 633 > 634 > (For this you have to uncomment in in miner/worker.go) 635 > 636 > ```go 637 > csvFile, _ := os.OpenFile("elapseTime.csv", os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644) 638 > 639 > wr := csv.NewWriter(csvFile) 640 > wr.Write([]string{block.Number().String(), time.Since(task.createdAt).String()}) 641 > wr.Flush() 642 > ``` 643 > 644 > This source will make `elapseTime.csv` file in /build/bin directory(Same directory with `geth` and `puppeth`). 645 > In this file, block generation time will be written by source code. 646 > You can see a example below 647 648 <img src="./img/elapse_time.png" alt="Elapse time" style="zoom:80%;" /> 649 650 - 1, 2, ... ,41 is block height 651 - 2m53.376, 3m24.504... , 5m44.6046 is elapsed time(block generation time) 652 653 --- 654 655 If there are errors or you want to add more details, please make a issue in my github or official Eth-ECC gitbub 656 657 Github : 658 659 - Official : https://github.com/cryptoecc/ETH-ECC 660 - Writer : https://github.com/HyoungsungKim/Studying-ethereum/tree/master/study-in-geth/docs