Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
version: stable

- name: Show Forge version
run: |
Expand Down
11 changes: 11 additions & 0 deletions foundry.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"lib/forge-std": {
"rev": "77041d2ce690e692d6e03cc812b57d1ddaa4d505"
},
"lib/openzeppelin-contracts": {
"rev": "e4f70216d759d8e6a64144a9e1f7bbeed78e7079"
},
"lib/openzeppelin-contracts-upgradeable": {
"rev": "60b305a8f3ff0c7688f02ac470417b6bbf1c4d27"
}
}
88 changes: 88 additions & 0 deletions script/Event/deployEvent.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "forge-std/Vm.sol";
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

import {EmptyContract} from "../../src/utils/EmptyContract.sol";
import {BLSApkRegistry} from "../../src/bls/BLSApkRegistry.sol";
import {EventManager} from "../../src/core/EventManager.sol";
import {console, Script} from "forge-std/Script.sol";

contract deployEventScript is Script {
EmptyContract public emptyContract;

ProxyAdmin public blsApkRegistryProxyAdmin;
ProxyAdmin public eventManagerAdmin;

BLSApkRegistry public blsApkRegistry;
BLSApkRegistry public blsApkRegistryImplementation;

EventManager public eventManager;
EventManager public eventManagerImplementation;

function run() public {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address relayerManagerAddr = vm.envAddress("RELAYER_MANAGER");

address deployerAddress = vm.addr(deployerPrivateKey);
vm.startBroadcast(deployerPrivateKey);

// Deploy BLSApkRegistry proxy and delegate to a empty contract first
emptyContract = new EmptyContract();
TransparentUpgradeableProxy proxyBlsApkRegistry =
new TransparentUpgradeableProxy(address(emptyContract), deployerAddress, "");
blsApkRegistry = BLSApkRegistry(address(proxyBlsApkRegistry));
blsApkRegistryImplementation = new BLSApkRegistry();
blsApkRegistryProxyAdmin = ProxyAdmin(getProxyAdminAddress(address(proxyBlsApkRegistry)));

// Deploy EventManager proxy and delegate to a empty contract first
TransparentUpgradeableProxy proxyEventManager =
new TransparentUpgradeableProxy(address(emptyContract), deployerAddress, "");
eventManager = EventManager(address(proxyEventManager));
eventManagerImplementation = new EventManager();
eventManagerAdmin = ProxyAdmin(getProxyAdminAddress(address(proxyEventManager)));

// Upgrade and initialize the implementations
blsApkRegistryProxyAdmin.upgradeAndCall(
ITransparentUpgradeableProxy(address(blsApkRegistry)),
address(blsApkRegistryImplementation),
abi.encodeWithSelector(
BLSApkRegistry.initialize.selector, deployerAddress, relayerManagerAddr, address(proxyEventManager)
)
);

eventManagerAdmin.upgradeAndCall(
ITransparentUpgradeableProxy(address(eventManager)),
address(eventManagerImplementation),
abi.encodeWithSelector(
EventManager.initialize.selector, deployerAddress, proxyBlsApkRegistry, deployerAddress
)
);

console.log("deploy proxyBlsApkRegistry:", address(proxyBlsApkRegistry));
console.log("deploy proxyEventManager:", address(proxyEventManager));
string memory path = "deployed_addresses.json";
string memory data = string(
abi.encodePacked(
'{"proxyBlsApkRegistry": "',
vm.toString(address(proxyBlsApkRegistry)),
'", ',
'"proxyEventManager": "',
vm.toString(address(proxyEventManager)),
'"}'
)
);
vm.writeJson(data, path);
vm.stopBroadcast();
}

function getProxyAdminAddress(address proxy) internal view returns (address) {
address CHEATCODE_ADDRESS = 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D;
Vm vm = Vm(CHEATCODE_ADDRESS);

bytes32 adminSlot = vm.load(proxy, ERC1967Utils.ADMIN_SLOT);
return address(uint160(uint256(adminSlot)));
}
}
71 changes: 71 additions & 0 deletions script/Event/deployEventPod.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "forge-std/Vm.sol";
import {console, Script} from "forge-std/Script.sol";
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

import {EmptyContract} from "../../src/utils/EmptyContract.sol";
import {EventPod} from "../../src/pod/EventPod.sol";
import {EventManager} from "../../src/core/EventManager.sol";

import {IEventManager} from "../../src/interfaces/IEventManager.sol";
import {IEventPod} from "../../src/interfaces/IEventPod.sol";

