-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a99b12
commit 868a573
Showing
20 changed files
with
3,009 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ coverage | |
coverage.json | ||
typechain | ||
typechain-types | ||
out | ||
|
||
# Hardhat files | ||
cache | ||
|
653 changes: 653 additions & 0 deletions
653
broadcast/1_DeployMockOFT.s.sol/252/dry-run/run-1731692004.json
Large diffs are not rendered by default.
Oops, something went wrong.
653 changes: 653 additions & 0 deletions
653
broadcast/1_DeployMockOFT.s.sol/252/dry-run/run-latest.json
Large diffs are not rendered by default.
Oops, something went wrong.
653 changes: 653 additions & 0 deletions
653
broadcast/2_DeployMockOFT.s.sol/252/dry-run/run-1731698162.json
Large diffs are not rendered by default.
Oops, something went wrong.
653 changes: 653 additions & 0 deletions
653
broadcast/2_DeployMockOFT.s.sol/252/dry-run/run-latest.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.22; | ||
|
||
import { FraxOFTUpgradeable } from "../FraxOFTUpgradeable.sol"; | ||
|
||
interface IEndpoint { | ||
function delegates(address _oapp) external view returns (address); | ||
} | ||
|
||
contract OFTUpgradeableMock is FraxOFTUpgradeable { | ||
constructor(address _lzEndpoint) FraxOFTUpgradeable(_lzEndpoint) {} | ||
|
||
function mint(address _to, uint256 _amount) public { | ||
require(msg.sender == IEndpoint(address(endpoint)).delegates(address(this))); | ||
_mint(_to, _amount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.22; | ||
|
||
import "../DeployFraxOFTProtocol/DeployFraxOFTProtocol.s.sol"; | ||
|
||
/// @dev remove ethereum from destinations, remove destinations from ethereum | ||
contract DisconnectEthereumPeer is DeployFraxOFTProtocol { | ||
using stdJson for string; | ||
using Strings for uint256; | ||
|
||
/// @dev override to alter file save location | ||
modifier simulateAndWriteTxs(L0Config memory _config) override { | ||
// Clear out arrays | ||
delete enforcedOptionsParams; | ||
delete setConfigParams; | ||
delete serializedTxs; | ||
|
||
vm.createSelectFork(_config.RPC); | ||
chainid = _config.chainid; | ||
vm.startPrank(_config.delegate); | ||
_; | ||
vm.stopPrank(); | ||
|
||
// create filename and save | ||
string memory root = vm.projectRoot(); | ||
root = string.concat(root, "/scripts/UpgradeFrax/txs/"); | ||
string memory filename = string.concat("1_DisconnectEthereumPeer-", activeConfig.chainid.toString()); | ||
filename = string.concat(filename, "-"); | ||
filename = string.concat(filename, _config.chainid.toString()); | ||
filename = string.concat(filename, ".json"); | ||
|
||
new SafeTxUtil().writeTxs(serializedTxs, string.concat(root, filename)); | ||
} | ||
|
||
|
||
/// @dev skip deployment, set oft addrs to only FRAX/sFRAX | ||
function run() public override { | ||
delete legacyOfts; | ||
legacyOfts.push(0x909DBdE1eBE906Af95660033e478D59EFe831fED); // FRAX | ||
legacyOfts.push(0x1f55a02A049033E3419a8E2975cF3F572F4e6E9A); // sFRAX | ||
|
||
delete proxyOfts; | ||
proxyOfts.push(0x80Eede496655FB9047dd39d9f418d5483ED600df); // FRAX | ||
proxyOfts.push(0x5Bff88cA1442c2496f7E475E9e7786383Bc070c0); // sFRAX | ||
|
||
// deploySource(); | ||
setupSource(); | ||
setupDestinations(); | ||
} | ||
|
||
/// @dev only set peers, simulate instead of broadcast | ||
function setupSource() public override simulateAndWriteTxs(activeConfig) { | ||
// setEnforcedOptions({ | ||
// _connectedOfts: proxyOfts, | ||
// _configs: configs | ||
// }); | ||
|
||
// setDVNs({ | ||
// _connectedConfig: activeConfig, | ||
// _connectedOfts: proxyOfts, | ||
// _configs: configs | ||
// }); | ||
|
||
/// @dev legacy, non-upgradeable OFTs | ||
setPeers({ | ||
_connectedOfts: proxyOfts, | ||
_peerOfts: legacyOfts, | ||
_configs: legacyConfigs | ||
}); | ||
/// @dev Upgradeable OFTs maintaining the same address cross-chain. | ||
setPeers({ | ||
_connectedOfts: proxyOfts, | ||
_peerOfts: proxyOfts, | ||
_configs: proxyConfigs | ||
}); | ||
|
||
// setPriviledgedRoles(); | ||
} | ||
|
||
/// @dev only set peers | ||
function setupDestination( | ||
L0Config memory _connectedConfig, | ||
address[] memory _connectedOfts | ||
) public override simulateAndWriteTxs(_connectedConfig) { | ||
// setEnforcedOptions({ | ||
// _connectedOfts: _connectedOfts, | ||
// _configs: activeConfigArray | ||
// }); | ||
|
||
// setDVNs({ | ||
// _connectedConfig: _connectedConfig, | ||
// _connectedOfts: _connectedOfts, | ||
// _configs: activeConfigArray | ||
// }); | ||
|
||
setPeers({ | ||
_connectedOfts: _connectedOfts, | ||
_peerOfts: proxyOfts, | ||
_configs: activeConfigArray | ||
}); | ||
} | ||
|
||
/// @dev override peer address to address(0) | ||
function setPeers( | ||
address[] memory _connectedOfts, | ||
address[] memory _peerOfts, | ||
L0Config[] memory _configs | ||
) public override { | ||
require(_connectedOfts.length == _peerOfts.length, "Must wire equal amount of source + dest addrs"); | ||
for (uint256 o=0; o<_connectedOfts.length; o++) { | ||
address connectedOft = _connectedOfts[o]; | ||
address peerOft = _peerOfts[o]; | ||
for (uint256 c=0; c<_configs.length; c++) { | ||
uint32 eid = uint32(_configs[c].eid); | ||
|
||
// cannot set peer to self | ||
if (chainid == activeConfig.chainid && eid == activeConfig.eid) continue; | ||
|
||
bytes memory data = abi.encodeCall( | ||
IOAppCore.setPeer, | ||
( | ||
// eid, addressToBytes32(peerOft) | ||
eid, addressToBytes32(address(0)) | ||
) | ||
); | ||
(bool success, ) = connectedOft.call(data); | ||
require(success, "Unable to setPeer"); | ||
serializedTxs.push( | ||
SerializedTx({ | ||
name: "setPeer", | ||
to: connectedOft, | ||
value: 0, | ||
data: data | ||
}) | ||
); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.22; | ||
|
||
import "../DeployFraxOFTProtocol/DeployFraxOFTProtocol.s.sol"; | ||
import { OFTUpgradeableMock } from "contracts/mocks/OFTUpgradeableMock.sol"; | ||
|
||
contract DeployMockOFT is DeployFraxOFTProtocol { | ||
using OptionsBuilder for bytes; | ||
using stdJson for string; | ||
using Strings for uint256; | ||
|
||
/// @dev override to only use FRAX, sFRAX as peer | ||
function setUp() public virtual override { | ||
chainid = block.chainid; | ||
loadJsonConfig(); | ||
|
||
delete legacyOfts; | ||
legacyOfts.push(0x909DBdE1eBE906Af95660033e478D59EFe831fED); // FRAX | ||
legacyOfts.push(0x1f55a02A049033E3419a8E2975cF3F572F4e6E9A); // sFRAX | ||
} | ||
|
||
/// @dev override to alter file save location | ||
modifier simulateAndWriteTxs(L0Config memory _config) override { | ||
// Clear out arrays | ||
delete enforcedOptionsParams; | ||
delete setConfigParams; | ||
delete serializedTxs; | ||
|
||
vm.createSelectFork(_config.RPC); | ||
chainid = _config.chainid; | ||
vm.startPrank(_config.delegate); | ||
_; | ||
vm.stopPrank(); | ||
|
||
// create filename and save | ||
string memory root = vm.projectRoot(); | ||
root = string.concat(root, "/scripts/UpgradeFrax/txs/"); | ||
string memory filename = string.concat("1_DeployMockOFT-", activeConfig.chainid.toString()); | ||
filename = string.concat(filename, "-"); | ||
filename = string.concat(filename, _config.chainid.toString()); | ||
filename = string.concat(filename, ".json"); | ||
|
||
new SafeTxUtil().writeTxs(serializedTxs, string.concat(root, filename)); | ||
} | ||
|
||
/// @dev only setup Ethereum destination | ||
function setupDestinations() public override { | ||
for (uint256 i=0; i<legacyConfigs.length; i++) { | ||
L0Config memory connectedConfig = legacyConfigs[i]; | ||
if (connectedConfig.chainid == 1) { | ||
setupDestination({ | ||
_connectedConfig: connectedConfig, | ||
_connectedOfts: legacyOfts | ||
}); | ||
} | ||
} | ||
} | ||
|
||
/// @dev simple checks override | ||
function postDeployChecks() public override view { | ||
require(fraxOft != address(0)); | ||
require(sFraxOft != address(0)); | ||
} | ||
|
||
/// @dev only deploy the mock FRAX and sFRAX | ||
function deployFraxOFTUpgradeablesAndProxies() broadcastAs(oftDeployerPK) public override { | ||
// already deployed | ||
proxyAdmin = 0x223a681fc5c5522c85C96157c0efA18cd6c5405c; | ||
implementationMock = 0x8f1B9c1fd67136D525E14D96Efb3887a33f16250; | ||
|
||
// deploy frax | ||
(, fraxOft) = deployFraxOFTUpgradeableAndProxy({ | ||
_name: "Mock Frax", | ||
_symbol: "mFRAX" | ||
}); | ||
|
||
// deploy sFrax | ||
(, sFraxOft) = deployFraxOFTUpgradeableAndProxy({ | ||
_name: "Mock sFrax", | ||
_symbol: "msFrax" | ||
}); | ||
} | ||
|
||
/// @dev override the bytecode to the mock contract | ||
function deployFraxOFTUpgradeableAndProxy( | ||
string memory _name, | ||
string memory _symbol | ||
) public override returns (address implementation, address proxy) { | ||
/// @dev override here | ||
bytes memory bytecode = bytes.concat( | ||
abi.encodePacked(type(OFTUpgradeableMock).creationCode), | ||
abi.encode(activeConfig.endpoint) | ||
); | ||
assembly { | ||
implementation := create(0, add(bytecode, 0x20), mload(bytecode)) | ||
if iszero(extcodesize(implementation)) { | ||
revert(0, 0) | ||
} | ||
} | ||
proxy = address(new TransparentUpgradeableProxy(implementationMock, vm.addr(oftDeployerPK), "")); | ||
|
||
bytes memory initializeArgs = abi.encodeWithSelector( | ||
FraxOFTUpgradeable.initialize.selector, | ||
_name, | ||
_symbol, | ||
vm.addr(configDeployerPK) | ||
); | ||
TransparentUpgradeableProxy(payable(proxy)).upgradeToAndCall({ | ||
newImplementation: implementation, | ||
data: initializeArgs | ||
}); | ||
TransparentUpgradeableProxy(payable(proxy)).changeAdmin(proxyAdmin); | ||
proxyOfts.push(proxy); | ||
|
||
// State checks | ||
require( | ||
isStringEqual(FraxOFTUpgradeable(proxy).name(), _name), | ||
"OFT name incorrect" | ||
); | ||
require( | ||
isStringEqual(FraxOFTUpgradeable(proxy).symbol(), _symbol), | ||
"OFT symbol incorrect" | ||
); | ||
require( | ||
address(FraxOFTUpgradeable(proxy).endpoint()) == activeConfig.endpoint, | ||
"OFT endpoint incorrect" | ||
); | ||
require( | ||
EndpointV2(activeConfig.endpoint).delegates(proxy) == vm.addr(configDeployerPK), | ||
"Endpoint delegate incorrect" | ||
); | ||
require( | ||
FraxOFTUpgradeable(proxy).owner() == vm.addr(configDeployerPK), | ||
"OFT owner incorrect" | ||
); | ||
} | ||
|
||
/// @dev proxy admin already deployed - do not transfer ownership | ||
function setPriviledgedRoles() public override { | ||
for (uint256 o=0; o<proxyOfts.length; o++) { | ||
address proxyOft = proxyOfts[o]; | ||
FraxOFTUpgradeable(proxyOft).setDelegate(activeConfig.delegate); | ||
Ownable(proxyOft).transferOwnership(activeConfig.delegate); | ||
} | ||
|
||
// Ownable(proxyAdmin).transferOwnership(activeConfig.delegate); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
scripts/UpgradeFrax/txs/1_DisconnectEthereumPeer-252-1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"chainId": 1, | ||
"createdAt": 1731693971000, | ||
"meta": { | ||
"description": "", | ||
"name": "Transactions Batch" | ||
}, | ||
"transactions": [{"data":"0x3400288b000000000000000000000000000000000000000000000000000000000000762f0000000000000000000000000000000000000000000000000000000000000000","operation":"0","to":"0x909DBdE1eBE906Af95660033e478D59EFe831fED","value":"0"},{"data":"0x3400288b000000000000000000000000000000000000000000000000000000000000762f0000000000000000000000000000000000000000000000000000000000000000","operation":"0","to":"0x1f55a02A049033E3419a8E2975cF3F572F4e6E9A","value":"0"}], | ||
"version": "1.0" | ||
} |
10 changes: 10 additions & 0 deletions
10
scripts/UpgradeFrax/txs/1_DisconnectEthereumPeer-252-1088.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"chainId": 1088, | ||
"createdAt": 1731693986000, | ||
"meta": { | ||
"description": "", | ||
"name": "Transactions Batch" | ||
}, | ||
"transactions": [{"data":"0x3400288b000000000000000000000000000000000000000000000000000000000000762f0000000000000000000000000000000000000000000000000000000000000000","operation":"0","to":"0x909DBdE1eBE906Af95660033e478D59EFe831fED","value":"0"},{"data":"0x3400288b000000000000000000000000000000000000000000000000000000000000762f0000000000000000000000000000000000000000000000000000000000000000","operation":"0","to":"0x1f55a02A049033E3419a8E2975cF3F572F4e6E9A","value":"0"}], | ||
"version": "1.0" | ||
} |
Oops, something went wrong.