Skip to content

Commit

Permalink
update fee vault script
Browse files Browse the repository at this point in the history
  • Loading branch information
cody-wang-cb committed Jan 27, 2024
1 parent d3c974f commit 623467a
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 3 deletions.
5 changes: 4 additions & 1 deletion sepolia/2024-01-22-deploy-revshare/.env
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ FEE_DISBURSER_ADMIN=0x4672425C27A942bB27e7b9709c1b21ab89a3cA13
FEE_DISBURSER_SALT=FeeDisburserProxy
FEE_DISBUSER_CHAIN_ID=84532

# # Contract Addresses
# Contract Addresses
BALANCE_TRACKER_PROXY=0x8D1b5e5614300F5c7ADA01fFA4ccF8F1752D9A57
FEE_DISBURSER_PROXY=0x76355A67fCBCDE6F9a69409A8EAd5EaA9D8d875d
BALANCE_TRACKER_IMPL=0x3A92D1B1dF54870245efF0C8B1a2EBF16d997cAA
FEE_DISBURSER_IMPL=0xCA9be02F8e417D20f33551BA22ddf3f7623FB345

# Fee vaults upgrade deployer
PROXY_ADMIN_OWNER=0x8937037a0bb08658e5a178c182e60b12f14720ce

# Verification
VERIFIER=etherscan
L1_VERIFIER_URL=https://api-sepolia.etherscan.io/api
Expand Down
9 changes: 7 additions & 2 deletions sepolia/2024-01-22-deploy-revshare/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ include .env
##
.PHONY: deploy-balance-tracker
deploy-balance-tracker:
@forge script DeployBalanceTracker --rpc-url $(L1_RPC_URL) --sig "run()"
forge script DeployBalanceTracker --rpc-url $(L1_RPC_URL) --sig "run()"

.PHONY: deploy-fee-disburser
deploy-fee-disburser:
@forge script DeployFeeDisburser --rpc-url $(L2_RPC_URL) --sig "run()"
forge script DeployFeeDisburser --rpc-url $(L2_RPC_URL) --sig "run()"

.PHONY: verify-balance-tracker
verify-balance-tracker:
Expand All @@ -22,3 +22,8 @@ verify-balance-tracker:
verify-fee-disburser:
ETHERSCAN_API_KEY=$(L2_ETHERSCAN_API_KEY) forge verify-contract ${FEE_DISBURSER_IMPL} ./lib/base-contracts/src/revenue-share/FeeDisburser.sol:FeeDisburser --constructor-args $(shell cast abi-encode "constructor(address,address,uint256)" ${OPTIMISM_WALLET} ${BALANCE_TRACKER_PROXY} ${FEE_DISBURSEMENT_INTERVAL}) --verifier ${VERIFIER} --verifier-url ${L2_VERIFIER_URL} --chain-id ${L2_CHAIN_ID} --optimizer-runs=999999 --retries=1 --compiler-version v0.8.15+commit.e14f2714 --watch
ETHERSCAN_API_KEY=$(L2_ETHERSCAN_API_KEY) forge verify-contract ${FEE_DISBURSER_PROXY} Proxy --constructor-args $(shell cast abi-encode "constructor(address)" ${FEE_DISBURSER_DEPLOYER}) --verifier ${VERIFIER} --verifier-url ${L2_VERIFIER_URL} --chain-id ${L2_CHAIN_ID} --num-of-optimizations=99999 --retries=1 --compiler-version v0.8.15+commit.e14f2714 --watch

.PHONY: update-fee-vaults
update-fee-vaults:
forge script UpdateFeeVaultRecipient --rpc-url $(L2_RPC_URL) --sig "run()"

Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

import "forge-std/Script.sol";

import "@eth-optimism-bedrock/src/libraries/Predeploys.sol";
import "@eth-optimism-bedrock/src/universal/ProxyAdmin.sol";
import {SequencerFeeVault, FeeVault} from "@eth-optimism-bedrock/src/L2/SequencerFeeVault.sol";
import {L1FeeVault} from "@eth-optimism-bedrock/src/L2/L1FeeVault.sol";
import {BaseFeeVault} from "@eth-optimism-bedrock/src/L2/BaseFeeVault.sol";

