Skip to content

Commit

Permalink
fix: kras deployment script fix (#454)
Browse files Browse the repository at this point in the history
* fix kras deployment script

* revert kras.json

* revert stage.json

* fix compare script
  • Loading branch information
crystalbit committed Jun 18, 2024
1 parent 256f50c commit 49ad3df
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ deploy-contracts-dar: ## Deploy to dar (IPC)

deploy-contracts-kras: ## Deploy to kras (IPC)
@make verify-command program=forge
@CONTRACTS_ENV_NAME=kras forge script script/Deploy.s.sol --rpc-url kras \
@CONTRACTS_ENV_NAME=kras forge script script/DeployKras.s.sol --rpc-url kras \
--private-key $(PRIVATE_KEY) --broadcast --skip-simulation --slow

@echo "\033[0;32mSuccess! Contracts deployed to $* chain.\033[0m"
Expand Down
4 changes: 1 addition & 3 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ extra_output = ["devdoc", "storageLayout"]

[rpc_endpoints]
local = "http://0.0.0.0:8545"
arbutrum = "http://0.0.0.0:8545"
stage = "https://ipc-stage.fluence.dev"
stage = "https://ipc.stage.fluence.dev"
dar = "https://ipc.dar.fluence.dev"
kras = "https://ipc.kras.fluence.dev"
mumbai = "https://rpc.ankr.com/polygon_mumbai"

[profile.test]
src = "test"
Expand Down
8 changes: 4 additions & 4 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ contract DeployContracts is Deployment, Script {
IERC20 tUSD = _deployTestTokens();

// Deploy Multicall3 as **helper** contract to fetch info only from the chain.
// Thus, this contract is not belongs to Fluence contract ecosystem.
// Thus, this contract does not belong to Fluence contract ecosystem.
_deployMulticall3();

if (env.chainId == LOCAL_CHAIN_ID) {
Expand Down Expand Up @@ -148,7 +148,7 @@ contract DeployContracts is Deployment, Script {
uint256 minProtocolVersion = vm.envOr("MIN_PROTOCOL_VERSION", DEFAULT_MIN_PROTOCOL_VERSION);
uint256 maxProtocolVersion = vm.envOr("MAX_PROTOCOL_VERSION", DEFAULT_MAX_PROTOCOL_VERSION);

uint256 fltPice = vm.envOr("FLT_PRICE", DEFAULT_FLT_PRICE);
uint256 fltPrice = vm.envOr("FLT_PRICE", DEFAULT_FLT_PRICE);
uint256 usdCollateralPerUnit = vm.envOr("USD_COLLATERAL_PER_UNIT", DEFAULT_USD_COLLATERAL_PER_UNIT);
uint256 usdTargetRevenuePerEpoch =
vm.envOr("USD_TARGET_REVENUE_PER_EPOCH", DEFAULT_USD_TARGET_REVENUE_PER_EPOCH);
Expand Down Expand Up @@ -178,7 +178,7 @@ contract DeployContracts is Deployment, Script {
console.log(StdStyle.blue("MIN_PROTOCOL_VERSION:"), minProtocolVersion);
console.log(StdStyle.blue("MAX_PROTOCOL_VERSION:"), maxProtocolVersion);

console.log(StdStyle.blue("FLT_PRICE:"), fltPice);
console.log(StdStyle.blue("FLT_PRICE:"), fltPrice);
console.log(StdStyle.blue("USD_COLLATERAL_PER_UNIT:"), usdCollateralPerUnit);
console.log(StdStyle.blue("USD_TARGET_REVENUE_PER_EPOCH:"), usdTargetRevenuePerEpoch);
console.log(StdStyle.blue("MIN_DURATION:"), minDuration);
Expand Down Expand Up @@ -207,7 +207,7 @@ contract DeployContracts is Deployment, Script {
minRematchingEpochs: minRematchingEpochs,
minProtocolVersion: minProtocolVersion,
maxProtocolVersion: maxProtocolVersion,
fltPrice: fltPice,
fltPrice: fltPrice,
usdCollateralPerUnit: usdCollateralPerUnit,
usdTargetRevenuePerEpoch: usdTargetRevenuePerEpoch,
minDuration: minDuration,
Expand Down
58 changes: 26 additions & 32 deletions script/DeployKras.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,15 @@ pragma solidity ^0.8.19;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "forge-std/Script.sol";
import "forge-std/Vm.sol";
import "src/deal/Deal.sol";
import "src/core/Core.sol";
import "src/dev/OwnableFaucet.sol";
import "src/dev/TestERC20.sol";
import "./utils/Depoyments.sol";
import "./utils/Deployment.sol";
import "src/core/Core.sol";
import "src/core/interfaces/ICore.sol";
import "src/core/modules/market/Market.sol";
import "src/core/modules/market/DealFactory.sol";
import "src/core/modules/market/interfaces/IMarket.sol";
import "src/core/modules/capacity/Capacity.sol";
import "src/core/modules/capacity/interfaces/ICapacity.sol";
import "src/utils/Multicall3.sol";

contract DeployKras is Depoyments, Script {
contract DeployKras is Deployment, Script {
using SafeERC20 for IERC20;

// ------------------ Default constant ------------------
Expand Down Expand Up @@ -74,7 +65,7 @@ contract DeployKras is Depoyments, Script {
console.log("\nStart deploying...");
console.log("Deployer address:", address(msg.sender));

Multicall3(_deployContract("Multicall3", "Multicall3", abi.encode()));
_deployContract("Multicall3", "Multicall3", abi.encode());
address randomXProxy = _deployContract("RandomXProxy", "RandomXProxy", new bytes(0));

address coreImpl = _deployContract("CoreImpl", "Core", new bytes(0));
Expand All @@ -94,22 +85,25 @@ contract DeployKras is Depoyments, Script {
MAX_PROTOCOL_VERSION,
dealImpl,
IS_WHITELIST_ENABLED,
FLT_PRICE,
USD_COLLATERAL_PER_UNIT,
USD_TARGET_REVENUE_PER_EPOCH,
MIN_DURATION,
MIN_REWARD_PER_EPOCH,
MAX_REWARD_PER_EPOCH,
VESTING_PERIOD_DURATION,
VESTING_PERIOD_COUNT,
SLASHING_RATE,
MIN_PROOFS_PER_EPOCH,
MAX_PROOFS_PER_EPOCH,
WITHDRAW_EPOCHS_AFTER_FAILED,
MAX_FAILED_RATIO,
DIFFICULTY,
INIT_REWARD_POOL,
randomXProxy
ICapacityConst.CapacityConstInitArgs({
fltPrice: FLT_PRICE,
usdCollateralPerUnit: USD_COLLATERAL_PER_UNIT,
usdTargetRevenuePerEpoch: USD_TARGET_REVENUE_PER_EPOCH,
minDuration: MIN_DURATION,
minRewardPerEpoch: MIN_REWARD_PER_EPOCH,
maxRewardPerEpoch: MAX_REWARD_PER_EPOCH,
vestingPeriodDuration: VESTING_PERIOD_DURATION,
vestingPeriodCount: VESTING_PERIOD_COUNT,
slashingRate: SLASHING_RATE,
minProofsPerEpoch: MIN_PROOFS_PER_EPOCH,
maxProofsPerEpoch: MAX_PROOFS_PER_EPOCH,
withdrawEpochsAfterFailed: WITHDRAW_EPOCHS_AFTER_FAILED,
maxFailedRatio: MAX_FAILED_RATIO,
difficulty: DIFFICULTY,
initRewardPool: INIT_REWARD_POOL,
randomXProxy: randomXProxy,
oracle: address(0)
})
)
)
);
Expand All @@ -119,19 +113,19 @@ contract DeployKras is Depoyments, Script {
address dealFactoryImpl = _deployContract("DealFactoryImpl", "DealFactory", abi.encode(coreAddr));

address marketProxy = _deployContract(
"Market", "ERC1967Proxy", abi.encode(marketImpl, abi.encodeWithSelector(Market.initialize.selector))
"Market", "ERC1967Proxy", abi.encode(marketImpl, abi.encodeWithSelector(IMarket.initialize.selector))
);
address capacityProxy = _deployContract(
"Capacity",
"ERC1967Proxy",
abi.encode(
capacityImpl, abi.encodeWithSelector(Capacity.initialize.selector, INIT_GLOBAL_NONCE, randomXProxy)
capacityImpl, abi.encodeWithSelector(ICapacity.initialize.selector, INIT_GLOBAL_NONCE, randomXProxy)
)
);
address dealFactoryProxy = _deployContract(
"DealFactory",
"ERC1967Proxy",
abi.encode(dealFactoryImpl, abi.encodeWithSelector(DealFactory.initialize.selector))
abi.encode(dealFactoryImpl, abi.encodeWithSelector(IDealFactory.initialize.selector))
);

(bool success,) = address(capacityProxy).call{value: INIT_CC_BALANCE}(new bytes(0));
Expand All @@ -143,7 +137,7 @@ contract DeployKras is Depoyments, Script {
);

_printDeployments();
_saveDeployments(fullDeploymentsPath);
_saveDeployment(fullDeploymentsPath);

vm.stopBroadcast();
console.log("\nDeploy finished");
Expand Down
7 changes: 5 additions & 2 deletions storage-checker/compare.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ const prevFiles = Object.keys(prevStorageLayout);
const files = fs
.readdirSync(outDir)
.map((dir) => {
if (!fs.lstatSync(path.join(outDir, dir)).isDirectory()) {
if (
!fs.lstatSync(path.join(outDir, dir)).isDirectory() ||
dir === "build-info"
) {
return "";
}
return fs.readdirSync(path.join(outDir, dir)).map((file) => {
Expand All @@ -42,7 +45,7 @@ for (const file of files) {
}
const data = fs.readFileSync(filePath, "utf8");
const json = JSON.parse(data);
const layout = json.storageLayout.storage;
const layout = json.storageLayout?.storage ?? [];
storageLayout[file] = layout;
if (!prevFiles.includes(file)) {
console.log("New file: ", file);
Expand Down

0 comments on commit 49ad3df

Please sign in to comment.