Skip to content

Commit

Permalink
Update deposit_data and check amount matches
Browse files Browse the repository at this point in the history
  • Loading branch information
NIC619 committed Mar 21, 2019
1 parent f25c5bd commit 4c8ad52
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion deposit_contract/contracts/validator_registration.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"abi": [{"name": "Deposit", "inputs": [{"type": "bytes", "name": "data", "indexed": false}, {"type": "bytes", "name": "merkle_tree_index", "indexed": false}], "anonymous": false, "type": "event"}, {"name": "Eth2Genesis", "inputs": [{"type": "bytes32", "name": "deposit_root", "indexed": false}, {"type": "bytes", "name": "deposit_count", "indexed": false}, {"type": "bytes", "name": "time", "indexed": false}], "anonymous": false, "type": "event"}, {"name": "__init__", "outputs": [], "inputs": [], "constant": false, "payable": false, "type": "constructor"}, {"name": "to_little_endian_64", "outputs": [{"type": "bytes", "name": "out"}], "inputs": [{"type": "uint256", "name": "value"}], "constant": true, "payable": false, "type": "function", "gas": 7089}, {"name": "get_deposit_root", "outputs": [{"type": "bytes32", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 26965}, {"name": "get_deposit_count", "outputs": [{"type": "bytes", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 11038}, {"name": "deposit", "outputs": [], "inputs": [{"type": "bytes", "name": "deposit_input"}], "constant": false, "payable": true, "type": "function", "gas": 320173}, {"name": "chainStarted", "outputs": [{"type": "bool", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 603}], "bytecode": "0x600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052341561009e57600080fd5b6101406000601f818352015b600061014051602081106100bd57600080fd5b600060c052602060c020015460208261016001015260208101905061014051602081106100e957600080fd5b600060c052602060c020015460208261016001015260208101905080610160526101609050805160208201209050606051600161014051018060405190131561013157600080fd5b809190121561013f57600080fd5b6020811061014c57600080fd5b600060c052602060c0200155606051600161014051018060405190131561017257600080fd5b809190121561018057600080fd5b6020811061018d57600080fd5b600060c052602060c020015460605160016101405101806040519013156101b357600080fd5b80919012156101c157600080fd5b602081106101ce57600080fd5b600160c052602060c02001555b81516001018083528114156100aa575b5050610ed756600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526380673289600051141561026b57602060046101403734156100b457600080fd5b67ffffffffffffffff6101405111156100cc57600080fd5b60006101605261014051610180526101a060006008818352015b6101605160086000811215610103578060000360020a820461010a565b8060020a82025b905090506101605260ff61018051166101c052610160516101c0516101605101101561013557600080fd5b6101c051610160510161016052610180517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8600081121561017e578060000360020a8204610185565b8060020a82025b90509050610180525b81516001018083528114156100e6575b5050601860086020820661026001602082840111156101bc57600080fd5b60208061028082610160600060046015f1505081815280905090509050805160200180610320828460006004600a8704601201f16101f957600080fd5b50506103205160206001820306601f8201039050610380610320516008818352015b8261038051111561022b57610247565b60006103805161034001535b815160010180835281141561021b575b5050506020610300526040610320510160206001820306601f8201039050610300f3005b63c5f2892f600051141561039957341561028457600080fd5b6000610140526002546101605261018060006020818352015b600160016101605116141561030957600061018051602081106102bf57600080fd5b600160c052602060c0200154602082610220010152602081019050610140516020826102200101526020810190508061022052610220905080516020820120905061014052610362565b6000610140516020826101a0010152602081019050610180516020811061032f57600080fd5b600060c052602060c02001546020826101a0010152602081019050806101a0526101a09050805160208201209050610140525b610160600261037057600080fd5b60028151048152505b815160010180835281141561029d575b50506101405160005260206000f3005b63621fd130600051141561046f5734156103b257600080fd5b60606101c060246380673289610140526002546101605261015c6000305af16103da57600080fd5b6101e0805160200180610260828460006004600a8704601201f16103fd57600080fd5b50506102605160206001820306601f82010390506102c0610260516008818352015b826102c051111561042f5761044b565b60006102c05161028001535b815160010180835281141561041f575b5050506020610240526040610260510160206001820306601f8201039050610240f3005b6398b1e06a6000511415610cb957602060046101403760d06004356004016101603760b06004356004013511156104a557600080fd5b633b9aca0061028052610280516104bb57600080fd5b61028051340461026052633b9aca006102605110156104d957600080fd5b6407735940006102605111156104ee57600080fd5b6002546102a05260006060610440602463806732896103c052610260516103e0526103dc6000305af161052057600080fd5b6104606008806020846104a001018260208501600060046012f150508051820191505061016060b0806020846104a001018260208501600060046023f1505080518201915050806104a0526104a090508051602001806102c0828460006004600a8704601201f161059057600080fd5b505060006105a05260026105c0526105e060006020818352015b60006105c0516105b957600080fd5b6105c0516102a05160016102a0510110156105d357600080fd5b60016102a05101061415156105e757610653565b6105a060605160018251018060405190131561060257600080fd5b809190121561061057600080fd5b8152506105c08051151561062557600061063f565b600281516002835102041461063957600080fd5b60028151025b8152505b81516001018083528114156105aa575b50506102c08051602082012090506106005261062060006020818352015b6105a0516106205112156106dc576000610620516020811061069257600080fd5b600160c052602060c02001546020826106400101526020810190506106005160208261064001015260208101905080610640526106409050805160208201209050610600526106e1565b6106f2565b5b8151600101808352811415610671575b5050610600516105a0516020811061070957600080fd5b600160c052602060c0200155600280546001825401101561072957600080fd5b60018154018155506020610740600463c5f2892f6106e0526106fc6000305af161075257600080fd5b610740516106c05260606107e060246380673289610760526102a0516107805261077c6000305af161078357600080fd5b610800805160200180610840828460006004600a8704601201f16107a657600080fd5b505060406108c0526108c051610900526102c08051602001806108c05161090001828460006004600a8704601201f16107de57600080fd5b50506108c051610900015160206001820306601f82010390506108c051610900016108a0815160c0818352015b836108a05110151561081c57610839565b60006108a0516020850101535b815160010180835281141561080b575b5050505060206108c051610900015160206001820306601f82010390506108c05101016108c0526108c051610920526108408051602001806108c05161090001828460006004600a8704601201f161089057600080fd5b50506108c051610900015160206001820306601f82010390506108c051610900016108a081516020818352015b836108a0511015156108ce576108eb565b60006108a0516020850101535b81516001018083528114156108bd575b5050505060206108c051610900015160206001820306601f82010390506108c05101016108c0527f42dc88172194fbb332e0cb2fd0d4411b0b44a152a0d05a406b6790641bdefec06108c051610900a1640773594000610260511415610cb757600380546001825401101561095f57600080fd5b6001815401815550620100006003541415610cb657426109605242610980526201518061098b57600080fd5b6201518061098051066109605110156109a357600080fd5b4261098052620151806109b557600080fd5b62015180610980510661096051036202a30042610960524261098052620151806109de57600080fd5b6201518061098051066109605110156109f657600080fd5b426109805262015180610a0857600080fd5b6201518061098051066109605103011015610a2257600080fd5b6202a3004261096052426109805262015180610a3d57600080fd5b620151806109805106610960511015610a5557600080fd5b426109805262015180610a6757600080fd5b620151806109805106610960510301610940526060610a20602463806732896109a0526002546109c0526109bc6000305af1610aa257600080fd5b610a40805160200180610a80828460006004600a8704601201f1610ac557600080fd5b50506060610b6060246380673289610ae05261094051610b0052610afc6000305af1610af057600080fd5b610b80805160200180610bc0828460006004600a8704601201f1610b1357600080fd5b50506106c051610c80526060610c4052610c4051610ca052610a80805160200180610c4051610c8001828460006004600a8704601201f1610b5357600080fd5b5050610c4051610c80015160206001820306601f8201039050610c4051610c8001610c2081516020818352015b83610c2051101515610b9157610bae565b6000610c20516020850101535b8151600101808352811415610b80575b505050506020610c4051610c80015160206001820306601f8201039050610c40510101610c4052610c4051610cc052610bc0805160200180610c4051610c8001828460006004600a8704601201f1610c0557600080fd5b5050610c4051610c80015160206001820306601f8201039050610c4051610c8001610c2081516020818352015b83610c2051101515610c4357610c60565b6000610c20516020850101535b8151600101808352811415610c32575b505050506020610c4051610c80015160206001820306601f8201039050610c40510101610c40527f08b71ef3f1b58f7a23ffb82e27f12f0888c8403f1ceb0ea7ea26b274e2189d4c610c4051610c80a160016004555b5b005b63845980e86000511415610cdf573415610cd257600080fd5b60045460005260206000f3005b60006000fd5b6101f2610ed7036101f26000396101f2610ed7036000f3"}
{"abi": [{"name": "Deposit", "inputs": [{"type": "bytes", "name": "data", "indexed": false}, {"type": "bytes", "name": "merkle_tree_index", "indexed": false}], "anonymous": false, "type": "event"}, {"name": "Eth2Genesis", "inputs": [{"type": "bytes32", "name": "deposit_root", "indexed": false}, {"type": "bytes", "name": "deposit_count", "indexed": false}, {"type": "bytes", "name": "time", "indexed": false}], "anonymous": false, "type": "event"}, {"name": "__init__", "outputs": [], "inputs": [], "constant": false, "payable": false, "type": "constructor"}, {"name": "to_little_endian_64", "outputs": [{"type": "bytes", "name": "out"}], "inputs": [{"type": "uint256", "name": "value"}], "constant": true, "payable": false, "type": "function", "gas": 7089}, {"name": "from_little_endian_64", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "bytes", "name": "value"}], "constant": true, "payable": false, "type": "function", "gas": 5983}, {"name": "get_deposit_root", "outputs": [{"type": "bytes32", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 26995}, {"name": "get_deposit_count", "outputs": [{"type": "bytes", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 11068}, {"name": "deposit", "outputs": [], "inputs": [{"type": "bytes", "name": "deposit_data"}], "constant": false, "payable": true, "type": "function", "gas": 318628}, {"name": "chainStarted", "outputs": [{"type": "bool", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 633}], "bytecode": "0x600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052341561009e57600080fd5b6101406000601f818352015b600061014051602081106100bd57600080fd5b600060c052602060c020015460208261016001015260208101905061014051602081106100e957600080fd5b600060c052602060c020015460208261016001015260208101905080610160526101609050805160208201209050606051600161014051018060405190131561013157600080fd5b809190121561013f57600080fd5b6020811061014c57600080fd5b600060c052602060c0200155606051600161014051018060405190131561017257600080fd5b809190121561018057600080fd5b6020811061018d57600080fd5b600060c052602060c020015460605160016101405101806040519013156101b357600080fd5b80919012156101c157600080fd5b602081106101ce57600080fd5b600160c052602060c02001555b81516001018083528114156100aa575b505061109256600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526380673289600051141561026b57602060046101403734156100b457600080fd5b67ffffffffffffffff6101405111156100cc57600080fd5b60006101605261014051610180526101a060006008818352015b6101605160086000811215610103578060000360020a820461010a565b8060020a82025b905090506101605260ff61018051166101c052610160516101c0516101605101101561013557600080fd5b6101c051610160510161016052610180517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8600081121561017e578060000360020a8204610185565b8060020a82025b90509050610180525b81516001018083528114156100e6575b5050601860086020820661026001602082840111156101bc57600080fd5b60208061028082610160600060046015f1505081815280905090509050805160200180610320828460006004600a8704601201f16101f957600080fd5b50506103205160206001820306601f8201039050610380610320516008818352015b8261038051111561022b57610247565b60006103805161034001535b815160010180835281141561021b575b5050506020610300526040610320510160206001820306601f8201039050610300f3005b639d70e8066000511415610405576020600461014037341561028c57600080fd5b60286004356004016101603760086004356004013511156102ac57600080fd5b60006101c0526101608060200151600082518060209013156102cd57600080fd5b80919012156102db57600080fd5b806020036101000a82049050905090506101e05261020060006008818352015b60ff6101e05116606051606051610200516007038060405190131561031f57600080fd5b809190121561032d57600080fd5b6008028060405190131561034057600080fd5b809190121561034e57600080fd5b6000811215610365578060000360020a820461036c565b8060020a82025b90509050610220526101c051610220516101c05101101561038c57600080fd5b610220516101c051016101c0526101e0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff860008112156103d5578060000360020a82046103dc565b8060020a82025b905090506101e0525b81516001018083528114156102fb575b50506101c05160005260206000f3005b63c5f2892f600051141561053357341561041e57600080fd5b6000610140526002546101605261018060006020818352015b60016001610160511614156104a3576000610180516020811061045957600080fd5b600160c052602060c02001546020826102200101526020810190506101405160208261022001015260208101905080610220526102209050805160208201209050610140526104fc565b6000610140516020826101a001015260208101905061018051602081106104c957600080fd5b600060c052602060c02001546020826101a0010152602081019050806101a0526101a09050805160208201209050610140525b610160600261050a57600080fd5b60028151048152505b8151600101808352811415610437575b50506101405160005260206000f3005b63621fd130600051141561060957341561054c57600080fd5b60606101c060246380673289610140526002546101605261015c6000305af161057457600080fd5b6101e0805160200180610260828460006004600a8704601201f161059757600080fd5b50506102605160206001820306601f82010390506102c0610260516008818352015b826102c05111156105c9576105e5565b60006102c05161028001535b81516001018083528114156105b9575b5050506020610240526040610260510160206001820306601f8201039050610240f3005b6398b1e06a6000511415610e7457602060046101403760d86004356004016101603760b860043560040135111561063f57600080fd5b60206107c060646020639d70e80661070052806107205260506008602082066105e00161016051828401111561067457600080fd5b60b8806106008260206020880688030161016001600060046024f1505081815280905090509050808051602001808461072001828460006004600a8704601201f16106be57600080fd5b50508051820160206001820306601f820103905060200191505061071c90506000305af16106eb57600080fd5b6107c05161026052633b9aca006107e0526107e05161070957600080fd5b6107e0513404610260511461071d57600080fd5b633b9aca0061026051101561073157600080fd5b64077359400061026051111561074657600080fd5b6002546108005260006108205260026108405261086060006020818352015b60006108405161077457600080fd5b610840516108005160016108005101101561078e57600080fd5b60016108005101061415156107a25761080e565b6108206060516001825101806040519013156107bd57600080fd5b80919012156107cb57600080fd5b815250610840805115156107e05760006107fa565b60028151600283510204146107f457600080fd5b60028151025b8152505b8151600101808352811415610765575b5050610160805160208201209050610880526108a060006020818352015b610820516108a05112156108975760006108a0516020811061084d57600080fd5b600160c052602060c02001546020826108c0010152602081019050610880516020826108c0010152602081019050806108c0526108c090508051602082012090506108805261089c565b6108ad565b5b815160010180835281141561082c575b50506108805161082051602081106108c457600080fd5b600160c052602060c020015560028054600182540110156108e457600080fd5b600181540181555060206109c0600463c5f2892f6109605261097c6000305af161090d57600080fd5b6109c051610940526060610a60602463806732896109e05261080051610a00526109fc6000305af161093e57600080fd5b610a80805160200180610ac0828460006004600a8704601201f161096157600080fd5b50506040610b4052610b4051610b8052610160805160200180610b4051610b8001828460006004600a8704601201f161099957600080fd5b5050610b4051610b80015160206001820306601f8201039050610b4051610b8001610b20815160c0818352015b83610b20511015156109d7576109f4565b6000610b20516020850101535b81516001018083528114156109c6575b505050506020610b4051610b80015160206001820306601f8201039050610b40510101610b4052610b4051610ba052610ac0805160200180610b4051610b8001828460006004600a8704601201f1610a4b57600080fd5b5050610b4051610b80015160206001820306601f8201039050610b4051610b8001610b2081516020818352015b83610b2051101515610a8957610aa6565b6000610b20516020850101535b8151600101808352811415610a78575b505050506020610b4051610b80015160206001820306601f8201039050610b40510101610b40527f42dc88172194fbb332e0cb2fd0d4411b0b44a152a0d05a406b6790641bdefec0610b4051610b80a1640773594000610260511415610e72576003805460018254011015610b1a57600080fd5b6001815401815550620100006003541415610e715742610be05242610c005262015180610b4657600080fd5b62015180610c005106610be0511015610b5e57600080fd5b42610c005262015180610b7057600080fd5b62015180610c005106610be051036202a30042610be05242610c005262015180610b9957600080fd5b62015180610c005106610be0511015610bb157600080fd5b42610c005262015180610bc357600080fd5b62015180610c005106610be05103011015610bdd57600080fd5b6202a30042610be05242610c005262015180610bf857600080fd5b62015180610c005106610be0511015610c1057600080fd5b42610c005262015180610c2257600080fd5b62015180610c005106610be0510301610bc0526060610ca060246380673289610c2052600254610c4052610c3c6000305af1610c5d57600080fd5b610cc0805160200180610d00828460006004600a8704601201f1610c8057600080fd5b50506060610de060246380673289610d6052610bc051610d8052610d7c6000305af1610cab57600080fd5b610e00805160200180610e40828460006004600a8704601201f1610cce57600080fd5b505061094051610f00526060610ec052610ec051610f2052610d00805160200180610ec051610f0001828460006004600a8704601201f1610d0e57600080fd5b5050610ec051610f00015160206001820306601f8201039050610ec051610f0001610ea081516020818352015b83610ea051101515610d4c57610d69565b6000610ea0516020850101535b8151600101808352811415610d3b575b505050506020610ec051610f00015160206001820306601f8201039050610ec0510101610ec052610ec051610f4052610e40805160200180610ec051610f0001828460006004600a8704601201f1610dc057600080fd5b5050610ec051610f00015160206001820306601f8201039050610ec051610f0001610ea081516020818352015b83610ea051101515610dfe57610e1b565b6000610ea0516020850101535b8151600101808352811415610ded575b505050506020610ec051610f00015160206001820306601f8201039050610ec0510101610ec0527f08b71ef3f1b58f7a23ffb82e27f12f0888c8403f1ceb0ea7ea26b274e2189d4c610ec051610f00a160016004555b5b005b63845980e86000511415610e9a573415610e8d57600080fd5b60045460005260206000f3005b60006000fd5b6101f2611092036101f26000396101f2611092036000f3"}
12 changes: 5 additions & 7 deletions deposit_contract/contracts/validator_registration.v.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,17 @@ def get_deposit_count() -> bytes[8]:

@payable
@public
# `deposit_input` includes 48 bytes `pubkey`, 32 bytes `withdrawal_credentials`
# `deposit_data` includes:
# 48 bytes `pubkey`, 32 bytes `withdrawal_credentials`, 8 bytes `amount`
# and 96 bytes `proof_of_possession`.
def deposit(deposit_input: bytes[176]):
deposit_amount: uint256 = msg.value / as_wei_value(1, "gwei")
def deposit(deposit_data: bytes[184]):
deposit_amount: uint256 = self.from_little_endian_64(slice(deposit_data, start=80, len=8))

assert deposit_amount == msg.value / as_wei_value(1, "gwei")
assert deposit_amount >= MIN_DEPOSIT_AMOUNT
assert deposit_amount <= MAX_DEPOSIT_AMOUNT

index: uint256 = self.deposit_count
deposit_data: bytes[184] = concat(
self.to_little_endian_64(deposit_amount),
deposit_input,
)

# add deposit to merkle tree
i: int128 = 0
Expand Down
Loading

0 comments on commit 4c8ad52

Please sign in to comment.