Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sepolia] deploy revshare contracts to sepolia #119

Merged
merged 10 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions sepolia/2024-01-22-deploy-revshare/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
OP_COMMIT=e3ba24e72085d85bb5584dda33a03ccf60db86f0
BASE_CONTRACTS_COMMIT=8e56038610812dc8411f9fc6ecbef2cba613b913

# BalanceTracker configuration
BALANCE_TRACKER_DEPLOYER=<>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think BALANCE_TRACKER_DEPLOYER and FEE_DISBURSER_DEPLOYER are filled in when the deploy happens?
(the address of the EOA wallet deployer)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd want to allocate a new key for this - let's sync offline!

PROFIT_WALLET=<>
Copy link
Contributor Author

@cody-wang-cb cody-wang-cb Jan 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not very sure where to find PROFIT_WALLET and OPTIMISM_WALLET for sepolia, would love some hints on this one

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use what we used for Goerli (0x5a822ea15764a6090b86b1eabffc051cec99afe9) for both values. This is a coinbase managed key

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although if we're anyways allocating an address for deploying, might be a good idea to allocate a new one here as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated it to 0x5a822ea15764a6090b86b1eabffc051cec99afe9 for now!

OUTPUT_PROPOSER=0x20044a0d104E9e788A0C984A2B7eAe615afD046b
BATCH_SENDER=0x6CDEbe940BC0F26850285cacA097C11c33103E47
OUTPUT_PROPOSER_TARGET_BALANCE=200000000000000000000
BATCH_SENDER_TARGET_BALANCE=1000000000000000000000
BALANCE_TRACKER_ADMIN=0x608081689Fe46936fB2fBDF7552CbB1D80ad4822
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is correct! but we do want to eventually change these admins to being the Gnosis safes we setup so would be ideal if we just set that to be the admin to avoid another owernship transfer later

BALANCE_TRACKER_SALT=BalanceTrackerProxyV2
BALANCE_TRACKER_CHAIN_ID=11155111

# FeeDisburser configuration
FEE_DISBURSER_DEPLOYER=<>
OPTIMISM_WALLET=<>
FEE_DISBURSEMENT_INTERVAL=604800 # 60 seconds * 60 minutes * 24 hours * 7 days
FEE_DISBURSER_ADMIN=0x8937037a0bb08658e5a178c182e60b12f14720ce
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cast call --rpc-url https://base-sepolia.cbhq.net 0x4200000000000000000000000000000000000018 "owner()"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above

FEE_DISBURSER_SALT=FeeDisburserProxy
FEE_DISBUSER_CHAIN_ID=84532

# # Contract Addresses
BALANCE_TRACKER_PROXY=<>
FEE_DISBURSER_PROXY=<>
BALANCE_TRACKER_IMPL=<>
FEE_DISBURSER_IMPL=<>

# Signing
CB_SAFE_ADDR=<>

# Signing
CB_SAFE_ADDR=<>

# Verification
VERIFIER=etherscan
VERIFIER_URL=https://api-sepolia.basescan.org/api
44 changes: 44 additions & 0 deletions sepolia/2024-01-22-deploy-revshare/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
include ../../Makefile
include ../.env
include .env

##
# Foundry commands
##
.PHONY: deploy-balance-tracker
deploy-balance-tracker:
@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()"

.PHONY: verify-balance-tracker
verify-balance-tracker:
@forge verify-contract ${BALANCE_TRACKER_IMPL} ./lib/base-contracts/src/revenue-share/BalanceTracker.sol:BalanceTracker --verifier ${VERIFIER} --verifier-url ${VERIFIER_URL} --chain-id ${BALANCE_TRACKER_CHAIN_ID} --retries=1 --etherscan-api-key ${ETHERSCAN_API_KEY} --watch
@forge verify-contract ${BALANCE_TRACKER_PROXY} Proxy --constructor-args $(shell cast abi-encode "constructor(address)" ${BALANCE_TRACKER_DEPLOYER}) --verifier ${VERIFIER} --verifier-url ${VERIFIER_URL} --chain-id ${BALANCE_TRACKER_CHAIN_ID} --retries=1 --etherscan-api-key ${ETHERSCAN_API_KEY} --watch

.PHONY: verify-fee-disburser
verify-fee-disburser:
ETHERSCAN_API_KEY=PLACEHOLDER_STRING 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 ${VERIFIER_URL} --chain-id ${L2_CHAIN_ID} --num-of-optimizations=99999 --retries=1 --compiler-version v0.8.15+commit.e14f2714 --watch
ETHERSCAN_API_KEY=PLACEHOLDER_STRING forge verify-contract ${FEE_DISBURSER_PROXY} Proxy --constructor-args $(shell cast abi-encode "constructor(address)" ${FEE_DISBURSER_DEPLOYER}) --verifier ${VERIFIER} --verifier-url ${VERIFIER_URL} --chain-id ${L2_CHAIN_ID} --num-of-optimizations=99999 --retries=1 --compiler-version v0.8.15+commit.e14f2714 --watch

