Skip to content

Commit

Permalink
Merge pull request #1697 from skalenetwork/release-2.1.0
Browse files Browse the repository at this point in the history
Merge develop to v2.2.0
  • Loading branch information
DimaStebaev authored Mar 27, 2024
2 parents eeb0e0e + e8aa7da commit 3c667f8
Show file tree
Hide file tree
Showing 10 changed files with 203 additions and 212 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ jobs:
cache: 'yarn'

- name: Install project
run: |
yarn install
run: yarn install

- name: Install slither
run: pip3 install -r scripts/requirements.txt
Expand All @@ -59,14 +58,19 @@ jobs:
- name: Slither checks
run: yarn slither

- name: Test ABI generation
env:
VERSION: "0.0.0"
run: npx hardhat run scripts/generateAbi.ts

- name: Gas calculation test
run: npx hardhat test gas/calculateGas.ts

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

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

- name: Run tests
run: |
Expand Down
150 changes: 75 additions & 75 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,93 +12,88 @@ on:
tags:
- 'custom-release-*'

env:
NODE_VERSION: 18
PYTHON_VERSION: 3.8

jobs:
build:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true

if: github.event_name != 'pull_request' || github.event.pull_request.merged == true

env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
PROXY_DIR: "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)"
defaults:
run:
working-directory: proxy

- 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-
outputs:
version: ${{ steps.version.outputs.version }}

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

- 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 Python 3.8
uses: actions/setup-python@v2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'

- name: Prepare for pip package building
run: |
python3 -m pip install --upgrade build
python3 -m pip install --user --upgrade twine
- name: Install project
working-directory: ${{env.PROXY_DIR}}
run: |
yarn install
run: yarn install

- name: Calculate version
id: version
working-directory: ./
run: |
export BRANCH=${GITHUB_REF##*/}
echo "Branch $BRANCH"
export VERSION=$(bash ./scripts/calculate_version.sh)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Version $VERSION"
( test $BRANCH = "stable" && export PRERELEASE=false ) || export PRERELEASE=true
echo "PRERELEASE=$PRERELEASE" >> $GITHUB_ENV
- name: Generate Manifest
working-directory: ${{env.PROXY_DIR}}
run: |
npx hardhat run migrations/generateManifest.ts
run: npx hardhat run migrations/generateManifest.ts

- name: Install python testing staff
working-directory: ${{env.PROXY_DIR}}
run: pip3 install -r predeployed/test/requirements.txt

- name: Build predeployed pip package
working-directory: ${{env.PROXY_DIR}}
env:
VERSION: ${{ env.VERSION }}
run: |
./predeployed/scripts/build_package.sh
run: ./predeployed/scripts/build_package.sh

- name: Publish predeployed pip package
working-directory: ${{env.PROXY_DIR}}
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
./predeployed/scripts/publish_package.sh
run: ./predeployed/scripts/publish_package.sh

- name: Generate mainnet ABIs
env:
VERSION: ${{ env.VERSION }}
run: npx hardhat run scripts/generateAbi.ts

- name: Generate ABIs
working-directory: ${{env.PROXY_DIR}}/predeployed
- name: Generate predeployed ABIs
working-directory: proxy/predeployed
env:
VERSION: ${{ env.VERSION }}
run: |
Expand All @@ -108,47 +103,52 @@ jobs:
mkdir data
python scripts/generate_abi.py > data/ima-$VERSION-predeployed-abi.json
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Store artifacts
uses: actions/upload-artifact@v4
with:
tag_name: ${{ env.VERSION }}
release_name: ${{ env.VERSION }}
draft: false
prerelease: ${{ env.PRERELEASE }}
name: data
path: proxy/data

- name: Upload Release Assets
id: upload-release-assets
uses: dwenegar/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_release.outputs.id }}
assets_path: proxy/predeployed/dist/

- name: Upload Release Assets
id: upload-static-data
uses: dwenegar/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_release.outputs.id }}
assets_path: proxy/predeployed/data/

- name: Upload Release Assets
id: upload-manifest-data
uses: dwenegar/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
uses: ncipollo/release-action@v1
with:
release_id: ${{ steps.create_release.outputs.id }}
assets_path: proxy/data/ima-schain-*-manifest.json
tag: ${{ env.VERSION }}
prerelease: ${{ env.PRERELEASE }}
artifacts: "proxy/predeployed/dist/*,\
proxy/predeployed/data/*,\
proxy/data/ima-schain-*-manifest.json,\
proxy/data/*-abi.json"

- name: Build and publish image
working-directory: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: scripts/build_and_publish_image.sh

abi:
runs-on: ubuntu-latest

needs:
build

env:
VERSION: ${{ needs.build.outputs.version }}

steps:
- uses: actions/checkout@v4
with:
ref: abi

- name: Load artifacts
uses: actions/download-artifact@v4
with:
name: data

