Skip to content

Latest commit

 

History

History
181 lines (143 loc) · 7.12 KB

v2.2_upgrade.md

File metadata and controls

181 lines (143 loc) · 7.12 KB

V2.2 Upgrade

Prerequisites

  1. Truffle 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 truffle exec scripts/getContractCreationBlock.js ${FiatTokenProxy address} --network ${NETWORK}
  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 truffle exec scripts/getBlacklistedAccounts.js ${FiatTokenProxy address} ${startBlockNumber} --network ${NETWORK}

Steps

  1. Ensure that the config.js file in the project root folder is configured with the correct values. The environment variables PROXY_ADMIN_ADDRESS, PROXY_CONTRACT_ADDRESS must be defined.

  2. Set the NETWORK variable to the network that you will like to deploy to in your terminal. Ensure that the NETWORK that the contracts are to be deployed to are defined in ./truffle-config.js.

    $ NETWORK=<mainnet|ropsten>;
  3. Look for the deploy_v2_2 and deploy_v2_2_upgrader scripts in ./migrations/. Set the MIGRATION_START and MIGRATION_END variables based off the migration numbers of these scripts.

    $ MIGRATION_START=<first_migration_number>
    $ MIGRATION_END=<last_migration_number>
  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 Truffle migrations using the Deployer Key, and get the address of the newly deployed V2_2Upgrader contract.

    $ yarn migrate --network ${NETWORK} --f ${MIGRATION_START} --to ${MIGRATION_END}
    ...
    ...
    Dry-run successful. Do you want to proceed with real deployment?  >> (y/n): y
    ...
    ...
    >>>>>>> Deployed V2_2Upgrader at 0x12345678 <<<<<<<
  6. 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 truffle exec scripts/callContractROFunctions.js --network ${NETWORK} \
       --contract-name V2_2Upgrader --contract-address ${V2_2Upgrader address} \
       proxy implementation newProxyAdmin
  7. 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 truffle exec scripts/callContractROFunctions.js --network ${NETWORK} \
       --contract-name V2_2Upgrader --contract-address ${V2_2Upgrader address} \
       helper
    $ yarn truffle exec scripts/callContractROFunctions.js --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 truffle exec scripts/callContractROFunctions.js --network ${NETWORK} \
       --contract-name FiatTokenV2_1 --contract-address ${FiatTokenProxy address} \
       name symbol decimals currency masterMinter fiatTokenOwner pauser blacklister version DOMAIN_SEPARATOR rescuer paused totalSupply
  8. 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 truffle exec scripts/validateAccountsToBlacklist.js ${FiatTokenProxy address} ${V2_2Upgrader address} --network=${NETWORK}
  9. Using the Admin Key, transfer the proxy admin role to the V2_2Upgrader contract address by calling changeAdmin(address) method on the FiatTokenProxy contract.

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

  11. 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.

Optional - Testing support for ERC-1271 compatible wallets

FiatToken version 2.2 supports signature validation on the ERC-2612 and ERC-3009 features for ERC-1271 compatible wallets. You may test this with a sample ERC-1271 wallet to the network.

Preparation

  1. Prepare a FiatToken version 2.2 contract for testing. If a FiatToken contract has never been deployed to the network, follow the steps in the deployment doc to deploy the contract to the network. Otherwise, follow the steps above to upgrade your FiatToken contract to version 2.2.
  2. Prepare an address A (Wallet Owner Address) that you own the private key to. This address does not require any chain-native token (e.g. ETH) for gas usage.
  3. Prepare an address B (Relayer Address) that you own the private key to. Add some chain-native token (e.g. ETH) to this address to pay for gas.

Instructions

  1. Look for the deploy_erc1271_wallet scripts in ./migrations/. Set the MIGRATION_START and MIGRATION_END variables based off the migration numbers of these scripts.

    $ MIGRATION_START=<first_migration_number>
    $ MIGRATION_END=<last_migration_number>
  2. Set the MOCK_ERC1271_WALLET_OWNER_ADDRESS in your config.js file to address A.

  3. Run Truffle migrations using the Deployer Key, and get the address of the newly deployed MockERC1271Wallet contract.

    $ yarn migrate --network ${NETWORK} --f ${MIGRATION_START} --to ${MIGRATION_END}
    ...
    ...
    Dry-run successful. Do you want to proceed with real deployment?  >> (y/n): y
    ...
    ...
    >>>>>>> Deployed MockERC1271Wallet at 0x12345678 <<<<<<<
  4. Generate a permit transaction signature using address A. This transaction signature would update the allowance of a designated spender to pull funds from the deployed smart contract wallet (MockERC1271Wallet).

  5. Broadcast the signed transaction using address B. You may rely on public tools (example for ETH mainnet) to complete this step.

  6. The transaction should succeed and the allowance should also be updated. You may validate these using a block explorer.