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

이더리움 geth 멀티 노드 테스트하기 . private test network

by SidePower 2022. 9. 21.

 

블록체인에 참가하는 모든 참가자(노드)는

항상 동일한 블록 정보를 보유하고 열람할 수 있고 공유됩니다.

 

한 곳에서 발생한 액션이 같은 블록체인 네트워크에 있는

모든 참가자들에게 전송해서 공유되는지

그리고 내가 이더리움 네트워크에 대해 이해한 게 맞는지 확인을 위해

멀티 노드를 구성해서 테스트해봤습니다.

 

 채굴하기

TestNet_1 노드에서 채굴을 하면

TestNet_2와 TestNet_3에 블록 생성 알림이 가는지 

노드간에 자동으로 통신이 되는지 확인해 봅니다.

 


 TestNet_1
[tmach@localhost shell]$ geth attach rpc:http://localhost:3331
Welcome to the Geth JavaScript console!

instance: Geth/v1.10.14-unstable-85064ed0-20211202/linux-amd64/go1.17.3
coinbase: 0xcfd730523767ef1ba6a3f4413f9a15306a5b9382
at block: 15 (Wed Dec 15 2021 07:57:56 GMT-0500 (EST))
 datadir: /home/tmach/gethmain/testnet_1
 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

To exit, press ctrl-d or type exit
> eth.accounts
["0xcfd730523767ef1ba6a3f4413f9a15306a5b9382", "0x81d4f40e579d47b754e98f182f5e6cc05d6ba916"]
> miner.start()
null
> miner.stop()
null
> eth.blockNumber
16
> eth.coinbase
"0xcfd730523767ef1ba6a3f4413f9a15306a5b9382"
> eth.getBalance("0xcfd730523767ef1ba6a3f4413f9a15306a5b9382")
80000000000000000000
>
 16개 블록이 생성되었고 80ether가
  지갑(0xcfd730523767ef1ba6a3f4413f9a15306a5b9382) 잔액으로 확인되네요.


 TestNet_2
[tmach@localhost shell]$ geth attach rpc:http://localhost:3332
Welcome to the Geth JavaScript console!

instance: Geth/v1.10.14-unstable-85064ed0-20211202/linux-amd64/go1.17.3
at block: 16 (Wed Dec 15 2021 07:59:57 GMT-0500 (EST))
 datadir: /home/tmach/gethmain/testnet_2
 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

To exit, press ctrl-d or type exit

 TestNet_2에서 block수를 체크하니 16개가 표시됩니다.
> eth.blockNumber
16

 TestNet_1 노드의 계정(지갑) 주소로 잔액을 확인하니 80ether가 확인되네요.
> eth.getBalance("0xcfd730523767ef1ba6a3f4413f9a15306a5b9382")
80000000000000000000

 TestNet_2에서는 계정(지갑)을 생성하지 않았기때문에
채굴이 불가능합니다.
> eth.accounts
[]

> miner.start()
Error: etherbase missing: etherbase must be explicitly specified
        at web3.js:6365:37(47)
        at send (web3.js:5099:62(35))
        at <eval>:1:12(3)


 TestNet_3
[tmach@localhost shell]$ geth attach rpc:http://localhost:3333
Welcome to the Geth JavaScript console!

instance: Geth/v1.10.14-unstable-85064ed0-20211202/linux-amd64/go1.17.3
at block: 16 (Wed Dec 15 2021 07:59:57 GMT-0500 (EST))
 datadir: /home/tmach/gethmain/testnet_3
 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

To exit, press ctrl-d or type exit

 TestNet_3에서 block수를 체크하니 16개가 표시됩니다.
> eth.blockNumber
16

 TestNet_1 노드의 계정(지갑) 주소로 잔액을 확인하니 80ether가 확인되네요.
> eth.getBalance("0xcfd730523767ef1ba6a3f4413f9a15306a5b9382")
80000000000000000000

 TestNet_3에서는 계정(지갑)을 생성하지 않았기때문에
채굴이 불가능합니다.
> eth.accounts
[]

> miner.start()
Error: etherbase missing: etherbase must be explicitly specified
        at web3.js:6365:37(47)
        at send (web3.js:5099:62(35))
        at <eval>:1:12(3)

 

