Skip to content

Commit

Permalink
Feat/support non evm (#22)
Browse files Browse the repository at this point in the history
* feat: init solana

* feat: initial solana output

* chore: fmt txs

* fix: solana config

* feat: support non-evm deployment
  • Loading branch information
pegahcarter authored Nov 27, 2024
1 parent e35a227 commit b2c3c4c
Show file tree
Hide file tree
Showing 8 changed files with 264 additions and 88 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,33 @@
- OFT Config: `BG9oPj76NRPbj1e1GbL4imnqo9VD7W2ukpnRFSWtq5CA`
- As bytes32: `0x9876880bee04a9020e619b1be124ee307e03ca94bab4f32a7a22cfd2ccee3927`

### Solana
- Admin: Chain-respective msig
- `FRAX`
- SPL Token: B4Ds2fCbxjSiVLNyGQd44htvvNuVxzdoJSxNsRv3nxpE
- OFT Config: 7pw5h3gc4LQCGPdq9qsqCdBDt6vtyk5CWjL9spsjp7Sa
- As bytes32: 0x656d91ab3d464c05cd1345ce21c78e36140a36491e102fbb08c58af73aafe89b
- `sFrax`
- SPL Token: DnVyztLHnDyTqL3xfPYF9Uqpgrhcxphn6e31sVAwtg6K
- OFT Config: 3BcysJF4fQx86fVTDTBGNpZyRpeMyTF8XsuvPHJQuP3V
- As bytes32: 0x206fdd7d0be90d8ff93f6f7f4bd4d8b42ca8977317da0b7d2861299e3c589dd8
- `sfrxETH`
- SPL Token: 6iHW2j5dvW8EiEVSXqQFjm7c5xNd4MdYuXLrW3eQ1UYw
- OFT Config: 8AdTghMT8yyNpWrTuPoDjrtXW7t1YEZgLVjWDftWfCxo
- As bytes32: 0x6a7942e4eb4938d5490d8187183d01123f515025f4244670aff7f8ecd2250d50
- `FXS`
- SPL Token: 8QRvtWw4XYQW7UqTiGhzyWZkhCqSwZDA5qjRWDotSZ4e
- OFT Config: 5KYEyuA1cAdnZFj4i6zUjTEre4s7snacyXbkTmNqLjJs
- As bytes32: 0x402e86d1cfd2cde4fac63aa8d9892eca6d3c0e08e8335622124332a95df6c10c
- `frxETH`
- SPL Token: CuXHLCxCcyPkmbemPxh7PAWedfFffeL82b6VPJmonTaa
- OFT Config: AzaSy9yr44e4bnWNdrNkxmye1kEYmbbgGfY8a3ZqzuMf
- As bytes32: 0x94791ba0aae2b57460c63d36346392d849b22f39fd3eafad5bc82d01e352dde6
- `FPI`
- SPL Token: FqRC7vNLS3ubbhtdqNSz8Q5ei8VdUxF6H6eoXQLHxihr
- OFT Config: BG9oPj76NRPbj1e1GbL4imnqo9VD7W2ukpnRFSWtq5CA
- As bytes32: 0x9876880bee04a9020e619b1be124ee307e03ca94bab4f32a7a22cfd2ccee3927

## New Chain Deployment
- Ensure `PK_OFT_DEPLOYER` and `PK_CONFIG_DEPLOYER` are the private keys for `0x9C9dD956b413cdBD81690c9394a6B4D22afe6745` and `0x0990be6dB8c785FBbF9deD8bAEc612A10CaE814b`, respectively.
- Modify `.env` `RPC_URL` to the new chain RPC
Expand Down
68 changes: 56 additions & 12 deletions scripts/BaseL0Script.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,24 @@ contract BaseL0Script is Script {
}
L0Config[] public legacyConfigs;
L0Config[] public proxyConfigs;
L0Config[] public configs; // legacy & proxy configs
L0Config[] public evmConfigs;
L0Config[] public nonEvmConfigs;
L0Config[] public allConfigs; // legacy, proxy, and non-evm allConfigs
L0Config public broadcastConfig; // config of actively-connected (broadcasting) chain
L0Config public simulateConfig; // Config of the simulated chain
L0Config[] public broadcastConfigArray; // length of 1 of broadcastConfig
bool public activeLegacy; // true if we're broadcasting to legacy chain
bool public activeLegacy; // true if we're broadcasting to legacy chain (setup by L0 team)

/// @dev alphabetical order as json is read in by keys alphabetically.
struct NonEvmPeer {
bytes32 fpi;
bytes32 frax;
bytes32 frxEth;
bytes32 fxs;
bytes32 sFrax;
bytes32 sFrxEth;
}
bytes32[][] public nonEvmPeersArrays;

// Mock implementation used to enable pre-determinsitic proxy creation
address public implementationMock;
Expand All @@ -73,9 +86,9 @@ contract BaseL0Script is Script {
// 1:1 match between these arrays for setting peers
address[] public legacyOfts;
address[] public expectedProxyOfts; // to assert against proxyOfts
address[] public proxyOfts;
address[] public proxyOfts; // the OFTs deployed through `DeployFraxOFTProtocol.s.sol`

EnforcedOptionParam[] public enforcedOptionsParams;
EnforcedOptionParam[] public enforcedOptionParams;

SetConfigParam[] public setConfigParams;

Expand All @@ -84,7 +97,7 @@ contract BaseL0Script is Script {
string public json;

function version() public virtual pure returns (uint256, uint256, uint256) {
return (1, 1, 3);
return (1, 2, 0);
}

modifier broadcastAs(uint256 privateKey) {
Expand All @@ -97,7 +110,7 @@ contract BaseL0Script is Script {
L0Config memory _simulateConfig
) virtual {
// Clear out any previous txs
delete enforcedOptionsParams;
delete enforcedOptionParams;
delete setConfigParams;
delete serializedTxs;

Expand Down Expand Up @@ -148,10 +161,11 @@ contract BaseL0Script is Script {

function loadJsonConfig() public virtual {
string memory root = vm.projectRoot();

// L0Config.json

string memory path = string.concat(root, "/scripts/L0Config.json");
json = vm.readFile(path);

// load and write to persistent storage

// legacy
L0Config[] memory legacyConfigs_ = abi.decode(json.parseRaw(".Legacy"), (L0Config[]));
Expand All @@ -163,7 +177,8 @@ contract BaseL0Script is Script {
activeLegacy = true;
}
legacyConfigs.push(config_);
configs.push(config_);
allConfigs.push(config_);
evmConfigs.push(config_);
}

// proxy (active deployment loaded as broadcastConfig)
Expand All @@ -176,10 +191,39 @@ contract BaseL0Script is Script {
activeLegacy = false;
}
proxyConfigs.push(config_);
configs.push(config_);
allConfigs.push(config_);
evmConfigs.push(config_);
}

// Non-EVM allConfigs
/// @dev as foundry cannot deploy to non-evm, a non-evm chain will never be the active/connected chain
L0Config[] memory nonEvmConfigs_ = abi.decode(json.parseRaw(".Non-EVM"), (L0Config[]));
for (uint256 i=0; i<nonEvmConfigs_.length; i++) {
L0Config memory config_ = nonEvmConfigs_[i];
nonEvmConfigs.push(config_);
allConfigs.push(config_);
}

// NonEvmPeers.json

path = string.concat(root, "/scripts/NonEvmPeers.json");
json = vm.readFile(path);

NonEvmPeer[] memory nonEvmPeers = abi.decode(json.parseRaw(".Peers"), (NonEvmPeer[]));

// As json has to be ordered alphabetically, sort the peer addresses in the order of OFT deployment
for (uint256 i=0; i<nonEvmPeers.length; i++) {
NonEvmPeer memory peer = nonEvmPeers[i];
bytes32[] memory peerArray = new bytes32[](6);
peerArray[0] = peer.fxs;
peerArray[1] = peer.sFrax;
peerArray[2] = peer.sFrxEth;
peerArray[3] = peer.frax;
peerArray[4] = peer.frxEth;
peerArray[5] = peer.fpi;

nonEvmPeersArrays.push(peerArray);
}
require(broadcastConfig.chainid != 0, "L0Config not set for broadcastConfig");
require(broadcastConfigArray.length == 1, "broadcastConfigArray does not equal 1");
}

function isStringEqual(string memory _a, string memory _b) public pure returns (bool) {
Expand Down
Loading

0 comments on commit b2c3c4c

Please sign in to comment.