• Mark Tyneway's avatar
    contracts-bedrock: deprecate `finalizeDeposit` (#10459) · 251af5e4
    Mark Tyneway authored
    The [finalizeDeposit](https://github.com/ethereum-optimism/optimism/blob/b9eb669aa5dfc36204ce2167da2e5ab8bbde61de/packages/contracts-bedrock/src/L2/L2StandardBridge.sol#L147)
    function is left over from the legacy OVM style standard bridge.
    It is impossible to be called as the bridge has moved to the modern interface which is based on `finalizeBridgeETH` or `finalizeBridgeERC20`.
    
    Methods actually used in bridge:
    
    - [finalizeBridgeETH](https://github.com/ethereum-optimism/optimism/blob/b9eb669aa5dfc36204ce2167da2e5ab8bbde61de/packages/contracts-bedrock/src/universal/StandardBridge.sol#L333)
    - [finalizeBridgeERC20](https://github.com/ethereum-optimism/optimism/blob/b9eb669aa5dfc36204ce2167da2e5ab8bbde61de/packages/contracts-bedrock/src/universal/StandardBridge.sol#L379)
    
    Proof that finalizeDeposit is not used anywhere. Its defined in the L2StandardBridge and otherwise only in tests.
    
    ```
    git grep -rin finalizeDeposit
    snapshots/abi/L2StandardBridge.json:272:    "name": "finalizeDeposit",
    src/L2/L2StandardBridge.sol:147:    function finalizeDeposit(
    test/L2/L2StandardBridge.t.sol:523:    /// @dev Tests that `finalizeDeposit` succeeds. It should:
    test/L2/L2StandardBridge.t.sol:527:    function test_finalizeDeposit_depositingERC20_succeeds() external {
    test/L2/L2StandardBridge.t.sol:544:        l2StandardBridge.finalizeDeposit(address(L1Token), address(L2Token), alice, alice, 100, hex"");
    test/L2/L2StandardBridge.t.sol:547:    /// @dev Tests that `finalizeDeposit` succeeds when depositing ERC20 with custom gas token.
    test/L2/L2StandardBridge.t.sol:548:    function test_finalizeDeposit_depositingERC20_customGasToken_reverts() external {
    test/L2/L2StandardBridge.t.sol:559:        l2StandardBridge.finalizeDeposit(address(L1Token), address(L2Token), alice, alice, 100, hex"");
    test/L2/L2StandardBridge.t.sol:562:    /// @dev Tests that `finalizeDeposit` succeeds when depositing ETH.
    test/L2/L2StandardBridge.t.sol:563:    function test_finalizeDeposit_depositingETH_succeeds() external {
    test/L2/L2StandardBridge.t.sol:579:        l2StandardBridge.finalizeDeposit{ value: 100 }(
    test/L2/L2StandardBridge.t.sol:584:    /// @dev Tests that `finalizeDeposit` reverts when depositing ETH with custom gas token.
    test/L2/L2StandardBridge.t.sol:585:    function test_finalizeDeposit_depositingETH_customGasToken_reverts() external {
    test/L2/L2StandardBridge.t.sol:594:        l2StandardBridge.finalizeDeposit(address(0), Predeploys.LEGACY_ERC20_ETH, alice, alice, 100, hex"");
    test/L2/L2StandardBridge.t.sol:597:    /// @dev Tests that `finalizeDeposit` reverts if the amounts do not match.
    test/L2/L2StandardBridge.t.sol:610:    /// @dev Tests that `finalizeDeposit` reverts if the receipient is the other bridge.
    test/L2/L2StandardBridge.t.sol:623:    /// @dev Tests that `finalizeDeposit` reverts if the receipient is the messenger.
    ```
    
    There cannot be third party integrations since it is `onlyBridge`,
    meaning only the `L1StandardBridge` can call it.
    
    This commit removes the tests and the function from the
    `L2StandardBridge`. This is part of refactoring as we go,
    ensuring that the code stays clean. Tend the garden.
    251af5e4
L2StandardBridge.sol 9.67 KB