ifndef LEDGER_ACCOUNT
override LEDGER_ACCOUNT = 1
endif

##
# MultisigBuilder commands
# The following commands can be used for tasks that utilize the MultisigBuilder.
# Note that --ledger --hd-paths <PATH> can be replaced with --private-key $(PRIVATE_KEY)
# in any command when using a local key.
##
.PHONY: sign-cb
sign-cb:
$(GOPATH)/bin/eip712sign --ledger --hd-paths "m/44'/60'/$(LEDGER_ACCOUNT)'/0/0" -- \
forge script UpgradeToFeeDisburser --via-ir --rpc-url $(L2_RPC_URL) UpgradeToFeeDisburser --sig "sign()"

.PHONY: execute
execute:
@forge script UpgradeToFeeDisburser --rpc-url $(L2_RPC_URL) UpgradeToFeeDisburser \
--sig "run(bytes)" $(SIGNATURES) --private-key ${PRIVATE_KEY} --sender $(SENDER)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to run local test for this multisig script? I tried to pass in --private-key $(PRIVATE_KEY) with my own private key and using my wallet address for CB_SAFE_ADDRESS to run sign-cb but it throws Revert error.
Not sure if that's the proper way to do it though

19 changes: 19 additions & 0 deletions sepolia/2024-01-22-deploy-revshare/foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[profile.default]
src = 'src'
out = 'out'
libs = ['lib']
broadcast = 'records'
fs_permissions = [ {access = "read-write", path = "./"} ]
optimizer = true
optimizer_runs = 999999
solc_version = "0.8.15"
via-ir = true
remappings = [
'@eth-optimism-bedrock/=lib/optimism/packages/contracts-bedrock/',
'@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts',
'@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts',
'@rari-capital/solmate/=lib/solmate/',
'@base-contracts/=lib/base-contracts'
]

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

import { console } from "forge-std/console.sol";
import { Script } from "forge-std/Script.sol";

import { Proxy } from "@eth-optimism-bedrock/src/universal/Proxy.sol";
import { BalanceTracker } from "@base-contracts/src/revenue-share/BalanceTracker.sol";

contract DeployBalanceTracker is Script {
address payable[] systemAddresses;
uint256[] targetBalances;

function run() external {
address deployer = vm.envAddress("BALANCE_TRACKER_DEPLOYER");
address payable profitWallet = payable(vm.envAddress("PROFIT_WALLET"));
address payable outputProposer = payable(vm.envAddress("OUTPUT_PROPOSER"));
address payable batchSender = payable(vm.envAddress("BATCH_SENDER"));
uint256 outputProposerTargetBalance = vm.envUint("OUTPUT_PROPOSER_TARGET_BALANCE");
uint256 batchSenderTargetBalance = vm.envUint("BATCH_SENDER_TARGET_BALANCE");
address admin = vm.envAddress("BALANCE_TRACKER_ADMIN");
string memory salt = vm.envString("BALANCE_TRACKER_SALT");

console.log("Deployer: %s", deployer);
console.log("Profit Wallet: %s", profitWallet);
console.log("Batch Sender: %s", batchSender);
console.log("Output Proposer: %s", outputProposer);
console.log("Batch Sender Target Balance: %s", batchSenderTargetBalance);
console.log("Output Proposer Target Balance: %s", outputProposerTargetBalance);
console.log("Admin: %s", admin);
console.log("Salt: %s", salt);

vm.broadcast(deployer);
BalanceTracker balanceTrackerImpl = new BalanceTracker(profitWallet);
require(balanceTrackerImpl.PROFIT_WALLET() == profitWallet, "DeployBalanceTracker: incorrect profit wallet");

systemAddresses.push(outputProposer);
systemAddresses.push(batchSender);
targetBalances.push(outputProposerTargetBalance);
targetBalances.push(batchSenderTargetBalance);

bytes memory initializeCall = abi.encodeCall(
BalanceTracker.initialize, (
systemAddresses,
targetBalances
)
);

vm.broadcast(deployer);
Proxy proxy = new Proxy{ salt: keccak256(abi.encode(salt))}(deployer);
vm.prank(address(0));
require(proxy.admin() == deployer, "DeployBalanceTracker: incorrect proxy admin");
vm.broadcast(deployer);
proxy.upgradeToAndCall(payable(address(balanceTrackerImpl)), initializeCall);
BalanceTracker balanceTracker = BalanceTracker(payable(address(proxy)));
require(balanceTracker.systemAddresses(0) == outputProposer, "DeployBalanceTracker: incorrect output proposer");
require(balanceTracker.systemAddresses(1) == batchSender, "DeployBalanceTracker: incorrect batch sender");
require(balanceTracker.targetBalances(0) == outputProposerTargetBalance, "DeployBalanceTracker: incorrect output proposer target balance");
require(balanceTracker.targetBalances(1) == batchSenderTargetBalance, "DeployBalanceTracker: incorrect batch sender target balance");

vm.broadcast(deployer);
proxy.changeAdmin(admin);
vm.prank(address(0));
require(proxy.admin() == admin, "DeployBalanceTracker: incorrect proxy admin");

console.log("Balance Tracker Impl address: %s", address(balanceTrackerImpl));
console.log("Balance Tracker Proxy address: %s", address(proxy));
}
}
38 changes: 38 additions & 0 deletions sepolia/2024-01-22-deploy-revshare/script/DeployFeeDisburser.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

