Skip to content

Latest commit

 

History

History
153 lines (116 loc) · 5.56 KB

v2.2_upgrade.md

File metadata and controls

153 lines (116 loc) · 5.56 KB

V2.2 Upgrade

Prerequisites

  1. Deployer Key ("Deployer Key")
  2. Proxy Admin Key ("Admin Key")
  3. A list of currently blacklisted accounts stored in blacklist.remote.json

Preparation

  1. Get the contract creation block number for the target FiatTokenProxy contract either using a block explorer, or the command below.

    $ yarn hardhat getContractCreationBlock --network ${NETWORK} ${FiatTokenProxy address}
  2. Get a list of accounts that are currently blacklisted on the target FiatTokenProxy contract by running the following command. startBlockNumber should be set to the contract creation block number of the target FiatTokenProxy contract.

    $ yarn hardhat downloadBlacklistedAccounts --network ${NETWORK} \
          --proxy-address ${FiatTokenProxy address} \
          --start-block-number ${startBlockNumber}

Steps

  1. From project root folder, make a copy of .env.example and name the file .env. Ensure .env is configured with the correct values. The environment variables PROXY_ADMIN_ADDRESS, FIAT_TOKEN_PROXY_ADDRESS must be defined.

  2. Set the NETWORK variable to the network that you will like to deploy to in your terminal.

    $ NETWORK=<mainnet|testnet>;
  3. Look for the deploy-impl-and-upgrader.s.sol script in ./scripts/deploy/. Ensure the the following variables are correctly configured in your local .env file:

    $ DEPLOYER_PRIVATE_KEY=<DEPLOYER_PRIVATE_KEY>
    $ FIAT_TOKEN_PROXY_ADDRESS=<FIAT_TOKEN_PROXY_ADDRESS>
    $ PROXY_ADMIN_ADDRESS=<PROXY_ADMIN_ADDRESS>
    $ LOST_AND_FOUND_ADDRESS=<LOST_AND_FOUND_ADDRESS>
    $ TOKEN_SYMBOL=<TOKEN_SYMBOL>
    
    # [Optional] Fill in if an implementation contract already exists
    $ FIAT_TOKEN_IMPLEMENTATION_ADDRESS=<FIAT_TOKEN_IMPLEMENTATION_ADDRESS>
  4. Ensure that the blacklist.remote.json file in the project root folder is configured with the correct list of addresses to blacklist.

  5. Run foundry deploy simulation by running the following command

    yarn forge:simulate scripts/deploy/deploy-impl-and-upgrader.s.sol --rpc-url $NETWORK

    Validate all fields are filled in correctly.

    NOTE: For additional information, you may also validate each of the transactions to be broadcasted by checking the ./broadcast/deploy-impl-and-upgrader.s.sol/:chainId/dry-run folder that gets auto created in your local machine.

  6. Deploy the contracts by running the following command

    yarn forge:broadcast scripts/deploy/deploy-impl-and-upgrader.s.sol --rpc-url $NETWORK
  7. Verify the contracts on an Etherscan flavored block explorer by running the following command. Ensure that ETHERSCAN_KEY is set in the .env file.

    yarn forge:verify scripts/deploy/deploy-impl-and-upgrader.s.sol --rpc-url $NETWORK
  8. Verify that the upgrader contract is deployed correctly. Verify that the values returned by proxy(), implementation() and newProxyAdmin() on the V2_2Upgrader contract are correct either using a block explorer, or the command below.

    $ yarn compile
    $ yarn hardhat readValuesFromContract --network ${NETWORK} \
          --contract-name V2_2Upgrader \
          --contract-address ${V2_2Upgrader address} \
          proxy implementation newProxyAdmin
  9. Verify that the V2_2UpgraderHelper contract is deployed correctly. Retrieve the address from the V2_2Upgrader contract helper() method, and verify that the return values of each view methods correspond with the FiatTokenProxy contract to be upgraded either using a block explorer, or the command below.

    $ yarn compile
    $ yarn hardhat readValuesFromContract --network ${NETWORK} \
          --contract-name V2_2Upgrader \
          --contract-address ${V2_2Upgrader address} \
          helper
    $ yarn hardhat readValuesFromContract --network ${NETWORK} \
          --contract-name V2_2UpgraderHelper \
          --contract-address ${V2_2UpgraderHelper address} \
          name symbol decimals currency masterMinter fiatTokenOwner pauser blacklister version DOMAIN_SEPARATOR rescuer paused totalSupply
    
    # Compare results above with
    $ yarn hardhat readValuesFromContract --network ${NETWORK} \
          --contract-name FiatTokenV2_1 \
          --contract-address ${FiatTokenProxy address} \
          name symbol decimals currency masterMinter fiatTokenOwner pauser blacklister version DOMAIN_SEPARATOR rescuer paused totalSupply
  10. Verify that the list of accounts to blacklist is correct, and is set correctly in the upgrader contract. Run the following command to check the list.

    $ yarn hardhat validateAccountsToBlacklist --network=${NETWORK} \
          --proxy-address ${FiatTokenProxy address} \
          --upgrader-address ${V2_2Upgrader address}
  11. Using the Admin Key, transfer the proxy admin role to the V2_2Upgrader contract address by calling changeAdmin(address) method on the FiatTokenProxy contract.

  12. Send 0.20 FiatToken (eg USDC) to the V2_2Upgrader contract address. (200,000 tokens)

  13. Using the Deployer Key, call upgrade() (0xd55ec697) method on the V2_2Upgrader.

IF THE UPGRADE TRANSACTION SUCCEEDS

  • Verify that the proxy admin role is transferred back to the Admin Key.
  • No further action needed.

IF THE UPGRADE TRANSACTION FAILS

  • If the transaction fails, any state change that happened during the upgrade function call will be reverted.
  • Call abortUpgrade() (0xd8f6a8f6) method on the V2_2Upgrader contract to tear it down.