Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge beta #1552

Merged
merged 33 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6018e82
Merge pull request #1513 from skalenetwork/develop
DmytroNazarenko Jun 26, 2023
4456a21
Merge pull request #1524 from skalenetwork/develop
DmytroNazarenko Jul 3, 2023
15cd13a
Merge pull request #1527 from skalenetwork/develop
DmytroNazarenko Jul 4, 2023
7c93034
Merge pull request #1529 from skalenetwork/develop
DmytroNazarenko Jul 7, 2023
5bec65f
Update upgrade-tools
DimaStebaev Jul 25, 2023
a66e4ad
Update ethers
DimaStebaev Aug 2, 2023
b60c6ae
Fix solidity-ast issue
DimaStebaev Aug 2, 2023
acbaf3b
List external artifacts
DimaStebaev Aug 2, 2023
ba73ec6
Fix imports
DimaStebaev Aug 2, 2023
174ce4a
Remove web3
DimaStebaev Aug 2, 2023
c8f8556
Update ganache
DimaStebaev Aug 2, 2023
188ebe4
Update ganache launch command
DimaStebaev Aug 3, 2023
47c4491
Fix typo
DimaStebaev Aug 3, 2023
b4fd8a8
Remove estimateGas call when deploy large smart contract to schain
DimaStebaev Aug 3, 2023
400a475
Fix provider issue
DimaStebaev Aug 3, 2023
b5b12f1
Merge pull request #1544 from skalenetwork/develop
DmytroNazarenko Aug 3, 2023
d06f8a3
Add eslint
DimaStebaev Aug 4, 2023
d0b765b
Remove unused vars
DimaStebaev Aug 4, 2023
bb28fb2
Remove unused vars
DimaStebaev Aug 4, 2023
d52b29a
Remove explicit any
DimaStebaev Aug 4, 2023
5457873
Use const where possible
DimaStebaev Aug 4, 2023
d8a5974
Remove unnecessary semicolons
DimaStebaev Aug 4, 2023
c3d28ff
Replace require with readFile
DimaStebaev Aug 4, 2023
ba4801c
Fix paths
DimaStebaev Aug 4, 2023
a35841d
Add typings
DimaStebaev Aug 4, 2023
ba02f47
Replace tslint with eslint
DimaStebaev Aug 4, 2023
56d65a7
Add wait
DimaStebaev Aug 4, 2023
8b5c009
Replace tslint with eslint
DimaStebaev Aug 4, 2023
c3e2e35
Use stringKeccak256
DimaStebaev Aug 9, 2023
cd1d7a6
Merge pull request #1549 from skalenetwork/develop
DmytroNazarenko Aug 10, 2023
1f7d059
Merge pull request #1536 from skalenetwork/hotfix/upgrade-tools
DimaStebaev Aug 14, 2023
3947d50
Merge branch 'beta' into merge-beta
DimaStebaev Aug 14, 2023
7e652c6
Stop running geth in dev mode
DimaStebaev Aug 16, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:

- name: Lint typescript
working-directory: ${{env.working-directory}}
run: yarn tslint
run: yarn eslint

- name: Slither checks
working-directory: ${{env.working-directory}}
Expand Down Expand Up @@ -351,7 +351,7 @@ jobs:
- name: Start background ganache
run: |
cd proxy
NODE_OPTIONS="--max_old_space_size=3072" npx ganache-cli --gasLimit 12000000 --quiet --allowUnlimitedContractSize --defaultBalanceEther 2000000 --acctKeys ../test/accounts.json &
npx ganache --miner.blockGasLimit 12000000 --logging.quiet --chain.allowUnlimitedContractSize --wallet.defaultBalance 2000000 --wallet.accountKeysPath ../test/accounts.json &

- name: Prepare test (PY part)
working-directory: ${{env.working-directory}}
Expand Down
16 changes: 16 additions & 0 deletions proxy/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* eslint-env node */
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
root: true,
rules: {

},
ignorePatterns: [

]
};
4 changes: 0 additions & 4 deletions proxy/customTypes/typings.d.ts

This file was deleted.

34 changes: 13 additions & 21 deletions proxy/gas/calculateGas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ import {
TokenManagerLinker,
Wallets,
Linker,
IMessageProxy,
} from "../typechain";

chai.should();
chai.use((chaiAsPromised as any));
chai.use(chaiAsPromised);

import { deployLinker } from "../test/utils/deploy/mainnet/linker";
import { deployDepositBoxEth } from "../test/utils/deploy/mainnet/depositBoxEth";
Expand All @@ -70,14 +71,6 @@ import { deployERC721OnChain } from "../test/utils/deploy/erc721OnChain";
import { deployERC1155OnChain } from "../test/utils/deploy/erc1155OnChain";

