Skip to content

yoomee1313/Ethereum_Deferred_Transaction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

61 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ethereum_parallel_execution

์ด๋”๋ฆฌ์›€์˜ ์‹คํ–‰ ๋ถ€๋ถ„์„ ๋ณ‘๋ ฌ๋กœ ์ฒ˜๋ฆฌํ•˜๋Š” ๊ฒƒ์ด ๋ชฉ์ ์ž…๋‹ˆ๋‹ค.

operating system: 18.04.02 LTS live-server, golang: >=1.10

1. geth, solidity ์„ค์น˜ -> github์„ cloneํ•œ ๊ธฐ๋ณธํด๋”์—์„œ ์‹œ์ž‘ํ•จ์„ ์ „์ œ

A. Go ์„ค์น˜

golang ์„ค์น˜. golang version์€ 1.10 ์ด์ƒ์ด๋‹ค.

$ sudo add-apt-repository ppa:longsleep/golang-backports
$ sudo apt-get update
$ sudo apt-get install golang-go

ํŽธ์˜๋ฅผ ์œ„ํ•ด ํ™˜๊ฒฝ์„ค์ •์„ ๋“ฑ๋ก.

$ cd $home
$ echo "PATH=\$PATH:/home/`logname`/ethereum_parallel_execution/go-ethereum/build/bin" >> ~/.bashrc
$ source .bashrc

B. github clone

$ git clone <github address>

C. geth ์ปดํŒŒ์ผ

$ cd go-ethereum
$ make all
ํ˜น์€ geth๋งŒ ๋นŒ๋“œํ•˜๊ณ  ์‹ถ์œผ๋ฉด
$ make geth

D. solidity ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ปดํŒŒ์ผ

solc ์ปดํŒŒ์ผ๋Ÿฌ๋ฅผ ์ปจํŠธ๋ž™ํŠธ ์ฝ”๋“œ๊ฐ€ ์œ„์น˜ํ•œ ํด๋”์— ๋‘์–ด ํ•ด๋‹น ํด๋”์—์„œ ์ปดํŒŒ์ผํ•˜๋„๋ก ํ•จ. ํ™˜๊ฒฝ๋ณ€์ˆ˜ ๋“ฑ๋กํ•˜์—ฌ ์‚ฌ์šฉํ•˜์—ฌ๋„ ๋ฌด๋ฐฉ

$ cd ethereum_parallel_execution/solidity
$ ./scripts/install_deps.sh
$ sudo apt remove --purge libz3-dev
$ mkdir build
$ cd build
$ cmake .. && make
$ cp solc/solc ../../sol_file

2. ์ด๋”๋ฆฌ์›€ ํ…Œ์ŠคํŠธ ํ™˜๊ฒฝ ๊ตฌ์ถ•

๋‹จ์ˆœํžˆ ๋ณ‘๋ ฌ ์ฒ˜๋ฆฌ๊ฐ€ ๊ฐ€๋Šฅํ•œ์ง€๋ฅผ ๋ณด๊ธฐ ์œ„ํ•œ ๊ฒƒ์ด๋ฏ€๋กœ no-discover ์˜ต์…˜์œผ๋กœ public network๋ฅผ ๊ตฌ์ถ•ํ•ด์„œ ์‚ฌ์šฉํ•œ๋‹ค. Network Id๋Š” 940625๋กœ ์‚ฌ์šฉํ•œ๋‹ค.

์ฐธ๊ณ  ์‚ฌ์ดํŠธ 1 - geth ์ปจํŠธ๋ž™ํŠธ ํ˜ธ์ถœ: https://stackoverflow.com/questions/48184969/calling-smart-contracts-methods-using-web3-ethereum?rq=1

A. ์ด๋”๋ฆฌ์›€ ๋ฐ์ดํ„ฐ ํด๋” ๋ฐ ๊ณ„์ขŒ ์ƒ์„ฑ

๋ฐ์ดํ„ฐ ํด๋”(workspace) ์ƒ์„ฑ(github์— ์˜ฌ๋ผ์™€์žˆ๋Š” paralleltestwork๋Š” ๋ฌด์‹œํ•ด๋„ ๋ฌด๋ฐฉ)

$ cd go-ethereum
$ mkdir paralleltestwork

