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 develop #1681

Merged
merged 8 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
88 changes: 27 additions & 61 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,82 +10,65 @@ on:
branches-ignore:
- 'docs-v*'

env:
NODE_VERSION: 18
PYTHON_VERSION: 3.8

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
test-contracts:
runs-on: ubuntu-latest

env:
working-directory: ./proxy
defaults:
run:
working-directory: proxy

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
submodules: true

- name: Install PYTHON
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'

- name: Install NODE JS
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 18
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'

- name: Install project
working-directory: ${{env.working-directory}}
run: |
yarn install

- name: Install slither
working-directory: ${{env.working-directory}}
run: pip3 install -r scripts/requirements.txt

- name: Lint solidity
working-directory: ${{env.working-directory}}
run: yarn lint

- name: Compile typescript
working-directory: ${{env.working-directory}}
run: yarn tsc

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

- name: Slither checks
working-directory: ${{env.working-directory}}
run: yarn slither

- name: Gas calculation test
working-directory: ${{env.working-directory}}
run: npx hardhat test gas/calculateGas.ts

- name: Test deploy
run: bash ./scripts/test_deploy.sh

- name: Test upgrade
run: bash ./proxy/scripts/test_upgrade.sh
run: bash ./scripts/test_upgrade.sh

- name: Run tests
working-directory: ${{env.working-directory}}
run: |
npx hardhat coverage --solcoverjs .solcover.js
bash <(curl -s https://codecov.io/bash) -f coverage/lcov.info -t $CODECOV_TOKEN || echo "Codecov did not collect coverage reports"
Expand All @@ -98,38 +81,21 @@ jobs:
working-directory: proxy

steps:
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- uses: actions/cache@v2
- uses: actions/checkout@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
submodules: true

- name: Install PYTHON
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'

- name: Install NODE JS
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 18
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'

- name: Install project
run: |
Expand Down
1 change: 0 additions & 1 deletion proxy/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ const config: HardhatUserConfig = {
},
schain: {
url: getCustomUrl(process.env.URL_W3_S_CHAIN),
gas: 12000000,
accounts: getCustomPrivateKey(process.env.PRIVATE_KEY_FOR_SCHAIN),
}
},
Expand Down
38 changes: 5 additions & 33 deletions proxy/migrations/deploySchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
import { promises as fs } from 'fs';
import { Interface } from "ethers/lib/utils";
import { ethers, upgrades, network } from "hardhat";
import { ethers, upgrades } from "hardhat";
import hre from "hardhat";
import { getAbi, getVersion } from '@skalenetwork/upgrade-tools';
import { Manifest } from "@openzeppelin/upgrades-core";
Expand Down Expand Up @@ -181,36 +181,8 @@ async function main() {
deployed.set( "TokenManagerEth", { address: tokenManagerEth.address, interface: tokenManagerEth.interface } );
console.log("Contract TokenManagerEth deployed to", tokenManagerEth.address);

/*
In the moment of this code was written
ganache had a bug
that prevented proper execution
of estimateGas function
during deployment of smart contract
that exceed 24KB limit.

In addition to this problem
upgrade-hardhat library
did not supported
manual gas limit configuration.

TODO: in case of any one or both issues fixed
please remove this crazy workaround below
*/
if (network.config.gas === "auto") {
throw Error("Can't use auto because of problems with gas estimations");
}
if (!process.env.PRIVATE_KEY_FOR_SCHAIN) {
throw Error("PRIVATE_KEY_FOR_SCHAIN is not set");
}
const key = process.env.PRIVATE_KEY_FOR_SCHAIN;
const signerWithFixedGasEstimation = new ethers.Wallet(key, ethers.provider);
signerWithFixedGasEstimation.estimateGas = async() => {
return ethers.BigNumber.from(network.config.gas as number);
}

console.log("Deploy TokenManagerERC20");
const tokenManagerERC20Factory = await ethers.getContractFactory("TokenManagerERC20", signerWithFixedGasEstimation);
const tokenManagerERC20Factory = await ethers.getContractFactory("TokenManagerERC20");
const tokenManagerERC20 = await upgrades.deployProxy(tokenManagerERC20Factory, [
schainName,
messageProxy.address,
Expand All @@ -225,7 +197,7 @@ async function main() {
// The end of TODO:

console.log("Deploy TokenManagerERC721");
const tokenManagerERC721Factory = await ethers.getContractFactory("TokenManagerERC721", signerWithFixedGasEstimation);
const tokenManagerERC721Factory = await ethers.getContractFactory("TokenManagerERC721");
const tokenManagerERC721 = await upgrades.deployProxy(tokenManagerERC721Factory, [
schainName,
messageProxy.address,
Expand All @@ -238,7 +210,7 @@ async function main() {
console.log("Contract TokenManagerERC721 deployed to", tokenManagerERC721.address);

console.log("Deploy TokenManagerERC1155");
const tokenManagerERC1155Factory = await ethers.getContractFactory("TokenManagerERC1155", signerWithFixedGasEstimation);
const tokenManagerERC1155Factory = await ethers.getContractFactory("TokenManagerERC1155");
const tokenManagerERC1155 = await upgrades.deployProxy(tokenManagerERC1155Factory, [
schainName,
messageProxy.address,
Expand All @@ -251,7 +223,7 @@ async function main() {
console.log("Contract TokenManagerERC1155 deployed to", tokenManagerERC1155.address);

console.log("Deploy TokenManagerERC721WithMetadata");
const tokenManagerERC721WithMetadataFactory = await ethers.getContractFactory("TokenManagerERC721WithMetadata", signerWithFixedGasEstimation);
const tokenManagerERC721WithMetadataFactory = await ethers.getContractFactory("TokenManagerERC721WithMetadata");
const tokenManagerERC721WithMetadata = await upgrades.deployProxy(tokenManagerERC721WithMetadataFactory, [
schainName,
messageProxy.address,
Expand Down
3 changes: 1 addition & 2 deletions proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@
"codecov": "^3.7.1",
"eslint": "^8.46.0",
"ethereum-waffle": "^4.0.10",
"ganache": "7.4.3",
"kill-port": "^1.6.1",
"ganache": "7.9.2",
"solhint": "3.3.6",
"solidity-coverage": "^0.8.4",
"ts-generator": "^0.1.1",
Expand Down
20 changes: 20 additions & 0 deletions proxy/scripts/test_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

set -e

ACCOUNTS=accounts.json
GANACHE=$(npx ganache \
--😈 \
--wallet.accountKeysPath "$ACCOUNTS" \
--chain.allowUnlimitedContractSize \
)
PRIVATE_KEY=$(jq -r "first(.private_keys[])" < "$ACCOUNTS")

export CHAIN_NAME_SCHAIN="d2-chain"
export PRIVATE_KEY_FOR_ETHEREUM=$PRIVATE_KEY
export PRIVATE_KEY_FOR_SCHAIN=$PRIVATE_KEY

yarn deploy-skale-manager-components
yarn deploy-to-both-chains

npx ganache instances stop "$GANACHE"
10 changes: 8 additions & 2 deletions proxy/scripts/test_upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ DEPLOYED_DIR=$GITHUB_WORKSPACE/deployed-IMA/
git clone --branch "$DEPLOYED_TAG" "https://github.com/$GITHUB_REPOSITORY.git" "$DEPLOYED_DIR"

ACCOUNTS_FILENAME="$DEPLOYED_DIR/proxy/generatedAccounts.json"
npx ganache-cli --gasLimit 9000000 --quiet --allowUnlimitedContractSize --account_keys_path "$ACCOUNTS_FILENAME" &
GANACHE=$(npx ganache \
--😈 \
--miner.blockGasLimit 9000000 \
--logging.quiet \
--chain.allowUnlimitedContractSize \
--wallet.accountKeysPath "$ACCOUNTS_FILENAME" \
)

cd "$DEPLOYED_DIR"
yarn install
Expand Down Expand Up @@ -66,4 +72,4 @@ ALLOW_NOT_ATOMIC_UPGRADE="OK" \
VERSION=$VERSION_TAG \
npx hardhat run migrations/upgradeSchain.ts --network localhost

npx kill-port 8545
npx ganache instances stop "$GANACHE"
Loading
Loading