Skip to content

Commit

Permalink
Merge pull request #15 from ronin-chain/feature/mainnet-deploy-script
Browse files Browse the repository at this point in the history
feat: mainnet deploy script
  • Loading branch information
thaixuandang authored Nov 21, 2024
2 parents 21294b4 + d8c6679 commit 00bc0ce
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 37 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ deploy-testnet:

deploy-testnet-broadcast:
op run --env-file="./.env" -- \
forge script DeployKatanaOperationTestnet -f ronin-testnet --verify --verifier sourcify --verifier-url https://sourcify.roninchain.com/server/ --legacy --broadcast
forge script DeployKatanaOperationTestnet -f ronin-testnet --verify --verifier sourcify --verifier-url https://sourcify.roninchain.com/server/ --legacy --broadcast

deploy-mainnet:
forge script DeployKatanaOperationMainnet -f ronin-mainnet -t

deploy-mainnet-broadcast:
forge script DeployKatanaOperationMainnet -f ronin-mainnet --verify --verifier sourcify --verifier-url https://sourcify.roninchain.com/server/ --legacy --broadcast -t
2 changes: 1 addition & 1 deletion lib/permit2x
44 changes: 22 additions & 22 deletions logs/contract-code-sizes.log
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
| Contract | Size (B) | Margin (B) |
|-----------------------------|----------|------------|
| Address | 58 | 24,518 |
| AggregateRouter | 13,859 | 10,717 |
| BytesLib | 58 | 24,518 |
| Commands | 58 | 24,518 |
| Constants | 58 | 24,518 |
| ERC1967Proxy | 145 | 24,431 |
| ERC1967Utils | 58 | 24,518 |
| EnumerableSet | 58 | 24,518 |
| KatanaGovernance | 11,049 | 13,527 |
| KatanaImmutables | 58 | 24,518 |
| KatanaV2Library | 58 | 24,518 |
| LockAndMsgSender | 58 | 24,518 |
| PaymentsImmutables | 58 | 24,518 |
| ProxyAdmin | 1,478 | 23,098 |
| SafeCast | 58 | 24,518 |
| SafeCast160 | 58 | 24,518 |
| SafeTransferLib | 58 | 24,518 |
| StorageSlot | 58 | 24,518 |
| TransparentUpgradeableProxy | 1,223 | 23,353 |
| V3Path | 58 | 24,518 |
| Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) |
|-----------------------------|------------------|-------------------|--------------------|---------------------|
| Address | 58 | 87 | 24,518 | 49,065 |
| AggregateRouter | 13,859 | 14,525 | 10,717 | 34,627 |
| BytesLib | 58 | 87 | 24,518 | 49,065 |
| Commands | 58 | 87 | 24,518 | 49,065 |
| Constants | 58 | 87 | 24,518 | 49,065 |
| ERC1967Proxy | 145 | 721 | 24,431 | 48,431 |
| ERC1967Utils | 58 | 87 | 24,518 | 49,065 |
| EnumerableSet | 58 | 87 | 24,518 | 49,065 |
| KatanaGovernance | 11,049 | 11,265 | 13,527 | 37,887 |
| KatanaImmutables | 58 | 363 | 24,518 | 48,789 |
| KatanaV2Library | 58 | 87 | 24,518 | 49,065 |
| LockAndMsgSender | 58 | 102 | 24,518 | 49,050 |
| PaymentsImmutables | 58 | 279 | 24,518 | 48,873 |
| ProxyAdmin | 1,478 | 1,694 | 23,098 | 47,458 |
| SafeCast | 58 | 87 | 24,518 | 49,065 |
| SafeCast160 | 58 | 87 | 24,518 | 49,065 |
| SafeTransferLib | 58 | 87 | 24,518 | 49,065 |
| StorageSlot | 58 | 87 | 24,518 | 49,065 |
| TransparentUpgradeableProxy | 1,223 | 3,790 | 23,353 | 45,362 |
| V3Path | 58 | 87 | 24,518 | 49,065 |

