diff --git a/beacon-chain/powchain/service_test.go b/beacon-chain/powchain/service_test.go index 653e538ab..4fcb33907 100644 --- a/beacon-chain/powchain/service_test.go +++ b/beacon-chain/powchain/service_test.go @@ -124,6 +124,7 @@ func setup() (*testAccount, error) { minDeposit, maxDeposit, false, + addr, ) if err != nil { return nil, err diff --git a/contracts/deposit-contract/abi.json b/contracts/deposit-contract/abi.json index 07814e4ec..3a68988cc 100644 --- a/contracts/deposit-contract/abi.json +++ b/contracts/deposit-contract/abi.json @@ -1 +1 @@ -[{"name": "Deposit", "inputs": [{"type": "bytes32", "name": "deposit_root", "indexed": false}, {"type": "bytes", "name": "data", "indexed": false}, {"type": "bytes", "name": "merkle_tree_index", "indexed": false}, {"type": "bytes32[32]", "name": "branch", "indexed": false}], "anonymous": false, "type": "event"}, {"name": "ChainStart", "inputs": [{"type": "bytes32", "name": "deposit_root", "indexed": false}, {"type": "bytes", "name": "time", "indexed": false}], "anonymous": false, "type": "event"}, {"name": "__init__", "outputs": [], "inputs": [{"type": "uint256", "name": "depositThreshold"}, {"type": "uint256", "name": "minDeposit"}, {"type": "uint256", "name": "maxDeposit"}, {"type": "bool", "name": "skipChainstartDelay"}], "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": 15330}, {"name": "get_deposit_root", "outputs": [{"type": "bytes32", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 30835}, {"name": "deposit", "outputs": [], "inputs": [{"type": "bytes", "name": "deposit_input"}], "constant": false, "payable": true, "type": "function", "gas": 531258}, {"name": "CHAIN_START_FULL_DEPOSIT_THRESHOLD", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 603}, {"name": "MIN_DEPOSIT_AMOUNT", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 633}, {"name": "MAX_DEPOSIT_AMOUNT", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 663}, {"name": "deposit_count", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 693}, {"name": "full_deposit_count", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 723}, {"name": "skip_chainstart_delay", "outputs": [{"type": "bool", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 753}, {"name": "genesisTime", "outputs": [{"type": "bytes", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 3006}] \ No newline at end of file +[{"name": "Deposit", "inputs": [{"type": "bytes32", "name": "deposit_root", "indexed": false}, {"type": "bytes", "name": "data", "indexed": false}, {"type": "bytes", "name": "merkle_tree_index", "indexed": false}, {"type": "bytes32[32]", "name": "branch", "indexed": false}], "anonymous": false, "type": "event"}, {"name": "ChainStart", "inputs": [{"type": "bytes32", "name": "deposit_root", "indexed": false}, {"type": "bytes", "name": "time", "indexed": false}], "anonymous": false, "type": "event"}, {"name": "__init__", "outputs": [], "inputs": [{"type": "uint256", "name": "depositThreshold"}, {"type": "uint256", "name": "minDeposit"}, {"type": "uint256", "name": "maxDeposit"}, {"type": "bool", "name": "skipChainstartDelay"}, {"type": "address", "name": "_drain_address"}], "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": 15330}, {"name": "get_deposit_root", "outputs": [{"type": "bytes32", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 30835}, {"name": "deposit", "outputs": [], "inputs": [{"type": "bytes", "name": "deposit_input"}], "constant": false, "payable": true, "type": "function", "gas": 531258}, {"name": "drain", "outputs": [], "inputs": [], "constant": false, "payable": false, "type": "function", "gas": 35793}, {"name": "CHAIN_START_FULL_DEPOSIT_THRESHOLD", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 633}, {"name": "MIN_DEPOSIT_AMOUNT", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 663}, {"name": "MAX_DEPOSIT_AMOUNT", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 693}, {"name": "deposit_count", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 723}, {"name": "full_deposit_count", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 753}, {"name": "skip_chainstart_delay", "outputs": [{"type": "bool", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 783}, {"name": "genesisTime", "outputs": [{"type": "bytes", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 3036}, {"name": "drain_address", "outputs": [{"type": "address", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 843}] diff --git a/contracts/deposit-contract/bytecode.bin b/contracts/deposit-contract/bytecode.bin index e96b55543..298acfbaf 100644 --- a/contracts/deposit-contract/bytecode.bin +++ b/contracts/deposit-contract/bytecode.bin @@ -1 +1 @@ -0x600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052608061165b6101403934156100a757600080fd5b6020606061165b0160c03960c051600281106100c257600080fd5b506101405160005561016051600155610180516002556101a0516007556101c06000601f818352015b60006101c051602081106100fe57600080fd5b600360c052602060c02001546020826101e00101526020810190506101c0516020811061012a57600080fd5b600360c052602060c02001546020826101e0010152602081019050806101e0526101e0905080516020820120905060605160016101c051018060405190131561017257600080fd5b809190121561018057600080fd5b6020811061018d57600080fd5b600360c052602060c020015560605160016101c05101806040519013156101b357600080fd5b80919012156101c157600080fd5b602081106101ce57600080fd5b600360c052602060c020015460605160016101c05101806040519013156101f457600080fd5b809190121561020257600080fd5b6020811061020f57600080fd5b600460c052602060c02001555b81516001018083528114156100eb575b505061164356600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526000156101a3575b6101605261014052601860086020820661020001602082840111156100bf57600080fd5b60208061022082610140600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16100fc57600080fd5b50506102c05160206001820306601f82010390506103206102c0516008818352015b8261032051111561012e5761014a565b6000610320516102e001535b815160010180835281141561011e575b50505060206102a05260406102c0510160206001820306601f8201039050610280525b60006102805111151561017f5761019b565b602061028051036102a00151602061028051036102805261016d565b610160515650005b638067328960005114156104f957602060046101403734156101c457600080fd5b67ffffffffffffffff6101405111156101dc57600080fd5b6101405161016051610180516101a05163b0429c706101c052610140516101e0526101e0516006580161009b565b506102405260006102a0525b6102405160206001820306601f82010390506102a05110151561023857610251565b6102a05161026001526102a0516020016102a052610216565b6101a052610180526101605261014052610240805160200180610160828460006004600a8704601201f161028457600080fd5b50506101608060200151600082518060209013156102a157600080fd5b80919012156102af57600080fd5b806020036101000a82049050905090506102c05260006102e05261030060006008818352015b6102e051600860008112156102f2578060000360020a82046102f9565b8060020a82025b905090506102e05260ff6102c05116610320526102e051610320516102e05101101561032457600080fd5b610320516102e051016102e0526102c0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8600081121561036d578060000360020a8204610374565b8060020a82025b905090506102c0525b81516001018083528114156102d5575b50506101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05163b0429c70610340526102e05161036052610360516006580161009b565b506103c0526000610420525b6103c05160206001820306601f8201039050610420511015156104135761042c565b610420516103e0015261042051602001610420526103f1565b6102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103c0805160200180610480828460006004600a8704601201f161048757600080fd5b50506104805160206001820306601f82010390506104e0610480516008818352015b826104e05111156104b9576104d5565b60006104e0516104a001535b81516001018083528114156104a9575b5050506020610460526040610480510160206001820306601f8201039050610460f3005b63c5f2892f600051141561063257341561051257600080fd5b6000610140526005546101605261018060006020818352015b6001600261053857600080fd5b6002610160510614156105a2576000610180516020811061055857600080fd5b600460c052602060c02001546020826102200101526020810190506101405160208261022001015260208101905080610220526102209050805160208201209050610140526105fb565b6000610140516020826101a001015260208101905061018051602081106105c857600080fd5b600360c052602060c02001546020826101a0010152602081019050806101a0526101a09050805160208201209050610140525b610160600261060957600080fd5b60028151048152505b815160010180835281141561052b575b50506101405160005260206000f3005b6398b1e06a60005114156112435760206004610140376102206004356004016101603761020060043560040135111561066a57600080fd5b633b9aca006103c0526103c05161068057600080fd5b6103c05134046103a0526001546103a051101561069c57600080fd5b6002546103a05111156106ae57600080fd5b6005546103e05242610400526000606061070060246380673289610680526103a0516106a05261069c6000305af16106e557600080fd5b61072060088060208461084001018260208501600060046012f150508051820191505060606107e06024638067328961076052610400516107805261077c6000305af161073157600080fd5b61080060088060208461084001018260208501600060046012f15050805182019150506101606102008060208461084001018260208501600060046045f150508051820191505080610840526108409050805160200180610420828460006004600a8704601201f16107a257600080fd5b50506000610aa0526002610ac052610ae060006020818352015b6000610ac0516107cb57600080fd5b610ac0516103e05160016103e0510110156107e557600080fd5b60016103e05101061415156107f957610865565b610aa060605160018251018060405190131561081457600080fd5b809190121561082257600080fd5b815250610ac080511515610837576000610851565b600281516002835102041461084b57600080fd5b60028151025b8152505b81516001018083528114156107bc575b5050610420805160208201209050610b0052610b2060006020818352015b610aa051610b205112156108ea576000610b2051602081106108a457600080fd5b600460c052602060c0200154602082610b40010152602081019050610b0051602082610b4001015260208101905080610b4052610b409050805160208201209050610b00525b5b8151600101808352811415610883575b5050610b0051610aa0516020811061091257600080fd5b600460c052602060c0200155600580546001825401101561093257600080fd5b60018154018155506020610c40600463c5f2892f610be052610bfc6000305af161095b57600080fd5b610c4051610bc0526060610ce060246380673289610c60526103e051610c8052610c7c6000305af161098c57600080fd5b610d00805160200180610d40828460006004600a8704601201f16109af57600080fd5b5050610bc051610e0052600460c052602060c02054610e60526001600460c052602060c0200154610e80526002600460c052602060c0200154610ea0526003600460c052602060c0200154610ec0526004600460c052602060c0200154610ee0526005600460c052602060c0200154610f00526006600460c052602060c0200154610f20526007600460c052602060c0200154610f40526008600460c052602060c0200154610f60526009600460c052602060c0200154610f8052600a600460c052602060c0200154610fa052600b600460c052602060c0200154610fc052600c600460c052602060c0200154610fe052600d600460c052602060c020015461100052600e600460c052602060c020015461102052600f600460c052602060c0200154611040526010600460c052602060c0200154611060526011600460c052602060c0200154611080526012600460c052602060c02001546110a0526013600460c052602060c02001546110c0526014600460c052602060c02001546110e0526015600460c052602060c0200154611100526016600460c052602060c0200154611120526017600460c052602060c0200154611140526018600460c052602060c0200154611160526019600460c052602060c020015461118052601a600460c052602060c02001546111a052601b600460c052602060c02001546111c052601c600460c052602060c02001546111e052601d600460c052602060c020015461120052601e600460c052602060c020015461122052601f600460c052602060c020015461124052610460610dc052610dc051610e2052610420805160200180610dc051610e0001828460006004600a8704601201f1610c2d57600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da08151610220818352015b83610da051101515610c6c57610c89565b6000610da0516020850101535b8151600101808352811415610c5b575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc052610dc051610e4052610d40805160200180610dc051610e0001828460006004600a8704601201f1610ce057600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da081516020818352015b83610da051101515610d1e57610d3b565b6000610da0516020850101535b8151600101808352811415610d0d575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc0527fce7a77a358682d6c81f71216fb7fb108b03bc8badbf67f5d131ba5363cbefb42610dc051610e00a16002546103a0511415611241576006805460018254011015610dac57600080fd5b600181540181555060005460065414156112405760075415610f975760606114c06024638067328961144052610400516114605261145c6000305af1610df157600080fd5b6114e080600860c052602060c020602082510161012060006002818352015b82610120516020021115610e2357610e45565b61012051602002850151610120518501555b8151600101808352811415610e10575b5050505050506020611580600463c5f2892f6115205261153c6000305af1610e6c57600080fd5b611580516115a0526115a0516116205260406115e0526115e0516116405260088060c052602060c0206115e05161162001602082540161012060006002818352015b82610120516020021115610ec157610ee3565b61012051850154610120516020028501525b8151600101808352811415610eae575b5050505050506115e051611620015160206001820306601f82010390506115e051611620016115c081516020818352015b836115c051101515610f2557610f42565b60006115c0516020850101535b8151600101808352811415610f14575b5050505060206115e051611620015160206001820306601f82010390506115e05101016115e0527fd1faa3f9bca1d698df559716fe6d1c9999155b38d3158fffbc98d76d568091fc6115e051611620a161123f565b4261128052426112a05262015180610fae57600080fd5b620151806112a05106611280511015610fc657600080fd5b426112a05262015180610fd857600080fd5b620151806112a051066112805103620151804261128052426112a0526201518061100157600080fd5b620151806112a0510661128051101561101957600080fd5b426112a0526201518061102b57600080fd5b620151806112a05106611280510301101561104557600080fd5b620151804261128052426112a0526201518061106057600080fd5b620151806112a0510661128051101561107857600080fd5b426112a0526201518061108a57600080fd5b620151806112a05106611280510301611260526060611340602463806732896112c052611260516112e0526112dc6000305af16110c657600080fd5b61136080600860c052602060c020602082510161012060006002818352015b826101205160200211156110f85761111a565b61012051602002850151610120518501555b81516001018083528114156110e5575b505050505050610bc0516114005260406113c0526113c0516114205260088060c052602060c0206113c05161140001602082540161012060006002818352015b8261012051602002111561116d5761118f565b61012051850154610120516020028501525b815160010180835281141561115a575b5050505050506113c051611400015160206001820306601f82010390506113c051611400016113a081516020818352015b836113a0511015156111d1576111ee565b60006113a0516020850101535b81516001018083528114156111c0575b5050505060206113c051611400015160206001820306601f82010390506113c05101016113c0527fd1faa3f9bca1d698df559716fe6d1c9999155b38d3158fffbc98d76d568091fc6113c051611400a15b5b5b005b634a637042600051141561126957341561125c57600080fd5b60005460005260206000f3005b631ea30fef600051141561128f57341561128257600080fd5b60015460005260206000f3005b634c34a98260005114156112b55734156112a857600080fd5b60025460005260206000f3005b63eb8545ee60005114156112db5734156112ce57600080fd5b60055460005260206000f3005b63188e6c8760005114156113015734156112f457600080fd5b60065460005260206000f3005b63eb5cc58e600051141561132757341561131a57600080fd5b60075460005260206000f3005b6342c6498a600051141561140a57341561134057600080fd5b60088060c052602060c020610180602082540161012060006002818352015b8261012051602002111561137257611394565b61012051850154610120516020028501525b815160010180835281141561135f575b5050505050506101805160206001820306601f82010390506101e0610180516008818352015b826101e05111156113ca576113e6565b60006101e0516101a001535b81516001018083528114156113ba575b5050506020610160526040610180510160206001820306601f8201039050610160f3005b60006000fd5b61023361164303610233600039610233611643036000f3 \ No newline at end of file +0x600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05260a06116d96101403934156100a757600080fd5b602060606116d90160c03960c051600281106100c257600080fd5b50602060806116d90160c03960c05160205181106100df57600080fd5b506101405160005561016051600155610180516002556101a0516007556101c0516009556101e06000601f818352015b60006101e0516020811061012257600080fd5b600360c052602060c02001546020826102000101526020810190506101e0516020811061014e57600080fd5b600360c052602060c02001546020826102000101526020810190508061020052610200905080516020820120905060605160016101e051018060405190131561019657600080fd5b80919012156101a457600080fd5b602081106101b157600080fd5b600360c052602060c020015560605160016101e05101806040519013156101d757600080fd5b80919012156101e557600080fd5b602081106101f257600080fd5b600360c052602060c020015460605160016101e051018060405190131561021857600080fd5b809190121561022657600080fd5b6020811061023357600080fd5b600460c052602060c02001555b815160010180835281141561010f575b50506116c156600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526000156101a3575b6101605261014052601860086020820661020001602082840111156100bf57600080fd5b60208061022082610140600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16100fc57600080fd5b50506102c05160206001820306601f82010390506103206102c0516008818352015b8261032051111561012e5761014a565b6000610320516102e001535b815160010180835281141561011e575b50505060206102a05260406102c0510160206001820306601f8201039050610280525b60006102805111151561017f5761019b565b602061028051036102a00151602061028051036102805261016d565b610160515650005b638067328960005114156104f957602060046101403734156101c457600080fd5b67ffffffffffffffff6101405111156101dc57600080fd5b6101405161016051610180516101a05163b0429c706101c052610140516101e0526101e0516006580161009b565b506102405260006102a0525b6102405160206001820306601f82010390506102a05110151561023857610251565b6102a05161026001526102a0516020016102a052610216565b6101a052610180526101605261014052610240805160200180610160828460006004600a8704601201f161028457600080fd5b50506101608060200151600082518060209013156102a157600080fd5b80919012156102af57600080fd5b806020036101000a82049050905090506102c05260006102e05261030060006008818352015b6102e051600860008112156102f2578060000360020a82046102f9565b8060020a82025b905090506102e05260ff6102c05116610320526102e051610320516102e05101101561032457600080fd5b610320516102e051016102e0526102c0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8600081121561036d578060000360020a8204610374565b8060020a82025b905090506102c0525b81516001018083528114156102d5575b50506101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05163b0429c70610340526102e05161036052610360516006580161009b565b506103c0526000610420525b6103c05160206001820306601f8201039050610420511015156104135761042c565b610420516103e0015261042051602001610420526103f1565b6102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103c0805160200180610480828460006004600a8704601201f161048757600080fd5b50506104805160206001820306601f82010390506104e0610480516008818352015b826104e05111156104b9576104d5565b60006104e0516104a001535b81516001018083528114156104a9575b5050506020610460526040610480510160206001820306601f8201039050610460f3005b63c5f2892f600051141561063257341561051257600080fd5b6000610140526005546101605261018060006020818352015b6001600261053857600080fd5b6002610160510614156105a2576000610180516020811061055857600080fd5b600460c052602060c02001546020826102200101526020810190506101405160208261022001015260208101905080610220526102209050805160208201209050610140526105fb565b6000610140516020826101a001015260208101905061018051602081106105c857600080fd5b600360c052602060c02001546020826101a0010152602081019050806101a0526101a09050805160208201209050610140525b610160600261060957600080fd5b60028151048152505b815160010180835281141561052b575b50506101405160005260206000f3005b6398b1e06a60005114156112435760206004610140376102206004356004016101603761020060043560040135111561066a57600080fd5b633b9aca006103c0526103c05161068057600080fd5b6103c05134046103a0526001546103a051101561069c57600080fd5b6002546103a05111156106ae57600080fd5b6005546103e05242610400526000606061070060246380673289610680526103a0516106a05261069c6000305af16106e557600080fd5b61072060088060208461084001018260208501600060046012f150508051820191505060606107e06024638067328961076052610400516107805261077c6000305af161073157600080fd5b61080060088060208461084001018260208501600060046012f15050805182019150506101606102008060208461084001018260208501600060046045f150508051820191505080610840526108409050805160200180610420828460006004600a8704601201f16107a257600080fd5b50506000610aa0526002610ac052610ae060006020818352015b6000610ac0516107cb57600080fd5b610ac0516103e05160016103e0510110156107e557600080fd5b60016103e05101061415156107f957610865565b610aa060605160018251018060405190131561081457600080fd5b809190121561082257600080fd5b815250610ac080511515610837576000610851565b600281516002835102041461084b57600080fd5b60028151025b8152505b81516001018083528114156107bc575b5050610420805160208201209050610b0052610b2060006020818352015b610aa051610b205112156108ea576000610b2051602081106108a457600080fd5b600460c052602060c0200154602082610b40010152602081019050610b0051602082610b4001015260208101905080610b4052610b409050805160208201209050610b00525b5b8151600101808352811415610883575b5050610b0051610aa0516020811061091257600080fd5b600460c052602060c0200155600580546001825401101561093257600080fd5b60018154018155506020610c40600463c5f2892f610be052610bfc6000305af161095b57600080fd5b610c4051610bc0526060610ce060246380673289610c60526103e051610c8052610c7c6000305af161098c57600080fd5b610d00805160200180610d40828460006004600a8704601201f16109af57600080fd5b5050610bc051610e0052600460c052602060c02054610e60526001600460c052602060c0200154610e80526002600460c052602060c0200154610ea0526003600460c052602060c0200154610ec0526004600460c052602060c0200154610ee0526005600460c052602060c0200154610f00526006600460c052602060c0200154610f20526007600460c052602060c0200154610f40526008600460c052602060c0200154610f60526009600460c052602060c0200154610f8052600a600460c052602060c0200154610fa052600b600460c052602060c0200154610fc052600c600460c052602060c0200154610fe052600d600460c052602060c020015461100052600e600460c052602060c020015461102052600f600460c052602060c0200154611040526010600460c052602060c0200154611060526011600460c052602060c0200154611080526012600460c052602060c02001546110a0526013600460c052602060c02001546110c0526014600460c052602060c02001546110e0526015600460c052602060c0200154611100526016600460c052602060c0200154611120526017600460c052602060c0200154611140526018600460c052602060c0200154611160526019600460c052602060c020015461118052601a600460c052602060c02001546111a052601b600460c052602060c02001546111c052601c600460c052602060c02001546111e052601d600460c052602060c020015461120052601e600460c052602060c020015461122052601f600460c052602060c020015461124052610460610dc052610dc051610e2052610420805160200180610dc051610e0001828460006004600a8704601201f1610c2d57600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da08151610220818352015b83610da051101515610c6c57610c89565b6000610da0516020850101535b8151600101808352811415610c5b575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc052610dc051610e4052610d40805160200180610dc051610e0001828460006004600a8704601201f1610ce057600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da081516020818352015b83610da051101515610d1e57610d3b565b6000610da0516020850101535b8151600101808352811415610d0d575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc0527fce7a77a358682d6c81f71216fb7fb108b03bc8badbf67f5d131ba5363cbefb42610dc051610e00a16002546103a0511415611241576006805460018254011015610dac57600080fd5b600181540181555060005460065414156112405760075415610f975760606114c06024638067328961144052610400516114605261145c6000305af1610df157600080fd5b6114e080600860c052602060c020602082510161012060006002818352015b82610120516020021115610e2357610e45565b61012051602002850151610120518501555b8151600101808352811415610e10575b5050505050506020611580600463c5f2892f6115205261153c6000305af1610e6c57600080fd5b611580516115a0526115a0516116205260406115e0526115e0516116405260088060c052602060c0206115e05161162001602082540161012060006002818352015b82610120516020021115610ec157610ee3565b61012051850154610120516020028501525b8151600101808352811415610eae575b5050505050506115e051611620015160206001820306601f82010390506115e051611620016115c081516020818352015b836115c051101515610f2557610f42565b60006115c0516020850101535b8151600101808352811415610f14575b5050505060206115e051611620015160206001820306601f82010390506115e05101016115e0527fd1faa3f9bca1d698df559716fe6d1c9999155b38d3158fffbc98d76d568091fc6115e051611620a161123f565b4261128052426112a05262015180610fae57600080fd5b620151806112a05106611280511015610fc657600080fd5b426112a05262015180610fd857600080fd5b620151806112a051066112805103620151804261128052426112a0526201518061100157600080fd5b620151806112a0510661128051101561101957600080fd5b426112a0526201518061102b57600080fd5b620151806112a05106611280510301101561104557600080fd5b620151804261128052426112a0526201518061106057600080fd5b620151806112a0510661128051101561107857600080fd5b426112a0526201518061108a57600080fd5b620151806112a05106611280510301611260526060611340602463806732896112c052611260516112e0526112dc6000305af16110c657600080fd5b61136080600860c052602060c020602082510161012060006002818352015b826101205160200211156110f85761111a565b61012051602002850151610120518501555b81516001018083528114156110e5575b505050505050610bc0516114005260406113c0526113c0516114205260088060c052602060c0206113c05161140001602082540161012060006002818352015b8261012051602002111561116d5761118f565b61012051850154610120516020028501525b815160010180835281141561115a575b5050505050506113c051611400015160206001820306601f82010390506113c051611400016113a081516020818352015b836113a0511015156111d1576111ee565b60006113a0516020850101535b81516001018083528114156111c0575b5050505060206113c051611400015160206001820306601f82010390506113c05101016113c0527fd1faa3f9bca1d698df559716fe6d1c9999155b38d3158fffbc98d76d568091fc6113c051611400a15b5b5b005b639890220b600051141561127757341561125c57600080fd5b600060006000600030316009546000f161127557600080fd5b005b634a637042600051141561129d57341561129057600080fd5b60005460005260206000f3005b631ea30fef60005114156112c35734156112b657600080fd5b60015460005260206000f3005b634c34a98260005114156112e95734156112dc57600080fd5b60025460005260206000f3005b63eb8545ee600051141561130f57341561130257600080fd5b60055460005260206000f3005b63188e6c87600051141561133557341561132857600080fd5b60065460005260206000f3005b63eb5cc58e600051141561135b57341561134e57600080fd5b60075460005260206000f3005b6342c6498a600051141561143e57341561137457600080fd5b60088060c052602060c020610180602082540161012060006002818352015b826101205160200211156113a6576113c8565b61012051850154610120516020028501525b8151600101808352811415611393575b5050505050506101805160206001820306601f82010390506101e0610180516008818352015b826101e05111156113fe5761141a565b60006101e0516101a001535b81516001018083528114156113ee575b5050506020610160526040610180510160206001820306601f8201039050610160f3005b638ba35cdf600051141561146457341561145757600080fd5b60095460005260206000f3005b60006000fd5b6102576116c1036102576000396102576116c1036000f3 diff --git a/contracts/deposit-contract/deployContract/BUILD.bazel b/contracts/deposit-contract/deployContract/BUILD.bazel index fd308436b..00a3f8d7c 100644 --- a/contracts/deposit-contract/deployContract/BUILD.bazel +++ b/contracts/deposit-contract/deployContract/BUILD.bazel @@ -13,6 +13,7 @@ go_library( "//shared/version:go_default_library", "@com_github_ethereum_go_ethereum//accounts/abi/bind:go_default_library", "@com_github_ethereum_go_ethereum//accounts/keystore:go_default_library", + "@com_github_ethereum_go_ethereum//common:go_default_library", "@com_github_ethereum_go_ethereum//crypto:go_default_library", "@com_github_ethereum_go_ethereum//ethclient:go_default_library", "@com_github_ethereum_go_ethereum//rpc:go_default_library", diff --git a/contracts/deposit-contract/deployContract/deployContract.go b/contracts/deposit-contract/deployContract/deployContract.go index b3db47c78..347709886 100644 --- a/contracts/deposit-contract/deployContract/deployContract.go +++ b/contracts/deposit-contract/deployContract/deployContract.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/keystore" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/rpc" @@ -36,6 +37,7 @@ func main() { var minDepositAmount int64 var maxDepositAmount int64 var skipChainstartDelay bool + var drainAddress string customFormatter := new(prefixed.TextFormatter) customFormatter.TimestampFormat = "2006-01-02 15:04:05" @@ -103,6 +105,12 @@ func main() { Usage: "Maximum deposit value allowed in contract", Destination: &maxDepositAmount, }, + cli.StringFlag{ + Name: "drainAddress", + Value: "", + Usage: "The drain address to specify in the contract. The default will be msg.sender", + Destination: &drainAddress, + }, } app.Action = func(c *cli.Context) { @@ -160,11 +168,20 @@ func main() { txOps.GasLimit = 4000000 } + drain := txOps.From + if drainAddress != "" { + drain = common.HexToAddress(drainAddress) + } + // Deploy validator registration contract addr, tx, _, err := contracts.DeployDepositContract( - txOps, client, big.NewInt(depositsForChainStart), - big.NewInt(minDepositAmount), big.NewInt(maxDepositAmount), + txOps, + client, + big.NewInt(depositsForChainStart), + big.NewInt(minDepositAmount), + big.NewInt(maxDepositAmount), skipChainstartDelay, + drain, ) if err != nil { diff --git a/contracts/deposit-contract/depositContract.go b/contracts/deposit-contract/depositContract.go index 9ac065bb3..42d92064e 100644 --- a/contracts/deposit-contract/depositContract.go +++ b/contracts/deposit-contract/depositContract.go @@ -28,18 +28,18 @@ var ( ) // DepositContractABI is the input ABI used to generate the binding from. -const DepositContractABI = "[{\"name\":\"Deposit\",\"inputs\":[{\"type\":\"bytes32\",\"name\":\"deposit_root\",\"indexed\":false},{\"type\":\"bytes\",\"name\":\"data\",\"indexed\":false},{\"type\":\"bytes\",\"name\":\"merkle_tree_index\",\"indexed\":false},{\"type\":\"bytes32[32]\",\"name\":\"branch\",\"indexed\":false}],\"anonymous\":false,\"type\":\"event\"},{\"name\":\"ChainStart\",\"inputs\":[{\"type\":\"bytes32\",\"name\":\"deposit_root\",\"indexed\":false},{\"type\":\"bytes\",\"name\":\"time\",\"indexed\":false}],\"anonymous\":false,\"type\":\"event\"},{\"name\":\"__init__\",\"outputs\":[],\"inputs\":[{\"type\":\"uint256\",\"name\":\"depositThreshold\"},{\"type\":\"uint256\",\"name\":\"minDeposit\"},{\"type\":\"uint256\",\"name\":\"maxDeposit\"},{\"type\":\"bool\",\"name\":\"skipChainstartDelay\"}],\"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\":15330},{\"name\":\"get_deposit_root\",\"outputs\":[{\"type\":\"bytes32\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":30835},{\"name\":\"deposit\",\"outputs\":[],\"inputs\":[{\"type\":\"bytes\",\"name\":\"deposit_input\"}],\"constant\":false,\"payable\":true,\"type\":\"function\",\"gas\":531258},{\"name\":\"CHAIN_START_FULL_DEPOSIT_THRESHOLD\",\"outputs\":[{\"type\":\"uint256\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":603},{\"name\":\"MIN_DEPOSIT_AMOUNT\",\"outputs\":[{\"type\":\"uint256\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":633},{\"name\":\"MAX_DEPOSIT_AMOUNT\",\"outputs\":[{\"type\":\"uint256\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":663},{\"name\":\"deposit_count\",\"outputs\":[{\"type\":\"uint256\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":693},{\"name\":\"full_deposit_count\",\"outputs\":[{\"type\":\"uint256\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":723},{\"name\":\"skip_chainstart_delay\",\"outputs\":[{\"type\":\"bool\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":753},{\"name\":\"genesisTime\",\"outputs\":[{\"type\":\"bytes\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":3006}]" +const DepositContractABI = "[{\"name\":\"Deposit\",\"inputs\":[{\"type\":\"bytes32\",\"name\":\"deposit_root\",\"indexed\":false},{\"type\":\"bytes\",\"name\":\"data\",\"indexed\":false},{\"type\":\"bytes\",\"name\":\"merkle_tree_index\",\"indexed\":false},{\"type\":\"bytes32[32]\",\"name\":\"branch\",\"indexed\":false}],\"anonymous\":false,\"type\":\"event\"},{\"name\":\"ChainStart\",\"inputs\":[{\"type\":\"bytes32\",\"name\":\"deposit_root\",\"indexed\":false},{\"type\":\"bytes\",\"name\":\"time\",\"indexed\":false}],\"anonymous\":false,\"type\":\"event\"},{\"name\":\"__init__\",\"outputs\":[],\"inputs\":[{\"type\":\"uint256\",\"name\":\"depositThreshold\"},{\"type\":\"uint256\",\"name\":\"minDeposit\"},{\"type\":\"uint256\",\"name\":\"maxDeposit\"},{\"type\":\"bool\",\"name\":\"skipChainstartDelay\"},{\"type\":\"address\",\"name\":\"_drain_address\"}],\"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\":15330},{\"name\":\"get_deposit_root\",\"outputs\":[{\"type\":\"bytes32\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":30835},{\"name\":\"deposit\",\"outputs\":[],\"inputs\":[{\"type\":\"bytes\",\"name\":\"deposit_input\"}],\"constant\":false,\"payable\":true,\"type\":\"function\",\"gas\":531258},{\"name\":\"drain\",\"outputs\":[],\"inputs\":[],\"constant\":false,\"payable\":false,\"type\":\"function\",\"gas\":35793},{\"name\":\"CHAIN_START_FULL_DEPOSIT_THRESHOLD\",\"outputs\":[{\"type\":\"uint256\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":633},{\"name\":\"MIN_DEPOSIT_AMOUNT\",\"outputs\":[{\"type\":\"uint256\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":663},{\"name\":\"MAX_DEPOSIT_AMOUNT\",\"outputs\":[{\"type\":\"uint256\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":693},{\"name\":\"deposit_count\",\"outputs\":[{\"type\":\"uint256\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":723},{\"name\":\"full_deposit_count\",\"outputs\":[{\"type\":\"uint256\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":753},{\"name\":\"skip_chainstart_delay\",\"outputs\":[{\"type\":\"bool\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":783},{\"name\":\"genesisTime\",\"outputs\":[{\"type\":\"bytes\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":3036},{\"name\":\"drain_address\",\"outputs\":[{\"type\":\"address\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":843}]" // DepositContractBin is the compiled bytecode used for deploying new contracts. -const DepositContractBin = `0x600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052608061165b6101403934156100a757600080fd5b6020606061165b0160c03960c051600281106100c257600080fd5b506101405160005561016051600155610180516002556101a0516007556101c06000601f818352015b60006101c051602081106100fe57600080fd5b600360c052602060c02001546020826101e00101526020810190506101c0516020811061012a57600080fd5b600360c052602060c02001546020826101e0010152602081019050806101e0526101e0905080516020820120905060605160016101c051018060405190131561017257600080fd5b809190121561018057600080fd5b6020811061018d57600080fd5b600360c052602060c020015560605160016101c05101806040519013156101b357600080fd5b80919012156101c157600080fd5b602081106101ce57600080fd5b600360c052602060c020015460605160016101c05101806040519013156101f457600080fd5b809190121561020257600080fd5b6020811061020f57600080fd5b600460c052602060c02001555b81516001018083528114156100eb575b505061164356600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526000156101a3575b6101605261014052601860086020820661020001602082840111156100bf57600080fd5b60208061022082610140600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16100fc57600080fd5b50506102c05160206001820306601f82010390506103206102c0516008818352015b8261032051111561012e5761014a565b6000610320516102e001535b815160010180835281141561011e575b50505060206102a05260406102c0510160206001820306601f8201039050610280525b60006102805111151561017f5761019b565b602061028051036102a00151602061028051036102805261016d565b610160515650005b638067328960005114156104f957602060046101403734156101c457600080fd5b67ffffffffffffffff6101405111156101dc57600080fd5b6101405161016051610180516101a05163b0429c706101c052610140516101e0526101e0516006580161009b565b506102405260006102a0525b6102405160206001820306601f82010390506102a05110151561023857610251565b6102a05161026001526102a0516020016102a052610216565b6101a052610180526101605261014052610240805160200180610160828460006004600a8704601201f161028457600080fd5b50506101608060200151600082518060209013156102a157600080fd5b80919012156102af57600080fd5b806020036101000a82049050905090506102c05260006102e05261030060006008818352015b6102e051600860008112156102f2578060000360020a82046102f9565b8060020a82025b905090506102e05260ff6102c05116610320526102e051610320516102e05101101561032457600080fd5b610320516102e051016102e0526102c0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8600081121561036d578060000360020a8204610374565b8060020a82025b905090506102c0525b81516001018083528114156102d5575b50506101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05163b0429c70610340526102e05161036052610360516006580161009b565b506103c0526000610420525b6103c05160206001820306601f8201039050610420511015156104135761042c565b610420516103e0015261042051602001610420526103f1565b6102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103c0805160200180610480828460006004600a8704601201f161048757600080fd5b50506104805160206001820306601f82010390506104e0610480516008818352015b826104e05111156104b9576104d5565b60006104e0516104a001535b81516001018083528114156104a9575b5050506020610460526040610480510160206001820306601f8201039050610460f3005b63c5f2892f600051141561063257341561051257600080fd5b6000610140526005546101605261018060006020818352015b6001600261053857600080fd5b6002610160510614156105a2576000610180516020811061055857600080fd5b600460c052602060c02001546020826102200101526020810190506101405160208261022001015260208101905080610220526102209050805160208201209050610140526105fb565b6000610140516020826101a001015260208101905061018051602081106105c857600080fd5b600360c052602060c02001546020826101a0010152602081019050806101a0526101a09050805160208201209050610140525b610160600261060957600080fd5b60028151048152505b815160010180835281141561052b575b50506101405160005260206000f3005b6398b1e06a60005114156112435760206004610140376102206004356004016101603761020060043560040135111561066a57600080fd5b633b9aca006103c0526103c05161068057600080fd5b6103c05134046103a0526001546103a051101561069c57600080fd5b6002546103a05111156106ae57600080fd5b6005546103e05242610400526000606061070060246380673289610680526103a0516106a05261069c6000305af16106e557600080fd5b61072060088060208461084001018260208501600060046012f150508051820191505060606107e06024638067328961076052610400516107805261077c6000305af161073157600080fd5b61080060088060208461084001018260208501600060046012f15050805182019150506101606102008060208461084001018260208501600060046045f150508051820191505080610840526108409050805160200180610420828460006004600a8704601201f16107a257600080fd5b50506000610aa0526002610ac052610ae060006020818352015b6000610ac0516107cb57600080fd5b610ac0516103e05160016103e0510110156107e557600080fd5b60016103e05101061415156107f957610865565b610aa060605160018251018060405190131561081457600080fd5b809190121561082257600080fd5b815250610ac080511515610837576000610851565b600281516002835102041461084b57600080fd5b60028151025b8152505b81516001018083528114156107bc575b5050610420805160208201209050610b0052610b2060006020818352015b610aa051610b205112156108ea576000610b2051602081106108a457600080fd5b600460c052602060c0200154602082610b40010152602081019050610b0051602082610b4001015260208101905080610b4052610b409050805160208201209050610b00525b5b8151600101808352811415610883575b5050610b0051610aa0516020811061091257600080fd5b600460c052602060c0200155600580546001825401101561093257600080fd5b60018154018155506020610c40600463c5f2892f610be052610bfc6000305af161095b57600080fd5b610c4051610bc0526060610ce060246380673289610c60526103e051610c8052610c7c6000305af161098c57600080fd5b610d00805160200180610d40828460006004600a8704601201f16109af57600080fd5b5050610bc051610e0052600460c052602060c02054610e60526001600460c052602060c0200154610e80526002600460c052602060c0200154610ea0526003600460c052602060c0200154610ec0526004600460c052602060c0200154610ee0526005600460c052602060c0200154610f00526006600460c052602060c0200154610f20526007600460c052602060c0200154610f40526008600460c052602060c0200154610f60526009600460c052602060c0200154610f8052600a600460c052602060c0200154610fa052600b600460c052602060c0200154610fc052600c600460c052602060c0200154610fe052600d600460c052602060c020015461100052600e600460c052602060c020015461102052600f600460c052602060c0200154611040526010600460c052602060c0200154611060526011600460c052602060c0200154611080526012600460c052602060c02001546110a0526013600460c052602060c02001546110c0526014600460c052602060c02001546110e0526015600460c052602060c0200154611100526016600460c052602060c0200154611120526017600460c052602060c0200154611140526018600460c052602060c0200154611160526019600460c052602060c020015461118052601a600460c052602060c02001546111a052601b600460c052602060c02001546111c052601c600460c052602060c02001546111e052601d600460c052602060c020015461120052601e600460c052602060c020015461122052601f600460c052602060c020015461124052610460610dc052610dc051610e2052610420805160200180610dc051610e0001828460006004600a8704601201f1610c2d57600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da08151610220818352015b83610da051101515610c6c57610c89565b6000610da0516020850101535b8151600101808352811415610c5b575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc052610dc051610e4052610d40805160200180610dc051610e0001828460006004600a8704601201f1610ce057600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da081516020818352015b83610da051101515610d1e57610d3b565b6000610da0516020850101535b8151600101808352811415610d0d575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc0527fce7a77a358682d6c81f71216fb7fb108b03bc8badbf67f5d131ba5363cbefb42610dc051610e00a16002546103a0511415611241576006805460018254011015610dac57600080fd5b600181540181555060005460065414156112405760075415610f975760606114c06024638067328961144052610400516114605261145c6000305af1610df157600080fd5b6114e080600860c052602060c020602082510161012060006002818352015b82610120516020021115610e2357610e45565b61012051602002850151610120518501555b8151600101808352811415610e10575b5050505050506020611580600463c5f2892f6115205261153c6000305af1610e6c57600080fd5b611580516115a0526115a0516116205260406115e0526115e0516116405260088060c052602060c0206115e05161162001602082540161012060006002818352015b82610120516020021115610ec157610ee3565b61012051850154610120516020028501525b8151600101808352811415610eae575b5050505050506115e051611620015160206001820306601f82010390506115e051611620016115c081516020818352015b836115c051101515610f2557610f42565b60006115c0516020850101535b8151600101808352811415610f14575b5050505060206115e051611620015160206001820306601f82010390506115e05101016115e0527fd1faa3f9bca1d698df559716fe6d1c9999155b38d3158fffbc98d76d568091fc6115e051611620a161123f565b4261128052426112a05262015180610fae57600080fd5b620151806112a05106611280511015610fc657600080fd5b426112a05262015180610fd857600080fd5b620151806112a051066112805103620151804261128052426112a0526201518061100157600080fd5b620151806112a0510661128051101561101957600080fd5b426112a0526201518061102b57600080fd5b620151806112a05106611280510301101561104557600080fd5b620151804261128052426112a0526201518061106057600080fd5b620151806112a0510661128051101561107857600080fd5b426112a0526201518061108a57600080fd5b620151806112a05106611280510301611260526060611340602463806732896112c052611260516112e0526112dc6000305af16110c657600080fd5b61136080600860c052602060c020602082510161012060006002818352015b826101205160200211156110f85761111a565b61012051602002850151610120518501555b81516001018083528114156110e5575b505050505050610bc0516114005260406113c0526113c0516114205260088060c052602060c0206113c05161140001602082540161012060006002818352015b8261012051602002111561116d5761118f565b61012051850154610120516020028501525b815160010180835281141561115a575b5050505050506113c051611400015160206001820306601f82010390506113c051611400016113a081516020818352015b836113a0511015156111d1576111ee565b60006113a0516020850101535b81516001018083528114156111c0575b5050505060206113c051611400015160206001820306601f82010390506113c05101016113c0527fd1faa3f9bca1d698df559716fe6d1c9999155b38d3158fffbc98d76d568091fc6113c051611400a15b5b5b005b634a637042600051141561126957341561125c57600080fd5b60005460005260206000f3005b631ea30fef600051141561128f57341561128257600080fd5b60015460005260206000f3005b634c34a98260005114156112b55734156112a857600080fd5b60025460005260206000f3005b63eb8545ee60005114156112db5734156112ce57600080fd5b60055460005260206000f3005b63188e6c8760005114156113015734156112f457600080fd5b60065460005260206000f3005b63eb5cc58e600051141561132757341561131a57600080fd5b60075460005260206000f3005b6342c6498a600051141561140a57341561134057600080fd5b60088060c052602060c020610180602082540161012060006002818352015b8261012051602002111561137257611394565b61012051850154610120516020028501525b815160010180835281141561135f575b5050505050506101805160206001820306601f82010390506101e0610180516008818352015b826101e05111156113ca576113e6565b60006101e0516101a001535b81516001018083528114156113ba575b5050506020610160526040610180510160206001820306601f8201039050610160f3005b60006000fd5b61023361164303610233600039610233611643036000f3` +const DepositContractBin = `0x600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05260a06116d96101403934156100a757600080fd5b602060606116d90160c03960c051600281106100c257600080fd5b50602060806116d90160c03960c05160205181106100df57600080fd5b506101405160005561016051600155610180516002556101a0516007556101c0516009556101e06000601f818352015b60006101e0516020811061012257600080fd5b600360c052602060c02001546020826102000101526020810190506101e0516020811061014e57600080fd5b600360c052602060c02001546020826102000101526020810190508061020052610200905080516020820120905060605160016101e051018060405190131561019657600080fd5b80919012156101a457600080fd5b602081106101b157600080fd5b600360c052602060c020015560605160016101e05101806040519013156101d757600080fd5b80919012156101e557600080fd5b602081106101f257600080fd5b600360c052602060c020015460605160016101e051018060405190131561021857600080fd5b809190121561022657600080fd5b6020811061023357600080fd5b600460c052602060c02001555b815160010180835281141561010f575b50506116c156600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526000156101a3575b6101605261014052601860086020820661020001602082840111156100bf57600080fd5b60208061022082610140600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16100fc57600080fd5b50506102c05160206001820306601f82010390506103206102c0516008818352015b8261032051111561012e5761014a565b6000610320516102e001535b815160010180835281141561011e575b50505060206102a05260406102c0510160206001820306601f8201039050610280525b60006102805111151561017f5761019b565b602061028051036102a00151602061028051036102805261016d565b610160515650005b638067328960005114156104f957602060046101403734156101c457600080fd5b67ffffffffffffffff6101405111156101dc57600080fd5b6101405161016051610180516101a05163b0429c706101c052610140516101e0526101e0516006580161009b565b506102405260006102a0525b6102405160206001820306601f82010390506102a05110151561023857610251565b6102a05161026001526102a0516020016102a052610216565b6101a052610180526101605261014052610240805160200180610160828460006004600a8704601201f161028457600080fd5b50506101608060200151600082518060209013156102a157600080fd5b80919012156102af57600080fd5b806020036101000a82049050905090506102c05260006102e05261030060006008818352015b6102e051600860008112156102f2578060000360020a82046102f9565b8060020a82025b905090506102e05260ff6102c05116610320526102e051610320516102e05101101561032457600080fd5b610320516102e051016102e0526102c0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8600081121561036d578060000360020a8204610374565b8060020a82025b905090506102c0525b81516001018083528114156102d5575b50506101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05163b0429c70610340526102e05161036052610360516006580161009b565b506103c0526000610420525b6103c05160206001820306601f8201039050610420511015156104135761042c565b610420516103e0015261042051602001610420526103f1565b6102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103c0805160200180610480828460006004600a8704601201f161048757600080fd5b50506104805160206001820306601f82010390506104e0610480516008818352015b826104e05111156104b9576104d5565b60006104e0516104a001535b81516001018083528114156104a9575b5050506020610460526040610480510160206001820306601f8201039050610460f3005b63c5f2892f600051141561063257341561051257600080fd5b6000610140526005546101605261018060006020818352015b6001600261053857600080fd5b6002610160510614156105a2576000610180516020811061055857600080fd5b600460c052602060c02001546020826102200101526020810190506101405160208261022001015260208101905080610220526102209050805160208201209050610140526105fb565b6000610140516020826101a001015260208101905061018051602081106105c857600080fd5b600360c052602060c02001546020826101a0010152602081019050806101a0526101a09050805160208201209050610140525b610160600261060957600080fd5b60028151048152505b815160010180835281141561052b575b50506101405160005260206000f3005b6398b1e06a60005114156112435760206004610140376102206004356004016101603761020060043560040135111561066a57600080fd5b633b9aca006103c0526103c05161068057600080fd5b6103c05134046103a0526001546103a051101561069c57600080fd5b6002546103a05111156106ae57600080fd5b6005546103e05242610400526000606061070060246380673289610680526103a0516106a05261069c6000305af16106e557600080fd5b61072060088060208461084001018260208501600060046012f150508051820191505060606107e06024638067328961076052610400516107805261077c6000305af161073157600080fd5b61080060088060208461084001018260208501600060046012f15050805182019150506101606102008060208461084001018260208501600060046045f150508051820191505080610840526108409050805160200180610420828460006004600a8704601201f16107a257600080fd5b50506000610aa0526002610ac052610ae060006020818352015b6000610ac0516107cb57600080fd5b610ac0516103e05160016103e0510110156107e557600080fd5b60016103e05101061415156107f957610865565b610aa060605160018251018060405190131561081457600080fd5b809190121561082257600080fd5b815250610ac080511515610837576000610851565b600281516002835102041461084b57600080fd5b60028151025b8152505b81516001018083528114156107bc575b5050610420805160208201209050610b0052610b2060006020818352015b610aa051610b205112156108ea576000610b2051602081106108a457600080fd5b600460c052602060c0200154602082610b40010152602081019050610b0051602082610b4001015260208101905080610b4052610b409050805160208201209050610b00525b5b8151600101808352811415610883575b5050610b0051610aa0516020811061091257600080fd5b600460c052602060c0200155600580546001825401101561093257600080fd5b60018154018155506020610c40600463c5f2892f610be052610bfc6000305af161095b57600080fd5b610c4051610bc0526060610ce060246380673289610c60526103e051610c8052610c7c6000305af161098c57600080fd5b610d00805160200180610d40828460006004600a8704601201f16109af57600080fd5b5050610bc051610e0052600460c052602060c02054610e60526001600460c052602060c0200154610e80526002600460c052602060c0200154610ea0526003600460c052602060c0200154610ec0526004600460c052602060c0200154610ee0526005600460c052602060c0200154610f00526006600460c052602060c0200154610f20526007600460c052602060c0200154610f40526008600460c052602060c0200154610f60526009600460c052602060c0200154610f8052600a600460c052602060c0200154610fa052600b600460c052602060c0200154610fc052600c600460c052602060c0200154610fe052600d600460c052602060c020015461100052600e600460c052602060c020015461102052600f600460c052602060c0200154611040526010600460c052602060c0200154611060526011600460c052602060c0200154611080526012600460c052602060c02001546110a0526013600460c052602060c02001546110c0526014600460c052602060c02001546110e0526015600460c052602060c0200154611100526016600460c052602060c0200154611120526017600460c052602060c0200154611140526018600460c052602060c0200154611160526019600460c052602060c020015461118052601a600460c052602060c02001546111a052601b600460c052602060c02001546111c052601c600460c052602060c02001546111e052601d600460c052602060c020015461120052601e600460c052602060c020015461122052601f600460c052602060c020015461124052610460610dc052610dc051610e2052610420805160200180610dc051610e0001828460006004600a8704601201f1610c2d57600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da08151610220818352015b83610da051101515610c6c57610c89565b6000610da0516020850101535b8151600101808352811415610c5b575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc052610dc051610e4052610d40805160200180610dc051610e0001828460006004600a8704601201f1610ce057600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da081516020818352015b83610da051101515610d1e57610d3b565b6000610da0516020850101535b8151600101808352811415610d0d575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc0527fce7a77a358682d6c81f71216fb7fb108b03bc8badbf67f5d131ba5363cbefb42610dc051610e00a16002546103a0511415611241576006805460018254011015610dac57600080fd5b600181540181555060005460065414156112405760075415610f975760606114c06024638067328961144052610400516114605261145c6000305af1610df157600080fd5b6114e080600860c052602060c020602082510161012060006002818352015b82610120516020021115610e2357610e45565b61012051602002850151610120518501555b8151600101808352811415610e10575b5050505050506020611580600463c5f2892f6115205261153c6000305af1610e6c57600080fd5b611580516115a0526115a0516116205260406115e0526115e0516116405260088060c052602060c0206115e05161162001602082540161012060006002818352015b82610120516020021115610ec157610ee3565b61012051850154610120516020028501525b8151600101808352811415610eae575b5050505050506115e051611620015160206001820306601f82010390506115e051611620016115c081516020818352015b836115c051101515610f2557610f42565b60006115c0516020850101535b8151600101808352811415610f14575b5050505060206115e051611620015160206001820306601f82010390506115e05101016115e0527fd1faa3f9bca1d698df559716fe6d1c9999155b38d3158fffbc98d76d568091fc6115e051611620a161123f565b4261128052426112a05262015180610fae57600080fd5b620151806112a05106611280511015610fc657600080fd5b426112a05262015180610fd857600080fd5b620151806112a051066112805103620151804261128052426112a0526201518061100157600080fd5b620151806112a0510661128051101561101957600080fd5b426112a0526201518061102b57600080fd5b620151806112a05106611280510301101561104557600080fd5b620151804261128052426112a0526201518061106057600080fd5b620151806112a0510661128051101561107857600080fd5b426112a0526201518061108a57600080fd5b620151806112a05106611280510301611260526060611340602463806732896112c052611260516112e0526112dc6000305af16110c657600080fd5b61136080600860c052602060c020602082510161012060006002818352015b826101205160200211156110f85761111a565b61012051602002850151610120518501555b81516001018083528114156110e5575b505050505050610bc0516114005260406113c0526113c0516114205260088060c052602060c0206113c05161140001602082540161012060006002818352015b8261012051602002111561116d5761118f565b61012051850154610120516020028501525b815160010180835281141561115a575b5050505050506113c051611400015160206001820306601f82010390506113c051611400016113a081516020818352015b836113a0511015156111d1576111ee565b60006113a0516020850101535b81516001018083528114156111c0575b5050505060206113c051611400015160206001820306601f82010390506113c05101016113c0527fd1faa3f9bca1d698df559716fe6d1c9999155b38d3158fffbc98d76d568091fc6113c051611400a15b5b5b005b639890220b600051141561127757341561125c57600080fd5b600060006000600030316009546000f161127557600080fd5b005b634a637042600051141561129d57341561129057600080fd5b60005460005260206000f3005b631ea30fef60005114156112c35734156112b657600080fd5b60015460005260206000f3005b634c34a98260005114156112e95734156112dc57600080fd5b60025460005260206000f3005b63eb8545ee600051141561130f57341561130257600080fd5b60055460005260206000f3005b63188e6c87600051141561133557341561132857600080fd5b60065460005260206000f3005b63eb5cc58e600051141561135b57341561134e57600080fd5b60075460005260206000f3005b6342c6498a600051141561143e57341561137457600080fd5b60088060c052602060c020610180602082540161012060006002818352015b826101205160200211156113a6576113c8565b61012051850154610120516020028501525b8151600101808352811415611393575b5050505050506101805160206001820306601f82010390506101e0610180516008818352015b826101e05111156113fe5761141a565b60006101e0516101a001535b81516001018083528114156113ee575b5050506020610160526040610180510160206001820306601f8201039050610160f3005b638ba35cdf600051141561146457341561145757600080fd5b60095460005260206000f3005b60006000fd5b6102576116c1036102576000396102576116c1036000f3` // DeployDepositContract deploys a new Ethereum contract, binding an instance of DepositContract to it. -func DeployDepositContract(auth *bind.TransactOpts, backend bind.ContractBackend, depositThreshold *big.Int, minDeposit *big.Int, maxDeposit *big.Int, skipChainstartDelay bool) (common.Address, *types.Transaction, *DepositContract, error) { +func DeployDepositContract(auth *bind.TransactOpts, backend bind.ContractBackend, depositThreshold *big.Int, minDeposit *big.Int, maxDeposit *big.Int, skipChainstartDelay bool, _drain_address common.Address) (common.Address, *types.Transaction, *DepositContract, error) { parsed, err := abi.JSON(strings.NewReader(DepositContractABI)) if err != nil { return common.Address{}, nil, nil, err } - address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(DepositContractBin), backend, depositThreshold, minDeposit, maxDeposit, skipChainstartDelay) + address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(DepositContractBin), backend, depositThreshold, minDeposit, maxDeposit, skipChainstartDelay, _drain_address) if err != nil { return common.Address{}, nil, nil, err } @@ -292,6 +292,32 @@ func (_DepositContract *DepositContractCallerSession) DepositCount() (*big.Int, return _DepositContract.Contract.DepositCount(&_DepositContract.CallOpts) } +// DrainAddress is a free data retrieval call binding the contract method 0x8ba35cdf. +// +// Solidity: function drain_address() constant returns(address out) +func (_DepositContract *DepositContractCaller) DrainAddress(opts *bind.CallOpts) (common.Address, error) { + var ( + ret0 = new(common.Address) + ) + out := ret0 + err := _DepositContract.contract.Call(opts, out, "drain_address") + return *ret0, err +} + +// DrainAddress is a free data retrieval call binding the contract method 0x8ba35cdf. +// +// Solidity: function drain_address() constant returns(address out) +func (_DepositContract *DepositContractSession) DrainAddress() (common.Address, error) { + return _DepositContract.Contract.DrainAddress(&_DepositContract.CallOpts) +} + +// DrainAddress is a free data retrieval call binding the contract method 0x8ba35cdf. +// +// Solidity: function drain_address() constant returns(address out) +func (_DepositContract *DepositContractCallerSession) DrainAddress() (common.Address, error) { + return _DepositContract.Contract.DrainAddress(&_DepositContract.CallOpts) +} + // FullDepositCount is a free data retrieval call binding the contract method 0x188e6c87. // // Solidity: function full_deposit_count() constant returns(uint256 out) @@ -443,6 +469,27 @@ func (_DepositContract *DepositContractTransactorSession) Deposit(deposit_input return _DepositContract.Contract.Deposit(&_DepositContract.TransactOpts, deposit_input) } +// Drain is a paid mutator transaction binding the contract method 0x9890220b. +// +// Solidity: function drain() returns() +func (_DepositContract *DepositContractTransactor) Drain(opts *bind.TransactOpts) (*types.Transaction, error) { + return _DepositContract.contract.Transact(opts, "drain") +} + +// Drain is a paid mutator transaction binding the contract method 0x9890220b. +// +// Solidity: function drain() returns() +func (_DepositContract *DepositContractSession) Drain() (*types.Transaction, error) { + return _DepositContract.Contract.Drain(&_DepositContract.TransactOpts) +} + +// Drain is a paid mutator transaction binding the contract method 0x9890220b. +// +// Solidity: function drain() returns() +func (_DepositContract *DepositContractTransactorSession) Drain() (*types.Transaction, error) { + return _DepositContract.Contract.Drain(&_DepositContract.TransactOpts) +} + // DepositContractChainStartIterator is returned from FilterChainStart and is used to iterate over the raw logs and unpacked data for ChainStart events raised by the DepositContract contract. type DepositContractChainStartIterator struct { Event *DepositContractChainStart // Event containing the contract specifics and raw log diff --git a/contracts/deposit-contract/depositContract.v.py b/contracts/deposit-contract/depositContract.v.py index 2dd296bd1..0caae6adc 100644 --- a/contracts/deposit-contract/depositContract.v.py +++ b/contracts/deposit-contract/depositContract.v.py @@ -16,13 +16,20 @@ deposit_count: public(uint256) full_deposit_count: public(uint256) skip_chainstart_delay: public(bool) genesisTime: public(bytes[8]) +drain_address: public(address) @public -def __init__(depositThreshold: uint256,minDeposit: uint256,maxDeposit: uint256, skipChainstartDelay: bool): +def __init__( # Parameters for debugging, not for production use! + depositThreshold: uint256, + minDeposit: uint256, + maxDeposit: uint256, + skipChainstartDelay: bool, + _drain_address: address): self.CHAIN_START_FULL_DEPOSIT_THRESHOLD = depositThreshold self.MIN_DEPOSIT_AMOUNT = minDeposit self.MAX_DEPOSIT_AMOUNT = maxDeposit self.skip_chainstart_delay = skipChainstartDelay + self.drain_address = _drain_address for i in range(31): self.zerohashes[i+1] = sha3(concat(self.zerohashes[i], self.zerohashes[i])) self.branch[i+1] = self.zerohashes[i+1] @@ -104,3 +111,10 @@ def deposit(deposit_input: bytes[512]): self.genesisTime = self.to_little_endian_64(timestamp_day_boundary) log.ChainStart(new_deposit_root, self.genesisTime) + +# !!! DEBUG ONLY !!! +# This method is NOT part of the final ETH2.0 deposit contract, but we use it +# to recover test funds. +@public +def drain(): + send(self.drain_address, self.balance) diff --git a/contracts/deposit-contract/depositContract_test.go b/contracts/deposit-contract/depositContract_test.go index 6dbf90e49..23c3ea7ca 100644 --- a/contracts/deposit-contract/depositContract_test.go +++ b/contracts/deposit-contract/depositContract_test.go @@ -54,7 +54,7 @@ func setup() (*testAccount, error) { depositsRequired := big.NewInt(8) minDeposit := big.NewInt(1e9) maxDeposit := big.NewInt(32e9) - contractAddr, _, contract, err := DeployDepositContract(txOpts, backend, depositsRequired, minDeposit, maxDeposit, false) + contractAddr, _, contract, err := DeployDepositContract(txOpts, backend, depositsRequired, minDeposit, maxDeposit, false, addr) if err != nil { return nil, err } @@ -189,3 +189,42 @@ func TestChainStarts(t *testing.T) { t.Error("Chain start even did not get emitted") } } + +func TestDrain(t *testing.T) { + testAccount, err := setup() + if err != nil { + t.Fatal(err) + } + testAccount.txOpts.Value = amount32Eth + + _, err = testAccount.contract.Deposit(testAccount.txOpts, []byte{'A'}) + if err != nil { + t.Errorf("Validator registration failed: %v", err) + } + + testAccount.backend.Commit() + + ctx := context.Background() + bal, err := testAccount.backend.BalanceAt(ctx, testAccount.contractAddr, nil) + if err != nil { + t.Fatal(err) + } + if bal.Cmp(amount32Eth) != 0 { + t.Fatal("deposit didnt work") + } + + testAccount.txOpts.Value = big.NewInt(0) + if _, err := testAccount.contract.Drain(testAccount.txOpts); err != nil { + t.Fatal(err) + } + + testAccount.backend.Commit() + + bal, err = testAccount.backend.BalanceAt(ctx, testAccount.contractAddr, nil) + if err != nil { + t.Fatal(err) + } + if big.NewInt(0).Cmp(bal) != 0 { + t.Errorf("Drain did not drain balance: %v", bal) + } +}