import { deployContractManager } from "../test/utils/skale-manager-utils/contractManager";
// import { deployContractManager } from "../test/utils/skale-manager-utils/keyStorage";
// const KeyStorage: KeyStorageContract = artifacts.require("./KeyStorage");
// const Nodes: NodesContract = artifacts.require("./Nodes");
// const Schains: SchainsContract = artifacts.require("./Schains");
// const SchainsInternal: SchainsInternalContract = artifacts.require("./SchainsInternal");
// const SkaleVerifierMock: SkaleVerifierMockContract = artifacts.require("./SkaleVerifierMock");
// const Wallets: WalletsContract = artifacts.require("./Wallets");

import { deployTokenManagerLinker } from "../test/utils/deploy/schain/tokenManagerLinker";
import { deployTokenManagerEth } from "../test/utils/deploy/schain/tokenManagerEth";
import { deployTokenManagerERC20 } from "../test/utils/deploy/schain/tokenManagerERC20";
Expand All @@ -86,16 +79,15 @@ import { deployTokenManagerERC1155 } from "../test/utils/deploy/schain/tokenMana
import { deployMessageProxyForSchain } from "../test/utils/deploy/schain/messageProxyForSchain";
import { deployMessages } from "../test/utils/deploy/messages";

import { stringValue, getPublicKey } from "../test/utils/helper";
import { stringKeccak256, getPublicKey } from "../test/utils/helper";

import { ethers, web3 } from "hardhat";
import { ethers } from "hardhat";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address";
import { BigNumber, BytesLike, Wallet } from "ethers";
import { BigNumber, Wallet } from "ethers";

import { assert, expect } from "chai";
import { expect } from "chai";
import { deployCommunityLocker } from "../test/utils/deploy/schain/communityLocker";
import { deployCommunityPool } from "../test/utils/deploy/mainnet/communityPool";
// import { LockAndDataForSchain } from "../typechain/LockAndDataForSchain";

