Skip to content

Commit b9b19ed

Browse files
authored
Merge branch 'feat_upgrade_polkadot_1.2.0' into feat_upgrade_polkadot_1.3.0
2 parents 078af00 + 3116f40 commit b9b19ed

File tree

105 files changed

+9545
-5715
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+9545
-5715
lines changed

.github/workflows/010_build_and_test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
- name: Build
4040
run: |
4141
cd substrate-node
42+
cargo clean
4243
cargo build --release
4344
4445
- name: Unit tests

.github/workflows/020_lint_and_test_go_client.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,28 @@ on:
66
- clients/tfchain-client-go/**
77
workflow_dispatch:
88

9-
defaults:
10-
run:
11-
working-directory: clients/tfchain-client-go
12-
139
jobs:
1410
lint:
1511
name: lint
1612
runs-on: ubuntu-latest
1713
timeout-minutes: 5
18-
steps:
14+
steps:
15+
- name: Check out code into the Go module directory
16+
uses: actions/checkout@v4
17+
with:
18+
submodules: "true"
19+
sparse-checkout: clients/tfchain-client-go
20+
1921
- name: Set up Go
20-
uses: actions/setup-go@v4
22+
uses: actions/setup-go@v5
2123
with:
2224
go-version: "1.20"
25+
cache: false
26+
# cache-dependency-path: clients/tfchain-client-go/go.sum
2327
id: go
2428

25-
- name: Check out code into the Go module directory
26-
uses: actions/checkout@v3.5.0
27-
with:
28-
submodules: "true"
29-
3029
- name: golangci-lint
31-
uses: golangci/golangci-lint-action@v3
30+
uses: golangci/golangci-lint-action@v3.7.0
3231
with:
3332
args: --timeout 3m --verbose
3433
working-directory: clients/tfchain-client-go
@@ -44,4 +43,5 @@ jobs:
4443
- name: gofmt
4544
uses: Jerome1337/gofmt-action@v1.0.5
4645
with:
47-
gofmt-flags: "-l -d"
46+
gofmt-path: './clients/tfchain-client-go'
47+
gofmt-flags: "-l -d"
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Generate benchmark weights
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
generate-benchmark-weights:
8+
runs-on: [self-hosted, tfchainrunner01]
9+
container:
10+
image: threefolddev/tfchain:4
11+
env:
12+
DEBIAN_FRONTEND: noninteractive
13+
PATH: /root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin
14+
RUSTUP_HOME: /root/.rustup
15+
CARGO_HOME: /root/.cargo
16+
17+
steps:
18+
- name: Fail if branch is main
19+
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/development'
20+
run: |
21+
echo "This workflow should not be triggered with workflow_dispatch on main branch"
22+
exit 1
23+
24+
- name: Checkout the repo
25+
uses: actions/checkout@v3
26+
27+
- name: Chown user
28+
run: |
29+
chown -R $USER:$USER $GITHUB_WORKSPACE
30+
31+
- name: Cache build
32+
uses: actions/cache@v3
33+
timeout-minutes: 6
34+
continue-on-error: true
35+
with:
36+
path: |
37+
/root/.cargo/bin/
38+
/root/.cargo/registry/index/
39+
/root/.cargo/registry/cache/
40+
/root/.cargo/git/db/
41+
substrate-node/target/
42+
key: ${{ runner.os }}-tfchain-build-cache-${{ hashFiles('**/Cargo.lock') }}
43+
restore-keys: ${{ runner.os }}-tfchain-build-cache
44+
45+
- name: Build
46+
run: |
47+
cd substrate-node
48+
cargo build --profile=production --features runtime-benchmarks
49+
50+
- name: Run benchmarking
51+
shell: bash
52+
run: |
53+
cd substrate-node
54+
for weights_rs_file in ./pallets/*/src/weights.rs
55+
do
56+
rm $weights_rs_file
57+
pal_name=$(awk -F'pallets/|/src' '{print $2}' <<< $weights_rs_file)
58+
./target/production/tfchain benchmark pallet \
59+
--chain=dev \
60+
--wasm-execution=compiled \
61+
--pallet="$pal_name" \
62+
--extrinsic="*" \
63+
--steps=50 \
64+
--repeat=20 \
65+
--heap-pages=409 \
66+
--output ./pallets/"$pal_name"/src/weights.rs \
67+
--template ./.maintain/frame-weight-template.hbs
68+
done
69+
70+
- name: Git config
71+
run: |
72+
git config --global --add safe.directory /__w/tfchain/tfchain
73+
git status
74+
75+
- name: Commit & Push changes
76+
uses: actions-js/push@master
77+
with:
78+
github_token: ${{ secrets.GITHUB_TOKEN }}
79+
message: 'chore: update benchmark `weights.rs` file for all pallets'
80+
branch: ${{ github.ref_name }}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish tfchain image
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-and-push:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
steps:
17+
- name: Checkout the repo
18+
uses: actions/checkout@v4
19+
20+
- name: Log in to the Container registry
21+
uses: docker/login-action@v3
22+
with:
23+
registry: ghcr.io
24+
username: ${{ github.actor }}
25+
password: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Extract metadata for Docker
28+
id: meta
29+
uses: docker/metadata-action@v5
30+
with:
31+
images: ghcr.io/threefoldtech/tfchain
32+
tags: |
33+
type=semver,pattern={{version}}
34+
35+
- name: Build and push Docker image
36+
uses: docker/build-push-action@v5
37+
with:
38+
file: ./substrate-node/Dockerfile
39+
context: ./substrate-node/.
40+
push: true
41+
tags: ${{ steps.meta.outputs.tags }}
42+
labels: ${{ steps.meta.outputs.labels }}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Lint Go bridge
2+
3+
on:
4+
push:
5+
paths:
6+
- bridge/tfchain_bridge/**
7+
workflow_dispatch:
8+
9+
jobs:
10+
lint:
11+
name: lint
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 5
14+
steps:
15+
- name: Check out code into the Go module directory
16+
uses: actions/checkout@v4
17+
with:
18+
submodules: "true"
19+
sparse-checkout: |
20+
clients/tfchain-client-go
21+
bridge/tfchain_bridge
22+
23+
- name: Set up Go
24+
uses: actions/setup-go@v5
25+
with:
26+
go-version: "1.20"
27+
cache: false
28+
# cache-dependency-path: bridge/tfchain_bridge/go.sum
29+
id: go
30+
31+
- name: golangci-lint
32+
uses: golangci/golangci-lint-action@v3.7.0
33+
with:
34+
args: --timeout 3m --verbose
35+
working-directory: bridge/tfchain_bridge
36+
37+
- name: staticcheck
38+
uses: dominikh/staticcheck-action@v1.3.0
39+
with:
40+
version: "2022.1.3"
41+
working-directory: bridge/tfchain_bridge
42+
env:
43+
GO111MODULE: on
44+
45+
- name: gofmt
46+
uses: Jerome1337/gofmt-action@v1.0.5
47+
with:
48+
gofmt-path: './bridge/tfchain_bridge'
49+
gofmt-flags: "-l -d"
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Check benchmark weights
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- development
7+
paths:
8+
- '**.rs'
9+
- 'substrate-node/pallets/**'
10+
11+
jobs:
12+
check-benchmark-weights:
13+
runs-on: ubuntu-22.04
14+
15+
steps:
16+
- name: Checkout the repo
17+
uses: actions/checkout@v3
18+
19+
- name: Get all rust files that have changed in pallets
20+
id: pallets-changed-rust-files
21+
uses: tj-actions/changed-files@v42
22+
with:
23+
files: |
24+
substrate-node/pallets/**/src/*.rs
25+
26+
- name: Get all pallets with changes in src dir
27+
id: pallets-changed-src-dir
28+
uses: tj-actions/changed-files@v42
29+
with:
30+
dir_names: "true"
31+
files: |
32+
substrate-node/pallets/**/src/*.rs
33+
34+
- name: List all changed files
35+
env:
36+
ALL_CHANGED_FILES: ${{ steps.pallets-changed-rust-files.outputs.all_changed_files }}
37+
run: |
38+
for file in ${ALL_CHANGED_FILES}; do
39+
echo "$file file was changed"
40+
done
41+
42+
- name: List all changed dir
43+
env:
44+
ALL_CHANGED_DIR: ${{ steps.pallets-changed-src-dir.outputs.all_changed_files }}
45+
run: |
46+
for dir in ${ALL_CHANGED_DIR}; do
47+
echo "$dir has changes"
48+
done
49+
50+
- name: Run benchmarking
51+
env:
52+
ALL_CHANGED_PALLETS_SRC_DIR: ${{ steps.pallets-changed-src-dir.outputs.all_changed_files }}
53+
ALL_CHANGED_PALLETS_FILES: ${{ steps.pallets-changed-rust-files.outputs.all_changed_files }}
54+
run: |
55+
count=0
56+
for pallet_src_dir in ${ALL_CHANGED_PALLETS_SRC_DIR}; do
57+
echo "pallet src dir: $pallet_src_dir"
58+
weights_file="$pallet_src_dir"/weights.rs
59+
echo "weights file: $weights_file"
60+
updated_weights=false
61+
for changed_file in ${ALL_CHANGED_PALLETS_FILES}; do
62+
if [ "$changed_file" = "$weights_file" ]; then
63+
updated_weights=true
64+
break
65+
fi
66+
done
67+
if [ "$updated_weights" = false ] ; then
68+
let "count=count+1"
69+
fi
70+
done
71+
if [ "$count" -gt 0 ]; then
72+
echo "Found changes on src rust file(s) for $count pallet(s) and respective weights.rs file(s) was not updated."
73+
echo "Make sure to generate these files again if pallet logic has changed by running generate_benchmark_weights workflow on branch."
74+
exit 1
75+
else
76+
echo "Found changes on src rust file(s) and respective weights.rs file(s) was updated."
77+
fi

Makefile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
.PHONY: version-bump
2+
3+
# * Usage Examples:*
4+
# type=patch make version-bump
5+
# type=minor make version-bump
6+
# type=major make version-bump
7+
# ** skip increment spec_version in substrate-node/runtime/src/lib.rs **
8+
# type=patch retain_spec_version=1 make version-bump
9+
version-bump:
10+
set -e; \
11+
if [ "$(type)" = "patch" ] || [ "$(type)" = "minor" ] || [ "$(type)" = "major" ]; then \
12+
default_branch=$$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'); \
13+
git checkout $$default_branch; \
14+
git pull origin $$default_branch; \
15+
new_version=$$(npx semver -i $(type) $$(jq -r .version clients/tfchain-client-js/package.json)); \
16+
branch_name="$$default_branch-bump-version-to-$$new_version"; \
17+
git checkout -b $$branch_name; \
18+
current_spec_version=$$(sed -n -e 's/^.*spec_version: \([0-9]\+\),$$/\1/p' substrate-node/runtime/src/lib.rs); \
19+
if [ -z "$${retain_spec_version}" ]; then \
20+
current_spec_version=$$(sed -n -e 's/^.*spec_version: \([0-9]\+\),$$/\1/p' substrate-node/runtime/src/lib.rs); \
21+
echo "Current spec_version: $$current_spec_version"; \
22+
new_spec_version=$$((current_spec_version + 1)); \
23+
echo "New spec_version: $$new_spec_version"; \
24+
sed -i "s/spec_version: $$current_spec_version,/spec_version: $$new_spec_version,/" substrate-node/runtime/src/lib.rs; \
25+
fi; \
26+
jq ".version = \"$$new_version\"" activation-service/package.json > temp.json && mv temp.json activation-service/package.json; \
27+
jq ".version = \"$$new_version\"" clients/tfchain-client-js/package.json > temp.json && mv temp.json clients/tfchain-client-js/package.json; \
28+
jq ".version = \"$$new_version\"" scripts/package.json > temp.json && mv temp.json scripts/package.json; \
29+
jq ".version = \"$$new_version\"" tools/fork-off-substrate/package.json > temp.json && mv temp.json tools/fork-off-substrate/package.json; \
30+
sed -i "s/^version = .*/version = \"$$new_version\"/" substrate-node/Cargo.toml; \
31+
sed -i "s/^version: .*/version: $$new_version/" substrate-node/charts/substrate-node/Chart.yaml; \
32+
sed -i "s/^appVersion: .*/appVersion: '$$new_version'/" substrate-node/charts/substrate-node/Chart.yaml; \
33+
sed -i "s/^version: .*/version: $$new_version/" bridge/tfchain_bridge/chart/tfchainbridge/Chart.yaml; \
34+
sed -i "s/^appVersion: .*/appVersion: '$$new_version'/" bridge/tfchain_bridge/chart/tfchainbridge/Chart.yaml; \
35+
sed -i "s/^version: .*/version: $$new_version/" activation-service/helm/tfchainactivationservice/Chart.yaml; \
36+
sed -i "s/^appVersion: .*/appVersion: '$$new_version'/" activation-service/helm/tfchainactivationservice/Chart.yaml; \
37+
cd substrate-node && cargo metadata -q 1> /dev/null && cd ..; \
38+
git add substrate-node/Cargo.toml substrate-node/Cargo.lock substrate-node/charts/substrate-node/Chart.yaml bridge/tfchain_bridge/chart/tfchainbridge/Chart.yaml activation-service/helm/tfchainactivationservice/Chart.yaml activation-service/package.json clients/tfchain-client-js/package.json scripts/package.json tools/fork-off-substrate/package.json substrate-node/runtime/src/lib.rs; \
39+
if [ -z "$${new_spec_version}" ]; then \
40+
git commit -m "Bump version to $$new_version"; \
41+
else \
42+
git commit -m "Bump version to $$new_version (spec v$$new_spec_version)"; \
43+
fi \
44+
else \
45+
echo "Invalid version type. Please use patch, minor, or major."; \
46+
fi

activation-service/Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ FROM node:16
44
WORKDIR /usr/src/app
55

66
# Install app dependencies
7-
# A wildcard is used to ensure both package.json AND package-lock.json are copied
8-
# where available (npm@5+)
9-
COPY package*.json ./
7+
COPY package.json yarn.lock ./
8+
9+
RUN yarn install && yarn cache clean
1010

11-
RUN yarn install
1211
# If you are building your code for production
1312
# RUN npm ci --only=production
1413

activation-service/helm/tfchainactivationservice/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ apiVersion: v2
22
name: tfchainactivationservice
33
description: TFchain account activation funding service
44
type: application
5-
version: 2.6.0-rc1
6-
appVersion: '2.6.0-rc1'
5+
version: 2.9.0
6+
appVersion: '2.9.0'

activation-service/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "substrate-funding-service",
3-
"version": "2.6.0-rc1",
3+
"version": "2.9.0",
44
"description": "Substrate funding service",
55
"main": "index.js",
66
"scripts": {
@@ -36,4 +36,4 @@
3636
"pino-pretty": "^5.0.2",
3737
"standard": "^16.0.3"
3838
}
39-
}
39+
}

0 commit comments

Comments
 (0)