import { console } from "forge-std/console.sol";
import { Script } from "forge-std/Script.sol";

import { Proxy } from "@eth-optimism-bedrock/src/universal/Proxy.sol";
import { FeeDisburser } from "@base-contracts/src/revenue-share/FeeDisburser.sol";

contract DeployFeeDisburser is Script {
function run() external {
address deployer = vm.envAddress("FEE_DISBURSER_DEPLOYER");
address payable optimismWallet = payable(vm.envAddress("OPTIMISM_WALLET"));
address balanceTracker = vm.envAddress("BALANCE_TRACKER_PROXY");
uint256 feeDisbursementInterval = vm.envUint("FEE_DISBURSEMENT_INTERVAL");
address admin = vm.envAddress("FEE_DISBURSER_ADMIN");
string memory salt = vm.envString("FEE_DISBURSER_SALT");

console.log("Deployer: %s", deployer);
console.log("Optimism Wallet: %s", optimismWallet);
console.log("Balance Tracker: %s", balanceTracker);
console.log("Fee Disbursement Interval: %s", feeDisbursementInterval);
console.log("Admin: %s", admin);
console.log("Salt: %s", salt);

vm.broadcast(deployer);
FeeDisburser feeDisburserImpl = new FeeDisburser(
optimismWallet,
balanceTracker,
feeDisbursementInterval
);
require(feeDisburserImpl.OPTIMISM_WALLET() == optimismWallet, "DeployFeeDisburser: incorrect optimism wallet");
require(feeDisburserImpl.L1_WALLET() == balanceTracker, "DeployFeeDisburser: incorrect l1 wallet");
require(feeDisburserImpl.FEE_DISBURSEMENT_INTERVAL() == feeDisbursementInterval, "DeployFeeDisburser: incorrect fee disbursement interval");

console.log("Fee Disburser Impl address: %s", address(feeDisburserImpl));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

import { console } from "forge-std/console.sol";

import { IMulticall3 } from "forge-std/interfaces/IMulticall3.sol";

import { Proxy } from "@eth-optimism-bedrock/src/universal/Proxy.sol";

import { MultisigBuilder } from "@base-contracts/script/universal/MultisigBuilder.sol";
import { FeeDisburser } from "@base-contracts/src/revenue-share/FeeDisburser.sol";

contract UpgradeToFeeDisburser is MultisigBuilder {
address payable internal FEE_DISBURSER_PROXY = payable(vm.envAddress("FEE_DISBURSER_PROXY"));
address payable internal FEE_DISBURSER_IMPL = payable(vm.envAddress("FEE_DISBURSER_IMPL"));
address internal OPTIMISM_WALLET = vm.envAddress("OPTIMISM_WALLET");
address internal CB_SAFE_ADDR = vm.envAddress("CB_SAFE_ADDR");

function _buildCalls() internal override view returns (IMulticall3.Call3[] memory) {
console.log("Fee Diburser Proxy %s", FEE_DISBURSER_PROXY);
console.log("Fee Diburser Impl %s", FEE_DISBURSER_IMPL);
console.log("Optimism Wallet %s", OPTIMISM_WALLET);
console.log("CB_SAFE_ADDR %s", CB_SAFE_ADDR);

IMulticall3.Call3[] memory calls = new IMulticall3.Call3[](1);

///
// FEE DISBURSER PROXY UPGRADE TO FEE DISBURSER IMPLEMENTATION CALL
///
calls[0] = IMulticall3.Call3({
target: FEE_DISBURSER_PROXY,
allowFailure: false,
callData: abi.encodeCall(
Proxy.upgradeTo,
(
FEE_DISBURSER_IMPL
)
)
});

return calls;
}

function _ownerSafe() internal override view returns (address) {
return CB_SAFE_ADDR;
}

function _postCheck() internal override view {
require(
FeeDisburser(FEE_DISBURSER_PROXY).OPTIMISM_WALLET() == OPTIMISM_WALLET,
"UpgradeToFeeDisburser: FeeDisburser incorrect Optimism Wallet"
);
}
}