describe("Gas calculation", () => {
let deployer: SignerWithAddress;
Expand Down Expand Up @@ -138,7 +130,7 @@ describe("Gas calculation", () => {
let ERC1155TokenOnSchain: ERC1155OnChain;

const schainName = "GasCalculation";
const schainNameHash = web3.utils.soliditySha3("GasCalculation");
const schainNameHash = stringKeccak256("GasCalculation");
const contractManagerAddress = "0x0000000000000000000000000000000000000000";
const mainnetName = "Mainnet";

Expand Down Expand Up @@ -204,8 +196,8 @@ describe("Gas calculation", () => {

// initialize schain and data
await schainsInternal.connect(deployer).initializeSchain(schainName, schainOwner.address, 12345678, 12345678);
await schainsInternal.connect(deployer).addNodesToSchainsGroups(stringValue(schainNameHash), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
await wallets.connect(deployer).rechargeSchainWallet(stringValue(schainNameHash), {value: "1000000000000000000"});
await schainsInternal.connect(deployer).addNodesToSchainsGroups(schainNameHash, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
await wallets.connect(deployer).rechargeSchainWallet(schainNameHash, {value: "1000000000000000000"});

// set BLS Public Key to schain
// P.s. this is test public key from test of SkaleManager.SkaleVerifier - please do not use it!!!
Expand All @@ -219,7 +211,7 @@ describe("Gas calculation", () => {
b: "14411459380456065006136894392078433460802915485975038137226267466736619639091",
}
}
await keyStorage.connect(deployer).setBlsCommonPublicKeyForSchain(stringValue(schainNameHash), BLSPublicKey);
await keyStorage.connect(deployer).setBlsCommonPublicKeyForSchain(schainNameHash, BLSPublicKey);
// await wallets.rechargeSchainWallet(stringValue(schainNameHash), {value: "1000000000000000000"});

// IMA mainnet part deployment
Expand Down Expand Up @@ -569,7 +561,7 @@ describe("Gas calculation", () => {
hashB: "15163860114293529009901628456926790077787470245128337652112878212941459329347",
};

async function postIncomingMessages(startingCounter: number, arrayOfMessages: any, action: string) {
async function postIncomingMessages(startingCounter: number, arrayOfMessages: IMessageProxy.MessageStruct[], action: string) {
const res = await (await messageProxyForMainnet.connect(nodeAddress).postIncomingMessages(
schainName,
startingCounter,
Expand Down Expand Up @@ -1091,7 +1083,7 @@ describe("Gas calculation", () => {
async function checkBalance() {
const balanceIds = await ERC1155TokenOnMainnet.balanceOfBatch([user.address, user.address, user.address, user.address, user.address], [1, 2, 3, 4, 5]);
const balanceIdsNumber: number[] = [];
balanceIds.forEach((element: any) => {
balanceIds.forEach((element) => {
balanceIdsNumber.push(BigNumber.from(element).toNumber())
});
expect(balanceIdsNumber).to.deep.equal([1, 2, 3, 4, 5]);
Expand Down Expand Up @@ -1225,4 +1217,4 @@ describe("Gas calculation", () => {
});
});
});
});
});
9 changes: 6 additions & 3 deletions proxy/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { HardhatUserConfig, task } from "hardhat/config";
import { HardhatUserConfig } from "hardhat/config";
import "@nomiclabs/hardhat-etherscan";
import "@nomiclabs/hardhat-waffle";
import "@nomiclabs/hardhat-web3";
import "@openzeppelin/hardhat-upgrades";
import "@typechain/hardhat";
import "solidity-coverage";
Expand Down Expand Up @@ -64,6 +63,7 @@ const config: HardhatUserConfig = {
},
schain: {
url: getCustomUrl(process.env.URL_W3_S_CHAIN),
gas: 12000000,
accounts: getCustomPrivateKey(process.env.PRIVATE_KEY_FOR_SCHAIN),
}
},
Expand All @@ -72,7 +72,10 @@ const config: HardhatUserConfig = {
},
typechain: {
outDir: "typechain/",
externalArtifacts: ['node_modules/@openzeppelin/upgrades-core/artifacts/*.json']
externalArtifacts: [
'node_modules/@openzeppelin/upgrades-core/artifacts/AdminUpgradeabilityProxy.json',
'node_modules/@openzeppelin/upgrades-core/artifacts/ProxyAdmin.json'
]
}
};

Expand Down
23 changes: 12 additions & 11 deletions proxy/migrations/deployMainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
*/
import { promises as fs } from 'fs';
import { Interface } from "ethers/lib/utils";
import { ethers, upgrades, web3 } from "hardhat";
import { ethers, upgrades } from "hardhat";
import { MessageProxyForMainnet, Linker } from "../typechain";
import { getAbi, getContractFactory, verifyProxy, getVersion } from '@skalenetwork/upgrade-tools';
import { Manifest } from "@openzeppelin/upgrades-core";
import { SkaleABIFile } from '@skalenetwork/upgrade-tools/dist/src/types/SkaleABIFile';

export function getContractKeyInAbiFile(contract: string) {
if (contract === "MessageProxyForMainnet") {
Expand All @@ -37,15 +38,15 @@ export function getContractKeyInAbiFile(contract: string) {
}

export async function getManifestFile(): Promise<string> {
return (await Manifest.forNetwork(ethers.provider)).file;;
return (await Manifest.forNetwork(ethers.provider)).file;
}

export function getContractManager() {
const defaultFilePath = "../data/skaleManagerComponents.json";
const jsonData = require(defaultFilePath);
async function getContractManager() {
const defaultFilePath = "data/skaleManagerComponents.json";
const jsonData = JSON.parse(await fs.readFile(defaultFilePath)) as SkaleABIFile;
try {
const contractManagerAddress = jsonData.contract_manager_address;
const contractManagerABI = jsonData.contract_manager_abi;
const contractManagerAddress = jsonData.contract_manager_address as string;
const contractManagerABI = jsonData.contract_manager_abi as [];
return { address: contractManagerAddress, abi: contractManagerABI };
} catch (e) {
console.log(e);
Expand Down Expand Up @@ -76,7 +77,7 @@ async function main() {
const [ owner,] = await ethers.getSigners();
const deployed = new Map<string, {address: string, interface: Interface}>();

const contractManager = getContractManager();
const contractManager = await getContractManager();
const version = await getVersion();

const messageProxyForMainnetName = "MessageProxyForMainnet";
Expand Down Expand Up @@ -188,7 +189,7 @@ async function main() {

console.log("Store ABIs");

const outputObject: {[k: string]: any} = {};
const outputObject: {[k: string]: string | []} = {};
for (const contract of contracts) {
const contractKey = getContractKeyInAbiFile(contract);
const deployedContract = deployed.get(contract);
Expand All @@ -209,8 +210,8 @@ async function main() {

if( contractManager?.address !== null && contractManager?.address !== "" && contractManager?.address !== "0x0000000000000000000000000000000000000000" ) {
// register MessageProxy in ContractManager
if( contractManager?.abi !== "" && contractManager?.abi !== undefined ) {
if( await web3.eth.getCode( contractManager?.address) !== "0x") {
if( contractManager?.abi !== undefined ) {
if( await ethers.provider.getCode( contractManager?.address) !== "0x") {
const contractManagerInst = new ethers.Contract(contractManager?.address, contractManager?.abi, owner);
if (await contractManagerInst.owner() !== owner.address) {
console.log( "Owner of ContractManager is not the same of the deployer" );
Expand Down
Loading
Loading