3개의 노드 창을 동시에 띄어놓고

TestNet_1 노드에서만 채굴하고 TestNet_2와 TestNet_3으로 잘 전달되는지 

실제로 테스트한 걸 화면 캡처했습니다.

 

 송금하기

TestNet_1 노드에서 송금을 하면 

TestNet_2와 TestNet_3에서도 송금된 결과가 확인되는지 볼게요.


 TestNet_1


[tmach@localhost shell]$ geth attach rpc:http://localhost:3331
Welcome to the Geth JavaScript console!

instance: Geth/v1.10.14-unstable-85064ed0-20211202/linux-amd64/go1.17.3
coinbase: 0xcfd730523767ef1ba6a3f4413f9a15306a5b9382
at block: 18 (Wed Dec 15 2021 08:29:36 GMT-0500 (EST))
 datadir: /home/tmach/gethmain/testnet_1
 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

To exit, press ctrl-d or type exit
> eth.accounts
["0xcfd730523767ef1ba6a3f4413f9a15306a5b9382", "0x81d4f40e579d47b754e98f182f5e6cc05d6ba916"]
> eth.getBalance(eth.accounts[0])
80000000000000000000
> eth.getBalance(eth.accounts[1])
10000000000000000000

 eth.accounts[1] 계정(지갑)으로 5ether를 송금합니다.
> eth.sendTransaction({from:eth.accounts[0], to:eth.accounts[1], value:web3.toWei(5)})
"0x127a904eb02b65d361f1e7ea90ce93f27463c767c390b85947ed4dd67d5d1b2a"
> miner.start()
null
> miner.stop()
null

 기존 10ether에서 15ether로 정상 송금되었습니다.
> eth.getBalance(eth.accounts[1])
15000000000000000000
 주소로 잔액확인
> eth.getBalance("0x81d4f40e579d47b754e98f182f5e6cc05d6ba916")
15000000000000000000
>


 TestNet_2

[tmach@localhost shell]$ geth attach rpc:http://localhost:3332
Welcome to the Geth JavaScript console!

instance: Geth/v1.10.14-unstable-85064ed0-20211202/linux-amd64/go1.17.3
at block: 18 (Wed Dec 15 2021 08:29:36 GMT-0500 (EST))
 datadir: /home/tmach/gethmain/testnet_2
 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

To exit, press ctrl-d or type exit
> eth.getBalance("0xcfd730523767ef1ba6a3f4413f9a15306a5b9382")
80000000000000000000
> eth.getBalance("0x81d4f40e579d47b754e98f182f5e6cc05d6ba916")
10000000000000000000

 TestNet_1의 5ether 송금 처리 후에 재확인으로 15ether가 확인됩니다.
> eth.getBalance("0x81d4f40e579d47b754e98f182f5e6cc05d6ba916")
15000000000000000000
>


 TestNet_3

[tmach@localhost shell]$ geth attach rpc:http://localhost:3333
Welcome to the Geth JavaScript console!

instance: Geth/v1.10.14-unstable-85064ed0-20211202/linux-amd64/go1.17.3
at block: 18 (Wed Dec 15 2021 08:29:36 GMT-0500 (EST))
 datadir: /home/tmach/gethmain/testnet_3
 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

To exit, press ctrl-d or type exit
> eth.getBalance("0xcfd730523767ef1ba6a3f4413f9a15306a5b9382")
80000000000000000000
> eth.getBalance("0x81d4f40e579d47b754e98f182f5e6cc05d6ba916")
10000000000000000000

 TestNet_1의 5ether 송금 처리 후에 재확인으로 15ether가 확인됩니다.
> eth.getBalance("0x81d4f40e579d47b754e98f182f5e6cc05d6ba916")
15000000000000000000
>

 

역시 실제 테스트한 걸 화면 캡처했습니다.

 

사설 테스트넷에서의 재현이지만

메인넷에서도 동일한 방식으로 이더리움 블록체인이 작동하기 때문에

이제야 이더리움 블록체인 네트워크에 대해서 조금은 알 거 같습니다.

 

 

감사합니다.

반응형

댓글