Ethereum hackers

Post on 01-Jul-2015

152 views 4 download

transcript

ethereumCoding society

ethereum

Internet is to communicationas

Ethereum is to agreements

basic premisePlace & run code in a decentralised singleton isolated

machine;

code can call into other people’s code on the machine;

all transactions with the machine are crypto-signed and archived;

state fully deterministic.

blockchain

Diffuse Singleton Data-Structure

(non-localised, no-authority, no-centre)

bitcoin & crypto-currencies

Used blockchain to implement basicclearing house ‘contract’

ethereum & crypto-law

Uses blockchain to implement basicarbitrary contracts

ethereum

Ethereum is to Bitcoinas

the iPhone is to a calculator

ethereum

100% Free software, open developmentgithub.com/ethereum

C++, Go, Python implementations(Java & Javascript, too)

ethereum

State of Ethereum is just the state of a number of accounts.

state: accounts

Address(160-bit excerpt from the 256-bit public key)

Balance, Nonce[, Code, Storage](latter two non-null if a ‘contract’)

transactions: state alteration

Alter state by introducing transactions:

either send a message callor

create a contract.

contract creation

endowment (ETH), init codegas, signature

on creation

Places a new account in the system with code

(code in account is whatever is returned from the init routine)

message calls

recipient, value (ETH), datagas, signature

on message receipt

value is transferred to recipient’s balance;recipient’s code (if any) runs.

code execution: virtual machineArbitrary size stack

PUSH, POP, SWAP, DUP

Arbitrary temp memory (2256 bytes addressable)

MLOAD, MSTORE

Code stored in virtual ROMCODESIZE, CODECOPY

virtual machine

Arithmetic/Logic & CryptoADD, EXP, EQ, AND, LT, BYTE, SHA3 &c

Flow controlJUMP, JUMPI, PC

vm: environment

Can read message input dataCALLDATALOAD, CALLDATASIZE, CALLDATACOPY

Can halt & give message output dataRETURN, STOP, SUICIDE

vm: environment

Arbitrary storage (2256 words addressable)ISOLATED FROM OTHER ACCOUNTS

SLOAD, SSTORE

Can create & send messages.CREATE, CALL

vm: environment

Can query blockchain informationTIMESTAMP, PREVHASH, NUMBER, COINBASE, &c.

Other informationADDRESS, BALANCE, ORIGIN, CALLER

vm

Storage, memory & processing costs ETH

(actually, costs GAS butGAS ⇔ ETH)

lll: basics

expression := ( <op-code> [<operand> ...] )<operand> is just expression

0 -> PUSH 0

(mload 0x20) -> PUSH 0x20 MLOAD

contract: currency(sstore (caller) 0x1000000000000)(returnlll (when (= (calldatasize) 64) (seq(mstore 0 (sload (caller)))(when (>= (mload 0) (calldataload 32)) (seq(sstore (caller) (sub (mload 0) (calldataload 32)))(sstore (calldataload 0)(add (sload (calldataload 0)) (calldataload 32))))))))

lll: advanced

variables: (set ‘name <expression>)

(mload x) / (mstore y z): @x / [y] z

(sload x) / (store y z): @@x / [[y]] z

(calldataload x): $x

contract: currency[[ (caller) ]] 0x1000000000000(returnlll (when (= (calldatasize) 64) { (set ‘a @@(caller)) (when (>= @a $32) { [[(caller)]] (- @a $32) [[$0]] (+ @@ $0 $32) })}))

transaction: transfer

to: <currency-contract>data: <recipient’s-address> <amount-to-transfer>

lll: advanced

variadic arithmetic/logic

macros: (def ‘sqr (x) (* x x)) (sqr 4): (* 4 4)

lll: name registration

(def ‘registrar 0x50441127ea5b9dfd835a9aba4e1dc9c1257b58ca)[0] 'register[32] 'Exchange(call (- (gas) 21) registrar 0 0 64 0 0)

exchange walkthrough...

thanks

Looking for devs, too...

C++ in Berlin especially!