๊ณ„์ขŒ ์ƒ์„ฑ: ๋ฏธ๋ฆฌ ๊ณ„์ขŒ๋ฅผ ์ƒ์„ฑํ•˜์—ฌ genesis ํŒŒ์ผ์—์„œ ์ดˆ๊ธฐ์— ์ฝ”์ธ์„ ๋ณด์œ ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•จ.

geth --datadir paralleltestwork/ account new

์ ๋‹นํ•œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๊ธฐ์–ตํ•œ๋‹ค. Public address of the key ๊ฐ’์ด ์ถœ๋ ฅ์ด ๋˜๋ฉด ๊ธฐ์–ตํ•œ๋‹ค.

์˜ˆ์‹œ: Passphrase-> 2523, Public address of the key-> 0xcb2940b6766Dd4bfFF30616e4e1d3e911C8d803e

B. puppeth ๋ชจ๋“ˆ์„ ์‚ฌ์šฉํ•œ genesis.json ์ƒ์„ฑ

puppeth ๋ชจ๋“ˆ์ด๋ž€ genesis.json ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜๋Š” ๋ชจ๋“ˆ์ด๋‹ค.(๋งŒ์•ฝ ํ•„์š”ํ•˜๋ฉด ์‚ฌ์šฉํ•˜๊ณ  github.com์— ์˜ˆ์ œ genesis.json ํŒŒ์ผ์ด ์˜ฌ๋ผ์™€ ์žˆ์–ด ์ด๋ฅผ ์‚ฌ์šฉํ•ด๋„ ๋ฌด๋ฐฉ)

$ cd go-ethereum
$ puppeth
$ cp <networkname>.json genesis.json
์˜ˆ์‹œ: network name=yoomeetestnet, what would you do=2, what would you do=1, which consensus engine=1, 
which accounts should be pre-funded=๋ฏธ๋ฆฌ ์ƒ์„ฑํ•ด ๋†“์€ ๊ณ„์ขŒ์˜ public key๋ฅผ ๋ณต์‚ฌํ•˜์—ฌ ๋„ฃ์Œ, 
pre-funded with 1 wei=yes, chain/network ID=940625, what would you like to do=2,2.

cp ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด genesis.json ํŒŒ์ผ์ด ์ƒ์„ฑ๋˜๋ฉด genesis.json ํŒŒ์ผ์„ ์ˆ˜์ •ํ•˜์—ฌ ์ถ”๊ฐ€ ์„ค์ •์„ ์™„๋ฃŒํ•œ๋‹ค.

์˜ˆ์‹œ: difficulty=0x0100, balance="0x200000000000000000000"

์ถ”ํ›„ password ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜์—ฌ geth ์‹คํ–‰ ์‹œ password๋ฅผ ์ฃผ๋Š” ํŒŒ์ผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค.

3. ์ด๋”๋ฆฌ์›€ ์ฝ˜์†” ๋ช…๋ น์–ด ๋ชจ์Œ

A. Geth ์‹คํ–‰ ์˜ต์…˜

$ geth --datadir paralleltestwork/ init genesis.json
$ geth --datadir paralleltestwork/ --networkid 940625 --rpc --rpcaddr "0.0.0.0" \
--rpcport 8600 --rpccorsdomain "*" --rpcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" \
--allow-insecure-unlock --nodiscover --port 30303 --unlock 0,1 --password password console

B. ์–ด์นด์šดํŠธ ๊ด€๋ จ

$ personal.newAccount(โ€œ2523โ€)
$ eth.accounts / personal.listAccounts
$ eth.getBalance(eth.accounts[0])

C. ๋งˆ์ด๋‹ ๊ด€๋ จ

$ eth.coinbase
$ miner.setEtherbase(eth.accounts[3])
$ miner.start(1)
$ miner.stop()
$ eth.mining
$ eth.blockNumber

D. ํŠธ๋žœ์žญ์…˜ ์ „์†ก(contract์„ ๊ฑฐ์น˜์ง€ ์•Š์€ ๊ฒฝ์šฐ)

$ personal.unlockAccount(eth.accounts[0])
$ eth.sendTransaction({from:eth.accounts[0], to:eth.accounts[2], value:10000})

E. ํŠธ๋žœ์žญ์…˜ ๋ฐ ๋ธ”๋ก ์ •๋ณด ์กฐํšŒ

