From 718f99ee10d85aa1cfe20e5d6752b64b198fe7dc Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Thu, 21 Feb 2019 10:51:29 -0600 Subject: [PATCH] Custom ChainStart Genesis Time Delay in Deposit Contract (#1666) * custom delay * completed custom delay --- beacon-chain/powchain/service_test.go | 2 +- contracts/deposit-contract/abi.json | 2 +- contracts/deposit-contract/bytecode.bin | 2 +- .../deployContract/deployContract.go | 13 ++-- contracts/deposit-contract/depositContract.go | 60 +++++++++---------- .../deposit-contract/depositContract.v.py | 11 ++-- .../deposit-contract/depositContract_test.go | 2 +- 7 files changed, 47 insertions(+), 45 deletions(-) diff --git a/beacon-chain/powchain/service_test.go b/beacon-chain/powchain/service_test.go index 49f4bf618a98..4934b18d70f5 100644 --- a/beacon-chain/powchain/service_test.go +++ b/beacon-chain/powchain/service_test.go @@ -123,7 +123,7 @@ func setup() (*testAccount, error) { depositsRequired, minDeposit, maxDeposit, - false, + big.NewInt(1), addr, ) if err != nil { diff --git a/contracts/deposit-contract/abi.json b/contracts/deposit-contract/abi.json index 3a68988cc52e..d0b7fcde1717 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"}, {"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}] +[{"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": "uint256", "name": "customChainstartDelay"}, {"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": 535502}, {"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": "custom_chainstart_delay", "outputs": [{"type": "uint256", "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 298acfbaf1f4..c477b9295856 100644 --- a/contracts/deposit-contract/bytecode.bin +++ b/contracts/deposit-contract/bytecode.bin @@ -1 +1 @@ -0x600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05260a06116d96101403934156100a757600080fd5b602060606116d90160c03960c051600281106100c257600080fd5b50602060806116d90160c03960c05160205181106100df57600080fd5b506101405160005561016051600155610180516002556101a0516007556101c0516009556101e06000601f818352015b60006101e0516020811061012257600080fd5b600360c052602060c02001546020826102000101526020810190506101e0516020811061014e57600080fd5b600360c052602060c02001546020826102000101526020810190508061020052610200905080516020820120905060605160016101e051018060405190131561019657600080fd5b80919012156101a457600080fd5b602081106101b157600080fd5b600360c052602060c020015560605160016101e05101806040519013156101d757600080fd5b80919012156101e557600080fd5b602081106101f257600080fd5b600360c052602060c020015460605160016101e051018060405190131561021857600080fd5b809190121561022657600080fd5b6020811061023357600080fd5b600460c052602060c02001555b815160010180835281141561010f575b50506116c156600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526000156101a3575b6101605261014052601860086020820661020001602082840111156100bf57600080fd5b60208061022082610140600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16100fc57600080fd5b50506102c05160206001820306601f82010390506103206102c0516008818352015b8261032051111561012e5761014a565b6000610320516102e001535b815160010180835281141561011e575b50505060206102a05260406102c0510160206001820306601f8201039050610280525b60006102805111151561017f5761019b565b602061028051036102a00151602061028051036102805261016d565b610160515650005b638067328960005114156104f957602060046101403734156101c457600080fd5b67ffffffffffffffff6101405111156101dc57600080fd5b6101405161016051610180516101a05163b0429c706101c052610140516101e0526101e0516006580161009b565b506102405260006102a0525b6102405160206001820306601f82010390506102a05110151561023857610251565b6102a05161026001526102a0516020016102a052610216565b6101a052610180526101605261014052610240805160200180610160828460006004600a8704601201f161028457600080fd5b50506101608060200151600082518060209013156102a157600080fd5b80919012156102af57600080fd5b806020036101000a82049050905090506102c05260006102e05261030060006008818352015b6102e051600860008112156102f2578060000360020a82046102f9565b8060020a82025b905090506102e05260ff6102c05116610320526102e051610320516102e05101101561032457600080fd5b610320516102e051016102e0526102c0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8600081121561036d578060000360020a8204610374565b8060020a82025b905090506102c0525b81516001018083528114156102d5575b50506101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05163b0429c70610340526102e05161036052610360516006580161009b565b506103c0526000610420525b6103c05160206001820306601f8201039050610420511015156104135761042c565b610420516103e0015261042051602001610420526103f1565b6102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103c0805160200180610480828460006004600a8704601201f161048757600080fd5b50506104805160206001820306601f82010390506104e0610480516008818352015b826104e05111156104b9576104d5565b60006104e0516104a001535b81516001018083528114156104a9575b5050506020610460526040610480510160206001820306601f8201039050610460f3005b63c5f2892f600051141561063257341561051257600080fd5b6000610140526005546101605261018060006020818352015b6001600261053857600080fd5b6002610160510614156105a2576000610180516020811061055857600080fd5b600460c052602060c02001546020826102200101526020810190506101405160208261022001015260208101905080610220526102209050805160208201209050610140526105fb565b6000610140516020826101a001015260208101905061018051602081106105c857600080fd5b600360c052602060c02001546020826101a0010152602081019050806101a0526101a09050805160208201209050610140525b610160600261060957600080fd5b60028151048152505b815160010180835281141561052b575b50506101405160005260206000f3005b6398b1e06a60005114156112435760206004610140376102206004356004016101603761020060043560040135111561066a57600080fd5b633b9aca006103c0526103c05161068057600080fd5b6103c05134046103a0526001546103a051101561069c57600080fd5b6002546103a05111156106ae57600080fd5b6005546103e05242610400526000606061070060246380673289610680526103a0516106a05261069c6000305af16106e557600080fd5b61072060088060208461084001018260208501600060046012f150508051820191505060606107e06024638067328961076052610400516107805261077c6000305af161073157600080fd5b61080060088060208461084001018260208501600060046012f15050805182019150506101606102008060208461084001018260208501600060046045f150508051820191505080610840526108409050805160200180610420828460006004600a8704601201f16107a257600080fd5b50506000610aa0526002610ac052610ae060006020818352015b6000610ac0516107cb57600080fd5b610ac0516103e05160016103e0510110156107e557600080fd5b60016103e05101061415156107f957610865565b610aa060605160018251018060405190131561081457600080fd5b809190121561082257600080fd5b815250610ac080511515610837576000610851565b600281516002835102041461084b57600080fd5b60028151025b8152505b81516001018083528114156107bc575b5050610420805160208201209050610b0052610b2060006020818352015b610aa051610b205112156108ea576000610b2051602081106108a457600080fd5b600460c052602060c0200154602082610b40010152602081019050610b0051602082610b4001015260208101905080610b4052610b409050805160208201209050610b00525b5b8151600101808352811415610883575b5050610b0051610aa0516020811061091257600080fd5b600460c052602060c0200155600580546001825401101561093257600080fd5b60018154018155506020610c40600463c5f2892f610be052610bfc6000305af161095b57600080fd5b610c4051610bc0526060610ce060246380673289610c60526103e051610c8052610c7c6000305af161098c57600080fd5b610d00805160200180610d40828460006004600a8704601201f16109af57600080fd5b5050610bc051610e0052600460c052602060c02054610e60526001600460c052602060c0200154610e80526002600460c052602060c0200154610ea0526003600460c052602060c0200154610ec0526004600460c052602060c0200154610ee0526005600460c052602060c0200154610f00526006600460c052602060c0200154610f20526007600460c052602060c0200154610f40526008600460c052602060c0200154610f60526009600460c052602060c0200154610f8052600a600460c052602060c0200154610fa052600b600460c052602060c0200154610fc052600c600460c052602060c0200154610fe052600d600460c052602060c020015461100052600e600460c052602060c020015461102052600f600460c052602060c0200154611040526010600460c052602060c0200154611060526011600460c052602060c0200154611080526012600460c052602060c02001546110a0526013600460c052602060c02001546110c0526014600460c052602060c02001546110e0526015600460c052602060c0200154611100526016600460c052602060c0200154611120526017600460c052602060c0200154611140526018600460c052602060c0200154611160526019600460c052602060c020015461118052601a600460c052602060c02001546111a052601b600460c052602060c02001546111c052601c600460c052602060c02001546111e052601d600460c052602060c020015461120052601e600460c052602060c020015461122052601f600460c052602060c020015461124052610460610dc052610dc051610e2052610420805160200180610dc051610e0001828460006004600a8704601201f1610c2d57600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da08151610220818352015b83610da051101515610c6c57610c89565b6000610da0516020850101535b8151600101808352811415610c5b575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc052610dc051610e4052610d40805160200180610dc051610e0001828460006004600a8704601201f1610ce057600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da081516020818352015b83610da051101515610d1e57610d3b565b6000610da0516020850101535b8151600101808352811415610d0d575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc0527fce7a77a358682d6c81f71216fb7fb108b03bc8badbf67f5d131ba5363cbefb42610dc051610e00a16002546103a0511415611241576006805460018254011015610dac57600080fd5b600181540181555060005460065414156112405760075415610f975760606114c06024638067328961144052610400516114605261145c6000305af1610df157600080fd5b6114e080600860c052602060c020602082510161012060006002818352015b82610120516020021115610e2357610e45565b61012051602002850151610120518501555b8151600101808352811415610e10575b5050505050506020611580600463c5f2892f6115205261153c6000305af1610e6c57600080fd5b611580516115a0526115a0516116205260406115e0526115e0516116405260088060c052602060c0206115e05161162001602082540161012060006002818352015b82610120516020021115610ec157610ee3565b61012051850154610120516020028501525b8151600101808352811415610eae575b5050505050506115e051611620015160206001820306601f82010390506115e051611620016115c081516020818352015b836115c051101515610f2557610f42565b60006115c0516020850101535b8151600101808352811415610f14575b5050505060206115e051611620015160206001820306601f82010390506115e05101016115e0527fd1faa3f9bca1d698df559716fe6d1c9999155b38d3158fffbc98d76d568091fc6115e051611620a161123f565b4261128052426112a05262015180610fae57600080fd5b620151806112a05106611280511015610fc657600080fd5b426112a05262015180610fd857600080fd5b620151806112a051066112805103620151804261128052426112a0526201518061100157600080fd5b620151806112a0510661128051101561101957600080fd5b426112a0526201518061102b57600080fd5b620151806112a05106611280510301101561104557600080fd5b620151804261128052426112a0526201518061106057600080fd5b620151806112a0510661128051101561107857600080fd5b426112a0526201518061108a57600080fd5b620151806112a05106611280510301611260526060611340602463806732896112c052611260516112e0526112dc6000305af16110c657600080fd5b61136080600860c052602060c020602082510161012060006002818352015b826101205160200211156110f85761111a565b61012051602002850151610120518501555b81516001018083528114156110e5575b505050505050610bc0516114005260406113c0526113c0516114205260088060c052602060c0206113c05161140001602082540161012060006002818352015b8261012051602002111561116d5761118f565b61012051850154610120516020028501525b815160010180835281141561115a575b5050505050506113c051611400015160206001820306601f82010390506113c051611400016113a081516020818352015b836113a0511015156111d1576111ee565b60006113a0516020850101535b81516001018083528114156111c0575b5050505060206113c051611400015160206001820306601f82010390506113c05101016113c0527fd1faa3f9bca1d698df559716fe6d1c9999155b38d3158fffbc98d76d568091fc6113c051611400a15b5b5b005b639890220b600051141561127757341561125c57600080fd5b600060006000600030316009546000f161127557600080fd5b005b634a637042600051141561129d57341561129057600080fd5b60005460005260206000f3005b631ea30fef60005114156112c35734156112b657600080fd5b60015460005260206000f3005b634c34a98260005114156112e95734156112dc57600080fd5b60025460005260206000f3005b63eb8545ee600051141561130f57341561130257600080fd5b60055460005260206000f3005b63188e6c87600051141561133557341561132857600080fd5b60065460005260206000f3005b63eb5cc58e600051141561135b57341561134e57600080fd5b60075460005260206000f3005b6342c6498a600051141561143e57341561137457600080fd5b60088060c052602060c020610180602082540161012060006002818352015b826101205160200211156113a6576113c8565b61012051850154610120516020028501525b8151600101808352811415611393575b5050505050506101805160206001820306601f82010390506101e0610180516008818352015b826101e05111156113fe5761141a565b60006101e0516101a001535b81516001018083528114156113ee575b5050506020610160526040610180510160206001820306601f8201039050610160f3005b638ba35cdf600051141561146457341561145757600080fd5b60095460005260206000f3005b60006000fd5b6102576116c1036102576000396102576116c1036000f3 +0x600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05260a06117b86101403934156100a757600080fd5b602060806117b80160c03960c05160205181106100c357600080fd5b506101405160005561016051600155610180516002556101a0516007556101c0516009556101e06000601f818352015b60006101e0516020811061010657600080fd5b600360c052602060c02001546020826102000101526020810190506101e0516020811061013257600080fd5b600360c052602060c02001546020826102000101526020810190508061020052610200905080516020820120905060605160016101e051018060405190131561017a57600080fd5b809190121561018857600080fd5b6020811061019557600080fd5b600360c052602060c020015560605160016101e05101806040519013156101bb57600080fd5b80919012156101c957600080fd5b602081106101d657600080fd5b600360c052602060c020015460605160016101e05101806040519013156101fc57600080fd5b809190121561020a57600080fd5b6020811061021757600080fd5b600460c052602060c02001555b81516001018083528114156100f3575b50506117a056600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526000156101a3575b6101605261014052601860086020820661020001602082840111156100bf57600080fd5b60208061022082610140600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16100fc57600080fd5b50506102c05160206001820306601f82010390506103206102c0516008818352015b8261032051111561012e5761014a565b6000610320516102e001535b815160010180835281141561011e575b50505060206102a05260406102c0510160206001820306601f8201039050610280525b60006102805111151561017f5761019b565b602061028051036102a00151602061028051036102805261016d565b610160515650005b638067328960005114156104f957602060046101403734156101c457600080fd5b67ffffffffffffffff6101405111156101dc57600080fd5b6101405161016051610180516101a05163b0429c706101c052610140516101e0526101e0516006580161009b565b506102405260006102a0525b6102405160206001820306601f82010390506102a05110151561023857610251565b6102a05161026001526102a0516020016102a052610216565b6101a052610180526101605261014052610240805160200180610160828460006004600a8704601201f161028457600080fd5b50506101608060200151600082518060209013156102a157600080fd5b80919012156102af57600080fd5b806020036101000a82049050905090506102c05260006102e05261030060006008818352015b6102e051600860008112156102f2578060000360020a82046102f9565b8060020a82025b905090506102e05260ff6102c05116610320526102e051610320516102e05101101561032457600080fd5b610320516102e051016102e0526102c0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8600081121561036d578060000360020a8204610374565b8060020a82025b905090506102c0525b81516001018083528114156102d5575b50506101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05163b0429c70610340526102e05161036052610360516006580161009b565b506103c0526000610420525b6103c05160206001820306601f8201039050610420511015156104135761042c565b610420516103e0015261042051602001610420526103f1565b6102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103c0805160200180610480828460006004600a8704601201f161048757600080fd5b50506104805160206001820306601f82010390506104e0610480516008818352015b826104e05111156104b9576104d5565b60006104e0516104a001535b81516001018083528114156104a9575b5050506020610460526040610480510160206001820306601f8201039050610460f3005b63c5f2892f600051141561063257341561051257600080fd5b6000610140526005546101605261018060006020818352015b6001600261053857600080fd5b6002610160510614156105a2576000610180516020811061055857600080fd5b600460c052602060c02001546020826102200101526020810190506101405160208261022001015260208101905080610220526102209050805160208201209050610140526105fb565b6000610140516020826101a001015260208101905061018051602081106105c857600080fd5b600360c052602060c02001546020826101a0010152602081019050806101a0526101a09050805160208201209050610140525b610160600261060957600080fd5b60028151048152505b815160010180835281141561052b575b50506101405160005260206000f3005b6398b1e06a600051141561133e5760206004610140376102206004356004016101603761020060043560040135111561066a57600080fd5b633b9aca006103c0526103c05161068057600080fd5b6103c05134046103a0526001546103a051101561069c57600080fd5b6002546103a05111156106ae57600080fd5b6005546103e05242610400526000606061070060246380673289610680526103a0516106a05261069c6000305af16106e557600080fd5b61072060088060208461084001018260208501600060046012f150508051820191505060606107e06024638067328961076052610400516107805261077c6000305af161073157600080fd5b61080060088060208461084001018260208501600060046012f15050805182019150506101606102008060208461084001018260208501600060046045f150508051820191505080610840526108409050805160200180610420828460006004600a8704601201f16107a257600080fd5b50506000610aa0526002610ac052610ae060006020818352015b6000610ac0516107cb57600080fd5b610ac0516103e05160016103e0510110156107e557600080fd5b60016103e05101061415156107f957610865565b610aa060605160018251018060405190131561081457600080fd5b809190121561082257600080fd5b815250610ac080511515610837576000610851565b600281516002835102041461084b57600080fd5b60028151025b8152505b81516001018083528114156107bc575b5050610420805160208201209050610b0052610b2060006020818352015b610aa051610b205112156108ea576000610b2051602081106108a457600080fd5b600460c052602060c0200154602082610b40010152602081019050610b0051602082610b4001015260208101905080610b4052610b409050805160208201209050610b00525b5b8151600101808352811415610883575b5050610b0051610aa0516020811061091257600080fd5b600460c052602060c0200155600580546001825401101561093257600080fd5b60018154018155506020610c40600463c5f2892f610be052610bfc6000305af161095b57600080fd5b610c4051610bc0526060610ce060246380673289610c60526103e051610c8052610c7c6000305af161098c57600080fd5b610d00805160200180610d40828460006004600a8704601201f16109af57600080fd5b5050610bc051610e0052600460c052602060c02054610e60526001600460c052602060c0200154610e80526002600460c052602060c0200154610ea0526003600460c052602060c0200154610ec0526004600460c052602060c0200154610ee0526005600460c052602060c0200154610f00526006600460c052602060c0200154610f20526007600460c052602060c0200154610f40526008600460c052602060c0200154610f60526009600460c052602060c0200154610f8052600a600460c052602060c0200154610fa052600b600460c052602060c0200154610fc052600c600460c052602060c0200154610fe052600d600460c052602060c020015461100052600e600460c052602060c020015461102052600f600460c052602060c0200154611040526010600460c052602060c0200154611060526011600460c052602060c0200154611080526012600460c052602060c02001546110a0526013600460c052602060c02001546110c0526014600460c052602060c02001546110e0526015600460c052602060c0200154611100526016600460c052602060c0200154611120526017600460c052602060c0200154611140526018600460c052602060c0200154611160526019600460c052602060c020015461118052601a600460c052602060c02001546111a052601b600460c052602060c02001546111c052601c600460c052602060c02001546111e052601d600460c052602060c020015461120052601e600460c052602060c020015461122052601f600460c052602060c020015461124052610460610dc052610dc051610e2052610420805160200180610dc051610e0001828460006004600a8704601201f1610c2d57600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da08151610220818352015b83610da051101515610c6c57610c89565b6000610da0516020850101535b8151600101808352811415610c5b575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc052610dc051610e4052610d40805160200180610dc051610e0001828460006004600a8704601201f1610ce057600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da081516020818352015b83610da051101515610d1e57610d3b565b6000610da0516020850101535b8151600101808352811415610d0d575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc0527fce7a77a358682d6c81f71216fb7fb108b03bc8badbf67f5d131ba5363cbefb42610dc051610e00a16002546103a051141561133c576006805460018254011015610dac57600080fd5b6001815401815550600054600654141561133b57600060075411156110925742611460524261148052600754610de157600080fd5b6007546114805106611460511015610df857600080fd5b4261148052600754610e0957600080fd5b6007546114805106611460510360075442611460524261148052600754610e2f57600080fd5b6007546114805106611460511015610e4657600080fd5b4261148052600754610e5757600080fd5b60075461148051066114605103011015610e7057600080fd5b60075442611460524261148052600754610e8957600080fd5b6007546114805106611460511015610ea057600080fd5b4261148052600754610eb157600080fd5b6007546114805106611460510301611440526060611520602463806732896114a052611440516114c0526114bc6000305af1610eec57600080fd5b61154080600860c052602060c020602082510161012060006002818352015b82610120516020021115610f1e57610f40565b61012051602002850151610120518501555b8151600101808352811415610f0b575b50505050505060206115e0600463c5f2892f6115805261159c6000305af1610f6757600080fd5b6115e051611600526116005161168052604061164052611640516116a05260088060c052602060c0206116405161168001602082540161012060006002818352015b82610120516020021115610fbc57610fde565b61012051850154610120516020028501525b8151600101808352811415610fa9575b50505050505061164051611680015160206001820306601f8201039050611640516116800161162081516020818352015b83611620511015156110205761103d565b6000611620516020850101535b815160010180835281141561100f575b50505050602061164051611680015160206001820306601f8201039050611640510101611640527fd1faa3f9bca1d698df559716fe6d1c9999155b38d3158fffbc98d76d568091fc61164051611680a161133a565b4261128052426112a052620151806110a957600080fd5b620151806112a051066112805110156110c157600080fd5b426112a052620151806110d357600080fd5b620151806112a051066112805103620151804261128052426112a052620151806110fc57600080fd5b620151806112a0510661128051101561111457600080fd5b426112a0526201518061112657600080fd5b620151806112a05106611280510301101561114057600080fd5b620151804261128052426112a0526201518061115b57600080fd5b620151806112a0510661128051101561117357600080fd5b426112a0526201518061118557600080fd5b620151806112a05106611280510301611260526060611340602463806732896112c052611260516112e0526112dc6000305af16111c157600080fd5b61136080600860c052602060c020602082510161012060006002818352015b826101205160200211156111f357611215565b61012051602002850151610120518501555b81516001018083528114156111e0575b505050505050610bc0516114005260406113c0526113c0516114205260088060c052602060c0206113c05161140001602082540161012060006002818352015b826101205160200211156112685761128a565b61012051850154610120516020028501525b8151600101808352811415611255575b5050505050506113c051611400015160206001820306601f82010390506113c051611400016113a081516020818352015b836113a0511015156112cc576112e9565b60006113a0516020850101535b81516001018083528114156112bb575b5050505060206113c051611400015160206001820306601f82010390506113c05101016113c0527fd1faa3f9bca1d698df559716fe6d1c9999155b38d3158fffbc98d76d568091fc6113c051611400a15b5b5b005b639890220b600051141561137257341561135757600080fd5b600060006000600030316009546000f161137057600080fd5b005b634a637042600051141561139857341561138b57600080fd5b60005460005260206000f3005b631ea30fef60005114156113be5734156113b157600080fd5b60015460005260206000f3005b634c34a98260005114156113e45734156113d757600080fd5b60025460005260206000f3005b63eb8545ee600051141561140a5734156113fd57600080fd5b60055460005260206000f3005b63188e6c87600051141561143057341561142357600080fd5b60065460005260206000f3005b63b6080cd2600051141561145657341561144957600080fd5b60075460005260206000f3005b6342c6498a600051141561153957341561146f57600080fd5b60088060c052602060c020610180602082540161012060006002818352015b826101205160200211156114a1576114c3565b61012051850154610120516020028501525b815160010180835281141561148e575b5050505050506101805160206001820306601f82010390506101e0610180516008818352015b826101e05111156114f957611515565b60006101e0516101a001535b81516001018083528114156114e9575b5050506020610160526040610180510160206001820306601f8201039050610160f3005b638ba35cdf600051141561155f57341561155257600080fd5b60095460005260206000f3005b60006000fd5b61023b6117a00361023b60003961023b6117a0036000f3 \ No newline at end of file diff --git a/contracts/deposit-contract/deployContract/deployContract.go b/contracts/deposit-contract/deployContract/deployContract.go index 347709886eb9..bfd003a37b41 100644 --- a/contracts/deposit-contract/deployContract/deployContract.go +++ b/contracts/deposit-contract/deployContract/deployContract.go @@ -36,7 +36,7 @@ func main() { var depositsForChainStart int64 var minDepositAmount int64 var maxDepositAmount int64 - var skipChainstartDelay bool + var customChainstartDelay uint64 var drainAddress string customFormatter := new(prefixed.TextFormatter) @@ -55,10 +55,11 @@ func main() { Usage: "Location of keystore", Destination: &keystoreUTCPath, }, - cli.BoolFlag{ - Name: "skipChainstartDelay", - Usage: "Whether to skip ChainStart log being fired a day later", - Destination: &skipChainstartDelay, + cli.Uint64Flag{ + Name: "customChainstartDelay", + Usage: "Number of seconds to delay the ChainStart genesis timestamp", + Value: 0, + Destination: &customChainstartDelay, }, cli.StringFlag{ Name: "ipcPath", @@ -180,7 +181,7 @@ func main() { big.NewInt(depositsForChainStart), big.NewInt(minDepositAmount), big.NewInt(maxDepositAmount), - skipChainstartDelay, + big.NewInt(int64(customChainstartDelay)), drain, ) diff --git a/contracts/deposit-contract/depositContract.go b/contracts/deposit-contract/depositContract.go index 42d92064edd0..46fb0ed15490 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\"},{\"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}]" +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\":\"uint256\",\"name\":\"customChainstartDelay\"},{\"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\":535502},{\"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\":\"custom_chainstart_delay\",\"outputs\":[{\"type\":\"uint256\",\"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 = `0x600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05260a06116d96101403934156100a757600080fd5b602060606116d90160c03960c051600281106100c257600080fd5b50602060806116d90160c03960c05160205181106100df57600080fd5b506101405160005561016051600155610180516002556101a0516007556101c0516009556101e06000601f818352015b60006101e0516020811061012257600080fd5b600360c052602060c02001546020826102000101526020810190506101e0516020811061014e57600080fd5b600360c052602060c02001546020826102000101526020810190508061020052610200905080516020820120905060605160016101e051018060405190131561019657600080fd5b80919012156101a457600080fd5b602081106101b157600080fd5b600360c052602060c020015560605160016101e05101806040519013156101d757600080fd5b80919012156101e557600080fd5b602081106101f257600080fd5b600360c052602060c020015460605160016101e051018060405190131561021857600080fd5b809190121561022657600080fd5b6020811061023357600080fd5b600460c052602060c02001555b815160010180835281141561010f575b50506116c156600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526000156101a3575b6101605261014052601860086020820661020001602082840111156100bf57600080fd5b60208061022082610140600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16100fc57600080fd5b50506102c05160206001820306601f82010390506103206102c0516008818352015b8261032051111561012e5761014a565b6000610320516102e001535b815160010180835281141561011e575b50505060206102a05260406102c0510160206001820306601f8201039050610280525b60006102805111151561017f5761019b565b602061028051036102a00151602061028051036102805261016d565b610160515650005b638067328960005114156104f957602060046101403734156101c457600080fd5b67ffffffffffffffff6101405111156101dc57600080fd5b6101405161016051610180516101a05163b0429c706101c052610140516101e0526101e0516006580161009b565b506102405260006102a0525b6102405160206001820306601f82010390506102a05110151561023857610251565b6102a05161026001526102a0516020016102a052610216565b6101a052610180526101605261014052610240805160200180610160828460006004600a8704601201f161028457600080fd5b50506101608060200151600082518060209013156102a157600080fd5b80919012156102af57600080fd5b806020036101000a82049050905090506102c05260006102e05261030060006008818352015b6102e051600860008112156102f2578060000360020a82046102f9565b8060020a82025b905090506102e05260ff6102c05116610320526102e051610320516102e05101101561032457600080fd5b610320516102e051016102e0526102c0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8600081121561036d578060000360020a8204610374565b8060020a82025b905090506102c0525b81516001018083528114156102d5575b50506101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05163b0429c70610340526102e05161036052610360516006580161009b565b506103c0526000610420525b6103c05160206001820306601f8201039050610420511015156104135761042c565b610420516103e0015261042051602001610420526103f1565b6102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103c0805160200180610480828460006004600a8704601201f161048757600080fd5b50506104805160206001820306601f82010390506104e0610480516008818352015b826104e05111156104b9576104d5565b60006104e0516104a001535b81516001018083528114156104a9575b5050506020610460526040610480510160206001820306601f8201039050610460f3005b63c5f2892f600051141561063257341561051257600080fd5b6000610140526005546101605261018060006020818352015b6001600261053857600080fd5b6002610160510614156105a2576000610180516020811061055857600080fd5b600460c052602060c02001546020826102200101526020810190506101405160208261022001015260208101905080610220526102209050805160208201209050610140526105fb565b6000610140516020826101a001015260208101905061018051602081106105c857600080fd5b600360c052602060c02001546020826101a0010152602081019050806101a0526101a09050805160208201209050610140525b610160600261060957600080fd5b60028151048152505b815160010180835281141561052b575b50506101405160005260206000f3005b6398b1e06a60005114156112435760206004610140376102206004356004016101603761020060043560040135111561066a57600080fd5b633b9aca006103c0526103c05161068057600080fd5b6103c05134046103a0526001546103a051101561069c57600080fd5b6002546103a05111156106ae57600080fd5b6005546103e05242610400526000606061070060246380673289610680526103a0516106a05261069c6000305af16106e557600080fd5b61072060088060208461084001018260208501600060046012f150508051820191505060606107e06024638067328961076052610400516107805261077c6000305af161073157600080fd5b61080060088060208461084001018260208501600060046012f15050805182019150506101606102008060208461084001018260208501600060046045f150508051820191505080610840526108409050805160200180610420828460006004600a8704601201f16107a257600080fd5b50506000610aa0526002610ac052610ae060006020818352015b6000610ac0516107cb57600080fd5b610ac0516103e05160016103e0510110156107e557600080fd5b60016103e05101061415156107f957610865565b610aa060605160018251018060405190131561081457600080fd5b809190121561082257600080fd5b815250610ac080511515610837576000610851565b600281516002835102041461084b57600080fd5b60028151025b8152505b81516001018083528114156107bc575b5050610420805160208201209050610b0052610b2060006020818352015b610aa051610b205112156108ea576000610b2051602081106108a457600080fd5b600460c052602060c0200154602082610b40010152602081019050610b0051602082610b4001015260208101905080610b4052610b409050805160208201209050610b00525b5b8151600101808352811415610883575b5050610b0051610aa0516020811061091257600080fd5b600460c052602060c0200155600580546001825401101561093257600080fd5b60018154018155506020610c40600463c5f2892f610be052610bfc6000305af161095b57600080fd5b610c4051610bc0526060610ce060246380673289610c60526103e051610c8052610c7c6000305af161098c57600080fd5b610d00805160200180610d40828460006004600a8704601201f16109af57600080fd5b5050610bc051610e0052600460c052602060c02054610e60526001600460c052602060c0200154610e80526002600460c052602060c0200154610ea0526003600460c052602060c0200154610ec0526004600460c052602060c0200154610ee0526005600460c052602060c0200154610f00526006600460c052602060c0200154610f20526007600460c052602060c0200154610f40526008600460c052602060c0200154610f60526009600460c052602060c0200154610f8052600a600460c052602060c0200154610fa052600b600460c052602060c0200154610fc052600c600460c052602060c0200154610fe052600d600460c052602060c020015461100052600e600460c052602060c020015461102052600f600460c052602060c0200154611040526010600460c052602060c0200154611060526011600460c052602060c0200154611080526012600460c052602060c02001546110a0526013600460c052602060c02001546110c0526014600460c052602060c02001546110e0526015600460c052602060c0200154611100526016600460c052602060c0200154611120526017600460c052602060c0200154611140526018600460c052602060c0200154611160526019600460c052602060c020015461118052601a600460c052602060c02001546111a052601b600460c052602060c02001546111c052601c600460c052602060c02001546111e052601d600460c052602060c020015461120052601e600460c052602060c020015461122052601f600460c052602060c020015461124052610460610dc052610dc051610e2052610420805160200180610dc051610e0001828460006004600a8704601201f1610c2d57600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da08151610220818352015b83610da051101515610c6c57610c89565b6000610da0516020850101535b8151600101808352811415610c5b575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc052610dc051610e4052610d40805160200180610dc051610e0001828460006004600a8704601201f1610ce057600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da081516020818352015b83610da051101515610d1e57610d3b565b6000610da0516020850101535b8151600101808352811415610d0d575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc0527fce7a77a358682d6c81f71216fb7fb108b03bc8badbf67f5d131ba5363cbefb42610dc051610e00a16002546103a0511415611241576006805460018254011015610dac57600080fd5b600181540181555060005460065414156112405760075415610f975760606114c06024638067328961144052610400516114605261145c6000305af1610df157600080fd5b6114e080600860c052602060c020602082510161012060006002818352015b82610120516020021115610e2357610e45565b61012051602002850151610120518501555b8151600101808352811415610e10575b5050505050506020611580600463c5f2892f6115205261153c6000305af1610e6c57600080fd5b611580516115a0526115a0516116205260406115e0526115e0516116405260088060c052602060c0206115e05161162001602082540161012060006002818352015b82610120516020021115610ec157610ee3565b61012051850154610120516020028501525b8151600101808352811415610eae575b5050505050506115e051611620015160206001820306601f82010390506115e051611620016115c081516020818352015b836115c051101515610f2557610f42565b60006115c0516020850101535b8151600101808352811415610f14575b5050505060206115e051611620015160206001820306601f82010390506115e05101016115e0527fd1faa3f9bca1d698df559716fe6d1c9999155b38d3158fffbc98d76d568091fc6115e051611620a161123f565b4261128052426112a05262015180610fae57600080fd5b620151806112a05106611280511015610fc657600080fd5b426112a05262015180610fd857600080fd5b620151806112a051066112805103620151804261128052426112a0526201518061100157600080fd5b620151806112a0510661128051101561101957600080fd5b426112a0526201518061102b57600080fd5b620151806112a05106611280510301101561104557600080fd5b620151804261128052426112a0526201518061106057600080fd5b620151806112a0510661128051101561107857600080fd5b426112a0526201518061108a57600080fd5b620151806112a05106611280510301611260526060611340602463806732896112c052611260516112e0526112dc6000305af16110c657600080fd5b61136080600860c052602060c020602082510161012060006002818352015b826101205160200211156110f85761111a565b61012051602002850151610120518501555b81516001018083528114156110e5575b505050505050610bc0516114005260406113c0526113c0516114205260088060c052602060c0206113c05161140001602082540161012060006002818352015b8261012051602002111561116d5761118f565b61012051850154610120516020028501525b815160010180835281141561115a575b5050505050506113c051611400015160206001820306601f82010390506113c051611400016113a081516020818352015b836113a0511015156111d1576111ee565b60006113a0516020850101535b81516001018083528114156111c0575b5050505060206113c051611400015160206001820306601f82010390506113c05101016113c0527fd1faa3f9bca1d698df559716fe6d1c9999155b38d3158fffbc98d76d568091fc6113c051611400a15b5b5b005b639890220b600051141561127757341561125c57600080fd5b600060006000600030316009546000f161127557600080fd5b005b634a637042600051141561129d57341561129057600080fd5b60005460005260206000f3005b631ea30fef60005114156112c35734156112b657600080fd5b60015460005260206000f3005b634c34a98260005114156112e95734156112dc57600080fd5b60025460005260206000f3005b63eb8545ee600051141561130f57341561130257600080fd5b60055460005260206000f3005b63188e6c87600051141561133557341561132857600080fd5b60065460005260206000f3005b63eb5cc58e600051141561135b57341561134e57600080fd5b60075460005260206000f3005b6342c6498a600051141561143e57341561137457600080fd5b60088060c052602060c020610180602082540161012060006002818352015b826101205160200211156113a6576113c8565b61012051850154610120516020028501525b8151600101808352811415611393575b5050505050506101805160206001820306601f82010390506101e0610180516008818352015b826101e05111156113fe5761141a565b60006101e0516101a001535b81516001018083528114156113ee575b5050506020610160526040610180510160206001820306601f8201039050610160f3005b638ba35cdf600051141561146457341561145757600080fd5b60095460005260206000f3005b60006000fd5b6102576116c1036102576000396102576116c1036000f3` +const DepositContractBin = `0x600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05260a06117b86101403934156100a757600080fd5b602060806117b80160c03960c05160205181106100c357600080fd5b506101405160005561016051600155610180516002556101a0516007556101c0516009556101e06000601f818352015b60006101e0516020811061010657600080fd5b600360c052602060c02001546020826102000101526020810190506101e0516020811061013257600080fd5b600360c052602060c02001546020826102000101526020810190508061020052610200905080516020820120905060605160016101e051018060405190131561017a57600080fd5b809190121561018857600080fd5b6020811061019557600080fd5b600360c052602060c020015560605160016101e05101806040519013156101bb57600080fd5b80919012156101c957600080fd5b602081106101d657600080fd5b600360c052602060c020015460605160016101e05101806040519013156101fc57600080fd5b809190121561020a57600080fd5b6020811061021757600080fd5b600460c052602060c02001555b81516001018083528114156100f3575b50506117a056600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526000156101a3575b6101605261014052601860086020820661020001602082840111156100bf57600080fd5b60208061022082610140600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16100fc57600080fd5b50506102c05160206001820306601f82010390506103206102c0516008818352015b8261032051111561012e5761014a565b6000610320516102e001535b815160010180835281141561011e575b50505060206102a05260406102c0510160206001820306601f8201039050610280525b60006102805111151561017f5761019b565b602061028051036102a00151602061028051036102805261016d565b610160515650005b638067328960005114156104f957602060046101403734156101c457600080fd5b67ffffffffffffffff6101405111156101dc57600080fd5b6101405161016051610180516101a05163b0429c706101c052610140516101e0526101e0516006580161009b565b506102405260006102a0525b6102405160206001820306601f82010390506102a05110151561023857610251565b6102a05161026001526102a0516020016102a052610216565b6101a052610180526101605261014052610240805160200180610160828460006004600a8704601201f161028457600080fd5b50506101608060200151600082518060209013156102a157600080fd5b80919012156102af57600080fd5b806020036101000a82049050905090506102c05260006102e05261030060006008818352015b6102e051600860008112156102f2578060000360020a82046102f9565b8060020a82025b905090506102e05260ff6102c05116610320526102e051610320516102e05101101561032457600080fd5b610320516102e051016102e0526102c0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8600081121561036d578060000360020a8204610374565b8060020a82025b905090506102c0525b81516001018083528114156102d5575b50506101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05163b0429c70610340526102e05161036052610360516006580161009b565b506103c0526000610420525b6103c05160206001820306601f8201039050610420511015156104135761042c565b610420516103e0015261042051602001610420526103f1565b6102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526101805261016052610140526103c0805160200180610480828460006004600a8704601201f161048757600080fd5b50506104805160206001820306601f82010390506104e0610480516008818352015b826104e05111156104b9576104d5565b60006104e0516104a001535b81516001018083528114156104a9575b5050506020610460526040610480510160206001820306601f8201039050610460f3005b63c5f2892f600051141561063257341561051257600080fd5b6000610140526005546101605261018060006020818352015b6001600261053857600080fd5b6002610160510614156105a2576000610180516020811061055857600080fd5b600460c052602060c02001546020826102200101526020810190506101405160208261022001015260208101905080610220526102209050805160208201209050610140526105fb565b6000610140516020826101a001015260208101905061018051602081106105c857600080fd5b600360c052602060c02001546020826101a0010152602081019050806101a0526101a09050805160208201209050610140525b610160600261060957600080fd5b60028151048152505b815160010180835281141561052b575b50506101405160005260206000f3005b6398b1e06a600051141561133e5760206004610140376102206004356004016101603761020060043560040135111561066a57600080fd5b633b9aca006103c0526103c05161068057600080fd5b6103c05134046103a0526001546103a051101561069c57600080fd5b6002546103a05111156106ae57600080fd5b6005546103e05242610400526000606061070060246380673289610680526103a0516106a05261069c6000305af16106e557600080fd5b61072060088060208461084001018260208501600060046012f150508051820191505060606107e06024638067328961076052610400516107805261077c6000305af161073157600080fd5b61080060088060208461084001018260208501600060046012f15050805182019150506101606102008060208461084001018260208501600060046045f150508051820191505080610840526108409050805160200180610420828460006004600a8704601201f16107a257600080fd5b50506000610aa0526002610ac052610ae060006020818352015b6000610ac0516107cb57600080fd5b610ac0516103e05160016103e0510110156107e557600080fd5b60016103e05101061415156107f957610865565b610aa060605160018251018060405190131561081457600080fd5b809190121561082257600080fd5b815250610ac080511515610837576000610851565b600281516002835102041461084b57600080fd5b60028151025b8152505b81516001018083528114156107bc575b5050610420805160208201209050610b0052610b2060006020818352015b610aa051610b205112156108ea576000610b2051602081106108a457600080fd5b600460c052602060c0200154602082610b40010152602081019050610b0051602082610b4001015260208101905080610b4052610b409050805160208201209050610b00525b5b8151600101808352811415610883575b5050610b0051610aa0516020811061091257600080fd5b600460c052602060c0200155600580546001825401101561093257600080fd5b60018154018155506020610c40600463c5f2892f610be052610bfc6000305af161095b57600080fd5b610c4051610bc0526060610ce060246380673289610c60526103e051610c8052610c7c6000305af161098c57600080fd5b610d00805160200180610d40828460006004600a8704601201f16109af57600080fd5b5050610bc051610e0052600460c052602060c02054610e60526001600460c052602060c0200154610e80526002600460c052602060c0200154610ea0526003600460c052602060c0200154610ec0526004600460c052602060c0200154610ee0526005600460c052602060c0200154610f00526006600460c052602060c0200154610f20526007600460c052602060c0200154610f40526008600460c052602060c0200154610f60526009600460c052602060c0200154610f8052600a600460c052602060c0200154610fa052600b600460c052602060c0200154610fc052600c600460c052602060c0200154610fe052600d600460c052602060c020015461100052600e600460c052602060c020015461102052600f600460c052602060c0200154611040526010600460c052602060c0200154611060526011600460c052602060c0200154611080526012600460c052602060c02001546110a0526013600460c052602060c02001546110c0526014600460c052602060c02001546110e0526015600460c052602060c0200154611100526016600460c052602060c0200154611120526017600460c052602060c0200154611140526018600460c052602060c0200154611160526019600460c052602060c020015461118052601a600460c052602060c02001546111a052601b600460c052602060c02001546111c052601c600460c052602060c02001546111e052601d600460c052602060c020015461120052601e600460c052602060c020015461122052601f600460c052602060c020015461124052610460610dc052610dc051610e2052610420805160200180610dc051610e0001828460006004600a8704601201f1610c2d57600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da08151610220818352015b83610da051101515610c6c57610c89565b6000610da0516020850101535b8151600101808352811415610c5b575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc052610dc051610e4052610d40805160200180610dc051610e0001828460006004600a8704601201f1610ce057600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da081516020818352015b83610da051101515610d1e57610d3b565b6000610da0516020850101535b8151600101808352811415610d0d575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc0527fce7a77a358682d6c81f71216fb7fb108b03bc8badbf67f5d131ba5363cbefb42610dc051610e00a16002546103a051141561133c576006805460018254011015610dac57600080fd5b6001815401815550600054600654141561133b57600060075411156110925742611460524261148052600754610de157600080fd5b6007546114805106611460511015610df857600080fd5b4261148052600754610e0957600080fd5b6007546114805106611460510360075442611460524261148052600754610e2f57600080fd5b6007546114805106611460511015610e4657600080fd5b4261148052600754610e5757600080fd5b60075461148051066114605103011015610e7057600080fd5b60075442611460524261148052600754610e8957600080fd5b6007546114805106611460511015610ea057600080fd5b4261148052600754610eb157600080fd5b6007546114805106611460510301611440526060611520602463806732896114a052611440516114c0526114bc6000305af1610eec57600080fd5b61154080600860c052602060c020602082510161012060006002818352015b82610120516020021115610f1e57610f40565b61012051602002850151610120518501555b8151600101808352811415610f0b575b50505050505060206115e0600463c5f2892f6115805261159c6000305af1610f6757600080fd5b6115e051611600526116005161168052604061164052611640516116a05260088060c052602060c0206116405161168001602082540161012060006002818352015b82610120516020021115610fbc57610fde565b61012051850154610120516020028501525b8151600101808352811415610fa9575b50505050505061164051611680015160206001820306601f8201039050611640516116800161162081516020818352015b83611620511015156110205761103d565b6000611620516020850101535b815160010180835281141561100f575b50505050602061164051611680015160206001820306601f8201039050611640510101611640527fd1faa3f9bca1d698df559716fe6d1c9999155b38d3158fffbc98d76d568091fc61164051611680a161133a565b4261128052426112a052620151806110a957600080fd5b620151806112a051066112805110156110c157600080fd5b426112a052620151806110d357600080fd5b620151806112a051066112805103620151804261128052426112a052620151806110fc57600080fd5b620151806112a0510661128051101561111457600080fd5b426112a0526201518061112657600080fd5b620151806112a05106611280510301101561114057600080fd5b620151804261128052426112a0526201518061115b57600080fd5b620151806112a0510661128051101561117357600080fd5b426112a0526201518061118557600080fd5b620151806112a05106611280510301611260526060611340602463806732896112c052611260516112e0526112dc6000305af16111c157600080fd5b61136080600860c052602060c020602082510161012060006002818352015b826101205160200211156111f357611215565b61012051602002850151610120518501555b81516001018083528114156111e0575b505050505050610bc0516114005260406113c0526113c0516114205260088060c052602060c0206113c05161140001602082540161012060006002818352015b826101205160200211156112685761128a565b61012051850154610120516020028501525b8151600101808352811415611255575b5050505050506113c051611400015160206001820306601f82010390506113c051611400016113a081516020818352015b836113a0511015156112cc576112e9565b60006113a0516020850101535b81516001018083528114156112bb575b5050505060206113c051611400015160206001820306601f82010390506113c05101016113c0527fd1faa3f9bca1d698df559716fe6d1c9999155b38d3158fffbc98d76d568091fc6113c051611400a15b5b5b005b639890220b600051141561137257341561135757600080fd5b600060006000600030316009546000f161137057600080fd5b005b634a637042600051141561139857341561138b57600080fd5b60005460005260206000f3005b631ea30fef60005114156113be5734156113b157600080fd5b60015460005260206000f3005b634c34a98260005114156113e45734156113d757600080fd5b60025460005260206000f3005b63eb8545ee600051141561140a5734156113fd57600080fd5b60055460005260206000f3005b63188e6c87600051141561143057341561142357600080fd5b60065460005260206000f3005b63b6080cd2600051141561145657341561144957600080fd5b60075460005260206000f3005b6342c6498a600051141561153957341561146f57600080fd5b60088060c052602060c020610180602082540161012060006002818352015b826101205160200211156114a1576114c3565b61012051850154610120516020028501525b815160010180835281141561148e575b5050505050506101805160206001820306601f82010390506101e0610180516008818352015b826101e05111156114f957611515565b60006101e0516101a001535b81516001018083528114156114e9575b5050506020610160526040610180510160206001820306601f8201039050610160f3005b638ba35cdf600051141561155f57341561155257600080fd5b60095460005260206000f3005b60006000fd5b61023b6117a00361023b60003961023b6117a0036000f3` // 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, _drain_address common.Address) (common.Address, *types.Transaction, *DepositContract, error) { +func DeployDepositContract(auth *bind.TransactOpts, backend bind.ContractBackend, depositThreshold *big.Int, minDeposit *big.Int, maxDeposit *big.Int, customChainstartDelay *big.Int, _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, _drain_address) + address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(DepositContractBin), backend, depositThreshold, minDeposit, maxDeposit, customChainstartDelay, _drain_address) if err != nil { return common.Address{}, nil, nil, err } @@ -266,6 +266,32 @@ func (_DepositContract *DepositContractCallerSession) MINDEPOSITAMOUNT() (*big.I return _DepositContract.Contract.MINDEPOSITAMOUNT(&_DepositContract.CallOpts) } +// CustomChainstartDelay is a free data retrieval call binding the contract method 0xb6080cd2. +// +// Solidity: function custom_chainstart_delay() constant returns(uint256 out) +func (_DepositContract *DepositContractCaller) CustomChainstartDelay(opts *bind.CallOpts) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _DepositContract.contract.Call(opts, out, "custom_chainstart_delay") + return *ret0, err +} + +// CustomChainstartDelay is a free data retrieval call binding the contract method 0xb6080cd2. +// +// Solidity: function custom_chainstart_delay() constant returns(uint256 out) +func (_DepositContract *DepositContractSession) CustomChainstartDelay() (*big.Int, error) { + return _DepositContract.Contract.CustomChainstartDelay(&_DepositContract.CallOpts) +} + +// CustomChainstartDelay is a free data retrieval call binding the contract method 0xb6080cd2. +// +// Solidity: function custom_chainstart_delay() constant returns(uint256 out) +func (_DepositContract *DepositContractCallerSession) CustomChainstartDelay() (*big.Int, error) { + return _DepositContract.Contract.CustomChainstartDelay(&_DepositContract.CallOpts) +} + // DepositCount is a free data retrieval call binding the contract method 0xeb8545ee. // // Solidity: function deposit_count() constant returns(uint256 out) @@ -396,32 +422,6 @@ func (_DepositContract *DepositContractCallerSession) GetDepositRoot() ([32]byte return _DepositContract.Contract.GetDepositRoot(&_DepositContract.CallOpts) } -// SkipChainstartDelay is a free data retrieval call binding the contract method 0xeb5cc58e. -// -// Solidity: function skip_chainstart_delay() constant returns(bool out) -func (_DepositContract *DepositContractCaller) SkipChainstartDelay(opts *bind.CallOpts) (bool, error) { - var ( - ret0 = new(bool) - ) - out := ret0 - err := _DepositContract.contract.Call(opts, out, "skip_chainstart_delay") - return *ret0, err -} - -// SkipChainstartDelay is a free data retrieval call binding the contract method 0xeb5cc58e. -// -// Solidity: function skip_chainstart_delay() constant returns(bool out) -func (_DepositContract *DepositContractSession) SkipChainstartDelay() (bool, error) { - return _DepositContract.Contract.SkipChainstartDelay(&_DepositContract.CallOpts) -} - -// SkipChainstartDelay is a free data retrieval call binding the contract method 0xeb5cc58e. -// -// Solidity: function skip_chainstart_delay() constant returns(bool out) -func (_DepositContract *DepositContractCallerSession) SkipChainstartDelay() (bool, error) { - return _DepositContract.Contract.SkipChainstartDelay(&_DepositContract.CallOpts) -} - // ToLittleEndian64 is a free data retrieval call binding the contract method 0x80673289. // // Solidity: function to_little_endian_64(uint256 value) constant returns(bytes out) diff --git a/contracts/deposit-contract/depositContract.v.py b/contracts/deposit-contract/depositContract.v.py index 0caae6adcde1..76bc6a202fcc 100644 --- a/contracts/deposit-contract/depositContract.v.py +++ b/contracts/deposit-contract/depositContract.v.py @@ -14,7 +14,7 @@ branch: bytes32[32] deposit_count: public(uint256) full_deposit_count: public(uint256) -skip_chainstart_delay: public(bool) +custom_chainstart_delay: public(uint256) genesisTime: public(bytes[8]) drain_address: public(address) @@ -23,12 +23,12 @@ def __init__( # Parameters for debugging, not for production use! depositThreshold: uint256, minDeposit: uint256, maxDeposit: uint256, - skipChainstartDelay: bool, + customChainstartDelay: uint256, _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.custom_chainstart_delay = customChainstartDelay self.drain_address = _drain_address for i in range(31): self.zerohashes[i+1] = sha3(concat(self.zerohashes[i], self.zerohashes[i])) @@ -103,8 +103,9 @@ def deposit(deposit_input: bytes[512]): if deposit_amount == self.MAX_DEPOSIT_AMOUNT: self.full_deposit_count += 1 if self.full_deposit_count == self.CHAIN_START_FULL_DEPOSIT_THRESHOLD: - if self.skip_chainstart_delay: - self.genesisTime = self.to_little_endian_64(deposit_timestamp) + if self.custom_chainstart_delay > 0: + timestamp_boundary: uint256 = as_unitless_number(block.timestamp) - as_unitless_number(block.timestamp) % self.custom_chainstart_delay + self.custom_chainstart_delay + self.genesisTime = self.to_little_endian_64(timestamp_boundary) log.ChainStart(self.get_deposit_root(), self.genesisTime) else: timestamp_day_boundary: uint256 = as_unitless_number(block.timestamp) - as_unitless_number(block.timestamp) % SECONDS_PER_DAY + SECONDS_PER_DAY diff --git a/contracts/deposit-contract/depositContract_test.go b/contracts/deposit-contract/depositContract_test.go index 23c3ea7ca380..fc8eb3c49cc5 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, addr) + contractAddr, _, contract, err := DeployDepositContract(txOpts, backend, depositsRequired, minDeposit, maxDeposit, big.NewInt(1), addr) if err != nil { return nil, err }