goquorum - private ibft

00_8_3·2023년 7월 17일
1

geth

목록 보기
3/3
post-thumbnail

1 quorum은 geth fork

기본적인 geth 명령와 비슷하지만 기존에 사용하던 geth를 사용하면 안된다.

https://github.com/Consensys/quorum.git 을 clone 후 build 해서 사용해야 한다.

나 같은 경우 qgeth로 PATH에 등록해서 사용 중이다.

2 기본적으로 가스비 0.

  • Quorum에서 기본값으로 가스비는 무료다.

https://docs.goquorum.consensys.net/concepts/free-gas-network

그렇다고 가스비 설정이 안되는 것은 아니다.

  • 가스비 설정
  • genesis 파일에서 enableGasPriceBlock 옵션 설정.
    • 옵션을 재 설정하고 시작하는 경우 geth init으로 재실행 해주어야 한다.

https://docs.goquorum.consensys.net/concepts/gas-enabled-network

  • 문서에 genesis.json에 어떻게 설정하는지 안나와 있는데
    코드 확인하면 config.enableGasPriceBlock: 1 이렇게 설정하는 듯 하다.

https://github.com/Consensys/quorum/blob/master/params/config_test.go#L598...L600

재 실행하면 콘솔에서 확인 가능하다.
https://github.com/ConsenSys/quorum/blob/master/params/config.go#L489

2.1 관련 코드

  1. cmd/geth/main.go에서 makeFullNode 함수 실행 하면
    SetEthConfig 함수로 cmd 커맨드를 읽고 GasPrice를 --miner.gasprice의 값으로 설정함.

https://github.com/ConsenSys/quorum/blob/master/cmd/geth/main.go#L381

  1. 그 후 cmd/geth/main.go 의 startNode에서
    gasprice := utils.GlobalBig(ctx, utils.MinerGasPriceFlag.Name)
    ethBackend.TxPool().SetGasPrice(gasprice) 실행 해서 트랜잭션들 gasFee 설정.

https://github.com/ConsenSys/quorum/blob/master/cmd/geth/main.go#L516...L517

  1. SetGasPrice 함수가 IsGasPriceEnabled 함수를 실행해서 enableGasPriceBlock genesis 파일의 config 확인 후
    설정 안되어 있으면 에러

  2. 새로운 트랜잭션이 생성 될 때
    quorum/core/types/transaction.go의 GasPrice() 함수를 실행해서 위에 설정한 가스비를 가져옴.
    https://github.com/Consensys/quorum/blob/master/core/types/transaction.go#L266

참고

2개의 댓글

comment-user-thumbnail
2023년 7월 18일

글이 많은 도움이 되었습니다, 감사합니다.

1개의 답글