diff --git a/deposit_contract/contracts/validator_registration.json b/deposit_contract/contracts/validator_registration.json index 9da4a015c..676bf470a 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}], "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": 6973}, {"name": "get_deposit_root", "outputs": [{"type": "bytes32", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 79221}, {"name": "get_deposit_count", "outputs": [{"type": "bytes", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 10922}, {"name": "deposit", "outputs": [], "inputs": [{"type": "bytes", "name": "pubkey"}, {"type": "bytes", "name": "withdrawal_credentials"}, {"type": "bytes", "name": "signature"}], "constant": false, "payable": true, "type": "function", "gas": 1318334}], "bytecode": "0x600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052341561009e57600080fd5b6101406000601f818352015b600061014051602081106100bd57600080fd5b600260c052602060c020015460208261016001015260208101905061014051602081106100e957600080fd5b600260c052602060c020015460208261016001015260208101905080610160526101609050602060c0825160208401600060025af161012757600080fd5b60c0519050606051600161014051018060405190131561014657600080fd5b809190121561015457600080fd5b6020811061016157600080fd5b600260c052602060c02001555b81516001018083528114156100aa575b5050610e9956600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526380673289600051141561025357602060046101403734156100b457600080fd5b60006101605261014051610180526101a060006008818352015b61016051600860008112156100eb578060000360020a82046100f2565b8060020a82025b905090506101605260ff61018051166101c052610160516101c0516101605101101561011d57600080fd5b6101c051610160510161016052610180517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff86000811215610166578060000360020a820461016d565b8060020a82025b90509050610180525b81516001018083528114156100ce575b505060186008602082066101e001602082840111156101a457600080fd5b60208061020082610160600060046015f15050818152809050905090508051602001806102a0828460006004600a8704601201f16101e157600080fd5b50506102a05160206001820306601f82010390506103006102a0516008818352015b826103005111156102135761022f565b6000610300516102c001535b8151600101808352811415610203575b50505060206102805260406102a0510160206001820306601f8201039050610280f3005b63c5f2892f60005114156103ab57341561026c57600080fd5b6000610140526001546101605261018060006020818352015b600160016101605116141561030657600061018051602081106102a757600080fd5b600060c052602060c02001546020826102200101526020810190506101405160208261022001015260208101905080610220526102209050602060c0825160208401600060025af16102f857600080fd5b60c051905061014052610374565b6000610140516020826101a0010152602081019050610180516020811061032c57600080fd5b600260c052602060c02001546020826101a0010152602081019050806101a0526101a09050602060c0825160208401600060025af161036a57600080fd5b60c0519050610140525b610160600261038257600080fd5b60028151048152505b8151600101808352811415610285575b50506101405160005260206000f3005b63621fd13060005114156104815734156103c457600080fd5b60606101c060246380673289610140526001546101605261015c6000305af16103ec57600080fd5b6101e0805160200180610260828460006004600a8704601201f161040f57600080fd5b50506102605160206001820306601f82010390506102c0610260516008818352015b826102c05111156104415761045d565b60006102c05161028001535b8151600101808352811415610431575b5050506020610240526040610260510160206001820306601f8201039050610240f3005b63c47e300d6000511415610d0e57606060046101403760506004356004016101a03760306004356004013511156104b757600080fd5b60406024356004016102203760206024356004013511156104d757600080fd5b60806044356004016102803760606044356004013511156104f757600080fd5b63ffffffff6001541061050957600080fd5b633b9aca00610340526103405161051f57600080fd5b61034051340461032052633b9aca0061032051101561053d57600080fd5b60306101a0511461054d57600080fd5b6020610220511461055d57600080fd5b6060610280511461056d57600080fd5b6060610440602463806732896103c052610320516103e0526103dc6000305af161059657600080fd5b610460805160200180610360828460006004600a8704601201f16105b957600080fd5b505060806104c0526104c051610500526101a08051602001806104c05161050001828460006004600a8704601201f16105f157600080fd5b50506104c051610500015160206001820306601f82010390506104c051610500016104a081516040818352015b836104a05110151561062f5761064c565b60006104a0516020850101535b815160010180835281141561061e575b5050505060206104c051610500015160206001820306601f82010390506104c05101016104c0526104c051610520526102208051602001806104c05161050001828460006004600a8704601201f16106a357600080fd5b50506104c051610500015160206001820306601f82010390506104c051610500016104a081516020818352015b836104a0511015156106e1576106fe565b60006104a0516020850101535b81516001018083528114156106d0575b5050505060206104c051610500015160206001820306601f82010390506104c05101016104c0526104c051610540526103608051602001806104c05161050001828460006004600a8704601201f161075557600080fd5b50506104c051610500015160206001820306601f82010390506104c051610500016104a081516020818352015b836104a051101515610793576107b0565b60006104a0516020850101535b8151600101808352811415610782575b5050505060206104c051610500015160206001820306601f82010390506104c05101016104c0526104c051610560526102808051602001806104c05161050001828460006004600a8704601201f161080757600080fd5b50506104c051610500015160206001820306601f82010390506104c051610500016104a081516060818352015b836104a05110151561084557610862565b60006104a0516020850101535b8151600101808352811415610834575b5050505060206104c051610500015160206001820306601f82010390506104c05101016104c0527f9d0a206c338cfcaf9198c04fe61b39a988e26b623ef97cb2f72bafcfbf8bb93e6104c051610500a160006101a060308060208461064001018260208501600060046016f150508051820191505060006010602082066105c001602082840111156108f357600080fd5b6020806105e082610580600060046015f150508181528090509050905060108060208461064001018260208501600060046013f150508051820191505080610640526106409050602060c0825160208401600060025af161095357600080fd5b60c05190506105a052600060006040602082066106e00161028051828401111561097c57600080fd5b606080610700826020602088068803016102800160006004601bf1505081815280905090509050602060c0825160208401600060025af16109bc57600080fd5b60c05190506020826108e0010152602081019050600060406020602082066107a0016102805182840111156109f057600080fd5b6060806107c0826020602088068803016102800160006004601bf150508181528090509050905060208060208461086001018260208501600060046015f15050805182019150506105805160208261086001015260208101905080610860526108609050602060c0825160208401600060025af1610a6d57600080fd5b60c05190506020826108e0010152602081019050806108e0526108e09050602060c0825160208401600060025af1610aa457600080fd5b60c05190506106c052600060006105a05160208261098001015260208101905061022060208060208461098001018260208501600060046015f150508051820191505080610980526109809050602060c0825160208401600060025af1610b0a57600080fd5b60c0519050602082610b000101526020810190506000610360600880602084610a8001018260208501600060046012f15050805182019150506000601860208206610a000160208284011115610b5f57600080fd5b602080610a2082610580600060046015f1505081815280905090509050601880602084610a8001018260208501600060046014f15050805182019150506106c051602082610a8001015260208101905080610a8052610a809050602060c0825160208401600060025af1610bd257600080fd5b60c0519050602082610b0001015260208101905080610b0052610b009050602060c0825160208401600060025af1610c0957600080fd5b60c0519050610960526001805460018254011015610c2657600080fd5b6001815401815550600154610b8052610ba060006020818352015b60016001610b8051161415610c765761096051610ba05160208110610c6557600080fd5b600060c052602060c0200155610d0a565b6000610ba05160208110610c8957600080fd5b600060c052602060c0200154602082610bc001015260208101905061096051602082610bc001015260208101905080610bc052610bc09050602060c0825160208401600060025af1610cda57600080fd5b60c051905061096052610b806002610cf157600080fd5b60028151048152505b8151600101808352811415610c41575b5050005b60006000fd5b610185610e9903610185600039610185610e99036000f3"} \ 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}], "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": 6973}, {"name": "get_deposit_root", "outputs": [{"type": "bytes32", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 79221}, {"name": "get_deposit_count", "outputs": [{"type": "bytes", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 10922}, {"name": "deposit", "outputs": [], "inputs": [{"type": "bytes", "name": "pubkey"}, {"type": "bytes", "name": "withdrawal_credentials"}, {"type": "bytes", "name": "signature"}], "constant": false, "payable": true, "type": "function", "gas": 1318334}], "bytecode": "0x600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052341561009e57600080fd5b6101406000601f818352015b600061014051602081106100bd57600080fd5b600260c052602060c020015460208261016001015260208101905061014051602081106100e957600080fd5b600260c052602060c020015460208261016001015260208101905080610160526101609050602060c0825160208401600060025af161012757600080fd5b60c0519050606051600161014051018060405190131561014657600080fd5b809190121561015457600080fd5b6020811061016157600080fd5b600260c052602060c02001555b81516001018083528114156100aa575b5050610e9956600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526380673289600051141561025357602060046101403734156100b457600080fd5b60006101605261014051610180526101a060006008818352015b61016051600860008112156100eb578060000360020a82046100f2565b8060020a82025b905090506101605260ff61018051166101c052610160516101c0516101605101101561011d57600080fd5b6101c051610160510161016052610180517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff86000811215610166578060000360020a820461016d565b8060020a82025b90509050610180525b81516001018083528114156100ce575b505060186008602082066101e001602082840111156101a457600080fd5b60208061020082610160600060046015f15050818152809050905090508051602001806102a0828460006004600a8704601201f16101e157600080fd5b50506102a05160206001820306601f82010390506103006102a0516008818352015b826103005111156102135761022f565b6000610300516102c001535b8151600101808352811415610203575b50505060206102805260406102a0510160206001820306601f8201039050610280f3005b63c5f2892f60005114156103ab57341561026c57600080fd5b6000610140526001546101605261018060006020818352015b600160016101605116141561030657600061018051602081106102a757600080fd5b600060c052602060c02001546020826102200101526020810190506101405160208261022001015260208101905080610220526102209050602060c0825160208401600060025af16102f857600080fd5b60c051905061014052610374565b6000610140516020826101a0010152602081019050610180516020811061032c57600080fd5b600260c052602060c02001546020826101a0010152602081019050806101a0526101a09050602060c0825160208401600060025af161036a57600080fd5b60c0519050610140525b610160600261038257600080fd5b60028151048152505b8151600101808352811415610285575b50506101405160005260206000f3005b63621fd13060005114156104815734156103c457600080fd5b60606101c060246380673289610140526001546101605261015c6000305af16103ec57600080fd5b6101e0805160200180610260828460006004600a8704601201f161040f57600080fd5b50506102605160206001820306601f82010390506102c0610260516008818352015b826102c05111156104415761045d565b60006102c05161028001535b8151600101808352811415610431575b5050506020610240526040610260510160206001820306601f8201039050610240f3005b63c47e300d6000511415610d0e57606060046101403760506004356004016101a03760306004356004013511156104b757600080fd5b60406024356004016102203760206024356004013511156104d757600080fd5b60806044356004016102803760606044356004013511156104f757600080fd5b63ffffffff6001541061050957600080fd5b633b9aca00610340526103405161051f57600080fd5b61034051340461032052633b9aca0061032051101561053d57600080fd5b60306101a0511461054d57600080fd5b6020610220511461055d57600080fd5b6060610280511461056d57600080fd5b6060610440602463806732896103c052610320516103e0526103dc6000305af161059657600080fd5b610460805160200180610360828460006004600a8704601201f16105b957600080fd5b505060006101a060308060208461056001018260208501600060046016f150508051820191505060006010602082066104e001602082840111156105fc57600080fd5b602080610500826104a0600060046015f150508181528090509050905060108060208461056001018260208501600060046013f150508051820191505080610560526105609050602060c0825160208401600060025af161065c57600080fd5b60c05190506104c052600060006040602082066106000161028051828401111561068557600080fd5b606080610620826020602088068803016102800160006004601bf1505081815280905090509050602060c0825160208401600060025af16106c557600080fd5b60c0519050602082610800010152602081019050600060406020602082066106c0016102805182840111156106f957600080fd5b6060806106e0826020602088068803016102800160006004601bf150508181528090509050905060208060208461078001018260208501600060046015f15050805182019150506104a05160208261078001015260208101905080610780526107809050602060c0825160208401600060025af161077657600080fd5b60c051905060208261080001015260208101905080610800526108009050602060c0825160208401600060025af16107ad57600080fd5b60c05190506105e052600060006104c0516020826108a00101526020810190506102206020806020846108a001018260208501600060046015f1505080518201915050806108a0526108a09050602060c0825160208401600060025af161081357600080fd5b60c0519050602082610a2001015260208101905060006103606008806020846109a001018260208501600060046012f15050805182019150506000601860208206610920016020828401111561086857600080fd5b602080610940826104a0600060046015f15050818152809050905090506018806020846109a001018260208501600060046014f15050805182019150506105e0516020826109a0010152602081019050806109a0526109a09050602060c0825160208401600060025af16108db57600080fd5b60c0519050602082610a2001015260208101905080610a2052610a209050602060c0825160208401600060025af161091257600080fd5b60c051905061088052600180546001825401101561092f57600080fd5b6001815401815550600154610aa052610ac060006020818352015b60016001610aa05116141561097f5761088051610ac0516020811061096e57600080fd5b600060c052602060c0200155610a13565b6000610ac0516020811061099257600080fd5b600060c052602060c0200154602082610ae001015260208101905061088051602082610ae001015260208101905080610ae052610ae09050602060c0825160208401600060025af16109e357600080fd5b60c051905061088052610aa060026109fa57600080fd5b60028151048152505b815160010180835281141561094a575b50506080610b8052610b8051610bc0526101a0805160200180610b8051610bc001828460006004600a8704601201f1610a4b57600080fd5b5050610b8051610bc0015160206001820306601f8201039050610b8051610bc001610b6081516040818352015b83610b6051101515610a8957610aa6565b6000610b60516020850101535b8151600101808352811415610a78575b505050506020610b8051610bc0015160206001820306601f8201039050610b80510101610b8052610b8051610be052610220805160200180610b8051610bc001828460006004600a8704601201f1610afd57600080fd5b5050610b8051610bc0015160206001820306601f8201039050610b8051610bc001610b6081516020818352015b83610b6051101515610b3b57610b58565b6000610b60516020850101535b8151600101808352811415610b2a575b505050506020610b8051610bc0015160206001820306601f8201039050610b80510101610b8052610b8051610c0052610360805160200180610b8051610bc001828460006004600a8704601201f1610baf57600080fd5b5050610b8051610bc0015160206001820306601f8201039050610b8051610bc001610b6081516020818352015b83610b6051101515610bed57610c0a565b6000610b60516020850101535b8151600101808352811415610bdc575b505050506020610b8051610bc0015160206001820306601f8201039050610b80510101610b8052610b8051610c2052610280805160200180610b8051610bc001828460006004600a8704601201f1610c6157600080fd5b5050610b8051610bc0015160206001820306601f8201039050610b8051610bc001610b6081516060818352015b83610b6051101515610c9f57610cbc565b6000610b60516020850101535b8151600101808352811415610c8e575b505050506020610b8051610bc0015160206001820306601f8201039050610b80510101610b80527f9d0a206c338cfcaf9198c04fe61b39a988e26b623ef97cb2f72bafcfbf8bb93e610b8051610bc0a1005b60006000fd5b610185610e9903610185600039610185610e99036000f3"} \ 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 6c4bd7dc7..b99a30784 100644 --- a/deposit_contract/contracts/validator_registration.v.py +++ b/deposit_contract/contracts/validator_registration.v.py @@ -72,11 +72,8 @@ def deposit(pubkey: bytes[PUBKEY_LENGTH], assert len(withdrawal_credentials) == WITHDRAWAL_CREDENTIALS_LENGTH assert len(signature) == SIGNATURE_LENGTH - # Emit `Deposit` log - amount: bytes[8] = self.to_little_endian_64(deposit_amount) - log.Deposit(pubkey, withdrawal_credentials, amount, signature) - # Compute `DepositData` root + amount: bytes[8] = self.to_little_endian_64(deposit_amount) zero_bytes32: bytes32 pubkey_root: bytes32 = sha256(concat(pubkey, slice(zero_bytes32, start=0, len=64 - PUBKEY_LENGTH))) signature_root: bytes32 = sha256(concat( @@ -97,3 +94,6 @@ def deposit(pubkey: bytes[PUBKEY_LENGTH], break node = sha256(concat(self.branch[height], node)) size /= 2 + + # Emit `Deposit` log + log.Deposit(pubkey, withdrawal_credentials, amount, signature) diff --git a/deposit_contract/tests/contracts/test_deposit.py b/deposit_contract/tests/contracts/test_deposit.py index c1c07aac9..12f3e7f8b 100644 --- a/deposit_contract/tests/contracts/test_deposit.py +++ b/deposit_contract/tests/contracts/test_deposit.py @@ -56,7 +56,7 @@ def deposit_input(): (10, True), (55555, True), (2**64 - 1, True), - (2**64, True), # Note that all calls to `to_little_endian_64` have an input less than 2**64 + # (2**64, True), # Note that all calls to `to_little_endian_64` have an input less than 2**64 ] ) def test_to_little_endian_64(registration_contract, value, success, assert_tx_failed):