본문 바로가기
IT/이더리움 Ethereum

이더리움 geth 채굴(마이닝)하기 . Ether 가상화폐 단위

by SidePower 2022. 9. 20.

채굴에 앞서 현재 상태와 기본적으로 알아야 될 것들을 체크할게요.

 geth console에 접속합니다.
eth.accounts 명령어로 테스트넷에 생성된 계정을 모두 볼수 있습니다.
계정 주소가 배열로 표시되네요.

eth.accounts
["0x117309097e7afac115949c9384addca22d65451c", 
 "0x8502af7eb47e8dcadc4f67923fdd7928a806f860", 
 "0xc88d7a5c2638bf695b2a6b5c8bee93695975ab92"]
>


 채굴에서 우승자가 되면 보상받는데요.
보상 받는 계정을 Etherbase라고 합니다.
eth.coinbase 명령어로 Etherbase가 누구인지 확인할수 있습니다.

eth.coinbase
"0x117309097e7afac115949c9384addca22d65451c"
>


 Etherbase를 바꿀수도 있습니다.
miner.setEtherbase(계정)

변경할 계정 주소 배열값 또는 계정주소를 지정하시면 됩니다.

> miner.setEtherbase(eth.accounts[2])
true
>
eth.coinbase
"0xc88d7a5c2638bf695b2a6b5c8bee93695975ab92"

다시 원래대로 ㅋ
miner.setEtherbase(eth.accounts[0])
true
>
eth.coinbase
"0x117309097e7afac115949c9384addca22d65451c"
>

 

채굴(마이닝)은 블록을 만들 수 있는 권리입니다.

블록체인에 참가한 모든 참가자(노드)들이

공평하게 연산 풀기 문제를 가지고 경쟁을 해서

우승자만이 블록을 만들수 있는 권리를 가지게 됩니다.

또 연산 풀기 문제를 해결하기 위해 오랜 시간 컴퓨터 자원을 소비한 것에 대한 보상으로 

우승자에게는 코인을 줍니다.

솔직히 코인을 안주면 계속 컴퓨터를 켜 놓고 블록체인에 참가할 사람이 있을까요.

암튼 이런 과정을 채굴(mining)이라고 합니다.

 

 현재 블록이 몇개 있는지 알아볼게요.
명령어 : eth.blockNumber

eth.blockNumber
0
▶ 아직 채굴하지 않아서 0으로 표시되죠.


 현재 코인이 몇개 있는지 알아볼게요.
이더리움의 코인은 Ether(이더) 라고 합니다.
명령어 : eth.getBalance(계정주소)
계정주소에 배열값 또는 계정주소를 직접 입력하셔도 됩니다.

eth.getBalance(eth.accounts[0])
0

eth.getBalance("0x117309097e7afac115949c9384addca22d65451c")
0

eth.getBalance(eth.coinbase)
0
▶역시 아직 채굴하지 않아서 0으로 표시되죠.
또 누가 송금해 주지 않았죠.ㅋ


 이더리움 네트워크 정상 유무 확인

net.listening
true

 

 채굴하기

채굴 시작 : miner.start(Thread 개수)
채굴 종료 : miner.stop()

최초로 채굴 할때는 DAG 파일을 먼저 생성합니다.

DAG 파일 생성 후에 채굴을 하며

miner.stop() 명령어로 중지할 때까지 네버엔딩 계속 채굴합니다.

 

 DAG . Directed Acyclic Graph

ASIC(Application Specific Integrated Circuit)라는 채굴 전용 IC칩을 사용해도 

채굴 성능이 좋아지지 않게 하기 위한 기능을 하는 구조를 말합니다.

DAG 파일은 1GB 정도 용량의 큰파일이라 만드는데 시간이 좀 걸립니다.

제 PC에서는 8분정도 걸렸네요.^^;;

 thread 개수는 CPU의 스레드이며 많을수록 좋겠죠.