contract deployEventPodScript is Script {
EmptyContract public emptyContract;

ProxyAdmin public eventPodAdmin;
EventPod public eventPod;
EventPod public eventPodImplementation;

function run() public {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address eventManagerAddr = vm.envAddress("ORACLE_MANAGER");

address deployerAddress = vm.addr(deployerPrivateKey);

vm.startBroadcast(deployerPrivateKey);

emptyContract = new EmptyContract();
TransparentUpgradeableProxy proxyEventPod =
new TransparentUpgradeableProxy(address(emptyContract), deployerAddress, "");
eventPod = EventPod(address(proxyEventPod));
eventPodImplementation = new EventPod();
eventPodAdmin = ProxyAdmin(getProxyAdminAddress(address(proxyEventPod)));

console.log("eventPodImplementation===", address(eventPodImplementation));

eventPodAdmin.upgradeAndCall(
ITransparentUpgradeableProxy(address(eventPod)),
address(eventPodImplementation),
abi.encodeWithSelector(EventPod.initialize.selector, deployerAddress, eventManagerAddr)
);

// EventManager(eventManagerAddr).addEventPodToFillWhitelist(proxyEventPod);

console.log("deploy proxyEventPod:", address(proxyEventPod));
string memory path = "deployed_addresses.json";
string memory data = string(
abi.encodePacked(
'{"proxyEventPod": "',
vm.toString(address(proxyEventPod)),
'", ',
'"eventPodImplementation": "',
vm.toString(address(eventPodImplementation)),
'"}'
)
);
vm.writeJson(data, path);
vm.stopBroadcast();
}

function getProxyAdminAddress(address proxy) internal view returns (address) {
address CHEATCODE_ADDRESS = 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D;
Vm vm = Vm(CHEATCODE_ADDRESS);

bytes32 adminSlot = vm.load(proxy, ERC1967Utils.ADMIN_SLOT);
return address(uint160(uint256(adminSlot)));
}
}
50 changes: 50 additions & 0 deletions script/Event/upgradeEventPod.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "forge-std/Vm.sol";
import {console, Script} from "forge-std/Script.sol";
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

import {EmptyContract} from "../../src/utils/EmptyContract.sol";
import {EventPod} from "../../src/pod/EventPod.sol";
import {IEventManager} from "../../src/interfaces/IEventManager.sol";
import {IEventPod} from "../../src/interfaces/IEventPod.sol";

contract upgradeEventPodScript is Script {
address public ORACLE_POD = vm.envAddress("ORACLE_POD");

function run() public {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address deployerAddress = vm.addr(deployerPrivateKey);

console.log("Deployer address:", deployerAddress);
console.log("Event Pod Proxy:", ORACLE_POD);

address proxyAdminAddress = getProxyAdminAddress(ORACLE_POD);
console.log("Calculated Event Pod Proxy Admin:", proxyAdminAddress);

ProxyAdmin messageManagerProxyAdmin = ProxyAdmin(proxyAdminAddress);

vm.startBroadcast(deployerPrivateKey);

EventPod newEventPodImplementation = new EventPod();

console.log("New EventPod implementation:", address(newEventPodImplementation));

messageManagerProxyAdmin.upgradeAndCall(
ITransparentUpgradeableProxy(ORACLE_POD), address(newEventPodImplementation), ""
);

console.log("Upgrade completed successfully!");
vm.stopBroadcast();
}

function getProxyAdminAddress(address proxy) internal view returns (address) {
address CHEATCODE_ADDRESS = 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D;
Vm vm = Vm(CHEATCODE_ADDRESS);

bytes32 adminSlot = vm.load(proxy, ERC1967Utils.ADMIN_SLOT);
return address(uint160(uint256(adminSlot)));
}
}
45 changes: 24 additions & 21 deletions script/deployOracle.s.sol → script/Oracle/deployOracle.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import "forge-std/Vm.sol";
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

import { EmptyContract } from "../src/utils/EmptyContract.sol";
import { BLSApkRegistry } from "../src/bls/BLSApkRegistry.sol";
import { OracleManager } from "../src/core/OracleManager.sol";
import { console, Script } from "forge-std/Script.sol";
import {EmptyContract} from "../../src/utils/EmptyContract.sol";
import {BLSApkRegistry} from "../../src/bls/BLSApkRegistry.sol";
import {OracleManager} from "../../src/core/OracleManager.sol";
import {console, Script} from "forge-std/Script.sol";

