Skip to content

Commit

Permalink
feat: add LegacySystemConfigProxy #54
Browse files Browse the repository at this point in the history
After implementing the challenge on Titan Candidate, we need to upgrade the logic, so use the proxy.
  • Loading branch information
Zena-park committed Oct 24, 2024
1 parent f3b5f1d commit 1db8b24
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 48 deletions.
1 change: 1 addition & 0 deletions contracts/dao/CandidateAddOnV1_1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ contract CandidateAddOnV1_1 is
/// @notice Call updateSeigniorage on SeigManager
/// @param afterCall After running the update seigniorage, the option to run additional functions
/// 0: none, 1: claim, 2: staking
/// @param flagTON If it is true, claim with ton, otherwise claim with wton
/// @return Whether or not the execution succeeded
function updateSeigniorage(uint256 afterCall, bool flagTON) public returns (bool) {

Expand Down
19 changes: 2 additions & 17 deletions contracts/layer2/LegacySystemConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,10 @@ pragma solidity ^0.8.4;

import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";

import "./LegacySystemConfigStorage.sol";

contract LegacySystemConfig is Ownable {

/// @notice Struct representing the addresses of L1 system contracts. These should be the
/// proxies and will differ for each OP Stack chain.
struct Addresses {
address l1CrossDomainMessenger;
address l1ERC721Bridge;
address l1StandardBridge;
address l2OutputOracle;
address optimismPortal;
address optimismMintableERC20Factory;
}

Addresses public addresses;
// address public l2Ton;
string public name;

address public l1BridgeRegistry;
contract LegacySystemConfig is Ownable, LegacySystemConfigStorage {

/* ========== CONSTRUCTOR ========== */
constructor() {
Expand Down
52 changes: 28 additions & 24 deletions deploy-staking-v2.5-mainnet/0.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { SeigManagerV1_3 } from "../typechain-types/contracts/stake/managers/Sei
import { DepositManagerV1_1 } from "../typechain-types/contracts/stake/managers/DepositManagerV1_1.sol"

import { LegacySystemConfig } from "../typechain-types/contracts/layer2/LegacySystemConfig"
import { LegacySystemConfigProxy } from "../typechain-types/contracts/layer2/LegacySystemConfigProxy"


import {Signer} from "ethers"
Expand Down Expand Up @@ -50,6 +51,7 @@ const deployV2Mainnet: DeployFunction = async function (hre: HardhatRuntimeEnvir
owner: DAOCommitteeProxy
},
Titan : {
proxyOwner: DAOCommitteeProxy,
manager: "0x340C44089bc45F86060922d2d89eFee9e0CDF5c7"
}
}
Expand All @@ -70,25 +72,6 @@ const deployV2Mainnet: DeployFunction = async function (hre: HardhatRuntimeEnvir
console.log("addresses: ", addresses)


// return;

console.log("\n=== ownerAddressInfo ===" )
console.log(ownerAddressInfo)

const name = 'Titan'
const addresses = {
l1CrossDomainMessenger: l1MessengerAddress,
l1ERC721Bridge: hre.ethers.constants.AddressZero,
l1StandardBridge: l1BridgeAddress,
l2OutputOracle: hre.ethers.constants.AddressZero,
optimismPortal: hre.ethers.constants.AddressZero,
optimismMintableERC20Factory: hre.ethers.constants.AddressZero
}
console.log("\n === Titan Candidate ===" )
console.log("name: ", name)
console.log("addresses: ", addresses)


// return;

const { deploy } = hre.deployments;
Expand Down Expand Up @@ -309,25 +292,46 @@ const deployV2Mainnet: DeployFunction = async function (hre: HardhatRuntimeEnvir
});

//==== LegacySystemConfig =================================
const LegacySystemConfig = await deploy("LegacySystemConfig", {
const LegacySystemConfigDep = await deploy("LegacySystemConfig", {
from: deployer,
args: [],
log: true
});

const LegacySystemConfigProxyDep = await deploy("LegacySystemConfigProxy", {
from: deployer,
args: [],
log: true
});

const LegacySystemConfigProxy = (await hre.ethers.getContractAt(
LegacySystemConfigProxyDep.abi,
LegacySystemConfigProxyDep.address
)) as LegacySystemConfigProxy;

const legacySystemConfig = (await hre.ethers.getContractAt(
LegacySystemConfig.abi,
LegacySystemConfig.address
LegacySystemConfigDep.abi,
LegacySystemConfigProxyDep.address
)) as LegacySystemConfig;


await (await LegacySystemConfigProxy.connect(deploySigner).upgradeTo(
LegacySystemConfigDep.address
)).wait()

await (await legacySystemConfig.connect(deploySigner).setAddresses(
name, addresses, l1BridgeRegistryProxy.address
)).wait()

await (await legacySystemConfig.connect(deploySigner).transferOwnership(
ownerAddressInfo.Titan.manager
console.log('ownerAddressInfo.Titan.proxyOwner', ownerAddressInfo.Titan.proxyOwner)
await (await LegacySystemConfigProxy.connect(deploySigner).transferProxyOwnership(
ownerAddressInfo.Titan.proxyOwner
)).wait()

console.log('ownerAddressInfo.Titan.manager', ownerAddressInfo.Titan.manager)
await (await LegacySystemConfigProxy.connect(deploySigner).transferOwnership(
ownerAddressInfo.Titan.manager
)).wait()

//======= TransferOwner to DAOCommittee ======================================

Expand Down
20 changes: 13 additions & 7 deletions test/layer2/units/7.dao-staking-v2.5.mainnet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ let ownerAddressInfo = {
owner: "0xDD9f0cCc044B0781289Ee318e5971b0139602C26"
},
Titan : {
MultiProposerableTransactionExecutor: "0x014E38eAA7C9B33FeF08661F8F0bFC6FE43f1496"
proxyOwner: "0xDD9f0cCc044B0781289Ee318e5971b0139602C26",
manager: "0x340C44089bc45F86060922d2d89eFee9e0CDF5c7"
}
}

Expand Down Expand Up @@ -237,21 +238,25 @@ describe('Layer2Manager', () => {
seigniorageCommittee = await hre.ethers.getSigner(seigniorageCommitteeAddress);

await hre.network.provider.send("hardhat_impersonateAccount", [
ownerAddressInfo.Titan.MultiProposerableTransactionExecutor,
ownerAddressInfo.Titan.manager,
]);
await hre.network.provider.send("hardhat_setBalance", [
ownerAddressInfo.Titan.MultiProposerableTransactionExecutor,
ownerAddressInfo.Titan.manager,
"0x10000000000000000000000000",
]);
titanManager = await hre.ethers.getSigner(ownerAddressInfo.Titan.MultiProposerableTransactionExecutor);

titanManager = await hre.ethers.getSigner(ownerAddressInfo.Titan.manager);
tonMinter = daoAdmin
})

describe('# Tester', () => {
it('mint ton', async () => {

await (await tonContract.connect(daoAdmin).mint(addr1.address, ethers.utils.parseEther("2000"))).wait()
await (await tonContract.connect(daoAdmin).mint(addr2.address, ethers.utils.parseEther("2000"))).wait()
await (await tonContract.connect(tonMinter).mint(tonHave.address, ethers.utils.parseEther("2000"))).wait()
await (await tonContract.connect(tonMinter).mint(pastAddr, ethers.utils.parseEther("2000"))).wait()
await (await wtonContract.connect(tonMinter).mint(wtonHave.address, ethers.utils.parseEther("3000000000000"))).wait()

})
})
Expand All @@ -274,7 +279,7 @@ describe('Layer2Manager', () => {
daoCommitteeProxy2Contract = (await ethers.getContractAt("DAOCommitteeProxy2", deployed.DAOCommitteeProxy2.address, deployer)) as DAOCommitteeProxy2;
daoCommitteeOwner = (await ethers.getContractAt("DAOCommitteeOwner", deployed.DAOCommitteeOwner.address, deployer)) as DAOCommitteeOwner;
daoCommittee_V1 = (await ethers.getContractAt("DAOCommittee_V1", deployed.DAOCommittee_V1.address, deployer)) as DAOCommittee_V1;
legacySystemConfig = (await ethers.getContractAt("LegacySystemConfig", deployed.LegacySystemConfig.address, deployer )) as LegacySystemConfig;
legacySystemConfig = (await ethers.getContractAt("LegacySystemConfig", deployed.LegacySystemConfigProxy.address, deployer )) as LegacySystemConfig;

// console.log('l1BridgeRegistryProxy', l1BridgeRegistryProxy.address)
// console.log('l1BridgeRegistry', l1BridgeRegistry.address)
Expand Down Expand Up @@ -1175,6 +1180,7 @@ describe('Layer2Manager', () => {
const prevWtonBalanceOfLayer2Manager = await wtonContract.balanceOf(layer2Manager.address)
const prevWtonBalanceOfLayer2Operator = await wtonContract.balanceOf(titanOperatorContractAddress)
const prevWtonBalanceOfManager = await wtonContract.balanceOf(titanManager.address)

const prevUnSettledReward = await seigManager.unSettledReward(titanLayerAddress)
expect(prevWtonBalanceOfLayer2Manager).to.be.gte(prevUnSettledReward)

Expand Down Expand Up @@ -1243,7 +1249,7 @@ describe('Layer2Manager', () => {
const topic1 = seigManager.interface.getEventTopic('SeigGiven2');
const log1 = receipt.logs.find(x => x.topics.indexOf(topic1) >= 0);
const deployedEvent1 = seigManager.interface.parseLog(log1);
// console.log(deployedEvent1.args)
console.log(deployedEvent1.args)

expect(estimatedDistribute.maxSeig).to.be.eq(deployedEvent1.args.totalSeig)
expect(estimatedDistribute.stakedSeig).to.be.eq(deployedEvent1.args.stakedSeig)
Expand Down Expand Up @@ -1280,7 +1286,7 @@ describe('Layer2Manager', () => {
)
expect(afterWtonBalanceOfLayer2Operator).to.be.eq(ethers.constants.Zero)

expect(afterWtonBalanceOfManager).to.be.eq(prevWtonBalanceOfLayer2Operator.add(estimatedDistribute.layer2Seigs))
expect(afterWtonBalanceOfManager).to.be.eq(prevWtonBalanceOfManager.add(prevWtonBalanceOfLayer2Operator).add(estimatedDistribute.layer2Seigs))

})

Expand Down

0 comments on commit 1db8b24

Please sign in to comment.