1부터 서서히 늘려가면서 테스트 해보셔도 될거 같지만
지정하지 않고 실행을 하니 1로 자동 세팅됩니다.

> miner.start()
null
>


 DAG 파일
위치 : 홈디렉터리의 .ethash 안에 생성됩니다.
리눅스에 파일이나 디렉터리 이름 앞에 .을 붙이면 숨김 파일이 됩니다.
.ethash도 숨김 파일이라 ls -al 로 찾아보셔야 되요.

[tmach@localhost ~]$ tree -h .ethash
.ethash
├── [1024M]  full-R23-0000000000000000


 DAG 파일 생성 로그
INFO [12-06|23:36:20.216] Updated mining threads                   threads=1
INFO [12-06|23:36:20.216] Transaction pool price threshold updated price=1,000,000,000
INFO [12-06|23:36:20.217] Commit new mining work                   number=1 sealhash=3124ad..1d4aaa uncles=0 txs=0 gas=0 fees=0 elapsed="183.297µs"
INFO [12-06|23:36:26.328] Generating DAG in progress               epoch=0 percentage=0 elapsed=5.155s
INFO [12-06|23:36:31.558] Generating DAG in progress               epoch=0 percentage=1 elapsed=10.386s
INFO [12-06|23:36:36.687] Generating DAG in progress               epoch=0 percentage=2 elapsed=15.514s
..
INFO [12-06|23:44:44.803] Generating DAG in progress               epoch=0 percentage=97 elapsed=8m23.630s
INFO [12-06|23:44:49.880] Generating DAG in progress               epoch=0 percentage=98 elapsed=8m28.708s
INFO [12-06|23:44:54.742] Generating DAG in progress               epoch=0 percentage=99 elapsed=8m33.569s


 채굴 진행 로그 . miner.start() 명령어 실행 로그
INFO [12-07|03:12:01.664] Updated mining threads                   threads=1
INFO [12-07|03:12:01.664] Transaction pool price threshold updated price=1,000,000,000

INFO [12-07|03:12:01.664] Commit new mining work                   number=1  sealhash=39f288..e0a3f9 uncles=0 txs=0 gas=0 fees=0 elapsed="158.368µs"
INFO [12-07|03:12:16.337] Successfully sealed new block            number=1  sealhash=39f288..e0a3f9 hash=d85edc..1b1d08 elapsed=14.673s
INFO [12-07|03:12:16.337] 🔨 mined potential block                  number=1  hash=d85edc..1b1d08

INFO [12-07|03:12:16.338] Commit new mining work                   number=2  sealhash=18e5b8..cdb77f uncles=0 txs=0 gas=0 fees=0 elapsed="280.859µs"
INFO [12-07|03:12:19.491] Successfully sealed new block            number=2  sealhash=18e5b8..cdb77f hash=4ae36e..c22738 elapsed=3.153s
INFO [12-07|03:12:19.491] 🔨 mined potential block                  number=2  hash=4ae36e..c22738

INFO [12-07|03:12:19.492] Commit new mining work                   number=3  sealhash=e04171..9c710f uncles=0 txs=0 gas=0 fees=0 elapsed="300.82µs"
INFO [12-07|03:12:19.930] Successfully sealed new block            number=3  sealhash=e04171..9c710f hash=cbc0da..325d76 elapsed=437.622ms
INFO [12-07|03:12:19.930] 🔨 mined potential block                  number=3  hash=cbc0da..325d76

