Giter Site home page Giter Site logo

scalalang2 / go-ethereum Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 10.42 MB

EVM 성능 feature 수집용 서버

License: GNU Lesser General Public License v3.0

Dockerfile 0.01% Makefile 0.11% Go 87.86% Shell 0.09% NSIS 0.21% Ruby 0.01% Python 0.05% JavaScript 3.87% HTML 0.10% Solidity 0.14% Assembly 0.84% C 5.13% C++ 0.83% M4 0.23% Sage 0.27% Java 0.27%

go-ethereum's Introduction

Geth / BASELAB

본 레포지토리는 실험용 geth 입니다.

Geth 설치하기

  1. go 언어 설치
  2. go get github.com/scalalang2/go-ethereum 으로 소스코드 내려 받기
  3. go mod tidy && go mod vendor 명령어로 의존성 패키지 다운로드

Geth 실행하기 Linux/Mac

$ make geth
$ nohup ./build/bin/geth \
      --ropsten \
      --rpc \
      --rpcport 8545 \
      --rpcaddr 127.0.0.1 \
      --rpccorsdomain 127.0.0.1 \
      --rpcapi "eth,web3,miner,net,admin,personal,debug" \
      --syncmode=full \ # Sync Mode
      --cache=4096 \ # Cache Size
      --measure.dsn <dsn> \ # Storage URI
      --datadir /home/ubuntu/.geth & # Blockchain Storage Dir Path

Geth 실행하기 Windows

$ go install -v ./cmd/...
$ geth

Geth Console 접근하기

$ ./build/bin/geth attach
> eth.syncing

Geth 동기화

  • Full - 모든 블록 내용을 다운로드 받는다.
  • Fast(default) - 최근 < N-K번째 블록까지는 블록 헤더만 다운로드 하고 > N-K 인 블록은 블록 내용까지 다운로드하여 동기화 속도를 높인다.
  • Light - 블록 헤더와 데이터만 받고 랜덤하게 몇개 블록만 선정해서 검증한다. 가장 빠르게 부팅하는 방법 중 하나

실험용 데이터 수집 활성화 하기

./build/bin/geth \
    --measure.dsn <dsn> \

분석

EVM의 OPCODE별 소요시간 측정하기

모든 EVM의 OPCODE는 Go언어 함수로 구현되어 있다. 함수의 시작점 및 끝에 시간을 측정하는 코드를 추가하면 쉽게 바이트 코드 단위의 소요시간을 측정할 수 있다.

// -- core/vm/instruction.go
func opExtCodeSize(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]byte, error) {
	defer measureTime(time.Now(), "EXTCODESIZE")
	slot := callContext.stack.peek()
	slot.SetUint64(uint64(interpreter.evm.StateDB.GetCodeSize(common.Address(slot.Bytes20()))))
	return nil, nil
}

추가로 블록 넘버와 컨트랙트를 수행한 계정의 주소와 같이 통계치를 뽑아내는데 도움이 되는 정보는 함수의 인자로 받은 interpretercallContext 변수를 이용하면 추가적인 정보도 기입할 수 있다. EVMInterpreter 구조체 안에 있는 Context 구조체에는 아래 정보가 포함되어 있다.

type Context struct {
	CanTransfer CanTransferFunc
	Transfer TransferFunc
	GetHash GetHashFunc

	// Message information
	Origin   common.Address 
	GasPrice *big.Int      

	// Block information
	Coinbase    common.Address 
	GasLimit    uint64         
	BlockNumber *big.Int       
	Time        *big.Int       
	Difficulty  *big.Int       
}

데이터 저장용 스토리지 생성

본 실험 코드에서는 실시간으로 대용량 데이터를 저장하기 위해 MongoDB를 이용한다.

go-ethereum's People

Contributors

scalalang2 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.