[DEV] 1,000 이더 의 고래가 되어보자 !! in test network.

krnews(45)
Published in
#kr-dev
Words
189
Reading
1 min
Listen
Play
8y

시작하기 전

테스트 네트워크에서 geth 를 기동하여 이더리움을 채굴해보자 !
테스트 네트워크이긴 하지만 나도 1,000 이더를 가져보자 !
실제 라이브 네트워크에서 여기서(테스트 네트워크) 채굴한 이더는 사용 불가 입니다.
go-ethereum (geth)을 통해 이더리움을 알아보고자 하는 것이 목표입니다.

  • virtualbox 등과 같은 vm 설치
  • ubuntu 16.04 버전 설치
  • 작업 편의상 ssh 로 접속하여 작업 수행 (개인취향)
  • 더 이상 자세한 건 생략한다.
sudo apt-get install openssh-server

1. 이더리움 설치 관련 프로그램 다운로드

  • 설치
sudo apt-get install -y build-essential libgmp3-dev golang git tree

2. 소스 다운로드 및 geth 컴파일

  • 소스 다운 및 컴파일
git clone https://github.com/ethereum/go-ethereum.git

cd go-ethereum

git checkout refs/tags/v1.5.5

make geth
  • 버전 정보 확인 및 복사
./build/bin/geth version 

sudo cp build/bin/geth /usr/local/bin/

3. geth 블록 초기화

  • 최초블럭 (genesis block) 초기화
mkdir eth_test
cd eth_test
geth --datadir /home/krnews/eth_test init /home/krnews/eth_test/genesis.json
  • genesis.json
{
    "nounce":"0x0000000000000042",
    "timestamp":"0x0",
    "parentHash":"0000000000000000000000000000000000000000000000000000000000000000",
    "extraData":"0x0",
    "gasLimit":"0x80000000",
    "difficulty":"0x4000",
    "minHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
    "coinbase":"0x3333333333333333333333333333333333333333",
    "alloc":{}
}
  • 실행 결과
I0319 15:14:20.132521 cmd/utils/flags.go:615] WARNING: No etherbase set and no accounts found as default
I0319 15:14:20.132576 ethdb/database.go:83] Allotted 128MB cache and 1024 file handles to /home/krnews/eth_test/geth/chaindata
I0319 15:14:20.149982 ethdb/database.go:176] closed db:/home/krnews/eth_test/geth/chaindata
I0319 15:14:20.150089 ethdb/database.go:83] Allotted 128MB cache and 1024 file handles to /home/krnews/eth_test/geth/chaindata
I0319 15:14:20.171670 cmd/geth/chaincmd.go:131] successfully wrote genesis block and/or chain rule set: ef8d79636e76e216a4babe7926af57c76444f735a91235b523e5b662444a33df
  • TREE 구조 확인

$ tree

.
 genesis.json
 geth
    chaindata
        000002.log
        CURRENT
        LOCK
        LOG
        MANIFEST-000003
 keystore

3 directories, 6 files

4. geth 실행

  • 콘솔 모드 실행
geth --networkid 4649 --nodiscover --maxpeers 0 --datadir /home/krnews/eth_test console 2>> /home/krnews/eth_test/geth.log
  • 계정 목록 확인
eth.accounts
[]
  • 계정생성 : 암호 - 1234
> personal.newAccount("1234")
"0xaafffa350858914b89e848076be6cf383bf32e8f"

exit

계정이 1개 이상 있어야 채굴이 되며, 기본적으로 coinbase (채굴계정)은 처음 생성된 계정으로 자동 맵핑 됨.

  • 확인

$ tree

.
 genesis.json
 geth
    chaindata
       000004.ldb
       000007.log
       CURRENT
       LOCK
       LOG
       MANIFEST-000008
    LOCK
    nodekey
 geth.log
 history
 keystore
     UTC--2018-03-19T06-17-11.359809908Z--aafffa350858914b89e848076be6cf383bf32e8f

3 directories, 12 files

키스토어에 계정정보가 생성된 것을 확인할 수 있다.

  • nohup을 통한 백그라운드 실행 ( with 채굴 )
nohup geth --networkid 4649 --nodiscover --maxpeers 0 --datadir /home/krnews/eth_test --mine --minerthreads 4 --rpc 2 >> /home/krnews/eth_test/geth.log &
  • 로그 보기

$ tail -f /home/krnews/eth_test/geth.log

