라이트코인은 비트코인 코어 소스코드와 얼마나 다를까?

in #kr6 years ago (edited)

이번에는 라이트코인 소스코드와 비트코인 소스코드를 비교하면서 얼마나 많은 차이가 있을지 알아보도록 하겠습니다.

라이트코인 개발 모델 역시 아인스타이늄의 개발모델과 거의 같은 개발모델을 사용하고 있습니다.

  1. 비트코인 안정 브랜치를 가져와서 라이트코인 개발 브랜치를 만든다.
  2. 비트코인 안정 브랜치(라이트코인 개발브랜치)에 라이트코인만의 변경을 추가한다.
    • 리브렌딩
    • 라이트코인만의 변경 추가
  3. 하드포크가 필요하다면 테스트넷에서 테스트하면서 라이트코인 릴리스
  4. 하드포크가 필요없다면 테스트 완료 후에 라이트코인 릴리스
  5. 반복.

라이트코인 이슈트래커를 보면 상당히 활발하여서 이슈 개수가 전체 220여개(오픈 19), pull 리퀘스트 전체 190여개(오픈 6)입니다. 아인스타이늄에 비해서 훨씬 활발합니다.

그러면 소스코드가 비트코인 안정버전과 비교해서 얼마나 다른지 살펴보도록 하겠습니다.

$ git clone https://github.com/litecoin-project/litecoin # 라이트코인 소스 가져옴
$ git remote add bitcoin https://github.com/bitcoin/bitcoin # 비트코인 소스와 비교를 위해서 비트코인 소스트리 추가
$ git fetch bitcoin # 비트코인 소스 가져옴
$ git branch -a # 리모트 브랜치를 비롯해서 모든 브랜치 보기
 master
  remotes/bitcoin/0.10
  remotes/bitcoin/0.11
  remotes/bitcoin/0.12
  remotes/bitcoin/0.13
  remotes/bitcoin/0.14
  remotes/bitcoin/0.15
  remotes/bitcoin/0.8
  remotes/bitcoin/0.9
  remotes/bitcoin/master
  remotes/origin/0.10
  remotes/origin/0.13
  remotes/origin/0.14
  remotes/origin/0.15
  remotes/origin/0.8
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

그런 다음 비트코인 안정브랜치 0.15와 라이트코인 개발브랜치 0.15를 비교해서 변경된 파일 개수를 살펴보면 다음과 같습니다.

$ git diff remotes/bitcoin/0.15 remotes/origin/0.15 |lsdiff |wc -l
431

431개의 파일이 변경되었습니다.

좀 더 의미있는 소스가 변경된 것은 몇개인지 범위를 좁혀서 살펴보기 위해서, 파일 리스트에서 문서나 테스트파일을 제외시키고 src/ 아래 폴더의 변경된 파일개수만 살펴보면

$ git diff remotes/bitcoin/0.15 remotes/origin/0.15 |lsdiff |grep '/src' |wc -l
220

220개의 파일이며, 여기에서 또 test//qt 혹은 /wallet을 제외시키면

$ git diff remotes/bitcoin/0.15 remotes/origin/0.15 |lsdiff |grep '/src' |grep -v 'qt\|test\|wallet'|wc -l
     59

59개의 파일이 변경된 것으로 나오며, 주요 변경 파일 목록은 다음과 같습니다.

a/src/Makefile.am
a/src/Makefile.bench.include
a/src/addrman.h
a/src/amount.h
a/src/base58.cpp
a/src/base58.h
a/src/bench/.gitignore
a/src/bench/checkblock.cpp
a/src/bitcoin-cli-res.rc
a/src/bitcoin-cli.cpp
a/src/bitcoin-tx-res.rc
a/src/bitcoin-tx.cpp
a/src/bitcoind-res.rc
a/src/bitcoind.cpp
a/src/chain.h
a/src/chainparams.cpp
a/src/chainparams.h
a/src/chainparamsbase.cpp
a/src/chainparamsseeds.h
a/src/clientversion.cpp
b/src/crypto/scrypt-sse2.cpp
b/src/crypto/scrypt.cpp
b/src/crypto/scrypt.h
a/src/httprpc.cpp
a/src/httpserver.cpp
a/src/init.cpp
a/src/miner.cpp
a/src/miner.h
a/src/net.cpp
a/src/net.h
a/src/net_processing.cpp
a/src/net_processing.h
a/src/netbase.cpp
a/src/policy/feerate.cpp
a/src/policy/policy.h
a/src/pow.cpp
a/src/primitives/block.cpp
a/src/primitives/block.h
a/src/rpc/blockchain.cpp
a/src/rpc/client.cpp
a/src/rpc/mining.cpp
a/src/rpc/misc.cpp
a/src/rpc/net.cpp
a/src/rpc/protocol.cpp
a/src/rpc/protocol.h
a/src/rpc/rawtransaction.cpp
a/src/rpc/server.cpp
a/src/rpc/server.h
a/src/script/ismine.cpp
a/src/timedata.h
a/src/txdb.cpp
a/src/util.cpp
a/src/utilstrencodings.cpp
a/src/utilstrencodings.h
a/src/validation.cpp
a/src/validation.h
a/src/validationinterface.cpp
a/src/version.h
a/src/versionbits.cpp

