More Related Content Similar to Ethereum hackers Similar to Ethereum hackers (20) Ethereum hackers3. basic premise
Place & 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.
8. ethereum
100% Free software, open development
github.com/ethereum
C++, Go, Python implementations
(Java & Javascript, too)
10. state: accounts
Address
(160-bit excerpt from the 256-bit public key)
Balance, Nonce[, Code, Storage]
(latter two non-null if a ‘contract’)
13. on creation
Places a new account in the system with code
(code in account is whatever is returned from
the init routine)
15. on message receipt
value is transferred to recipient’s balance;
recipient’s code (if any) runs.
16. code execution: virtual machine
Arbitrary size stack
PUSH, POP, SWAP, DUP
Arbitrary temp memory (2256 bytes
addressable)
MLOAD, MSTORE
Code stored in virtual ROM
CODESIZE, CODECOPY
18. vm: environment
Can read message input data
CALLDATALOAD, CALLDATASIZE, CALLDATACOPY
Can halt & give message output data
RETURN, STOP, SUICIDE
19. vm: environment
Arbitrary storage (2256 words addressable)
ISOLATED FROM OTHER ACCOUNTS
SLOAD, SSTORE
Can create & send messages.
CREATE, CALL
20. vm: environment
Can query blockchain information
TIMESTAMP, PREVHASH, NUMBER, COINBASE, &c.
Other information
ADDRESS, BALANCE, ORIGIN, CALLER
22. lll: basics
expression := ( <op-code> [<operand> ...] )
<operand> is just expression
0 -> PUSH 0
(mload 0x20) -> PUSH 0x20 MLOAD
23. 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)))
))
)))
24. 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
25. contract: currency
[[ (caller) ]] 0x1000000000000
(returnlll (when (= (calldatasize) 64) {
(set ‘a @@(caller))
(when (>= @a $32) {
[[(caller)]] (- @a $32)
[[$0]] (+ @@ $0 $32)
})
}))
28. lll: name registration
(def ‘registrar
0x50441127ea5b9dfd835a9aba4e1dc9c1257b58ca)
[0] 'register
[32] 'Exchange
(call (- (gas) 21) registrar 0 0 64 0 0)