contract deployOracleScript is Script {
EmptyContract public emptyContract;
Expand All @@ -24,53 +24,56 @@ contract deployOracleScript is Script {

function run() public {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address relayerManagerAddr = vm.envAddress("RELAYER_MANAGER");
address relayerManagerAddr = vm.envAddress("RELAYER_MANAGER");

address deployerAddress = vm.addr(deployerPrivateKey);
vm.startBroadcast(deployerPrivateKey);

// Deploy BLSApkRegistry proxy and delegate to a empty contract first
emptyContract = new EmptyContract();
TransparentUpgradeableProxy proxyBlsApkRegistry = new TransparentUpgradeableProxy(address(emptyContract), deployerAddress, "");
TransparentUpgradeableProxy proxyBlsApkRegistry =
new TransparentUpgradeableProxy(address(emptyContract), deployerAddress, "");
blsApkRegistry = BLSApkRegistry(address(proxyBlsApkRegistry));
blsApkRegistryImplementation = new BLSApkRegistry();
blsApkRegistryProxyAdmin = ProxyAdmin(getProxyAdminAddress(address(proxyBlsApkRegistry)));


TransparentUpgradeableProxy proxyOracleManager = new TransparentUpgradeableProxy(address(emptyContract), deployerAddress, "");
// Deploy OracleManager proxy and delegate to a empty contract first
TransparentUpgradeableProxy proxyOracleManager =
new TransparentUpgradeableProxy(address(emptyContract), deployerAddress, "");
oracleManager = OracleManager(address(proxyOracleManager));
oracleManagerImplementation = new OracleManager();
oracleManagerAdmin = ProxyAdmin(getProxyAdminAddress(address(proxyOracleManager)));


// Upgrade and initialize the implementations
blsApkRegistryProxyAdmin.upgradeAndCall(
ITransparentUpgradeableProxy(address(blsApkRegistry)),
address(blsApkRegistryImplementation),
abi.encodeWithSelector(
BLSApkRegistry.initialize.selector,
deployerAddress,
relayerManagerAddr,
address(proxyOracleManager)
BLSApkRegistry.initialize.selector, deployerAddress, relayerManagerAddr, address(proxyOracleManager)
)
);

oracleManagerAdmin.upgradeAndCall(
ITransparentUpgradeableProxy(address(oracleManager)),
address(oracleManagerImplementation),
abi.encodeWithSelector(
OracleManager.initialize.selector,
deployerAddress,
proxyBlsApkRegistry,
deployerAddress
OracleManager.initialize.selector, deployerAddress, proxyBlsApkRegistry, deployerAddress
)
);

console.log("deploy proxyBlsApkRegistry:", address(proxyBlsApkRegistry));
console.log("deploy proxyOracleManager:", address(proxyOracleManager));
string memory path = "deployed_addresses.json";
string memory data = string(abi.encodePacked(
'{"proxyBlsApkRegistry": "', vm.toString(address(proxyBlsApkRegistry)), '", ',
'"proxyOracleManager": "', vm.toString(address(proxyOracleManager)), '"}'
));
string memory data = string(
abi.encodePacked(
'{"proxyBlsApkRegistry": "',
vm.toString(address(proxyBlsApkRegistry)),
'", ',
'"proxyOracleManager": "',
vm.toString(address(proxyOracleManager)),
'"}'
)
);
vm.writeJson(data, path);
vm.stopBroadcast();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
pragma solidity ^0.8.20;

import "forge-std/Vm.sol";
import { console, Script } from "forge-std/Script.sol";
import {console, Script} from "forge-std/Script.sol";
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

import { EmptyContract } from "../src/utils/EmptyContract.sol";
import { OraclePod } from "../src/pod/OraclePod.sol";
import { OracleManager } from "../src/core/OracleManager.sol";

import { IOracleManager } from "../src/interfaces/IOracleManager.sol";
import { IOraclePod } from "../src/interfaces/IOraclePod.sol";
import {EmptyContract} from "../../src/utils/EmptyContract.sol";
import {OraclePod} from "../../src/pod/OraclePod.sol";
import {OracleManager} from "../../src/core/OracleManager.sol";

import {IOracleManager} from "../../src/interfaces/IOracleManager.sol";
import {IOraclePod} from "../../src/interfaces/IOraclePod.sol";

contract deployOraclePodScript is Script {
EmptyContract public emptyContract;
Expand All @@ -30,7 +29,8 @@ contract deployOraclePodScript is Script {
vm.startBroadcast(deployerPrivateKey);

emptyContract = new EmptyContract();
TransparentUpgradeableProxy proxyOraclePod = new TransparentUpgradeableProxy(address(emptyContract), deployerAddress, "");
TransparentUpgradeableProxy proxyOraclePod =
new TransparentUpgradeableProxy(address(emptyContract), deployerAddress, "");
oraclePod = OraclePod(address(proxyOraclePod));
oraclePodImplementation = new OraclePod();
oraclePodAdmin = ProxyAdmin(getProxyAdminAddress(address(proxyOraclePod)));
Expand All @@ -40,22 +40,23 @@ contract deployOraclePodScript is Script {
oraclePodAdmin.upgradeAndCall(
ITransparentUpgradeableProxy(address(oraclePod)),
address(oraclePodImplementation),
abi.encodeWithSelector(
OraclePod.initialize.selector,
deployerAddress,
oracleManagerAddr
)
abi.encodeWithSelector(OraclePod.initialize.selector, deployerAddress, oracleManagerAddr)
);

// OracleManager(oracleManagerAddr).addOraclePodToFillWhitelist(proxyOraclePod);

// OracleManager(oracleManagerAddr).addOraclePodToFillWhitelist(proxyOraclePod);

console.log("deploy proxyOraclePod:", address(proxyOraclePod));
string memory path = "deployed_addresses.json";
string memory data = string(abi.encodePacked(
'{"proxyOraclePod": "', vm.toString(address(proxyOraclePod)), '", ',
'"oraclePodImplementation": "', vm.toString(address(oraclePodImplementation)), '"}'
));
string memory data = string(
abi.encodePacked(
'{"proxyOraclePod": "',
vm.toString(address(proxyOraclePod)),
'", ',
'"oraclePodImplementation": "',
vm.toString(address(oraclePodImplementation)),
'"}'
)
);
vm.writeJson(data, path);
vm.stopBroadcast();
}
Expand Down
Loading