위의 파일을 목록으로 만든 후에 filterdiff를 적용해서 변경부분만 빼보려면 다음과 같이 합니다.

$ git diff remotes/bitcoin/0.15 remotes/origin/0.15 |lsdiff |grep '/src' |grep -v 'qt\|test\|wallet' >litecoin-mod.txt # 파일 리스트를 저장.
$ git diff remotes/bitcoin/0.15 remotes/origin/0.15 |filterdiff -I litecoin-mod.txt | lsdiff |wc -l # 확인
59
$ git diff remotes/bitcoin/0.15 remotes/origin/0.15 |filterdiff -I litecoin-mod.txt > litecoin.diff # diff파일로 저장

첨부한 파일은 이렇게 해서 얻어진 diff 패치 파일입니다. (파일 첨부가 안되는 모양이네요;; 다른 곳에 링크를 걸거나 하겠습니다)

이 파일의 변경점을 diffstat 명령으로 대충 살펴보면 다음과 같습니다.

$ diffstat litecoin.diff
 Makefile.am             |   55 -
 Makefile.bench.include  |   24
 addrman.h               |    2
 amount.h                |    2
 base58.cpp              |   29
 base58.h                |    4
 bench/.gitignore        |    2
 bench/checkblock.cpp    |    3
 bitcoin-cli-res.rc      |   10
 bitcoin-cli.cpp         |    8
 bitcoin-tx-res.rc       |   10
 bitcoin-tx.cpp          |   27
 bitcoind-res.rc         |   10
 bitcoind.cpp            |    6
 chain.h                 |    5
 chainparams.cpp         |  190 ++---
 chainparams.h           |    1
 chainparamsbase.cpp     |    8
 chainparamsseeds.h      | 1692 ++++++------------------------------------------
 clientversion.cpp       |    2
 crypto/scrypt-sse2.cpp  |  140 +++
 crypto/scrypt.cpp       |  331 +++++++++
 crypto/scrypt.h         |   46 +
 httprpc.cpp             |    2
 httpserver.cpp          |   32
 init.cpp                |   54 -
 miner.cpp               |   39 +
 miner.h                 |    4
 net.cpp                 |   69 -
 net.h                   |   51 -
 net_processing.cpp      |  896 ++++++++-----------------
 net_processing.h        |   57 -
 netbase.cpp             |  125 +--
 policy/feerate.cpp      |    2
 policy/policy.h         |    8
 pow.cpp                 |   25
 primitives/block.cpp    |    8
 primitives/block.h      |    2
 rpc/blockchain.cpp      |   19
 rpc/client.cpp          |    4
 rpc/mining.cpp          |   12
 rpc/misc.cpp            |   32
 rpc/net.cpp             |    8
 rpc/protocol.cpp        |   21
 rpc/protocol.h          |    2
 rpc/rawtransaction.cpp  |   10
 rpc/server.cpp          |   15
 rpc/server.h            |    2
 script/ismine.cpp       |    2
 timedata.h              |    2
 txdb.cpp                |   10
 util.cpp                |   16
 utilstrencodings.cpp    |   13
 utilstrencodings.h      |    6
 validation.cpp          |  124 ---
 validation.h            |   11
 validationinterface.cpp |    2
 version.h               |    2
 versionbits.cpp         |    2
 59 files changed, 1551 insertions(+), 2745 deletions(-)

