Upgrade to Pro — share decks privately, control downloads, hide ads and more …

transaction of Ethereum

Taiki
May 24, 2018

transaction of Ethereum

I studied the transaction of Ethereum.

Taiki

May 24, 2018
Tweet

More Decks by Taiki

Other Decks in Research

Transcript

  1. Content What is the Transaction ? EOA & CA Message

    call Contract Creation Life Cycle of Transaction State Change
  2. What is transaction more mathematicallyɾɾɾ Transactions is like a map

    from previous state to next state on the Ethererum World State σ m World State σ m+1 Transactions A transaction is a single cryptographically-signed instruction. References : [2]
  3. What is transaction From the view point of State, transaction

    is also like “Chain” of the State Chain. orld State σ m World State σ m+1 Transactions World S σ m Transactions References : [2]
  4. What is transaction τϥϯβΫγϣϯ͕ຬͨ͢΂͖৚݅ τϥϯβΫγϣϯ͸ɺRLPϑΥʔϚοτʹै͍ͬͯΔɻ (RLP͸recursive length prefixͷུ) τϥϯβΫγϣϯͷॺ໊͕༗ޮͰ͋Δɻ τϥϯβΫγϣϯͷnonce͕༗ޮͰ͋Δɻɹɹɹɹɹɹɹɹɹɹɹɹɹ

    ૹ৴ऀͷݱࡏͷnonceͱ౳͍͔͠Ͳ͏͔ݕূ͢Δɻ τϥϯβΫγϣϯʹࣄલʹఆΊΒΕ͍ͯΔGasྔΑΓ΋ɺɹɹɹɹɹɹ gas limit͕େ͖͘ઃఆ͞Ε͍ͯΔɻ ૹ৴ऀͷΞΧ΢ϯτͷ࢒ߴ͕ɺࢧ෷͍ͷඅ༻ΑΓ΋্ճ͍ͬͯΔɻ ☑ ☑ ☑ ☑ ☑
  5. What is transaction τϥϯβΫγϣϯͷݕূ͕ߦΘΕͨΒɺsubstate͕࡞੒͞ΕΔɻ substate͸ɺ self-destruct set τϥϯβΫγϣϯมߋޙʹ͸ه͞ΕΔΞΧ΢ϯτ৘ใ log sires

    τϥϯβΫγϣϯ͕Ͳ͜·Ͱ࣮ߦ͞Εͨͷ͔Λอ࣋͢Δ refund balance τϥϯαΫγϣϯ׬ྃޙʹϝϞϦʔΛݮΒͨ͠෼ͱͯ͠ฦ͞ΕΔeth ͔ΒͳΔɻ Substate
  6. EOA & CA EthereumͷAccountʹ͸ɼೋछྨ͋Δ EOA(Externally Owned Account) ֎෦ΞΧ΢ϯτ CA(Contract Account)

    ίϯτϥΫτ༻ͷΞΧ΢ϯτ τϥϯβΫγϣϯ͸ɺ͜ΕΒͷΞΧ΢ϯτؒͰߦΘΕΔɻ CA͸ɺContrac༻ͷ CodeΛ͍࣋ͬͯΔ
  7. EOA & CA EOA STORAGE BLANCE NONCE CODE ADDREDD CA

    STORAGE BLANCE NONCE CODE ADDREDD EOA͸ɺൿີ伴Ͱ؅ཧ͞ΕɺCodeΛ࣋ͨͳ͍ɻ CA͸ɺEVM codeΛ΋ͪɺEVMCodeͰ؅ཧ͞ΕΔɻ References : [2]
  8. EOA & CA def mk_contract_address(sender, nonce): return sha3(rlp.encode([normalize_address(sender), nonce]))[12:] ͪͳΈʹɺCA(Contract

    Account)ͷΞυϨε͸ɺ senderͷΞυϨεͱnonce͔Βࢉग़͞ΕΔ https://github.com/ethereum/pyethereum/blob/782842758e219e40739531a5e56fff6e63ca567b/ethereum/ utils.py
  9. input code Contract Creation World State σm World State σ

    m+1 Transactions Init code Account State A Account State B Account State C ɾ ɾ ɾ Account State A Account State B Account State C ɾ ɾ Account State X NEW ৽͍͠CAͷΞυϨεΛੜ੒͠ॳظઃఆޙɺτϥϯβΫγϣϯͱͯ͠initίʔυ ΛૹΔ͜ͱͰίϯτϥΫτΞΧ΢ϯτ͕ੜ੒͞ΕΔ References : [2]
  10. Message Call World State σm World State σ m+1 Transactions

    Init data Account State A Account State B Account State C ɾ ɾ Account State A Account State B Account State C ɾ ɾ Account State X Update Message CallʹΑͬͯContract Accountͷσʔλ͸update͞ΕΔɻ input data Account State X References : [2]
  11. Information of Transaction blockHash: “0x3584caa04632ce227cf259ab8086d460d497067e666fdf9c5b58756f738ad51c", blockNumber: 37214317, from: “0x0eea8963fd6f19ff4299ac9ccb774266a98ba6b1", gas:

    4600000, gasPrice: 100000000000, hash: “0xd59f0a4c159aa2a2058bd7d8dc4b759d1d6474d3f4b85606e3b4a3d00ff73e10", input: "0x", nonce: 42, r; “0xa4c159aa2a2058bd7d8dca4c159aa2a2058bd7d8dca4c159aa2a2058bd7d” s; “0xb759d1d6474d3f4b85606e3b4a3b759d1d6474d3f4b85606e3b4a34279a6” to: “0x0f0a4c159aa2a2058bd7d8dc4b759d1d6474d3f", transactionIndex: 3, v; “0x66” value: 5000000000
  12. GAS LIMIT GAS PRICE NONCE INIT / DATA R.S.V TO

    VALU Information of Transaction