devops

Geth 사용해보기 본문

DevOps/Chain

Geth 사용해보기

vata500 2022. 11. 28. 23:28
반응형

Geth(Go Ethereum)은 Go로 개발된 Ethereum client다. JSON-RPC를 이용해서 이더리움 콘솔에 접속할 수 있는 환경을 제공한다.

+ JSON-RPC?
JSON으로 인코딩된 원격 프로시저 호출이다. 매우 간단한 프로토콜로, 소량의 데이터 타입과 명령어들만으로 정의한다.
JSON-RPC는 알림을 허용하고, 다수의 호출이 서버로 전송되고 순서없이 응답한다.
참고 자료 : https://www.getoutsidedoor.com/2019/08/10/%EC%99%9C-json-rpc%EB%A5%BC-%EC%82%AC%EC%9A%A9%ED%95%A0%EA%B9%8C/

기본적으로 Geth를 이용해서 Ethereum wallet 정보와, state를 확인할 수 있다.

Geth 설치방법

$ sudo apt-get install -y build-essentail libgmp3-dev golang git tree
$ git clone https://github.com/ethereum/go-ethereum.git
$ cd go-ethereum
$ git checkout refs/tags/v1.5.5
$ make geth

Geth github

https://github.com/ethereum/go-ethereum

 

GitHub - ethereum/go-ethereum: Official Go implementation of the Ethereum protocol

Official Go implementation of the Ethereum protocol - GitHub - ethereum/go-ethereum: Official Go implementation of the Ethereum protocol

github.com

Genesis.json

최초의 블록을 Genesis 블록이라고 하여, Genesis.json 파일로 설정한다. 대체로 아래와 같이 설정값들이 있다.

{
  "config": {
    "chainId": 12345,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0,
    "istanbulBlock": 0,
    "berlinBlock": 0,
    "clique": {
      "period": 5,
      "epoch": 30000
    }
  },
  "difficulty": "1",
  "gasLimit": "8000000",
  "extradata": "0x00000000000000000000000000000000000000000000000000000000000000007df9a875a174b3bc565e6424a0050ebc1b2d1d820000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "alloc": {
    "7df9a875a174b3bc565e6424a0050ebc1b2d1d82": { "balance": "300000" },
    "f41c74c9ae680c1aa78f42e5647a62f353b7bdde": { "balance": "400000" }
  }
}
  • config : 블록체인 구성 정보가 있는 오브젝트
  • chainId : 블록체인 네트워크를 식별하는 값
  • homesteadBlock : 이더리움 블록체인의 버전을 말한다. Olympic, Frontier, Ropsten, Homestead 버전이 있다. 0 지정 시, Homestad 버전을 사용한다는 의미다.
  • eip150Block : EIP 이더리움 업그레이드 설정
  • eip155Block : Reply attack을 막는 설정
  • eip158BLock : state clearing
  • nonce : 블록 생성을 위해 얼마나 많이 실행했는지를 나타내는 작업 증명값이다.
  • timestamp : 블록 생성 시간
  • parentHash : 이전 블록의 해시값
  • extraData : 블록 관련 추가 정보
  • gasLimit : 이 블록 수수료의 최대값
  • difficulty : 이 블록의 nonce 값 범위의 난이도. 숫자가 낮을 수록 난이도가 낮음
  • mixhash : 이더리움 채굴 난이도 결정값, 256 비트 해시값으로 nonce와 같이 증명에 사용함
  • coinbase : 블록을 채굴한 보상을 지급할 wallet 주소
  • allloc : 블록체인 시작과 동시에 특정 지갑 주소에 코인 지급

Start geth 설정값

geth --networkid 식별자  --nodeiscover --maxpeers 0 --datadir 디렉토리 console 2 >> geth.log
  • networkid : 블록체인 네트워크 식별자
  • nodiscover : 생성자 노드를 다른 노드에서 검색할 수 없도록 설정
  • maxpeers : 생정자 노드에 연결할 수 있는 최대 노드 수
  • datadir : 블록데이터 디렉토리 지정
  • console : Javascript 대화형 콘솔 실행

 

반응형
Comments