Skip to content

Commit 4e3e9ff

Browse files
authored
Bring back CI stage to measure contract size regressions (#2440)
* Use v2 of `rust-cache` * Only fuzz multiple times on `master` * First iteration over submitting contract sizes * Fix yaml * Fix yaml * Fix available toolchains * Replace `substrate-contracts-node` with `ink-node` * Replace Twitter with X * Simplify readme * Use branch name in file name * Use branch * Fix yaml * Update readme * Use `bash` to support shell substitution * Revert "Use `bash` to support shell substitution" This reverts commit 13228e1. * Use `github.ref` * Use `github.ref_name` * Extract branch name * Update readme * Revert me: debug stage * Debug toolchains * Fix syntax * Debug script * Debug script * Debug script * Debug script * Debug script * Debug script * Debug script * Debug script * Debug script * Revert "Revert me: debug stage" This reverts commit c9e08e8.
1 parent 84ae2da commit 4e3e9ff

File tree

22 files changed

+366
-289
lines changed

22 files changed

+366
-289
lines changed

.github/rust-info/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ runs:
99
rustup +nightly show
1010
cargo +nightly --version
1111
bash --version
12-
substrate-contracts-node --version
12+
ink-node --version
1313
cargo contract --version
1414
git --version
1515
shell: bash

.github/workflows/ci.yml

Lines changed: 79 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ jobs:
139139
fetch-depth: 1
140140

141141
- name: Cache
142-
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
142+
uses: Swatinem/rust-cache@v2
143143
with:
144144
cache-directories: ${{ env.CARGO_TARGET_DIR }}
145145
cache-all-crates: true
@@ -174,7 +174,7 @@ jobs:
174174
fetch-depth: 1
175175

176176
- name: Cache
177-
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
177+
uses: Swatinem/rust-cache@v2
178178
with:
179179
cache-directories: ${{ env.CARGO_TARGET_DIR }}
180180
cache-all-crates: true
@@ -213,7 +213,7 @@ jobs:
213213
fetch-depth: 1
214214

215215
- name: Cache
216-
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
216+
uses: Swatinem/rust-cache@v2
217217
with:
218218
cache-directories: ${{ env.CARGO_TARGET_DIR }}
219219
cache-all-crates: true
@@ -253,7 +253,7 @@ jobs:
253253
fetch-depth: 1
254254

255255
- name: Cache
256-
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
256+
uses: Swatinem/rust-cache@v2
257257
with:
258258
cache-directories: ${{ env.CARGO_TARGET_DIR }}
259259
cache-all-crates: true
@@ -295,7 +295,7 @@ jobs:
295295
fetch-depth: 1
296296

297297
- name: Cache
298-
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
298+
uses: Swatinem/rust-cache@v2
299299
with:
300300
cache-directories: ${{ env.CARGO_TARGET_DIR }}
301301
cache-all-crates: true
@@ -332,7 +332,7 @@ jobs:
332332
fetch-depth: 1
333333

334334
- name: Cache
335-
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
335+
uses: Swatinem/rust-cache@v2
336336
with:
337337
cache-directories: ${{ env.CARGO_TARGET_DIR }}
338338
cache-all-crates: true
@@ -371,7 +371,7 @@ jobs:
371371
fetch-depth: 1
372372

373373
- name: Cache
374-
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
374+
uses: Swatinem/rust-cache@v2
375375
with:
376376
cache-directories: ${{ env.CARGO_TARGET_DIR }}
377377
cache-all-crates: true
@@ -421,7 +421,7 @@ jobs:
421421
fetch-depth: 1
422422

423423
- name: Cache
424-
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
424+
uses: Swatinem/rust-cache@v2
425425
with:
426426
cache-directories: ${{ env.CARGO_TARGET_DIR }}
427427
cache-all-crates: true
@@ -436,7 +436,8 @@ jobs:
436436
# at the same time, hence we use this workaround.
437437
QUICKCHECK_TESTS: 0
438438
run: |
439-
rustup toolchain remove nightly-2025-02-20; rustup toolchain remove stable; rustup toolchain remove 1.85.0;
439+
rustup toolchain remove nightly-2025-02-20
440+
rustup toolchain remove stable
440441
cargo +nightly nextest run --all-features --no-fail-fast --workspace --locked --jobs 1 --partition count:${{ matrix.partition }}/30
441442
442443
test-docs:
@@ -458,7 +459,7 @@ jobs:
458459
fetch-depth: 1
459460

460461
- name: Cache
461-
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
462+
uses: Swatinem/rust-cache@v2
462463
with:
463464
cache-directories: ${{ env.CARGO_TARGET_DIR }}
464465
cache-all-crates: true
@@ -503,7 +504,7 @@ jobs:
503504
fetch-depth: 1
504505

505506
- name: Cache
506-
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
507+
uses: Swatinem/rust-cache@v2
507508
with:
508509
cache-directories: ${{ env.CARGO_TARGET_DIR }}
509510
cache-all-crates: true
@@ -539,7 +540,7 @@ jobs:
539540
fetch-depth: 1
540541

541542
- name: Cache
542-
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
543+
uses: Swatinem/rust-cache@v2
543544
with:
544545
cache-directories: ${{ env.CARGO_TARGET_DIR }}
545546
cache-all-crates: true
@@ -588,7 +589,7 @@ jobs:
588589
# uses: ./.github/rust-info
589590
#
590591
# - name: Cache
591-
# uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
592+
# uses: Swatinem/rust-cache@v2
592593
# with:
593594
# cache-on-failure: true
594595
# cache-directories: ${{ env.CARGO_TARGET_DIR }}
@@ -630,7 +631,7 @@ jobs:
630631
fetch-depth: 1
631632

632633
- name: Cache
633-
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
634+
uses: Swatinem/rust-cache@v2
634635
with:
635636
cache-directories: ${{ env.CARGO_TARGET_DIR }}
636637
cache-all-crates: true
@@ -661,7 +662,7 @@ jobs:
661662
fetch-depth: 1
662663

663664
- name: Cache
664-
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
665+
uses: Swatinem/rust-cache@v2
665666
with:
666667
cache-directories: ${{ env.CARGO_TARGET_DIR }}
667668
cache-all-crates: true
@@ -698,7 +699,7 @@ jobs:
698699
fetch-depth: 1
699700

700701
- name: Cache
701-
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
702+
uses: Swatinem/rust-cache@v2
702703
with:
703704
cache-directories: ${{ env.CARGO_TARGET_DIR }}
704705
cache-all-crates: true
@@ -725,7 +726,7 @@ jobs:
725726
RUSTFLAGS: -Clink-arg=-z -Clink-arg=nostart-stop-gc -Clink-dead-code
726727
run: |
727728
# run flipper E2E test with on-chain contract
728-
substrate-contracts-node -lruntime::revive=debug 2>&1 &
729+
ink-node -lruntime::revive=debug 2>&1 &
729730
cargo +nightly contract build --release --manifest-path integration-tests/public/flipper/Cargo.toml
730731
export CONTRACT_ADDR_HEX=$(cargo +nightly-2025-02-20 contract instantiate \
731732
--manifest-path integration-tests/public/flipper/Cargo.toml \
@@ -737,7 +738,7 @@ jobs:
737738
e2e_test_deployed_contract \
738739
-- --ignored --nocapture
739740
740-
examples-contract-build:
741+
examples-contract-build-riscv:
741742
runs-on: ubuntu-latest
742743
needs: [set-image, build]
743744
defaults:
@@ -748,36 +749,77 @@ jobs:
748749
strategy:
749750
fail-fast: false
750751
matrix:
751-
type: [RISCV]
752-
partition: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
752+
partition: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
753753
steps:
754754
- name: Checkout
755755
uses: actions/checkout@v4
756756
with:
757757
fetch-depth: 1
758758

759759
- name: Cache
760-
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
760+
uses: Swatinem/rust-cache@v2
761761
with:
762762
cache-directories: ${{ env.CARGO_TARGET_DIR }}
763763
cache-all-crates: true
764764

765765
- name: Rust Info
766766
uses: ./.github/rust-info
767767

768-
- name: Build Contract RISCV Examples
769-
if: ${{ matrix.type == 'RISCV' }}
768+
- name: Extract branch name
769+
shell: bash
770+
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
771+
id: extract_branch
772+
773+
- name: Build Contract Examples for RISC-V
770774
env:
771775
RUSTC_BOOTSTRAP: 1
776+
MANIFEST_PATH: ""
777+
CONTRACT_SIZE_FILE: "measurements-${{ steps.extract_branch.outputs.branch }}/contract_size_"
772778
run: |
773-
# We skip some examples for those reasons:
774-
# This uses dlmalloc which is only supported on select targets.
775-
# - custom_allocator
776-
# Pulls in sp-std which needlessly requires atomic pointers (TODO: Fix sp-std and enable this example)
777-
# - call-runtime
778-
scripts/for_all_contracts_exec.sh --path integration-tests --ignore public/custom-allocator --ignore public/call-runtime --ignore public/contract-xcm \
779-
--partition ${{ matrix.partition }}/15 -- \
780-
cargo +nightly build --manifest-path {} --no-default-features --target $RISCV_TARGET -Zbuild-std="core,alloc"
779+
mkdir -p measurements-${{ steps.extract_branch.outputs.branch }}/
780+
scripts/for_all_contracts_exec2.sh --path integration-tests --partition ${{ matrix.partition }}/20 --ignore integration-tests/public/multi-contract-caller -- \
781+
scripts/build_and_determine_contract_size.sh {}
782+
783+
#bash -c "scripts/build_and_determine_contract_size.sh {} >> ${CONTRACT_SIZE_FILE} && \
784+
#sed -ie 's/^integration-tests\/\(public\/\|internal\/\)\?//' ${CONTRACT_SIZE_FILE}"
785+
786+
- uses: actions/upload-artifact@v4
787+
#env:
788+
#CONTRACT_SIZE_FILE: ${{ matrix.branch }}_contract_size_${{ matrix.partition }}
789+
with:
790+
#name: ${{ github.job }}-${{ matrix.branch }}-data
791+
#name: ./measurements-${{ PR_NUMBER }}
792+
path: ./measurements-${{ steps.extract_branch.outputs.branch }}/*
793+
name: ${{ env.RUN_UNIQUE_ID }}_artifact_${{ matrix.partition }}
794+
retention-days: 1
795+
796+
process-contract-sizes:
797+
needs: [examples-contract-build-riscv]
798+
runs-on: ubuntu-latest
799+
steps:
800+
- name: Download reports' artifacts
801+
uses: actions/download-artifact@v4
802+
with:
803+
path: downloaded_artifacts
804+
805+
- name: Extract branch name
806+
shell: bash
807+
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
808+
id: extract_branch
809+
810+
- name: Combine contract sizes from individual examples
811+
run: |
812+
find .
813+
cat downloaded_artifacts/*/* | \
814+
sed -e 's/^integration-tests\/\(public\/\|internal\/\)\?//' | \
815+
sort | uniq > measurements-${{ steps.extract_branch.outputs.branch }}
816+
echo "----"
817+
cat measurements-${{ steps.extract_branch.outputs.branch }}
818+
819+
- uses: actions/upload-artifact@v4
820+
with:
821+
path: ./measurements-${{ steps.extract_branch.outputs.branch }}
822+
retention-days: 31
781823

782824
examples-docs:
783825
runs-on: ubuntu-latest
@@ -794,7 +836,7 @@ jobs:
794836
fetch-depth: 1
795837

796838
- name: Cache
797-
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
839+
uses: Swatinem/rust-cache@v2
798840
with:
799841
cache-directories: ${{ env.CARGO_TARGET_DIR }}
800842
cache-all-crates: true
@@ -823,13 +865,10 @@ jobs:
823865
# fuzz
824866
fuzz:
825867
runs-on: ubuntu-latest
826-
# todo bring back more needs, so that we only run this `fuzz` stage
827-
# if pre-conditions are filled.
828-
#needs: [set-image, examples-docs, examples-contract-build, examples-test, examples-custom-test]
829-
needs: [set-image]
830-
#if: >
831-
#github.event_name == 'push' &&
832-
#github.ref == 'refs/heads/master'
868+
needs: [set-image, examples-docs, examples-contract-build-riscv, examples-test, examples-custom-test]
869+
if: >
870+
github.event_name == 'push' &&
871+
github.ref == 'refs/heads/master'
833872
permissions:
834873
issues: write
835874
defaults:
@@ -844,7 +883,7 @@ jobs:
844883
fetch-depth: 1
845884

846885
- name: Cache
847-
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
886+
uses: Swatinem/rust-cache@v2
848887
with:
849888
cache-directories: ${{ env.CARGO_TARGET_DIR }}
850889
cache-all-crates: true

.github/workflows/issue-notifier.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- link
2626
- squink-splash-advanced
2727
- squink-splash-beginner
28-
- substrate-contracts-node
28+
- ink-node
2929
steps:
3030
- name: Generate token
3131
id: generate_token

.github/workflows/measurements.yml

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ env:
77
CARGO_TARGET_DIR: /ci-cache/${{ github.repository }}/targets/${{ github.ref_name }}/${{ github.job }}
88

99
jobs:
10-
contract-sizes:
10+
compare-contract-sizes:
1111
if: ${{ github.event_name == 'pull_request' }}
1212
runs-on: ubuntu-latest
1313
defaults:
@@ -20,29 +20,10 @@ jobs:
2020
matrix:
2121
branch: [master, pull_request]
2222
steps:
23-
- name: Checkout Pull Request
24-
if: ${{ matrix.branch == 'pull_request' }}
25-
uses: actions/checkout@v4
26-
with:
27-
fetch-depth: 1
28-
29-
- name: Checkout Master
30-
if: ${{ matrix.branch == 'master' }}
31-
uses: actions/checkout@v4
32-
with:
33-
ref: master
34-
fetch-depth: 1
35-
36-
- name: Cache
37-
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
38-
with:
39-
cache-directories: ${{ env.CARGO_TARGET_DIR }}
40-
cache-all-crates: true
41-
4223
- name: Rust Info
4324
uses: ./.github/rust-info
4425

45-
- name: Measure Contract Sizes
26+
- name: Post Contract Sizes Measurements
4627
env:
4728
PR_NUMBER: ${{ github.event.number }}
4829
run: |

.github/workflows/pr-notifier.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- smart-bench
2828
- squink-splash-advanced
2929
- squink-splash-beginner
30-
- substrate-contracts-node
30+
- ink-node
3131
steps:
3232
- name: Generate token
3333
id: generate_token

.github/workflows/submit-contract-sizes.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,25 @@ jobs:
2020
github.event.workflow_run.event == 'pull_request' &&
2121
github.event.workflow_run.conclusion == 'success'
2222
steps:
23-
- name: Checkout
24-
uses: actions/checkout@v4
25-
with:
26-
fetch-depth: 100
27-
2823
- name: Download Master Contract Sizes
2924
uses: ./.github/download-artifact
3025
with:
3126
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32-
ARTIFACT_NAME: contract-sizes-master-data
27+
ARTIFACT_NAME: measurements-master
28+
29+
- name: Extract branch name
30+
shell: bash
31+
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
32+
id: extract_branch
3333

3434
- name: Download Pull-Request Contract Sizes
3535
uses: ./.github/download-artifact
36+
#PR_NUMBER: ${{ github.event.number }}
3637
with:
3738
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38-
ARTIFACT_NAME: contract-sizes-pull_request-data
39+
#ARTIFACT_NAME: contract-sizes-pull_request-data
40+
#ARTIFACT_NAME: contract-sizes-${{ github.event.number }}
41+
ARTIFACT_NAME: measurements-${{ steps.extract_branch.outputs.branch }}
3942

4043
- name: Collect Contract Sizes
4144
run: |

ARCHITECTURE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ink!ternals
1+
# ink! v6 Architecture
22

33
This document describes the architecture of ink!. The information
44
here targets those who want to understand or modify the inner

0 commit comments

Comments
 (0)