-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat[contracts]: add sequencer fee wallet (#1029)
* wip: first draft of the fee wallet * add fee wallet to dump * rename to sequencer vault * add L1 fee wallet to geth config * add unit tests * fix geth linting error * add a basic integration test * fix broken integration test * add test for correct storage slot * add integration test for fee withdrawal * fix typo in integration tests * fix a bug bin integration tests * Update OVM_SequencerFeeVault.sol * fix bug in contract tests * chore: add changeset * fix bug in contract tests
- Loading branch information
1 parent
baacda3
commit e045f58
Showing
18 changed files
with
279 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@eth-optimism/integration-tests': patch | ||
'@eth-optimism/l2geth': patch | ||
'@eth-optimism/contracts': patch | ||
--- | ||
|
||
Adds new SequencerFeeVault contract to store generated fees |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_SequencerFeeVault.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >0.5.0 <0.8.0; | ||
|
||
/* Library Imports */ | ||
import { Lib_PredeployAddresses } from "../../libraries/constants/Lib_PredeployAddresses.sol"; | ||
|
||
/* Contract Imports */ | ||
import { OVM_ETH } from "../predeploys/OVM_ETH.sol"; | ||
|
||
/** | ||
* @title OVM_SequencerFeeVault | ||
* @dev Simple holding contract for fees paid to the Sequencer. Likely to be replaced in the future | ||
* but "good enough for now". | ||
* | ||
* Compiler used: optimistic-solc | ||
* Runtime target: OVM | ||
*/ | ||
contract OVM_SequencerFeeVault { | ||
|
||
/************* | ||
* Constants * | ||
*************/ | ||
|
||
// Minimum ETH balance that can be withdrawn in a single withdrawal. | ||
uint256 public constant MIN_WITHDRAWAL_AMOUNT = 15 ether; | ||
|
||
|
||
/************* | ||
* Variables * | ||
*************/ | ||
|
||
// Address on L1 that will hold the fees once withdrawn. Dynamically initialized within l2geth. | ||
address public l1FeeWallet; | ||
|
||
|
||
/*************** | ||
* Constructor * | ||
***************/ | ||
|
||
/** | ||
* @param _l1FeeWallet Initial address for the L1 wallet that will hold fees once withdrawn. | ||
* Currently HAS NO EFFECT in production because l2geth will mutate this storage slot during | ||
* the genesis block. This is ONLY for testing purposes. | ||
*/ | ||
constructor( | ||
address _l1FeeWallet | ||
) { | ||
l1FeeWallet = _l1FeeWallet; | ||
} | ||
|
||
|
||
/******************** | ||
* Public Functions * | ||
********************/ | ||
|
||
function withdraw() | ||
public | ||
{ | ||
uint256 balance = OVM_ETH(Lib_PredeployAddresses.OVM_ETH).balanceOf(address(this)); | ||
|
||
require( | ||
balance >= MIN_WITHDRAWAL_AMOUNT, | ||
"OVM_SequencerFeeVault: withdrawal amount must be greater than minimum withdrawal amount" | ||
); | ||
|
||
OVM_ETH(Lib_PredeployAddresses.OVM_ETH).withdrawTo( | ||
l1FeeWallet, | ||
balance, | ||
0, | ||
bytes("") | ||
); | ||
} | ||
} |
Oops, something went wrong.