I0319 15:18:08.261027 p2p/server.go:610] Listening on [::]:30303
I0319 15:18:08.261268 eth/backend.go:475] Automatic pregeneration of ethash DAG ON (ethash dir: /home/krnews/.ethash)
I0319 15:18:08.261465 node/node.go:411] HTTP endpoint opened: http://localhost:8545
I0319 15:18:08.261498 miner/miner.go:136] Starting mining operation (CPU=4 TOT=5)
I0319 15:18:08.261541 node/node.go:341] IPC endpoint opened: /home/krnews/eth_test/geth.ipc
I0319 15:18:08.261640 miner/worker.go:516] commit new work on block 1 with 0 txs & 0 uncles. Took 129.229µs
I0319 15:18:08.261683 vendor/github.com/ethereum/ethash/ethash.go:259] Generating DAG for epoch 0 (size 1073739904) (0000000000000000000000000000000000000000000000000000000000000000)
I0319 15:18:08.268069 eth/backend.go:482] checking DAG (ethash dir: /home/krnews/.ethash)
I0319 15:18:09.138272 vendor/github.com/ethereum/ethash/ethash.go:291] Generating DAG: 0%
I0319 15:18:13.682244 vendor/github.com/ethereum/ethash/ethash.go:291] Generating DAG: 1%

...

I0319 15:26:54.994705 vendor/github.com/ethereum/ethash/ethash.go:276] Done generating DAG for epoch 0, it took 866.353328ms
I0319 15:26:56.251559 p2p/nat/nat.go:111] mapped network port tcp:30303 -> 30303 (ethereum p2p) using UPNP IGDv1-IP1
I0319 15:26:57.634226 miner/unconfirmed.go:83]   mined potential block #1 [6c3e61f2…], waiting for 5 blocks to confirm
I0319 15:26:57.634670 miner/worker.go:516] commit new work on block 2 with 0 txs & 0 uncles. Took 165.316µs
I0319 15:26:57.637848 miner/unconfirmed.go:83]   mined potential block #1 [c3f08f35…], waiting for 5 blocks to confirm
I0319 15:26:57.641208 miner/unconfirmed.go:83]   mined potential block #1 [bb2938e6…], waiting for 5 blocks to confirm
I0319 15:26:58.255486 miner/unconfirmed.go:83]   mined potential block #2 [743e6438…], waiting for 5 blocks to confirm
I0319 15:26:58.255670 miner/worker.go:516] commit new work on block 3 with 0 txs & 0 uncles. Took 135.274µs
I0319 15:26:58.476917 miner/unconfirmed.go:83]   mined potential block #3 [39a4f65a…], waiting for 5 blocks to confirm
I0319 15:26:58.477152 miner/worker.go:516] commit new work on block 4 with 0 txs & 0 uncles. Took 178.923µs
I0319 15:27:00.417434 miner/unconfirmed.go:83]   mined potential block #4 [99c9ed4b…], waiting for 5 blocks to confirm
I0319 15:27:00.418177 miner/worker.go:516] commit new work on block 5 with 0 txs & 0 uncles. Took 298.019µs
I0319 15:27:01.142443 miner/unconfirmed.go:83]   mined potential block #5 [b04aaea4…], waiting for 5 blocks to confirm
I0319 15:27:01.143100 miner/worker.go:516] commit new work on block 6 with 0 txs & 0 uncles. Took 248.994µs
I0319 15:27:01.180959 miner/unconfirmed.go:105]   mined block #1 [6c3e61f2…] reached canonical chain
I0319 15:27:01.181243 miner/unconfirmed.go:107]  mined block #1 [c3f08f35…] became a side fork
I0319 15:27:01.181457 miner/unconfirmed.go:107]  mined block #1 [bb2938e6…] became a side fork
I0319 15:27:01.181620 miner/unconfirmed.go:83]   mined potential block #6 [07e2974e…], waiting for 5 blocks to confirm

[참조] Done generating DAG for epoch 0 에서 멈춰 있는 경우는 hashrate가 너무 낮아 채광을 할 수 없는 상태임 ( 가상 PC의 RAM과 코어를 적절하게 늘려준다. )

[참조] /home/krnews/.ethash/ 경로에 DAG 파일이 생성된다. (약 1GB 이상)

  • console에 접속하기
geth attach rpc:http://localhost:8545

스크린샷 2018-03-19 오후 3.29.44.png

962 이더리움 이제 나도 돌고래?다 -_-/

[DEV] 1,000 이더 의 고래가 되어보자 !! in test network. | Ecency