$ eth.pendingTransactions
$ eth.getBlock(22)
$ eth.getTransaction("ํŠธ๋žœ์žญ์…˜ ์ฃผ์†Œ")
$ eth.getTransactionReceipt("ํŠธ๋žœ์žญ์…˜ ์ฃผ์†Œ") //๋ฐฐํฌํ•œ contract์˜ ์ฃผ์†Œ๋ฅผ ๋ณด๊ธฐ ์œ„ํ•ด ์ฃผ๋กœ ์‚ฌ์šฉ
$ eth.getCode("์ปจํŠธ๋ž™ํŠธ ์ฃผ์†Œ") //๋ฐฐํฌํ•œ contract์˜ ๋ฐ”์ดํŠธ์ฝ”๋“œ๋ฅผ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด ์ฃผ๋กœ ์‚ฌ์šฉ

F. geth๋ฅผ ํ†ตํ•œ Contract ์ƒ์„ฑ๋ฐฉ๋ฒ• (TODO: ํŽธ์˜๋ฅผ ์œ„ํ•ด javascript(+nodejs)๋กœ ๋ณ€๊ฒฝํ•จ, update ํ•„์š”)

remix๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ contract๋ฅผ deployํ•˜๋ฉด deploy ํ•  ๋•Œ๋งˆ๋‹ค ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ contract๋„ ๊ณ„์† ์ƒˆ๋กœ ์ƒ์„ฑ๋˜๋Š” ๋‹จ์ ์ด ์กด์žฌํ•œ๋‹ค. 
mutex ์ปจํŠธ๋ž™ํŠธ๊ฐ€ ๋‚œ๋ฌดํ•˜๋Š” ๊ฒƒ์„ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด geth์—์„œ contract์„ deployํ•˜๋Š” ๊ฒƒ์„ ์„ ํƒํ•˜์˜€๋‹ค.
์ค€๋น„์‚ฌํ•ญ์€ ์›ํ•˜๋Š” ์œ„์น˜์— .sol ์†Œ์ŠคํŒŒ์ผ์„ ์œ„์น˜ํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ํŽธ์˜๋ฅผ ์œ„ํ•ด paralleltestwork(์ž‘์—…ํด๋”)์•ˆ์— solidity_file์ด๋ž€ 
ํด๋”๋ฅผ ์ƒ์„ฑํ•˜์—ฌ ์ปดํŒŒ์ผ์„ ์›ํ•˜๋Š” ์†Œ์Šค์ฝ”๋“œ์™€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์†Œ์Šค์ฝ”๋“œ๋ฅผ ๊ฐ™์ด ์œ„์น˜์‹œํ‚จ๋‹ค.
$ cd ~/paralleltestwork/solidity_file
$ solc --abi voting_v2.sol
$ solc --bin voting_v2.sol
$ var contract = eth.contract([{"constant":false,"inputs":[{"name":"candidate_num","type":"uint256"}],"name":"vote","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"candidate_num","type":"uint256"}],"name":"get_candidate","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"get_v","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}])
$ var bytecode = '0x608060405234801561001057600080fd5b5061048f806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80630121b93f1461004657806395fc395d1461008c578063fbfbfd97146100ce575b600080fd5b6100726004803603602081101561005c57600080fd5b81019080803590602001909291905050506100ec565b604051808215151515815260200191505060405180910390f35b6100b8600480360360208110156100a257600080fd5b8101908080359060200190929190505050610439565b6040518082815260200191505060405180910390f35b6100d6610450565b6040518082815260200191505060405180910390f35b600073efe38f307df41975ba058dfe2824ed53dd36be00637308809e60056040518263ffffffff1660e01b81526004018082815260200191505060006040518083038186803b15801561013e57600080fd5b505af4158015610152573d6000803e3d6000fd5b505050506005600354106101d15773efe38f307df41975ba058dfe2824ed53dd36be0063b5fba83d60056040518263ffffffff1660e01b81526004018082815260200191505060006040518083038186803b1580156101b057600080fd5b505af41580156101c4573d6000803e3d6000fd5b5050505060009050610434565b60036000815480929190600101919050555073efe38f307df41975ba058dfe2824ed53dd36be0063b5fba83d60056040518263ffffffff1660e01b81526004018082815260200191505060006040518083038186803b15801561023357600080fd5b505af4158015610247573d6000803e3d6000fd5b5050505073efe38f307df41975ba058dfe2824ed53dd36be00637308809e60066040518263ffffffff1660e01b81526004018082815260200191505060006040518083038186803b15801561029b57600080fd5b505af41580156102af573d6000803e3d6000fd5b50505050600560035414156102da576001600460006101000a81548160ff0219169083151502179055505b73efe38f307df41975ba058dfe2824ed53dd36be0063b5fba83d60066040518263ffffffff1660e01b81526004018082815260200191505060006040518083038186803b15801561032a57600080fd5b505af415801561033e573d6000803e3d6000fd5b5050505073efe38f307df41975ba058dfe2824ed53dd36be00637308809e60076040518263ffffffff1660e01b81526004018082815260200191505060006040518083038186803b15801561039257600080fd5b505af41580156103a6573d6000803e3d6000fd5b505050506001600083600381106103b957fe5b016000828254019250508190555073efe38f307df41975ba058dfe2824ed53dd36be0063b5fba83d60076040518263ffffffff1660e01b81526004018082815260200191505060006040518083038186803b15801561041757600080fd5b505af415801561042b573d6000803e3d6000fd5b50505050600190505b919050565b600080826003811061044757fe5b01549050919050565b600060035490509056fea265627a7a7230582042e82287105bbb594545c04327f3a4d14702d2c56f6fe113e6c480cc6bddfa8d64736f6c63430005090032'
$ var deploy = {from:eth.coinbase, data:bytecode, gas: 2000000}
$ var contract_instance = contract.new("DISQUALIFIED!", deploy)

G. contract ํ•จ์ˆ˜ ํ˜ธ์ถœ (TODO: ํŽธ์˜๋ฅผ ์œ„ํ•ด javascript(+nodejs)๋กœ ๋ณ€๊ฒฝํ•จ, update ํ•„์š”)

i. contract ๊ฐ์ฒด ์ƒ์„ฑ

contract ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” contract์˜ abi์™€ ์ปจํŠธ๋ž™ํŠธ ์ฃผ์†Œ๊ฐ€ ํ•„์š”ํ•˜๋‹ค. ์—ฌ๊ธฐ์„œ๋Š” vote ์ปจํŠธ๋ž™ํŠธ๋ฅผ ์‚ฌ์šฉํ•˜์˜€๋‹ค. abi์™€ address๋Š” 6๋ฒˆ์„ ํ†ตํ•ด ์•Œ์•„๋‚ด์•ผ ํ•œ๋‹ค.

$ abi = [{"constant":false,"inputs":[{"name":"candidate_num","type":"uint256"}],"name":"vote","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"candidate_num","type":"uint256"}],"name":"get_candidate","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"get_v","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]
$ c_address = "0xcef3434d109bb33b9dca073c4970ed174318eb0a"
$ c_instance = eth.contract(abi).at(c_address)

ii. call

์ฝ๊ธฐ๋งŒ ํ•˜๋Š” ํ•จ์ˆ˜์˜ ๊ฒฝ์šฐ geth์˜ call์„ ์‚ฌ์šฉํ•˜์—ฌ ํ˜ธ์ถœํ•œ๋‹ค. ํŠธ๋žœ์žญ์…˜์„ ๋ฐœ์ƒ์‹œํ‚ค์ง€ ์•Š๋Š”๋‹ค. ์œ„์—์„œ ์ƒ์„ฑํ•œ ์ปจํŠธ๋ž™ํŠธ ๊ฐ์ฒด๋ฅผ ๊ฐ€์ ธ๋‹ค๊ฐ€ ์‚ฌ์šฉํ•˜์˜€๋‹ค.

$ c_instance.get_v.call()
$ c_instance.get_candidate.call()

iii. sendTransaction

state๋ฅผ ๋ณ€๊ฒฝ์‹œํ‚ค๋Š” ๊ฒฝ์šฐ sendTransaction์„ ํ˜ธ์ถœํ•˜์—ฌ ํŠธ๋žœ์žญ์…˜์„ ์ƒ์„ฑํ•ด์ค€๋‹ค. ๋งˆ์ด๋‹์ด ๋œ ํ›„ ๊ฒฐ๊ณผ๊ฐ€ ๋ฐ˜์˜๋œ๋‹ค.

$ c_instance.vote.sendTransaction(0,{from: eth.accounts[0]})

4. GIT ์‚ฌ์šฉ๋ฒ•

A. GIT ์ œ๊ณต๋ฐฉ๋ฒ• โ€“ gitlab์„ ์‚ฌ์šฉํ•  ๊ฒƒ์ž„

Git ์„ค์น˜ ๋ฐ ์ดˆ๊ธฐ ์„ค์ •

$ sudo apt-get install git
$ git config --global user.name "John Doe"
$ git config --global user.email [email protected]

Gitlab ์‹œ ssh๋กœ ์ ‘๊ทผํ•˜๋Š” ๊ฒƒ์ด ํŽธํ•˜๋ฏ€๋กœ ๋‚ด ๊ฐ€์ƒ๋จธ์‹ (์ปดํ“จํ„ฐ)์—์„œ ssh ํ‚ค ์ƒ์„ฑ ํ›„ gitlab์— ๋“ฑ๋กํ•ด์คŒ

์ฐธ๊ณ  - https://dejavuqa.tistory.com/139
$ ssh-keygen -t rsa -C "GitLab" -b 4096

gitlab.com์œผ๋กœ ๋“ค์–ด๊ฐ€ ๋กœ๊ทธ์ธ ํ›„ ํ”„๋กœ์ ํŠธ๋ฅผ ์œ„ํ•œ git repository ์ƒ์„ฑ. ์ƒ์„ฑํ–ˆ์œผ๋ฉด git repository๋ฅผ ssh ๋ฒ„์ „์œผ๋กœ git clone

$ git clone [email protected]:yoomeeko/ethereum_parallel_execution.git
$ mv go_ethereum ethereum_parallel_execution.git/go_ethereum
$ mv genesis.json ethereum_parallel_execution.git/genesis.json
$ git add *
$ git commit -m โ€œEthereum ์ถ”๊ฐ€โ€
$ git push

B. git ๋ช…๋ น์–ด

git ์ˆ˜์ • ํ›„ commit ๋ฐ push ๋ฐฉ๋ฒ•

$ git add *
$ git commit -m โ€œadded ~~โ€
$ git push

git ์ตœ์‹ ๋ฒ„์ „ ๊ฐ€์ ธ์˜ค๊ธฐ

$ git pull

Block explorer

block explorer๋Š” ๋ธ”๋ก์ •๋ณด, ๋ธ”๋ก ์•ˆ์— ๋‹ด๊ฒจ ์žˆ๋Š” ํŠธ๋žœ์žญ์…˜ ์ •๋ณด, account ์ •๋ณด๋ฅผ ui๋กœ ์˜ˆ์˜๊ฒŒ ๋ณผ ์ˆ˜ ์žˆ๋Š” ํˆด์„ ๋งํ•œ๋‹ค. ์•„์ง ์ด๋”๋ฆฌ์›€์—์„œ private chain์„ ์œ„ํ•ด ๊ณต์‹์ ์œผ๋กœ ์ง€์›ํ•˜๋Š” ํˆด์€ ์—†์ง€๋งŒ, ์˜คํ”ˆ์†Œ์Šค๊ฐ€ ๊ต‰์žฅํžˆ ๋งŽ๋‹ค. ์šฐ๋ฆฌ๋Š” ๊ทธ์ค‘์—์„œ๋„ Carsenk์˜ ์˜คํ”ˆ์†Œ์Šค explorer๋ฅผ ์‚ฌ์šฉํ•  ๊ฒƒ์ด๋‹ค. ํ™˜๊ฒฝ ์„ค์ •ํ•˜๋Š” ๋ฐ ์—๋Ÿฌ๊ฐ€ ๋‚˜์„œ ์‹ค์ œ๋กœ๋Š” ๋ชป ์‹คํ–‰ํ•ด ๋ณด์•˜์ง€๋งŒ, ๋‚˜์ค‘์— ์ด์šฉํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™๋‹ค.

์ฐธ๊ณ  github: https://github.com/carsenk/explorer

๋ถ„์‚ฐ๋ฝ ๊ด€๋ จ ๋งํฌ

1. CRDT: Conflict-free Replicated Data Types(modification์— ๋Œ€ํ•ด ๋ฝ์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ํ”„๋กœํ† ์ฝœ๋งŒ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋™๊ธฐํ™”๊ฐ€ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•˜๋Š” ๊ธฐ๋ฒ• ์ค‘์˜ ํ•˜๋‚˜)
https://medium.com/@amberovsky/crdt-conflict-free-replicated-data-types-b4bfc8459d26

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published