여기까지 해보신 분은 다음에 라이트코인 소스가 얼마나 다른지 diff 파일을 한번 훝어보시기 바랍니다. 라이트코인이 비트코인에 비해서 특별한 그 무엇이 있을것이라는 기대는 하지 마시기 바랍니다.
얼핏 보기에는 거의 다를 바 없어 보이고지요. 암호화 알고리즘이 비트코인은 sha256이고 라이트코인은 scrypt 라는 점이 달라서 이에 대한 소스코드 scrypt*.* 파일이 눈에 띌 뿐, 비트코인 / 라이트코인 소스를 꿰뚫고 있지 않다면 두 소스가 어떤 차이가 있는지 쉽게 알기 어렵습니다.

아인스타이늄 소스와 라이트코인 소스는 얼마나 다를까

위와 같은 방식으로 emc2 소스코드 리모트 브랜치를 가져옵니다.

$ git remote add emc2  https://github.com/emc2foundation/einsteinium # emc2 리모트 브렌치 추가
$ git fetch emc2 # emc2 깃허브 가져옴

지난번에는 눈으로 대충 훝어봤었는데, 이번에는 위의 방식으로 diff 파일 리스트를 뽑아보겠습니다.

  1. 우선 아인스타이늄 최신 소스(하드포크 브랜치)와 라이트코인 소스 0.13을 대충 비교해서 가장 비슷한 커밋을 찾아보니 아인스타이늄 소스의 dab7cd087b 커밋과 라이트코인 0.13 안정브랜치가 거의 99% 일치한다는 것을 알 수 있었습니다.
$ git diff remotes/origin/0.13 dab7cd087b | lsdiff
a/Makefile.am
a/configure.ac
a/contrib/macdeploy/macdeployqtplus
a/depends/packages/miniupnpc.mk
a/doc/build-osx.md
a/doc/release-notes-litecoin.md
a/src/net.cpp
a/src/qt/bitcoingui.cpp

그러면 라이트코인 안정소스 remotes/origin/0.13 와 아인스타이늄 하드포크 브랜치 remotes/emc2/master_EMC2_HardFork는 얼마나 다른지 보겠습니다.

$ git diff remotes/origin/0.13 remotes/emc2/master_EMC2_HardFork  |lsdiff |wc -l # 변경된 파일 개수
222

변경된 파일 개수는 222개이며, 이중에 의미있는 소스코드만 추리기 위해서 test, doc 등등을 제외시키면

$ git diff remotes/origin/0.13 remotes/emc2/master_EMC2_HardFork |lsdiff |grep '/src' |grep -v 'qt\|test\|wallet' 
 | wc -l
33

33개의 의미 있는 변경을 한 파일이 나오며 그 파일들은 다음과 같습니다.

a/src/Makefile.am
a/src/Makefile.bench.include
a/src/amount.cpp
a/src/amount.h
a/src/bitcoin-cli-res.rc
a/src/bitcoin-cli.cpp
a/src/bitcoin-tx-res.rc
a/src/bitcoin-tx.cpp
a/src/bitcoind-res.rc
a/src/bitcoind.cpp
a/src/chainparams.cpp
a/src/chainparamsbase.cpp
a/src/chainparamsseeds.h
a/src/clientversion.cpp
a/src/clientversion.h
a/src/consensus/params.h
a/src/httpserver.cpp
a/src/init.cpp
a/src/main.cpp
a/src/main.h
a/src/miner.cpp
a/src/net.cpp
a/src/pow.cpp
a/src/pow.h
a/src/rpc/blockchain.cpp
a/src/rpc/mining.cpp
a/src/rpc/misc.cpp
a/src/rpc/net.cpp
a/src/rpc/rawtransaction.cpp
a/src/rpc/server.cpp
a/src/txdb.cpp
a/src/util.cpp
a/src/util.h

이 파일들의 변경점을 diffstat으로 살펴보면 다음과 같습니다.