28 changes: 25 additions & 3 deletions script/UpgradeKatanaGovernance.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ pragma solidity ^0.8.17;
import { Script, console } from "forge-std/Script.sol";
import { ITransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import { KatanaGovernance } from "@katana/operation-contracts/governance/KatanaGovernance.sol";
import { ProxyAdmin } from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import { ISpenderPermit } from "permit2/src/interfaces/ISpenderPermit.sol";
import { DeployAggregateRouter } from "./DeployAggregateRouter.s.sol";

abstract contract UpgradeKatanaGovernance is DeployAggregateRouter {
address public nonfungiblePositionManager;
address public v3Migrator;
address public legacyPermissionedRouter;
address public katanaGovernanceProxy;
address public multisig;
address public proxyAdmin;

address public katanaGovernanceLogic;
Expand All @@ -20,6 +23,7 @@ abstract contract UpgradeKatanaGovernance is DeployAggregateRouter {
require(v3Migrator != address(0));
require(legacyPermissionedRouter != address(0));
require(katanaGovernanceProxy != address(0));
require(multisig != address(0));
require(proxyAdmin != address(0));

super.setUp();
Expand All @@ -31,17 +35,35 @@ abstract contract UpgradeKatanaGovernance is DeployAggregateRouter {
vm.broadcast();
katanaGovernanceLogic = address(new KatanaGovernance());
console.log("Katana Governance (logic) deployed:", katanaGovernanceLogic);
console.log("");

console.log("Please upgrade to Katana Governance (logic) using ProxyAdmin", proxyAdmin);
console.log("----------------------------------------------------------------");
console.log("[Proposal] Upgrade to Katana Governance");
console.log("From:", multisig);
console.log("To:", proxyAdmin);
console.log(
"Data:",
vm.toString(
abi.encodeCall(
KatanaGovernance.initializeV2,
(params.v3Factory, nonfungiblePositionManager, v3Migrator, legacyPermissionedRouter, router)
ProxyAdmin.upgradeAndCall,
(
ITransparentUpgradeableProxy(katanaGovernanceProxy),
katanaGovernanceLogic,
abi.encodeCall(
KatanaGovernance.initializeV2,
(params.v3Factory, nonfungiblePositionManager, v3Migrator, legacyPermissionedRouter, router)
)
)
)
)
);
console.log("");

console.log("----------------------------------------------------------------");
console.log("[Proposal] Set AggregateRouter as a permitted spender in Permit2");
console.log("From:", multisig);
console.log("To:", params.permit2);
console.log("Data:", vm.toString(abi.encodeCall(ISpenderPermit.permitSpender, (router, true))));
}

function logParams() internal view override {
Expand Down
18 changes: 9 additions & 9 deletions script/ronin-mainnet/DeployKatanaOperationMainnet.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ import { UpgradeKatanaGovernance } from "../UpgradeKatanaGovernance.s.sol";
contract DeployKatanaOperationMainnet is UpgradeKatanaGovernance {
function setUp() public override {
params = RouterParameters({
permit2: 0x000000000022D473030F116dDEE9F6B43aC78BA3,
permit2: 0x771CA29e483Df5447E20a89e0F00E1DAF09eF534, // Permit2
weth9: 0xe514d9DEB7966c8BE0ca922de8a064264eA6bcd4, // WRON
governance: 0x2C1726346d83cBF848bD3C2B208ec70d32a9E44a,
governance: 0x2C1726346d83cBF848bD3C2B208ec70d32a9E44a, // KatanaGovernance
v2Factory: 0xB255D6A720BB7c39fee173cE22113397119cB930, // KatanaV2Factory
v3Factory: address(0), // TODO: To be deployed
v3Factory: 0x1f0B70d9A137e3cAEF0ceAcD312BC5f81Da0cC0c, // KatanaV3Factory
pairInitCodeHash: 0xe85772d2fe4ad93037659afaee57751696456eb5dd99987e43f3cf11c6e255a2,
poolInitCodeHash: 0xb381dabeb6037396a764deb39e57a4a3f75b641ce3e9944b1e4b18d036e322e1
});

proxyAdmin = 0xA3e7d085E65CB0B916f6717da876b7bE5cC92f03; // Proxy Admin
nonfungiblePositionManager = address(0); // TODO: To be deployed
v3Migrator = address(0); // TODO: To be deployed
legacyPermissionedRouter = 0xC05AFC8c9353c1dd5f872EcCFaCD60fd5A2a9aC7;
katanaGovernanceProxy = 0x2C1726346d83cBF848bD3C2B208ec70d32a9E44a;
multisig = 0x9D05D1F5b0424F8fDE534BC196FFB6Dd211D902a; // Multisig
proxyAdmin = 0xA3e7d085E65CB0B916f6717da876b7bE5cC92f03; // ProxyAdmin

vm.rememberKey(vm.envUint("MAINNET_PK"));
nonfungiblePositionManager = 0x7cF0fb64d72b733695d77d197c664e90D07cF45A; // NonfungiblePositionManager
v3Migrator = 0x0124c9Ce7E77eD166f6d53AF679B491555b5C0F7; // V3Migrator
legacyPermissionedRouter = 0xC05AFC8c9353c1dd5f872EcCFaCD60fd5A2a9aC7; // Legacy PermissionedRouter
katanaGovernanceProxy = 0x2C1726346d83cBF848bD3C2B208ec70d32a9E44a;

super.setUp();
}
Expand Down
1 change: 1 addition & 0 deletions script/ronin-testnet/DeployKatanaOperationTestnet.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ contract DeployKatanaOperationTestnet is UpgradeKatanaGovernance {
poolInitCodeHash: 0xb381dabeb6037396a764deb39e57a4a3f75b641ce3e9944b1e4b18d036e322e1
});

multisig = 0x968D0Cd7343f711216817E617d3f92a23dC91c07;
proxyAdmin = 0x505d91E8fd2091794b45b27f86C045529fa92CD7;

nonfungiblePositionManager = 0x7C2716803c09cd5eeD78Ba40117084af3c803565;
Expand Down

0 comments on commit 00bc0ce

Please sign in to comment.