Share
Embed
Plasma を理解するための Ethereum Protocol のキホン
Akinori Machino
April 26, 2018
Transcript
36 slides
-
• ౦ژେֶཧֶՊଔۀɾಉେֶӃதୀ • ࣗͰͷىۀɺҎདྷελʔτΞοϓാͰԿͰ • Ethereum ʹڵຯΛͪ҉߸௨՟ʗϒϩοΫνΣʔϯք۾ • τʔΫϯΤίϊϛʔ࣮ݱͷͨΊʹࠓͰ͖Δ͜ͱΛࡧத •
ΤϯδχΞίϛϡχςΟͷඞཁੑΛײͯ͡ Hi-Ether Λ։ઃ ܦྺ @amachino Akinori Machino -
ϓ ϥ ζ Ϛ Ethereum ͷϨΠϠʔٕ̎ज़ͷ̍ͭͰ͋Δ Plasma Λɺཧղ͢ΔͨΊͷ Ethereum Protocol
ͷجຊ ࢲ͕͢͜ͱ Plasma ʹ͍ͭͯޙͷઌੜํ͔Βฉ͜͏ʂ -
ETHEREUM: A SECURE DECENTRALISED GENERALISED TRANSACTION LEDGER EIP-150 REVISION DR.
GAVIN WOOD FOUNDER, ETHEREUM & ETHCORE [email protected] Abstract. The blockchain paradigm when coupled with cryptographically-secured transactions has demonstrated its utility through a number of projects, not least Bitcoin. Each such project can be seen as a simple application on a decentralised, but singleton, compute resource. We can call this paradigm a transactional singleton machine with shared-state. Ethereum implements this paradigm in a generalised manner. Furthermore it provides a plurality of such resources, each with a distinct state and operating code but able to interact through a message-passing framework with others. We discuss its design, implementation issues, the opportunities it provides and the future hurdles we envisage. “Transactional Singleton Machine with Shared-State” -
World State Account State ͷू߹ͱͯ͠ද͞ΕΔ ੈքͷ”ঢ়ଶ” ʮA͞Μ10ETH͍࣋ͬͯΔʯ ʮ͜ͷೣͷࣂ͍ओB͞ΜͰ͋Δʯ ʮ͜ͷυϝΠϯʹ1ETHͷஈ͕͍͍ͭͯΔʯ ộ
‣ Externally Owned Accountʢਓؒʣ ‣ Contract AccountʢϓϩάϥϜʣ -
State Database World State ϚʔΫϧύτϦγΞͱͯ͠ه͞ΕΔ ‣ World State 20
byte ͷ Ethereum ΞυϨεΛ Key ͯ͠ɺ ͦͷΞυϨεͷ Account State Λ Value ʹ࣋ͭσʔλͷू߹ ‣ Account State ʹɺNonce, Balance, Code, Storage ͷ ̐छྨͷσʔλؚ͕·ΕΔʢEOA Nonce, Balance ͷΈʣ ‣ ͜ΕΒΛϚʔΫϧύτϦγΞͰදݱ͠ɺRLP ͰγϦΞϥΠζ ͨ͠ͷ͕ State Databaseʢgeth Ͱ LevelDB Λ༻ʣ ‣ State Database ϒϩοΫνΣʔϯʹؚ·Εͣɺϧʔτͷ ϋογϡͷΈ͕ϒϩοΫνΣʔϯϔομʔʹه͞ΕΔ -
Transaction τϥϯβΫγϣϯʹΑͬͯঢ়ଶมԽ͢Δ State 14c5f8ba: - 1024 eth bb75a980: - 5202
eth if !contract.storage[tx.data[0]]: contract.storage[tx.data[0]] = tx.data[1] [0, 235235, 0, ALICE … 892bf92f: - 0 eth send(tx.value / 3, contract.storage[0]) send(tx.value / 3, contract.storage[1]) send(tx.value / 3, contract.storage[2]) [ALICE, BOB, CHARLIE] 4096ad65: - 77 eth State’ 14c5f8ba: - 1014 eth bb75a980: - 5212 eth if !contract.storage[tx.data[0]]: contract.storage[tx.data[0]] = tx.data[1] [0, 235235, CHARLIE, ALICE … 892bf92f: - 0 eth send(tx.value / 3, contract.storage[0]) send(tx.value / 3, contract.storage[1]) send(tx.value / 3, contract.storage[2]) [ALICE, BOB, CHARLIE] 4096ad65: - 77 eth Transaction From: 14c5f88a To: bb75a980 Value: 10 Data: 2, CHARLIE Sig: 30452fdedb3d f7959f2ceb8a1 ộ ộ -
Transaction-Based State Machine n൪ͷϫʔϧυεςʔτ n+1൪ͷϫʔϧυεςʔτ ঢ়ଶભҠؔ n൪ͷτϥϯβΫγϣϯ S[n+1] = APPLY(S[n],
Tx[n]) τϥϯβΫγϣϯϕʔεͷεςʔτϚγϯ S[1] Tx[1] APPLY S[0] Tx[0] APPLY S[2] Tx[n-1] APPLY … S[n] S[n-1] -
Tx Tx Tx Tx Tx Tx Propagation of Transactions τϥϯβΫγϣϯͷωοτϫʔΫͷ
Tx Tx Tx Tx ֤ϊʔυʹະ࣮ߦτϥϯβΫγϣϯ͕ཷ·͍ͬͯ͘ -
B B B B B Propagation of Transactions τϥϯβΫγϣϯͷωοτϫʔΫͷ ᶇ5Yͷ࣮ߦ
τϥϯβΫγϣϯ͕࣮ߦ͞ΕΔ͜ͱͰঢ়ଶ͕มԽ͢Δ -
B B B B B B B B Propagation of
Transactions τϥϯβΫγϣϯͷωοτϫʔΫͷ ϒϩοΫ͕ਁಁ͠৽ͨͳʮੈքͷঢ়ଶʯ͕߹ҙ͞ΕΔ -
Scalability Problem ͳͥϒϩοΫνΣʔϯॲཧੑೳ͕͍ͷ͔ Tx Tx Tx Tx Tx Tx Tx
Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx Tx શͯͷϊʔυ͕શͯͷτϥϯβΫγϣϯΛॲཧ͍ͯ͠Δ