$ diffstat emc2-only.diff
 Makefile.am            |   46 ++++++------
 Makefile.bench.include |   20 ++---
 amount.cpp             |    2
 amount.h               |    2
 bitcoin-cli-res.rc     |   10 +-
 bitcoin-cli.cpp        |    6 -
 bitcoin-tx-res.rc      |   10 +-
 bitcoin-tx.cpp         |    6 -
 bitcoind-res.rc        |   10 +-
 bitcoind.cpp           |    8 +-
 chainparams.cpp        |  187 ++++++++++++++++++++++++-------------------------
 chainparamsbase.cpp    |    6 -
 chainparamsseeds.h     |   88 +++--------------------
 clientversion.cpp      |    2
 clientversion.h        |    6 -
 consensus/params.h     |    1
 httpserver.cpp         |    4 -
 init.cpp               |   10 +-
 main.cpp               |   97 +++++++++++++++++++++----
 main.h                 |    3
 miner.cpp              |   12 ++-
 net.cpp                |    4 -
 pow.cpp                |  144 ++++++++++++++++++++++++++++++-------
 pow.h                  |    3
 rpc/blockchain.cpp     |    4 -
 rpc/mining.cpp         |   12 +--
 rpc/misc.cpp           |   34 ++++----
 rpc/net.cpp            |   10 +-
 rpc/rawtransaction.cpp |   10 +-
 rpc/server.cpp         |    8 +-
 txdb.cpp               |    2
 util.cpp               |   12 +--
 util.h                 |    2
 33 files changed, 444 insertions(+), 337 deletions(-)
  • 비트코인 소스 - 라이트코인 주요 소스 변경점 : 59 files changed, 1551 insertions(+), 2745 deletions(-)
  • 라이트코인 소스 - 아인스타인 주요 소스변경점 : 33 files changed, 444 insertions(+), 337 deletions(-)

이 글은 라이트코인 소스코드를 비하하려 한다는 식의 오해를 하지 마시기 바랍니다.

이상 저의 단순 호기심을 풀기 위한 매우 간단한 소스 비교 추적 방식을 설명해드렸으며, 혹시 소스카피 의혹이 있어서 스캠일지 아닐지 판별하는데에 이 방식을 사용해 보시기 바랍니다.

재미없는 글이 되었지만 추천 및 댓글은 언제나 제게 힘이 됩니다~

※ 변경사항

  • 12/27 오후 6:47 - 졸려서 잠을 이기려고 소스 추적하고 글 초안 작성
Sort:  

Congratulations @hackyminer, this post is the ninth most rewarded post (based on pending payouts) in the last 12 hours written by a Dust account holder (accounts that hold between 0 and 0.01 Mega Vests). The total number of posts by Dust account holders during this period was 8380 and the total pending payments to posts in this category was $1811.31. To see the full list of highest paid posts across all accounts categories, click here.

If you do not wish to receive these messages in future, please reply stop to this comment.

분석글 감사합니다.

좋은 분석 감사합니다. Litecoin <--> EMC2 구현부 변경점은 아래 네 파일정도입니다.

main.cpp
miner.cpp
chainparams.cpp
chainparamsbase.cpp

다른 파일은 심볼 변경같습니다.

넵 거의 그럴겁니다. @asbear 님께서 이미 지적하신바대로 emc2는 리브랜딩/기부 코드/웜홀(지금은 제외됨) 등등의 코드가 추가된 것이 다죠. 굳이 소스코드 내용에 대해서까지 본문에는 언급을 하지 않았습니다.

코인 만들기가 매우 쉽군요...

저도 라이트코인 소스로 새로운 코인 만드려보려고 시도 중입니다.

@hackyminer님이 보시기에 완전히 새로 설계 된 코인이나
유의미하게 수정된 코인들은 어떤게 있을까요?

좋은글 잘 보고 갑니다.

저는 개인적으로 myriadcoin처럼 여러 해시알고리즘으로 채굴 가능한 코인을 살펴보려고 계획중입니다. (bitcoin => zetacoin 소스에서 포크됨) // digibyte 코인도 bitcoin 기반인 멀티 해시알고리즘 지원 코인이고요.

비트코인 소스코드가 아닌 완전히 새롭게 설계된 코인으로 이더리움 / IOTA / NXT 정도밖에 모릅니다.

재미있는 시도입니다.

댓글 감사합니다~

Congratulations @hackyminer! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the total payout received

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

양질의 정보와 뉴비를 향한 관심 감사드립니다!!

감사합니다~!!

감사합니다.

분석 감사합니다.

Coin Marketplace

STEEM 0.28
TRX 0.13
JST 0.032
BTC 60793.36
ETH 2909.65
USDT 1.00
SBD 3.64