contract UpdateFeeVaultRecipient is Script {
address internal recipient = vm.envAddress("FEE_DISBURSER_PROXY");

error FeeVaultFailedToUpdate(string feeVaultType, string reason);

function run() public {
ProxyAdmin proxyAdmin = ProxyAdmin(Predeploys.PROXY_ADMIN);
address proxyAdminOwner = vm.envAddress("PROXY_ADMIN_OWNER");

address payable sfvProxy = payable(Predeploys.SEQUENCER_FEE_WALLET);
address payable lfvProxy = payable(Predeploys.L1_FEE_VAULT);
address payable bfvProxy = payable(Predeploys.BASE_FEE_VAULT);

SequencerFeeVault sfvOld = SequencerFeeVault(sfvProxy);
L1FeeVault lfvOld = L1FeeVault(lfvProxy);
BaseFeeVault bfvOld = BaseFeeVault(bfvProxy);

///
// CREATE THE NEW FEE VAULTS
// totalProcessed() should be 0 for existing vaults since no withdraw has done yet
///
vm.startBroadcast(proxyAdminOwner);
SequencerFeeVault sfvNew = new SequencerFeeVault(
recipient,
sfvOld.MIN_WITHDRAWAL_AMOUNT(),
sfvOld.WITHDRAWAL_NETWORK()
);
_checks(sfvOld, sfvNew, "SequencerFeeVault");
L1FeeVault lfvNew = new L1FeeVault(
recipient,
lfvOld.MIN_WITHDRAWAL_AMOUNT(),
lfvOld.WITHDRAWAL_NETWORK()
);
_checks(lfvOld, lfvNew, "L1FeeVault");
BaseFeeVault bfvNew = new BaseFeeVault(
recipient,
bfvOld.MIN_WITHDRAWAL_AMOUNT(),
bfvOld.WITHDRAWAL_NETWORK()
);
_checks(bfvOld, bfvNew, "BaseFeeVault");
console.log("Sequencer Fee Vault Impl address: %s", address(sfvNew));
console.log("L1 Fee Vault Impl address: %s", address(lfvNew));
console.log("Base Fee Vault Impl address: %s", address(bfvNew));

///
// UPDATE THE PROXY IMPLEMENTATIONS
///
proxyAdmin.upgrade(sfvProxy, address(sfvNew));
require(
proxyAdmin.getProxyImplementation(sfvProxy).codehash ==
address(sfvNew).codehash,
"L1FeeVault not upgraded"
);
proxyAdmin.upgrade(lfvProxy, address(lfvNew));
require(
proxyAdmin.getProxyImplementation(address(lfvProxy)).codehash ==
address(lfvNew).codehash,
"L1FeeVault not upgraded"
);
proxyAdmin.upgrade(bfvProxy, address(bfvNew));
require(
proxyAdmin.getProxyImplementation(address(bfvProxy)).codehash ==
address(bfvNew).codehash,
"BaseFeeVault not upgraded"
);
vm.stopBroadcast();
}

function _checks(
FeeVault _oldFV,
FeeVault _newFV,
string memory typeOfVault
) internal view {
if (_newFV.totalProcessed() != _oldFV.totalProcessed()) {
revert FeeVaultFailedToUpdate({
feeVaultType: typeOfVault,
reason: "totalProcessed mismatch."
});
}
if (_newFV.MIN_WITHDRAWAL_AMOUNT() != _oldFV.MIN_WITHDRAWAL_AMOUNT()) {
revert FeeVaultFailedToUpdate({
feeVaultType: typeOfVault,
reason: "MIN_WITHDRAWAL_AMOUNT mismatch."
});
}
if (_newFV.WITHDRAWAL_NETWORK() != _oldFV.WITHDRAWAL_NETWORK()) {
revert FeeVaultFailedToUpdate({
feeVaultType: typeOfVault,
reason: "WITHDRAWAL_NETWORK mismatch."
});
}
if (_newFV.RECIPIENT() != recipient) {
revert FeeVaultFailedToUpdate({
feeVaultType: typeOfVault,
reason: "incorrect new recipient."
});
}
}
}

0 comments on commit 623467a

Please sign in to comment.