- name: Commit ABI
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: "Add ABI for version ${{ env.VERSION }}"
add: "*-abi.json"
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0
2.2.0
7 changes: 7 additions & 0 deletions proxy/migrations/deployMainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ async function main() {
try {
await contractManagerInst.setContractsAddress( "MessageProxyForMainnet", deployed.get( "MessageProxyForMainnet" )?.address);
await contractManagerInst.setContractsAddress( "CommunityPool", deployed.get( "CommunityPool" )?.address);
for (const contractName of contractsToDeploy) {
const contractAddress = deployed.get(contractName);
if (contractAddress === undefined) {
throw new Error(`${contractName} was not found`);
}
await contractManagerInst.setContractsAddress( contractName, contractAddress);
}
console.log( "Successfully registered MessageProxy in ContractManager" );
} catch ( error ) {
console.log( "Registration of MessageProxy is failed on ContractManager. Please redo it by yourself!\nError:", error );
Expand Down
2 changes: 0 additions & 2 deletions proxy/migrations/deploySchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,6 @@ async function main() {
deployed.set( "TokenManagerERC20", { address: tokenManagerERC20.address, interface: tokenManagerERC20.interface } );
console.log("Contract TokenManagerERC20 deployed to", tokenManagerERC20.address);

// The end of TODO:

console.log("Deploy TokenManagerERC721");
const tokenManagerERC721Factory = await ethers.getContractFactory("TokenManagerERC721");
const tokenManagerERC721 = await upgrades.deployProxy(tokenManagerERC721Factory, [
Expand Down
68 changes: 66 additions & 2 deletions proxy/migrations/upgradeMainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { ethers } from "hardhat";
import { promises as fs } from "fs";
import { AutoSubmitter, Upgrader } from "@skalenetwork/upgrade-tools";
import { SkaleABIFile } from "@skalenetwork/upgrade-tools/dist/src/types/SkaleABIFile";
import { contracts } from "./deployMainnet";
import { contracts, contractsToDeploy, getContractKeyInAbiFile } from "./deployMainnet";
import { MessageProxyForMainnet } from "../typechain";
import { Interface } from "@ethersproject/abi";


class ImaMainnetUpgrader extends Upgrader {

Expand Down Expand Up @@ -44,7 +46,69 @@ class ImaMainnetUpgrader extends Upgrader {

// deployNewContracts = () => { };

// initialize = async () => { };
initialize = async () => {
const contractManagerAddress = await (await this.getMessageProxyForMainnet()).contractManagerOfSkaleManager();
const contractManagerInterface = new Interface([{
"type": "function",
"name": "getContract",
"constant": true,
"stateMutability": "view",
"payable": false,
"inputs": [
{
"type": "string",
"name": "name"
}
],
"outputs": [
{
"type": "address",
"name": "contractAddress"
}
]
},
{
"type": "function",
"name": "setContractsAddress",
"constant": false,
"payable": false,
"inputs": [
{
"type": "string",
"name": "contractsName"
},
{
"type": "address",
"name": "newContractsAddress"
}
],
"outputs": []
}]);
const contractManager = new ethers.Contract(
contractManagerAddress,
contractManagerInterface,
ethers.provider
)
for (const contractName of contractsToDeploy) {
try {
const contractAddress = await contractManager.getContract(contractName);
console.log(`Address of ${contractName} is set to ${contractAddress}`);
} catch {
// getContract failed because the contract is not set
const contractAddress = this.abi[`${getContractKeyInAbiFile(contractName)}_address`] as string;
this.transactions.push(
{
to: contractManager.address,
data: contractManager.interface.encodeFunctionData(
"setContractsAddress",
[contractAddress]
)
}
)
console.log(`Set ${contractName} address to ${contractAddress}`);
}
}
};

_getContractKeyInAbiFile(contract: string) {
if (contract === "MessageProxyForMainnet") {
Expand Down
8 changes: 1 addition & 7 deletions proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@
"@skalenetwork/upgrade-tools": "^2.0.2",
"axios": "^0.21.4",
"dotenv": "^16.0.0",
"ethereumjs-tx": "2.1.2",
"ethereumjs-util": "^7.1.5",
"ethers": "^5.7.2",
"ethers-eip712": "^0.2.0",
"hardhat": "2.11.0 - 2.16.1",
"path": "^0.12.7"
"hardhat": "2.11.0 - 2.16.1"
},
"devDependencies": {
"@nomiclabs/hardhat-etherscan": "^3.1.0",
Expand All @@ -51,11 +47,9 @@
"@types/sinon-chai": "^3.2.5",
"@typescript-eslint/eslint-plugin": "^6.2.1",
"@typescript-eslint/parser": "^6.2.1",
"bignumber.js": "^9.0.0",
"chai": "^4.2.0",
"chai-almost": "^1.0.1",
"chai-as-promised": "^7.1.1",
"codecov": "^3.7.1",
"eslint": "^8.46.0",
"ethereum-waffle": "^4.0.10",
"ganache": "7.9.2",
Expand Down
Loading

0 comments on commit 3c667f8

Please sign in to comment.