• Mark Tyneway's avatar
    contracts-bedrock: fix custom gas token withdrawals to L1 (#10685) · c04ca0c4
    Mark Tyneway authored
    * contracts-bedrock: fix custom gas token withdrawals to L1
    
    The previous implementation of the `FeeVault` used the `StandardBridge`
    to withdraw `ether`. Under custom gas token, this meant that withdrawals
    to L1 didn't work and withdrawals to L2 were the only supported path.
    This updates the `L2ToL1Messenger` to withdraw to L1 via the `L2ToL1Messenger`.
    This fixes the ability to withdraw to L1 while custom gas token is
    enabled while also saving some gas on both L1 and L2 by removing
    extra call frames. The reason why this was originally implemented using
    the `StandardBridge` was to reduce additional changes during the
    development of bedrock so that more effort could be spent thinking
    about the new protocol design, as the legacy implementation used
    the `StandardBridge` for doing the withdrawal.
    
    Having the `StandardBridge` used for `ether` deposits and withdrawals
    is unncessarily expensive and a bit of a leaky abstraction.
    
    Gas savings are scalability improvements, both on L1 and on L2.
    
    Also uses a new variant of `SafeCall` that passes through all gas
    in its `transfer`. The implementation ensures to assert on the return
    value of the call to hold the invariant true that the `totalProcessed`
    will always be consistent. If the call reverts, then its possible for
    the `ether` to not be transferred and `totalProcessed` to be incremented.
    
    Also bump the semver of the contracts to a beta version. They will
    be bumped out of beta at a release of the contracts.
    
    The tests are also improved for both the `SafeCall` library as well
    as the `FeeVault`.
    
    * op-e2e: withdrawal tests
    
    * e2e: update test with comments
    
    * feevault: fix tech debt
    
    Updates the `FeeVault` to use modern style guide.
    Its not great to leak `immutable` style into the ABI
    so add extra getters and mark the legacy getters as
    deprecated. Doing this now will help to migrate to the
    new getters in 1 year from now.
    
    Also add in the storage layout spacer that was previously
    noticed in an audit, see https://github.com/ethereum-optimism/optimism/pull/9477.
    
    * semver-lock: update + compiler warning
    
    * snapshots: regenerate
    
    * lint: fix
    
    * tests: fixup
    
    * gas-snapshot: update
    
    * test: fix
    
    * contracts-bedrock: reuse existing implementation of send in SafeCall
    Co-authored-by: default avatarMatt Solomon <matt@mattsolomon.dev>
    
    * contracts-bedrock: update gap in FeeVault for inheritance to start at 50 gap
    
    * contracts-bedrock: add missing assertions in tests for SequencerFeeVault
    
    * contracts-bedrock: remove redundant if clause in SafeCall tests
    
    * contracts-bedrock: fix gas relation in SafeCall tests
    
    * contracts-bedrock: update send method tests for SafeCall
    
    * op-e2e: add missing check in custom gas token tests
    
    * contracts-bedrock: fix types in SafeCall tests
    
    * contracts-bedrock: update snapshots
    
    * contracts-bedrock: update semver-lock
    
    * op-e2e: fix custom_gas_token test
    
    * op-e2e: fix custom gas token test
    
    * contracts-bedrock: fix tests for custom gas token
    
    * op-e2e: fix tests for custom gas token
    
    * op-e2e: fix build
    
    ---------
    Co-authored-by: default avatarDiego <105765223+0xfuturistic@users.noreply.github.com>
    Co-authored-by: default avatarMatt Solomon <matt@mattsolomon.dev>
    c04ca0c4
custom_gas_token_test.go 23.4 KB