eth-clients / holesky

the holesovice post-merge testnet configuration.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom deposit contract for infinite supply

pk910 opened this issue · comments

commented

Heya,

I'd like to propose a small modification to the pre-deployed deposit contract, that will give a pre-defined wallet address the ability to drain the funds from the contract.

This will allow increasing the network supply by depositing/withdrawing funds (& draining them from the contract), just in case we ever run into such supply issues again.
Due to the restriction to a pre-defined wallet address, this drain functionality cannot be abused by the open public.

Sepolia is using a custom deposit contract that allows the same type of supply inflation (besides restricting the validator set), so I guess a non-standard deposit contract is a acceptable testnet-only difference.

Drainable DepositContract Code: https://pastebin.com/YNWkEWvJ
Modification to the original deposit contract:

    // pre-defined wallet that is allowed to drain - stored in slot 0x41
    address drainer_address;

    // public drain() function that can be used by drainer_address to drain the contract
    function drain(uint256 amount) public {
        require(msg.sender == drainer_address, "draining not allowed");
 
        if(amount == 0) {
            amount = address(this).balance;
        }
 
        (bool sent, ) = payable(msg.sender).call{value: amount}("");
        require(sent, "failed to send ether");
    }

Compiled with the same compiler options as used for the original deposit contract, that leads to the following genesis sideload:

    "0x000000006465706F73697420636f6E7472616374":{
      "balance":"0x0",
      "code": "0x60806040526004361061005a5760003560e01c8063621fd13011610043578063621fd130146101d5578063c5f2892f1461025f578063f6b19c74146102865761005a565b806301ffc9a71461005f57806322895118146100bf575b600080fd5b34801561006b57600080fd5b506100ab6004803603602081101561008257600080fd5b50357fffffffff00000000000000000000000000000000000000000000000000000000166102b0565b604080519115158252519081900360200190f35b6101d3600480360360808110156100d557600080fd5b8101906020810181356401000000008111156100f057600080fd5b82018360208201111561010257600080fd5b8035906020019184600183028401116401000000008311171561012457600080fd5b91939092909160208101903564010000000081111561014257600080fd5b82018360208201111561015457600080fd5b8035906020019184600183028401116401000000008311171561017657600080fd5b91939092909160208101903564010000000081111561019457600080fd5b8201836020820111156101a657600080fd5b803590602001918460018302840111640100000000831117156101c857600080fd5b919350915035610349565b005b3480156101e157600080fd5b506101ea6110fa565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561022457818101518382015260200161020c565b50505050905090810190601f1680156102515780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561026b57600080fd5b5061027461110c565b60408051918252519081900360200190f35b34801561029257600080fd5b506101d3600480360360208110156102a957600080fd5b50356114ff565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a700000000000000000000000000000000000000000000000000000000148061034357507fffffffff0000000000000000000000000000000000000000000000000000000082167f8564090700000000000000000000000000000000000000000000000000000000145b92915050565b603086146103a2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806119936026913960400191505060405180910390fd5b602084146103fb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061192a6036913960400191505060405180910390fd5b60608214610454576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526029815260200180611a066029913960400191505060405180910390fd5b670de0b6b3a76400003410156104b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806119e06026913960400191505060405180910390fd5b633b9aca00340615610512576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806119606033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff81111561057a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260278152602001806119b96027913960400191505060405180910390fd5b606061058582611648565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105ba602054611648565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910187810386528c815260200190508c8c808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690920188810386528c5181528c51602091820193918e019250908190849084905b8381101561068d578181015183820152602001610675565b50505050905090810190601f1680156106ba5780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018881038452895181528951602091820193918b019250908190849084905b8381101561073457818101518382015260200161071c565b50505050905090810190601f1680156107615780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284377fffffffffffffffffffffffffffffffff0000000000000000000000000000000090941691909301908152604080517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0818403018152601090920190819052815191955093508392506020850191508083835b6020831061084157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610804565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561089e573d6000803e3d6000fd5b5050506040513d60208110156108b357600080fd5b5051905060006002806108c96040848a8c61188c565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b6020831061093d57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610900565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561099a573d6000803e3d6000fd5b5050506040513d60208110156109af57600080fd5b505160026109c0896040818d61188c565b60405160009060200180848480828437919091019283525050604080518083038152602092830191829052805190945090925082918401908083835b60208310610a3957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016109fc565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610a96573d6000803e3d6000fd5b5050506040513d6020811015610aab57600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610b1f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610ae2565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610b7c573d6000803e3d6000fd5b5050506040513d6020811015610b9157600080fd5b50516040805160208101858152929350600092600292839287928f928f92018383808284378083019250505093505050506040516020818303038152906040526040518082805190602001908083835b60208310610c1e57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610be1565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610c7b573d6000803e3d6000fd5b5050506040513d6020811015610c9057600080fd5b50516040518651600291889160009188916020918201918291908601908083835b60208310610cee57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610cb1565b6001836020036101000a0380198251168184511680821785525050505050509050018367ffffffffffffffff191667ffffffffffffffff1916815260180182815260200193505050506040516020818303038152906040526040518082805190602001908083835b60208310610d9357805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610d56565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610df0573d6000803e3d6000fd5b5050506040513d6020811015610e0557600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610e7957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610e3c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610ed6573d6000803e3d6000fd5b5050506040513d6020811015610eeb57600080fd5b50519050858114610f47576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260548152602001806118d66054913960600191505060405180910390fd5b60205463ffffffff11610fa5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806118b56021913960400191505060405180910390fd5b602080546001019081905560005b60208110156110ee578160011660011415610fe5578260008260208110610fd657fe5b0155506110f195505050505050565b600260008260208110610ff457fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061106a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161102d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156110c7573d6000803e3d6000fd5b5050506040513d60208110156110dc57600080fd5b50519250600282049150600101610fb3565b50fe5b50505050505050565b6060611107602054611648565b905090565b6020546000908190815b602081101561133557816001166001141561122b5760026000826020811061113a57fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b602083106111b057805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611173565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561120d573d6000803e3d6000fd5b5050506040513d602081101561122257600080fd5b50519250611327565b6002836021836020811061123b57fe5b015460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b602083106112b057805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611273565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561130d573d6000803e3d6000fd5b5050506040513d602081101561132257600080fd5b505192505b600282049150600101611116565b50600282611344602054611648565b600060401b6040516020018084815260200183805190602001908083835b6020831061139f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611362565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790527fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000095909516920191825250604080518083037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8018152601890920190819052815191955093508392850191508083835b6020831061148457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611447565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156114e1573d6000803e3d6000fd5b5050506040513d60208110156114f657600080fd5b50519250505090565b60415473ffffffffffffffffffffffffffffffffffffffff16331461158557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f647261696e696e67206e6f7420616c6c6f776564000000000000000000000000604482015290519081900360640190fd5b8061158d5750475b604051600090339083908381818185875af1925050503d80600081146115cf576040519150601f19603f3d011682016040523d82523d6000602084013e6115d4565b606091505b505090508061164457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f6661696c656420746f2073656e64206574686572000000000000000000000000604482015290519081900360640190fd5b5050565b60408051600880825281830190925260609160208201818036833701905050905060c082901b8060071a60f81b8260008151811061168257fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060061a60f81b826001815181106116c557fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060051a60f81b8260028151811061170857fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060041a60f81b8260038151811061174b57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060031a60f81b8260048151811061178e57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060021a60f81b826005815181106117d157fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060011a60f81b8260068151811061181457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060001a60f81b8260078151811061185757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050919050565b6000808585111561189b578182fd5b838611156118a7578182fd5b505082019391909203915056fe4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c6c4465706f736974436f6e74726163743a207265636f6e7374727563746564204465706f7369744461746120646f6573206e6f74206d6174636820737570706c696564206465706f7369745f646174615f726f6f744465706f736974436f6e74726163743a20696e76616c6964207769746864726177616c5f63726564656e7469616c73206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c7565206e6f74206d756c7469706c65206f6620677765694465706f736974436f6e74726163743a20696e76616c6964207075626b6579206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f20686967684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f206c6f774465706f736974436f6e74726163743a20696e76616c6964207369676e6174757265206c656e677468a264697066735822122056175284a873d0561211ed7a56a24d3bb024f11feb2146a23294033bb5ffcc6b64736f6c63430006080033",
      "storage": {
        "0x0000000000000000000000000000000000000000000000000000000000000022": "0xf5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b",
        "0x0000000000000000000000000000000000000000000000000000000000000023": "0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71",
        "0x0000000000000000000000000000000000000000000000000000000000000024": "0xc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c",
        "0x0000000000000000000000000000000000000000000000000000000000000025": "0x536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123c",
        "0x0000000000000000000000000000000000000000000000000000000000000026": "0x9efde052aa15429fae05bad4d0b1d7c64da64d03d7a1854a588c2cb8430c0d30",
        "0x0000000000000000000000000000000000000000000000000000000000000027": "0xd88ddfeed400a8755596b21942c1497e114c302e6118290f91e6772976041fa1",
        "0x0000000000000000000000000000000000000000000000000000000000000028": "0x87eb0ddba57e35f6d286673802a4af5975e22506c7cf4c64bb6be5ee11527f2c",
        "0x0000000000000000000000000000000000000000000000000000000000000029": "0x26846476fd5fc54a5d43385167c95144f2643f533cc85bb9d16b782f8d7db193",
        "0x000000000000000000000000000000000000000000000000000000000000002a": "0x506d86582d252405b840018792cad2bf1259f1ef5aa5f887e13cb2f0094f51e1",
        "0x000000000000000000000000000000000000000000000000000000000000002b": "0xffff0ad7e659772f9534c195c815efc4014ef1e1daed4404c06385d11192e92b",
        "0x000000000000000000000000000000000000000000000000000000000000002c": "0x6cf04127db05441cd833107a52be852868890e4317e6a02ab47683aa75964220",
        "0x000000000000000000000000000000000000000000000000000000000000002d": "0xb7d05f875f140027ef5118a2247bbb84ce8f2f0f1123623085daf7960c329f5f",
        "0x000000000000000000000000000000000000000000000000000000000000002e": "0xdf6af5f5bbdb6be9ef8aa618e4bf8073960867171e29676f8b284dea6a08a85e",
        "0x000000000000000000000000000000000000000000000000000000000000002f": "0xb58d900f5e182e3c50ef74969ea16c7726c549757cc23523c369587da7293784",
        "0x0000000000000000000000000000000000000000000000000000000000000030": "0xd49a7502ffcfb0340b1d7885688500ca308161a7f96b62df9d083b71fcc8f2bb",
        "0x0000000000000000000000000000000000000000000000000000000000000031": "0x8fe6b1689256c0d385f42f5bbe2027a22c1996e110ba97c171d3e5948de92beb",
        "0x0000000000000000000000000000000000000000000000000000000000000032": "0x8d0d63c39ebade8509e0ae3c9c3876fb5fa112be18f905ecacfecb92057603ab",
        "0x0000000000000000000000000000000000000000000000000000000000000033": "0x95eec8b2e541cad4e91de38385f2e046619f54496c2382cb6cacd5b98c26f5a4",
        "0x0000000000000000000000000000000000000000000000000000000000000034": "0xf893e908917775b62bff23294dbbe3a1cd8e6cc1c35b4801887b646a6f81f17f",
        "0x0000000000000000000000000000000000000000000000000000000000000035": "0xcddba7b592e3133393c16194fac7431abf2f5485ed711db282183c819e08ebaa",
        "0x0000000000000000000000000000000000000000000000000000000000000036": "0x8a8d7fe3af8caa085a7639a832001457dfb9128a8061142ad0335629ff23ff9c",
        "0x0000000000000000000000000000000000000000000000000000000000000037": "0xfeb3c337d7a51a6fbf00b9e34c52e1c9195c969bd4e7a0bfd51d5c5bed9c1167",
        "0x0000000000000000000000000000000000000000000000000000000000000038": "0xe71f0aa83cc32edfbefa9f4d3e0174ca85182eec9f3a09f6a6c0df6377a510d7",
        "0x0000000000000000000000000000000000000000000000000000000000000039": "0x31206fa80a50bb6abe29085058f16212212a60eec8f049fecb92d8c8e0a84bc0",
        "0x000000000000000000000000000000000000000000000000000000000000003a": "0x21352bfecbeddde993839f614c3dac0a3ee37543f9b412b16199dc158e23b544",
        "0x000000000000000000000000000000000000000000000000000000000000003b": "0x619e312724bb6d7c3153ed9de791d764a366b389af13c58bf8a8d90481a46765",
        "0x000000000000000000000000000000000000000000000000000000000000003c": "0x7cdd2986268250628d0c10e385c58c6191e6fbe05191bcc04f133f2cea72c1c4",
        "0x000000000000000000000000000000000000000000000000000000000000003d": "0x848930bd7ba8cac54661072113fb278869e07bb8587f91392933374d017bcbe1",
        "0x000000000000000000000000000000000000000000000000000000000000003e": "0x8869ff2c22b28cc10510d9853292803328be4fb0e80495e8bb8d271f5b889636",
        "0x000000000000000000000000000000000000000000000000000000000000003f": "0xb5fe28e79f1b850f8658246ce9b6a1e7b49fc06db7143e8fe0b4f2b0c5523a5c",
        "0x0000000000000000000000000000000000000000000000000000000000000040": "0x985e929f70af28d0bdd1a90a808f977f597c7c778c489e98d3bd8910d31ac0f7",
        "0x0000000000000000000000000000000000000000000000000000000000000041": "0x000000000000000000000000CaA29806044A08E533963b2e573C1230A2cd9a2d"
      }
    }

The pre-defined wallet address can be configured via storage slot 0x41.
0xCaA29806044A08E533963b2e573C1230A2cd9a2d (q9f's wallet) is allowed to drain in the example above.

Open for discussion :)

commented

This has been discussed in the Launch Call (ethereum/pm#803)
Closing this, as the general consensus was more for keeping the deposit contract untouched :)