From 9a1fae340ad3dc76f0fac32e449d85f7f07d2615 Mon Sep 17 00:00:00 2001 From: Carl Beekhuizen Date: Fri, 19 Apr 2019 09:12:19 +0200 Subject: [PATCH 1/3] Removes MAX_DEPOSIT_AMOUNT --- .../contracts/validator_registration.json | 2 +- .../contracts/validator_registration.v.py | 5 ++--- tests/contracts/conftest.py | 3 ++- tests/contracts/test_deposit.py | 22 +++++++++---------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/deposit_contract/contracts/validator_registration.json b/deposit_contract/contracts/validator_registration.json index 945609f..253eedf 100644 --- a/deposit_contract/contracts/validator_registration.json +++ b/deposit_contract/contracts/validator_registration.json @@ -1 +1 @@ -{"abi": [{"name": "Deposit", "inputs": [{"type": "bytes", "name": "pubkey", "indexed": false}, {"type": "bytes", "name": "withdrawal_credentials", "indexed": false}, {"type": "bytes", "name": "amount", "indexed": false}, {"type": "bytes", "name": "signature", "indexed": false}, {"type": "bytes", "name": "merkle_tree_index", "indexed": false}], "anonymous": false, "type": "event"}, {"name": "Eth2Genesis", "inputs": [{"type": "bytes32", "name": "deposit_root", "indexed": false}, {"type": "bytes", "name": "deposit_count", "indexed": false}, {"type": "bytes", "name": "time", "indexed": false}], "anonymous": false, "type": "event"}, {"outputs": [], "inputs": [], "constant": false, "payable": false, "type": "constructor"}, {"name": "to_little_endian_64", "outputs": [{"type": "bytes", "name": "out"}], "inputs": [{"type": "uint256", "name": "value"}], "constant": true, "payable": false, "type": "function", "gas": 7077}, {"name": "from_little_endian_64", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "bytes", "name": "value"}], "constant": true, "payable": false, "type": "function", "gas": 5983}, {"name": "get_deposit_root", "outputs": [{"type": "bytes32", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 79251}, {"name": "get_deposit_count", "outputs": [{"type": "bytes", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 11056}, {"name": "deposit", "outputs": [], "inputs": [{"type": "bytes", "name": "pubkey"}, {"type": "bytes", "name": "withdrawal_credentials"}, {"type": "bytes", "name": "signature"}], "constant": false, "payable": true, "type": "function", "gas": 456614}, {"name": "chainStarted", "outputs": [{"type": "bool", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 633}], "bytecode": "0x600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052341561009e57600080fd5b6101406000601f818352015b600061014051602081106100bd57600080fd5b600060c052602060c020015460208261016001015260208101905061014051602081106100e957600080fd5b600060c052602060c020015460208261016001015260208101905080610160526101609050602060c0825160208401600060025af161012757600080fd5b60c0519050606051600161014051018060405190131561014657600080fd5b809190121561015457600080fd5b6020811061016157600080fd5b600060c052602060c0200155606051600161014051018060405190131561018757600080fd5b809190121561019557600080fd5b602081106101a257600080fd5b600060c052602060c020015460605160016101405101806040519013156101c857600080fd5b80919012156101d657600080fd5b602081106101e357600080fd5b600160c052602060c02001555b81516001018083528114156100aa575b505061161c56600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526380673289600051141561026b57602060046101403734156100b457600080fd5b67ffffffffffffffff6101405111156100cc57600080fd5b60006101605261014051610180526101a060006008818352015b6101605160086000811215610103578060000360020a820461010a565b8060020a82025b905090506101605260ff61018051166101c052610160516101c0516101605101101561013557600080fd5b6101c051610160510161016052610180517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8600081121561017e578060000360020a8204610185565b8060020a82025b90509050610180525b81516001018083528114156100e6575b505060186008602082066101e001602082840111156101bc57600080fd5b60208061020082610160600060046015f15050818152809050905090508051602001806102a0828460006004600a8704601201f16101f957600080fd5b50506102a05160206001820306601f82010390506103006102a0516008818352015b8261030051111561022b57610247565b6000610300516102c001535b815160010180835281141561021b575b50505060206102805260406102a0510160206001820306601f8201039050610280f3005b639d70e8066000511415610405576020600461014037341561028c57600080fd5b60286004356004016101603760086004356004013511156102ac57600080fd5b60006101c0526101608060200151600082518060209013156102cd57600080fd5b80919012156102db57600080fd5b806020036101000a82049050905090506101e05261020060006008818352015b60ff6101e05116606051606051610200516007038060405190131561031f57600080fd5b809190121561032d57600080fd5b6008028060405190131561034057600080fd5b809190121561034e57600080fd5b6000811215610365578060000360020a820461036c565b8060020a82025b90509050610220526101c051610220516101c05101101561038c57600080fd5b610220516101c051016101c0526101e0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff860008112156103d5578060000360020a82046103dc565b8060020a82025b905090506101e0525b81516001018083528114156102fb575b50506101c05160005260206000f3005b63c5f2892f600051141561055d57341561041e57600080fd5b6000610140526002546101605261018060006020818352015b60016001610160511614156104b8576000610180516020811061045957600080fd5b600160c052602060c02001546020826102200101526020810190506101405160208261022001015260208101905080610220526102209050602060c0825160208401600060025af16104aa57600080fd5b60c051905061014052610526565b6000610140516020826101a001015260208101905061018051602081106104de57600080fd5b600060c052602060c02001546020826101a0010152602081019050806101a0526101a09050602060c0825160208401600060025af161051c57600080fd5b60c0519050610140525b610160600261053457600080fd5b60028151048152505b8151600101808352811415610437575b50506101405160005260206000f3005b63621fd130600051141561063357341561057657600080fd5b60606101c060246380673289610140526002546101605261015c6000305af161059e57600080fd5b6101e0805160200180610260828460006004600a8704601201f16105c157600080fd5b50506102605160206001820306601f82010390506102c0610260516008818352015b826102c05111156105f35761060f565b60006102c05161028001535b81516001018083528114156105e3575b5050506020610240526040610260510160206001820306601f8201039050610240f3005b63c47e300d60005114156113e957606060046101403760506004356004016101a037603060043560040135111561066957600080fd5b604060243560040161022037602060243560040135111561068957600080fd5b60806044356004016102803760606044356004013511156106a957600080fd5b633b9aca0061034052610340516106bf57600080fd5b61034051340461032052633b9aca006103205110156106dd57600080fd5b6407735940006103205111156106f257600080fd5b6060610440602463806732896103c052610320516103e0526103dc6000305af161071b57600080fd5b610460805160200180610360828460006004600a8704601201f161073e57600080fd5b50506002546104a05260006104c05260026104e05261050060006020818352015b60006104e05161076e57600080fd5b6104e0516104a05160016104a05101101561078857600080fd5b60016104a051010614151561079c57610808565b6104c06060516001825101806040519013156107b757600080fd5b80919012156107c557600080fd5b8152506104e0805115156107da5760006107f4565b60028151600283510204146107ee57600080fd5b60028151025b8152505b815160010180835281141561075f575b505060006101a06030806020846105e001018260208501600060046016f15050805182019150506000601060208206610560016020828401111561084b57600080fd5b60208061058082610520600060046015f15050818152809050905090506010806020846105e001018260208501600060046013f1505080518201915050806105e0526105e09050602060c0825160208401600060025af16108ab57600080fd5b60c05190506105405260006000604060208206610680016102805182840111156108d457600080fd5b6060806106a0826020602088068803016102800160006004601bf1505081815280905090509050602060c0825160208401600060025af161091457600080fd5b60c0519050602082610880010152602081019050600060406020602082066107400161028051828401111561094857600080fd5b606080610760826020602088068803016102800160006004601bf150508181528090509050905060208060208461080001018260208501600060046015f15050805182019150506105205160208261080001015260208101905080610800526108009050602060c0825160208401600060025af16109c557600080fd5b60c051905060208261088001015260208101905080610880526108809050602060c0825160208401600060025af16109fc57600080fd5b60c051905061066052600060006105405160208261092001015260208101905061022060208060208461092001018260208501600060046015f150508051820191505080610920526109209050602060c0825160208401600060025af1610a6257600080fd5b60c0519050602082610aa00101526020810190506000610360600880602084610a2001018260208501600060046012f150508051820191505060006018602082066109a00160208284011115610ab757600080fd5b6020806109c082610520600060046015f1505081815280905090509050601880602084610a2001018260208501600060046014f150508051820191505061066051602082610a2001015260208101905080610a2052610a209050602060c0825160208401600060025af1610b2a57600080fd5b60c0519050602082610aa001015260208101905080610aa052610aa09050602060c0825160208401600060025af1610b6157600080fd5b60c051905061090052610b2060006020818352015b6104c051610b20511215610bf6576000610b205160208110610b9757600080fd5b600160c052602060c0200154602082610b4001015260208101905061090051602082610b4001015260208101905080610b4052610b409050602060c0825160208401600060025af1610be857600080fd5b60c051905061090052610bfb565b610c0c565b5b8151600101808352811415610b76575b5050610900516104c05160208110610c2357600080fd5b600160c052602060c02001556002805460018254011015610c4357600080fd5b60018154018155506020610c40600463c5f2892f610be052610bfc6000305af1610c6c57600080fd5b610c4051610bc0526060610ce060246380673289610c60526104a051610c8052610c7c6000305af1610c9d57600080fd5b610d00805160200180610d40828460006004600a8704601201f1610cc057600080fd5b505060a0610dc052610dc051610e00526101a0805160200180610dc051610e0001828460006004600a8704601201f1610cf857600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da081516040818352015b83610da051101515610d3657610d53565b6000610da0516020850101535b8151600101808352811415610d25575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc052610dc051610e2052610220805160200180610dc051610e0001828460006004600a8704601201f1610daa57600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da081516020818352015b83610da051101515610de857610e05565b6000610da0516020850101535b8151600101808352811415610dd7575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc052610dc051610e4052610360805160200180610dc051610e0001828460006004600a8704601201f1610e5c57600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da081516020818352015b83610da051101515610e9a57610eb7565b6000610da0516020850101535b8151600101808352811415610e89575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc052610dc051610e6052610280805160200180610dc051610e0001828460006004600a8704601201f1610f0e57600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da081516060818352015b83610da051101515610f4c57610f69565b6000610da0516020850101535b8151600101808352811415610f3b575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc052610dc051610e8052610d40805160200180610dc051610e0001828460006004600a8704601201f1610fc057600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da081516020818352015b83610da051101515610ffe5761101b565b6000610da0516020850101535b8151600101808352811415610fed575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc0527fdc5fc95703516abd38fa03c3737ff3b52dc52347055c8028460fdf5bbe2f12ce610dc051610e00a16407735940006103205114156113e757600380546001825401101561108f57600080fd5b60018154018155506201000060035414156113e65742610ec05242610ee052620151806110bb57600080fd5b62015180610ee05106610ec05110156110d357600080fd5b42610ee052620151806110e557600080fd5b62015180610ee05106610ec051036202a30042610ec05242610ee0526201518061110e57600080fd5b62015180610ee05106610ec051101561112657600080fd5b42610ee0526201518061113857600080fd5b62015180610ee05106610ec0510301101561115257600080fd5b6202a30042610ec05242610ee0526201518061116d57600080fd5b62015180610ee05106610ec051101561118557600080fd5b42610ee0526201518061119757600080fd5b62015180610ee05106610ec0510301610ea0526060610f8060246380673289610f0052600254610f2052610f1c6000305af16111d257600080fd5b610fa0805160200180610fe0828460006004600a8704601201f16111f557600080fd5b505060606110c06024638067328961104052610ea0516110605261105c6000305af161122057600080fd5b6110e0805160200180611120828460006004600a8704601201f161124357600080fd5b5050610bc0516111e05260606111a0526111a05161120052610fe08051602001806111a0516111e001828460006004600a8704601201f161128357600080fd5b50506111a0516111e0015160206001820306601f82010390506111a0516111e00161118081516020818352015b83611180511015156112c1576112de565b6000611180516020850101535b81516001018083528114156112b0575b5050505060206111a0516111e0015160206001820306601f82010390506111a05101016111a0526111a051611220526111208051602001806111a0516111e001828460006004600a8704601201f161133557600080fd5b50506111a0516111e0015160206001820306601f82010390506111a0516111e00161118081516020818352015b836111805110151561137357611390565b6000611180516020850101535b8151600101808352811415611362575b5050505060206111a0516111e0015160206001820306601f82010390506111a05101016111a0527f08b71ef3f1b58f7a23ffb82e27f12f0888c8403f1ceb0ea7ea26b274e2189d4c6111a0516111e0a160016004555b5b005b63845980e8600051141561140f57341561140257600080fd5b60045460005260206000f3005b60006000fd5b61020761161c0361020760003961020761161c036000f3"} \ No newline at end of file +{"abi": [{"name": "Deposit", "inputs": [{"type": "bytes", "name": "pubkey", "indexed": false}, {"type": "bytes", "name": "withdrawal_credentials", "indexed": false}, {"type": "bytes", "name": "amount", "indexed": false}, {"type": "bytes", "name": "signature", "indexed": false}, {"type": "bytes", "name": "merkle_tree_index", "indexed": false}], "anonymous": false, "type": "event"}, {"name": "Eth2Genesis", "inputs": [{"type": "bytes32", "name": "deposit_root", "indexed": false}, {"type": "bytes", "name": "deposit_count", "indexed": false}, {"type": "bytes", "name": "time", "indexed": false}], "anonymous": false, "type": "event"}, {"outputs": [], "inputs": [], "constant": false, "payable": false, "type": "constructor"}, {"name": "to_little_endian_64", "outputs": [{"type": "bytes", "name": "out"}], "inputs": [{"type": "uint256", "name": "value"}], "constant": true, "payable": false, "type": "function", "gas": 7077}, {"name": "from_little_endian_64", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "bytes", "name": "value"}], "constant": true, "payable": false, "type": "function", "gas": 5983}, {"name": "get_deposit_root", "outputs": [{"type": "bytes32", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 79251}, {"name": "get_deposit_count", "outputs": [{"type": "bytes", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 11056}, {"name": "deposit", "outputs": [], "inputs": [{"type": "bytes", "name": "pubkey"}, {"type": "bytes", "name": "withdrawal_credentials"}, {"type": "bytes", "name": "signature"}], "constant": false, "payable": true, "type": "function", "gas": 456517}, {"name": "chainStarted", "outputs": [{"type": "bool", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 633}], "bytecode": "0x600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052341561009e57600080fd5b6101406000601f818352015b600061014051602081106100bd57600080fd5b600060c052602060c020015460208261016001015260208101905061014051602081106100e957600080fd5b600060c052602060c020015460208261016001015260208101905080610160526101609050602060c0825160208401600060025af161012757600080fd5b60c0519050606051600161014051018060405190131561014657600080fd5b809190121561015457600080fd5b6020811061016157600080fd5b600060c052602060c0200155606051600161014051018060405190131561018757600080fd5b809190121561019557600080fd5b602081106101a257600080fd5b600060c052602060c020015460605160016101405101806040519013156101c857600080fd5b80919012156101d657600080fd5b602081106101e357600080fd5b600160c052602060c02001555b81516001018083528114156100aa575b505061160856600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526380673289600051141561026b57602060046101403734156100b457600080fd5b67ffffffffffffffff6101405111156100cc57600080fd5b60006101605261014051610180526101a060006008818352015b6101605160086000811215610103578060000360020a820461010a565b8060020a82025b905090506101605260ff61018051166101c052610160516101c0516101605101101561013557600080fd5b6101c051610160510161016052610180517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8600081121561017e578060000360020a8204610185565b8060020a82025b90509050610180525b81516001018083528114156100e6575b505060186008602082066101e001602082840111156101bc57600080fd5b60208061020082610160600060046015f15050818152809050905090508051602001806102a0828460006004600a8704601201f16101f957600080fd5b50506102a05160206001820306601f82010390506103006102a0516008818352015b8261030051111561022b57610247565b6000610300516102c001535b815160010180835281141561021b575b50505060206102805260406102a0510160206001820306601f8201039050610280f3005b639d70e8066000511415610405576020600461014037341561028c57600080fd5b60286004356004016101603760086004356004013511156102ac57600080fd5b60006101c0526101608060200151600082518060209013156102cd57600080fd5b80919012156102db57600080fd5b806020036101000a82049050905090506101e05261020060006008818352015b60ff6101e05116606051606051610200516007038060405190131561031f57600080fd5b809190121561032d57600080fd5b6008028060405190131561034057600080fd5b809190121561034e57600080fd5b6000811215610365578060000360020a820461036c565b8060020a82025b90509050610220526101c051610220516101c05101101561038c57600080fd5b610220516101c051016101c0526101e0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff860008112156103d5578060000360020a82046103dc565b8060020a82025b905090506101e0525b81516001018083528114156102fb575b50506101c05160005260206000f3005b63c5f2892f600051141561055d57341561041e57600080fd5b6000610140526002546101605261018060006020818352015b60016001610160511614156104b8576000610180516020811061045957600080fd5b600160c052602060c02001546020826102200101526020810190506101405160208261022001015260208101905080610220526102209050602060c0825160208401600060025af16104aa57600080fd5b60c051905061014052610526565b6000610140516020826101a001015260208101905061018051602081106104de57600080fd5b600060c052602060c02001546020826101a0010152602081019050806101a0526101a09050602060c0825160208401600060025af161051c57600080fd5b60c0519050610140525b610160600261053457600080fd5b60028151048152505b8151600101808352811415610437575b50506101405160005260206000f3005b63621fd130600051141561063357341561057657600080fd5b60606101c060246380673289610140526002546101605261015c6000305af161059e57600080fd5b6101e0805160200180610260828460006004600a8704601201f16105c157600080fd5b50506102605160206001820306601f82010390506102c0610260516008818352015b826102c05111156105f35761060f565b60006102c05161028001535b81516001018083528114156105e3575b5050506020610240526040610260510160206001820306601f8201039050610240f3005b63c47e300d60005114156113d557606060046101403760506004356004016101a037603060043560040135111561066957600080fd5b604060243560040161022037602060243560040135111561068957600080fd5b60806044356004016102803760606044356004013511156106a957600080fd5b633b9aca0061034052610340516106bf57600080fd5b61034051340461032052633b9aca006103205110156106dd57600080fd5b6060610440602463806732896103c052610320516103e0526103dc6000305af161070657600080fd5b610460805160200180610360828460006004600a8704601201f161072957600080fd5b50506002546104a05260006104c05260026104e05261050060006020818352015b60006104e05161075957600080fd5b6104e0516104a05160016104a05101101561077357600080fd5b60016104a0510106141515610787576107f3565b6104c06060516001825101806040519013156107a257600080fd5b80919012156107b057600080fd5b8152506104e0805115156107c55760006107df565b60028151600283510204146107d957600080fd5b60028151025b8152505b815160010180835281141561074a575b505060006101a06030806020846105e001018260208501600060046016f15050805182019150506000601060208206610560016020828401111561083657600080fd5b60208061058082610520600060046015f15050818152809050905090506010806020846105e001018260208501600060046013f1505080518201915050806105e0526105e09050602060c0825160208401600060025af161089657600080fd5b60c05190506105405260006000604060208206610680016102805182840111156108bf57600080fd5b6060806106a0826020602088068803016102800160006004601bf1505081815280905090509050602060c0825160208401600060025af16108ff57600080fd5b60c0519050602082610880010152602081019050600060406020602082066107400161028051828401111561093357600080fd5b606080610760826020602088068803016102800160006004601bf150508181528090509050905060208060208461080001018260208501600060046015f15050805182019150506105205160208261080001015260208101905080610800526108009050602060c0825160208401600060025af16109b057600080fd5b60c051905060208261088001015260208101905080610880526108809050602060c0825160208401600060025af16109e757600080fd5b60c051905061066052600060006105405160208261092001015260208101905061022060208060208461092001018260208501600060046015f150508051820191505080610920526109209050602060c0825160208401600060025af1610a4d57600080fd5b60c0519050602082610aa00101526020810190506000610360600880602084610a2001018260208501600060046012f150508051820191505060006018602082066109a00160208284011115610aa257600080fd5b6020806109c082610520600060046015f1505081815280905090509050601880602084610a2001018260208501600060046014f150508051820191505061066051602082610a2001015260208101905080610a2052610a209050602060c0825160208401600060025af1610b1557600080fd5b60c0519050602082610aa001015260208101905080610aa052610aa09050602060c0825160208401600060025af1610b4c57600080fd5b60c051905061090052610b2060006020818352015b6104c051610b20511215610be1576000610b205160208110610b8257600080fd5b600160c052602060c0200154602082610b4001015260208101905061090051602082610b4001015260208101905080610b4052610b409050602060c0825160208401600060025af1610bd357600080fd5b60c051905061090052610be6565b610bf7565b5b8151600101808352811415610b61575b5050610900516104c05160208110610c0e57600080fd5b600160c052602060c02001556002805460018254011015610c2e57600080fd5b60018154018155506020610c40600463c5f2892f610be052610bfc6000305af1610c5757600080fd5b610c4051610bc0526060610ce060246380673289610c60526104a051610c8052610c7c6000305af1610c8857600080fd5b610d00805160200180610d40828460006004600a8704601201f1610cab57600080fd5b505060a0610dc052610dc051610e00526101a0805160200180610dc051610e0001828460006004600a8704601201f1610ce357600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da081516040818352015b83610da051101515610d2157610d3e565b6000610da0516020850101535b8151600101808352811415610d10575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc052610dc051610e2052610220805160200180610dc051610e0001828460006004600a8704601201f1610d9557600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da081516020818352015b83610da051101515610dd357610df0565b6000610da0516020850101535b8151600101808352811415610dc2575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc052610dc051610e4052610360805160200180610dc051610e0001828460006004600a8704601201f1610e4757600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da081516020818352015b83610da051101515610e8557610ea2565b6000610da0516020850101535b8151600101808352811415610e74575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc052610dc051610e6052610280805160200180610dc051610e0001828460006004600a8704601201f1610ef957600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da081516060818352015b83610da051101515610f3757610f54565b6000610da0516020850101535b8151600101808352811415610f26575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc052610dc051610e8052610d40805160200180610dc051610e0001828460006004600a8704601201f1610fab57600080fd5b5050610dc051610e00015160206001820306601f8201039050610dc051610e0001610da081516020818352015b83610da051101515610fe957611006565b6000610da0516020850101535b8151600101808352811415610fd8575b505050506020610dc051610e00015160206001820306601f8201039050610dc0510101610dc0527fdc5fc95703516abd38fa03c3737ff3b52dc52347055c8028460fdf5bbe2f12ce610dc051610e00a1640773594000610320511015156113d357600380546001825401101561107b57600080fd5b60018154018155506201000060035414156113d25742610ec05242610ee052620151806110a757600080fd5b62015180610ee05106610ec05110156110bf57600080fd5b42610ee052620151806110d157600080fd5b62015180610ee05106610ec051036202a30042610ec05242610ee052620151806110fa57600080fd5b62015180610ee05106610ec051101561111257600080fd5b42610ee0526201518061112457600080fd5b62015180610ee05106610ec0510301101561113e57600080fd5b6202a30042610ec05242610ee0526201518061115957600080fd5b62015180610ee05106610ec051101561117157600080fd5b42610ee0526201518061118357600080fd5b62015180610ee05106610ec0510301610ea0526060610f8060246380673289610f0052600254610f2052610f1c6000305af16111be57600080fd5b610fa0805160200180610fe0828460006004600a8704601201f16111e157600080fd5b505060606110c06024638067328961104052610ea0516110605261105c6000305af161120c57600080fd5b6110e0805160200180611120828460006004600a8704601201f161122f57600080fd5b5050610bc0516111e05260606111a0526111a05161120052610fe08051602001806111a0516111e001828460006004600a8704601201f161126f57600080fd5b50506111a0516111e0015160206001820306601f82010390506111a0516111e00161118081516020818352015b83611180511015156112ad576112ca565b6000611180516020850101535b815160010180835281141561129c575b5050505060206111a0516111e0015160206001820306601f82010390506111a05101016111a0526111a051611220526111208051602001806111a0516111e001828460006004600a8704601201f161132157600080fd5b50506111a0516111e0015160206001820306601f82010390506111a0516111e00161118081516020818352015b836111805110151561135f5761137c565b6000611180516020850101535b815160010180835281141561134e575b5050505060206111a0516111e0015160206001820306601f82010390506111a05101016111a0527f08b71ef3f1b58f7a23ffb82e27f12f0888c8403f1ceb0ea7ea26b274e2189d4c6111a0516111e0a160016004555b5b005b63845980e860005114156113fb5734156113ee57600080fd5b60045460005260206000f3005b60006000fd5b61020761160803610207600039610207611608036000f3"} \ No newline at end of file diff --git a/deposit_contract/contracts/validator_registration.v.py b/deposit_contract/contracts/validator_registration.v.py index 20e4800..751d3a2 100644 --- a/deposit_contract/contracts/validator_registration.v.py +++ b/deposit_contract/contracts/validator_registration.v.py @@ -1,5 +1,5 @@ MIN_DEPOSIT_AMOUNT: constant(uint256) = 1000000000 # Gwei -MAX_DEPOSIT_AMOUNT: constant(uint256) = 32000000000 # Gwei +FULL_DEPOSIT_AMOUNT: constant(uint256) = 32000000000 # Gwei CHAIN_START_FULL_DEPOSIT_THRESHOLD: constant(uint256) = 65536 # 2**16 DEPOSIT_CONTRACT_TREE_DEPTH: constant(uint256) = 32 SECONDS_PER_DAY: constant(uint256) = 86400 @@ -80,7 +80,6 @@ def get_deposit_count() -> bytes[8]: def deposit(pubkey: bytes[48], withdrawal_credentials: bytes[32], signature: bytes[96]): deposit_amount: uint256 = msg.value / as_wei_value(1, "gwei") assert deposit_amount >= MIN_DEPOSIT_AMOUNT - assert deposit_amount <= MAX_DEPOSIT_AMOUNT amount: bytes[8] = self.to_little_endian_64(deposit_amount) index: uint256 = self.deposit_count @@ -125,7 +124,7 @@ def deposit(pubkey: bytes[48], withdrawal_credentials: bytes[32], signature: byt self.to_little_endian_64(index), ) - if deposit_amount == MAX_DEPOSIT_AMOUNT: + if deposit_amount >= FULL_DEPOSIT_AMOUNT: self.full_deposit_count += 1 if self.full_deposit_count == CHAIN_START_FULL_DEPOSIT_THRESHOLD: timestamp_day_boundary: uint256 = ( diff --git a/tests/contracts/conftest.py b/tests/contracts/conftest.py index fbe50da..634ab26 100644 --- a/tests/contracts/conftest.py +++ b/tests/contracts/conftest.py @@ -24,7 +24,8 @@ # Constants MIN_DEPOSIT_AMOUNT = 1000000000 # Gwei -MAX_DEPOSIT_AMOUNT = 32000000000 # Gwei +FULL_DEPOSIT_AMOUNT = 32000000000 # Gwei +CHAIN_START_FULL_DEPOSIT_THRESHOLD = 65536 # 2**16 DEPOSIT_CONTRACT_TREE_DEPTH = 32 TWO_TO_POWER_OF_TREE_DEPTH = 2**DEPOSIT_CONTRACT_TREE_DEPTH diff --git a/tests/contracts/test_deposit.py b/tests/contracts/test_deposit.py index 7b86208..3e90777 100644 --- a/tests/contracts/test_deposit.py +++ b/tests/contracts/test_deposit.py @@ -10,7 +10,7 @@ import eth_utils from tests.contracts.conftest import ( DEPOSIT_CONTRACT_TREE_DEPTH, - MAX_DEPOSIT_AMOUNT, + FULL_DEPOSIT_AMOUNT, MIN_DEPOSIT_AMOUNT, ) from tests.utils.minimal_ssz import ( @@ -38,7 +38,7 @@ def compute_merkle_root(leaf_nodes): assert len(leaf_nodes) >= 1 empty_node = b'\x00' * 32 child_nodes = leaf_nodes[:] - for i in range(DEPOSIT_CONTRACT_TREE_DEPTH): + for _ in range(DEPOSIT_CONTRACT_TREE_DEPTH): parent_nodes = [] if len(child_nodes) % 2 == 1: child_nodes.append(empty_node) @@ -95,10 +95,10 @@ def test_from_little_endian_64(registration_contract, assert_tx_failed): @pytest.mark.parametrize( 'success,deposit_amount', [ - (True, MAX_DEPOSIT_AMOUNT), + (True, FULL_DEPOSIT_AMOUNT), (True, MIN_DEPOSIT_AMOUNT), (False, MIN_DEPOSIT_AMOUNT - 1), - (False, MAX_DEPOSIT_AMOUNT + 1) + (True, FULL_DEPOSIT_AMOUNT + 1) ] ) def test_deposit_amount(registration_contract, @@ -121,7 +121,7 @@ def test_deposit_log(registration_contract, a0, w3, deposit_input): fromBlock='latest', ) - deposit_amount_list = [randint(MIN_DEPOSIT_AMOUNT, MAX_DEPOSIT_AMOUNT) for _ in range(3)] + deposit_amount_list = [randint(MIN_DEPOSIT_AMOUNT, FULL_DEPOSIT_AMOUNT * 2) for _ in range(3)] for i in range(3): registration_contract.functions.deposit( *deposit_input, @@ -143,7 +143,7 @@ def test_deposit_tree(registration_contract, w3, assert_tx_failed, deposit_input fromBlock='latest', ) - deposit_amount_list = [MAX_DEPOSIT_AMOUNT for _ in range(10)] + deposit_amount_list = [randint(MIN_DEPOSIT_AMOUNT, FULL_DEPOSIT_AMOUNT * 2) for _ in range(10)] leaf_nodes = [] for i in range(0, 10): tx_hash = registration_contract.functions.deposit( @@ -174,7 +174,7 @@ def test_chain_start(modified_registration_contract, w3, assert_tx_failed, depos t = getattr(modified_registration_contract, 'chain_start_full_deposit_threshold') # CHAIN_START_FULL_DEPOSIT_THRESHOLD is set to t min_deposit_amount = MIN_DEPOSIT_AMOUNT * eth_utils.denoms.gwei # in wei - max_deposit_amount = MAX_DEPOSIT_AMOUNT * eth_utils.denoms.gwei + max_deposit_amount = FULL_DEPOSIT_AMOUNT * eth_utils.denoms.gwei log_filter = modified_registration_contract.events.Eth2Genesis.createFilter( fromBlock='latest', ) @@ -182,7 +182,7 @@ def test_chain_start(modified_registration_contract, w3, assert_tx_failed, depos index_not_full_deposit = randint(0, t - 1) for i in range(t): if i == index_not_full_deposit: - # Deposit with value below MAX_DEPOSIT_AMOUNT + # Deposit with value below FULL_DEPOSIT_AMOUNT modified_registration_contract.functions.deposit( *deposit_input, ).transact({"value": min_deposit_amount}) @@ -190,7 +190,7 @@ def test_chain_start(modified_registration_contract, w3, assert_tx_failed, depos # Eth2Genesis event should not be triggered assert len(logs) == 0 else: - # Deposit with value MAX_DEPOSIT_AMOUNT + # Deposit with value FULL_DEPOSIT_AMOUNT modified_registration_contract.functions.deposit( *deposit_input, ).transact({"value": max_deposit_amount}) @@ -198,7 +198,7 @@ def test_chain_start(modified_registration_contract, w3, assert_tx_failed, depos # Eth2Genesis event should not be triggered assert len(logs) == 0 - # Make 1 more deposit with value MAX_DEPOSIT_AMOUNT to trigger Eth2Genesis event + # Make 1 more deposit with value FULL_DEPOSIT_AMOUNT to trigger Eth2Genesis event modified_registration_contract.functions.deposit( *deposit_input, ).transact({"value": max_deposit_amount}) @@ -211,7 +211,7 @@ def test_chain_start(modified_registration_contract, w3, assert_tx_failed, depos assert int.from_bytes(log['time'], byteorder='little') == timestamp_day_boundary assert modified_registration_contract.functions.chainStarted().call() is True - # Make 1 deposit with value MAX_DEPOSIT_AMOUNT and check that Eth2Genesis event is not triggered + # Make 1 deposit with value FULL_DEPOSIT_AMOUNT and check that Eth2Genesis event is not triggered modified_registration_contract.functions.deposit( *deposit_input, ).transact({"value": max_deposit_amount}) From 7d3b6e222a78379c2976521e45a4943b6c970bd5 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Fri, 19 Apr 2019 19:39:07 +0800 Subject: [PATCH 2/3] Rename variable `max_deposit_amount` to `full_deposit_amount` --- tests/contracts/test_deposit.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/contracts/test_deposit.py b/tests/contracts/test_deposit.py index 3e90777..ff409c0 100644 --- a/tests/contracts/test_deposit.py +++ b/tests/contracts/test_deposit.py @@ -174,7 +174,7 @@ def test_chain_start(modified_registration_contract, w3, assert_tx_failed, depos t = getattr(modified_registration_contract, 'chain_start_full_deposit_threshold') # CHAIN_START_FULL_DEPOSIT_THRESHOLD is set to t min_deposit_amount = MIN_DEPOSIT_AMOUNT * eth_utils.denoms.gwei # in wei - max_deposit_amount = FULL_DEPOSIT_AMOUNT * eth_utils.denoms.gwei + full_deposit_amount = FULL_DEPOSIT_AMOUNT * eth_utils.denoms.gwei log_filter = modified_registration_contract.events.Eth2Genesis.createFilter( fromBlock='latest', ) @@ -193,7 +193,7 @@ def test_chain_start(modified_registration_contract, w3, assert_tx_failed, depos # Deposit with value FULL_DEPOSIT_AMOUNT modified_registration_contract.functions.deposit( *deposit_input, - ).transact({"value": max_deposit_amount}) + ).transact({"value": full_deposit_amount}) logs = log_filter.get_new_entries() # Eth2Genesis event should not be triggered assert len(logs) == 0 @@ -201,7 +201,7 @@ def test_chain_start(modified_registration_contract, w3, assert_tx_failed, depos # Make 1 more deposit with value FULL_DEPOSIT_AMOUNT to trigger Eth2Genesis event modified_registration_contract.functions.deposit( *deposit_input, - ).transact({"value": max_deposit_amount}) + ).transact({"value": full_deposit_amount}) logs = log_filter.get_new_entries() assert len(logs) == 1 timestamp = int(w3.eth.getBlock(w3.eth.blockNumber)['timestamp']) @@ -214,6 +214,6 @@ def test_chain_start(modified_registration_contract, w3, assert_tx_failed, depos # Make 1 deposit with value FULL_DEPOSIT_AMOUNT and check that Eth2Genesis event is not triggered modified_registration_contract.functions.deposit( *deposit_input, - ).transact({"value": max_deposit_amount}) + ).transact({"value": full_deposit_amount}) logs = log_filter.get_new_entries() assert len(logs) == 0 From bf1c43b20cb09537b25e144ee927bc9c60785519 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Tue, 23 Apr 2019 12:27:31 +0800 Subject: [PATCH 3/3] Update test_deposit.py --- tests/contracts/test_deposit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/contracts/test_deposit.py b/tests/contracts/test_deposit.py index ff409c0..fb33ed3 100644 --- a/tests/contracts/test_deposit.py +++ b/tests/contracts/test_deposit.py @@ -211,7 +211,8 @@ def test_chain_start(modified_registration_contract, w3, assert_tx_failed, depos assert int.from_bytes(log['time'], byteorder='little') == timestamp_day_boundary assert modified_registration_contract.functions.chainStarted().call() is True - # Make 1 deposit with value FULL_DEPOSIT_AMOUNT and check that Eth2Genesis event is not triggered + # Make 1 deposit with value FULL_DEPOSIT_AMOUNT and + # check that Eth2Genesis event is not triggered modified_registration_contract.functions.deposit( *deposit_input, ).transact({"value": full_deposit_amount})