INFO [12-07|03:12:19.930] Commit new mining work                   number=4  sealhash=f16914..4702a7 uncles=0 txs=0 gas=0 fees=0 elapsed="346.204µs"
INFO [12-07|03:12:21.080] Successfully sealed new block            number=4  sealhash=f16914..4702a7 hash=6620b2..1b5b65 elapsed=1.150s
INFO [12-07|03:12:21.080] 🔨 mined potential block                  number=4  hash=6620b2..1b5b65
...
...
INFO [12-07|03:12:52.441] Commit new mining work                   number=15 sealhash=dc9eab..c25608 uncles=0 txs=0 gas=0 fees=0 elapsed="221.05µs"
INFO [12-07|03:12:57.099] Successfully sealed new block            number=15 sealhash=dc9eab..c25608 hash=f1b71e..55a19c elapsed=4.658s
INFO [12-07|03:12:57.099] 🔗 block reached canonical chain          number=8  hash=597344..ee3370
INFO [12-07|03:12:57.099] 🔨 mined potential block                  number=15 hash=f1b71e..55a19c

INFO [12-07|03:12:57.100] Commit new mining work                   number=16 sealhash=67d7b6..fb18f4 uncles=0 txs=0 gas=0 fees=0 elapsed="165.532µs"
INFO [12-07|03:12:57.135] Successfully sealed new block            number=16 sealhash=67d7b6..fb18f4 hash=c6dee4..e718ec elapsed=35.086ms
INFO [12-07|03:12:57.135] 🔗 block reached canonical chain          number=9  hash=0f14d8..a8c3af
INFO [12-07|03:12:57.135] 🔨 mined potential block                  number=16 hash=c6dee4..e718ec

INFO [12-07|03:12:57.135] Commit new mining work                   number=17 sealhash=7c3de9..f9d881 uncles=0 txs=0 gas=0 fees=0 elapsed="160.434µs"

▶ 채굴 진행 4가지 메시지
① Commit new mining work : 새로운 채굴 작업
② Successfully sealed new block : 새로운 블록 생성 성공
③ block reached canonical chain : 블록에 도달한 표준 체인
④ mined potential block : 채굴된 블록

▶ Commit new mining work로 시작해서 mined potential block로 끝나면
채굴 한번 성공한 것입니다.


 채굴 진행중인지 체크 
true면 진행중 false면 채굴 하지 않는 상태

> eth.mining
true


 채굴 할때 해시 속도 확인

> eth.hashrate
0
▶ 채굴 난이도가 높을경우 큰숫자가 표시될거에요.


 채굴된 블록수

> eth.blockNumber
16

▶ 채굴 진행 로그를 보면 마지막 번호가 17입니다. number=17 
17번째 채굴중에 제가 miner.stop()을 실행해서 중단되어
결국 16개 블록이 생성되었어요.


 보상을 얼마나 받았는지 잔고를 확인합니다.

> eth.getBalance(eth.coinbase)
80000000000000000000

0이 엄청 많아요. 20자리 숫자입니다.
보상은 이더리움의 작은 단위 wei로 지급되네요.
1ether는 10^18wei 라서 0을 18개 빼니깐 80ether네요.
블록이 16개. 채굴 한번 성공해서 1개 블록 생성하는데
5ether를 보상받았습니다. 80/16=5

지금 실제로 가상화폐 거래소 가격을 보니 1ehter가 530만원정도네요.
80ether면 4억2천만원....꿈을 꿔 봅니다.ㅋㅋ

이더리움의 가상화폐 단위에 대해서 알아봐야 될거 같아요.

 

 Ether 가상화폐 단위

이더리움의 가상화폐는 Ether (이더)입니다.

Ether의 단위는 ether로 표시하고 가장 작은 단위는 wei(웨이)가 있으며

1ether는 10^18wei입니다.

ether wei wei 가치 wei 단위
1     1,000,000,000,000,000,000 10^18 Ewei
0.001     1,000,000,000,000,000 10^15 Pwei
0.000001     1,000,000,000,000 10^12 Twei
0.000000001     1,000,000,000 10^9 Gwei
0.000000000001     1,000,000 10^6 Mwei
0.000000000000001     1,000 10^3 Kwei
0.000000000000000001     1 1 wei

 

감사합니다.

반응형

댓글