{
    "Function": "deposit",
    "File": "src/DepositContract.sol",
    "Parent Contracts": [
        "src/DepositContract.sol",
        "src/DepositContract.sol"
    ],
    "High-Level Calls": [],
    "Internal Calls": [
        "require(bool,string)",
        "sha256(bytes)",
        "require(bool,string)",
        "sha256(bytes)",
        "sha256(bytes)",
        "assert(bool)",
        "sha256(bytes)",
        "to_little_endian_64",
        "require(bool,string)",
        "abi.encodePacked()",
        "abi.encodePacked()",
        "require(bool,string)",
        "abi.encodePacked()",
        "require(bool,string)",
        "sha256(bytes)",
        "sha256(bytes)",
        "abi.encodePacked()",
        "sha256(bytes)",
        "abi.encodePacked()",
        "require(bool,string)",
        "to_little_endian_64",
        "sha256(bytes)",
        "abi.encodePacked()",
        "require(bool,string)",
        "require(bool,string)",
        "abi.encodePacked()",
        "abi.encodePacked()"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function deposit(\n        bytes calldata pubkey,\n        bytes calldata withdrawal_credentials,\n        bytes calldata signature,\n        bytes32 deposit_data_root\n    ) override external payable {\n        // Extended ABI length checks since dynamic types are used.\n        require(pubkey.length == 48, \"DepositContract: invalid pubkey length\");\n        require(withdrawal_credentials.length == 32, \"DepositContract: invalid withdrawal_credentials length\");\n        require(signature.length == 96, \"DepositContract: invalid signature length\");\n\n        // Check deposit amount\n        require(msg.value >= 1 ether, \"DepositContract: deposit value too low\");\n        require(msg.value % 1 gwei == 0, \"DepositContract: deposit value not multiple of gwei\");\n        uint deposit_amount = msg.value / 1 gwei;\n        require(deposit_amount <= type(uint64).max, \"DepositContract: deposit value too high\");\n\n        // Emit `DepositEvent` log\n        bytes memory amount = to_little_endian_64(uint64(deposit_amount));\n        emit DepositEvent(\n            pubkey,\n            withdrawal_credentials,\n            amount,\n            signature,\n            to_little_endian_64(uint64(deposit_count))\n        );\n\n        // Compute deposit data root (`DepositData` hash tree root)\n        bytes32 pubkey_root = sha256(abi.encodePacked(pubkey, bytes16(0)));\n        bytes32 signature_root = sha256(abi.encodePacked(\n            sha256(abi.encodePacked(signature[:64])),\n            sha256(abi.encodePacked(signature[64:], bytes32(0)))\n        ));\n        bytes32 node = sha256(abi.encodePacked(\n            sha256(abi.encodePacked(pubkey_root, withdrawal_credentials)),\n            sha256(abi.encodePacked(amount, bytes24(0), signature_root))\n        ));\n\n        // Verify computed and expected deposit data roots match\n        require(node == deposit_data_root, \"DepositContract: reconstructed DepositData does not match supplied deposit_data_root\");\n\n        // Avoid overflowing the Merkle tree (and prevent edge case in computing `branch`)\n        require(deposit_count < MAX_DEPOSIT_COUNT, \"DepositContract: merkle tree full\");\n\n        // Add deposit data root to Merkle tree (update a single `branch` node)\n        deposit_count += 1;\n        uint size = deposit_count;\n        for (uint height = 0; height < DEPOSIT_CONTRACT_TREE_DEPTH; height++) {\n            if ((size & 1) == 1) {\n                branch[height] = node;\n                return;\n            }\n            node = sha256(abi.encodePacked(branch[height], node));\n            size /= 2;\n        }\n        // As the loop should always end prematurely with the `return` statement,\n        // this code should be unreachable. We assert `false` just to be safe.\n        assert(false);\n    }"
}