From 6f74ca9f81cc9e26886b64cb1ef1c951b22ebb95 Mon Sep 17 00:00:00 2001
From: smartcontracts <kelvin@optimism.io>
Date: Mon, 11 Jul 2022 14:35:04 -0400
Subject: [PATCH] style(ctb): clean up PredeployAddresses (#2967)

Cleans up the PredeployAddresses contract. I went ahead and clearly
marked and separated the legacy addresses and the non-legacy addresses.
I also renamed the L2StandardTokenFactory address to correspond to the
new name (OptimismMintableERC20Factory) and deleted several predeploy
addresses which no longer exist in the state of L2.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
---
 .changeset/shaggy-radios-unite.md             |  5 ++
 .../libraries/PredeployAddresses.sol          | 60 ++++++++++++++++---
 .../contracts/test/CommonTest.t.sol           |  6 +-
 3 files changed, 61 insertions(+), 10 deletions(-)
 create mode 100644 .changeset/shaggy-radios-unite.md

diff --git a/.changeset/shaggy-radios-unite.md b/.changeset/shaggy-radios-unite.md
new file mode 100644
index 000000000..9f3e13f26
--- /dev/null
+++ b/.changeset/shaggy-radios-unite.md
@@ -0,0 +1,5 @@
+---
+'@eth-optimism/contracts-bedrock': patch
+---
+
+Clean up the PredeployAddresses library
diff --git a/packages/contracts-bedrock/contracts/libraries/PredeployAddresses.sol b/packages/contracts-bedrock/contracts/libraries/PredeployAddresses.sol
index 88a08917e..8fe039330 100644
--- a/packages/contracts-bedrock/contracts/libraries/PredeployAddresses.sol
+++ b/packages/contracts-bedrock/contracts/libraries/PredeployAddresses.sol
@@ -3,20 +3,66 @@ pragma solidity ^0.8.9;
 
 /**
  * @title PredeployAddresses
+ * @notice Contains constant addresses for contracts that are pre-deployed to the L2 system.
  */
 library PredeployAddresses {
+    /**
+     * @notice Address of the L2ToL1MessagePasser predeploy.
+     */
     address internal constant L2_TO_L1_MESSAGE_PASSER = 0x4200000000000000000000000000000000000000;
-    address internal constant L1_MESSAGE_SENDER = 0x4200000000000000000000000000000000000001;
-    address internal constant DEPLOYER_WHITELIST = 0x4200000000000000000000000000000000000002;
-    address internal constant LEGACY_ERC20_ETH = 0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000;
+
+    /**
+     * @notice Address of the L2CrossDomainMessenger predeploy.
+     */
     address internal constant L2_CROSS_DOMAIN_MESSENGER =
         0x4200000000000000000000000000000000000007;
-    address internal constant ADDRESS_MANAGER = 0x4200000000000000000000000000000000000008;
-    address internal constant PROXY_EOA = 0x4200000000000000000000000000000000000009;
+
+    /**
+     * @notice Address of the L2StandardBridge predeploy.
+     */
     address internal constant L2_STANDARD_BRIDGE = 0x4200000000000000000000000000000000000010;
+
+    /**
+     * @notice Address of the SequencerFeeWallet predeploy.
+     */
     address internal constant SEQUENCER_FEE_WALLET = 0x4200000000000000000000000000000000000011;
-    address internal constant L2_STANDARD_TOKEN_FACTORY =
+
+    /**
+     * @notice Address of the OptimismMintableERC20Factory predeploy.
+     */
+    address internal constant OPTIMISM_MINTABLE_ERC20_FACTORY =
         0x4200000000000000000000000000000000000012;
-    address internal constant L1_BLOCK_NUMBER = 0x4200000000000000000000000000000000000013;
+
+    /**
+     * @notice Address of the L1Block predeploy.
+     */
     address internal constant L1_BLOCK_ATTRIBUTES = 0x4200000000000000000000000000000000000015;
+
+    /**
+     * @custom:legacy
+     * @notice Address of the L1MessageSender predeploy. Deprecated. Use L2CrossDomainMessenger
+     *         or access tx.origin (or msg.sender) in a L1 to L2 transaction instead.
+     */
+    address internal constant L1_MESSAGE_SENDER = 0x4200000000000000000000000000000000000001;
+
+    /**
+     * @custom:legacy
+     * @notice Address of the DeployerWhitelist predeploy. No longer active.
+     */
+    address internal constant DEPLOYER_WHITELIST = 0x4200000000000000000000000000000000000002;
+
+    /**
+     * @custom:legacy
+     * @notice Address of the LegacyERC20ETH predeploy. Deprecated. Balances are migrated to the
+     *         state trie as of the Bedrock upgrade. Contract has been locked and write functions
+     *         can no longer be accessed.
+     */
+    address internal constant LEGACY_ERC20_ETH = 0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000;
+
+    /**
+     * @custom:legacy
+     * @notice Address of the L1BlockNumber predeploy. Deprecated. Use the L1Block predeploy
+     *         instead, which exposes more information about the L1 state.
+     */
+    address internal constant L1_BLOCK_NUMBER = 0x4200000000000000000000000000000000000013;
 }
diff --git a/packages/contracts-bedrock/contracts/test/CommonTest.t.sol b/packages/contracts-bedrock/contracts/test/CommonTest.t.sol
index 91a045a60..c4b611aa1 100644
--- a/packages/contracts-bedrock/contracts/test/CommonTest.t.sol
+++ b/packages/contracts-bedrock/contracts/test/CommonTest.t.sol
@@ -334,7 +334,7 @@ contract Bridge_Initializer is Messenger_Initializer {
         super.setUp();
 
         vm.label(PredeployAddresses.L2_STANDARD_BRIDGE, "L2StandardBridge");
-        vm.label(PredeployAddresses.L2_STANDARD_TOKEN_FACTORY, "L2StandardTokenFactory");
+        vm.label(PredeployAddresses.OPTIMISM_MINTABLE_ERC20_FACTORY, "OptimismMintableERC20Factory");
 
         // Deploy the L1 bridge and initialize it with the address of the
         // L1CrossDomainMessenger
@@ -367,9 +367,9 @@ contract Bridge_Initializer is Messenger_Initializer {
         OptimismMintableERC20Factory factory = new OptimismMintableERC20Factory(
             PredeployAddresses.L2_STANDARD_BRIDGE
         );
-        vm.etch(PredeployAddresses.L2_STANDARD_TOKEN_FACTORY, address(factory).code);
+        vm.etch(PredeployAddresses.OPTIMISM_MINTABLE_ERC20_FACTORY, address(factory).code);
         L2TokenFactory = OptimismMintableERC20Factory(
-            PredeployAddresses.L2_STANDARD_TOKEN_FACTORY
+            PredeployAddresses.OPTIMISM_MINTABLE_ERC20_FACTORY
         );
 
         vm.etch(PredeployAddresses.LEGACY_ERC20_ETH, address(new LegacyERC20ETH()).code);
-- 
2.23.0