Skip to content

Fetch Contracts

Fetch Contracts #1455

name: Fetch Contracts
on:
push:
branches: [ main ]
schedule:
- cron: '0 */6 * * *'
workflow_dispatch:
permissions:
contents: write
jobs:
list-buckets:
runs-on: ubuntu-latest
outputs:
bucket0: ${{ steps.list-buckets.outputs.bucket0 }}
bucket1: ${{ steps.list-buckets.outputs.bucket1 }}
bucket2: ${{ steps.list-buckets.outputs.bucket2 }}
bucket3: ${{ steps.list-buckets.outputs.bucket3 }}
bucket4: ${{ steps.list-buckets.outputs.bucket4 }}
bucket5: ${{ steps.list-buckets.outputs.bucket5 }}
bucket6: ${{ steps.list-buckets.outputs.bucket6 }}
bucket7: ${{ steps.list-buckets.outputs.bucket7 }}
bucket8: ${{ steps.list-buckets.outputs.bucket8 }}
bucket9: ${{ steps.list-buckets.outputs.bucket9 }}
bucket10: ${{ steps.list-buckets.outputs.bucket10 }}
bucket11: ${{ steps.list-buckets.outputs.bucket11 }}
bucket12: ${{ steps.list-buckets.outputs.bucket12 }}
bucket13: ${{ steps.list-buckets.outputs.bucket13 }}
bucket14: ${{ steps.list-buckets.outputs.bucket14 }}
bucket15: ${{ steps.list-buckets.outputs.bucket15 }}
bucket16: ${{ steps.list-buckets.outputs.bucket16 }}
bucket17: ${{ steps.list-buckets.outputs.bucket17 }}
bucket18: ${{ steps.list-buckets.outputs.bucket18 }}
bucket19: ${{ steps.list-buckets.outputs.bucket19 }}
bucket20: ${{ steps.list-buckets.outputs.bucket20 }}
bucket21: ${{ steps.list-buckets.outputs.bucket21 }}
steps:
- uses: actions/checkout@v4
- run: rustup upgrade
- uses: stellar/actions/rust-cache@main
- name: Check list-buckets
run: cargo check --locked --release --manifest-path .scripts/list-buckets/Cargo.toml
- name: Run list-buckets
id: list-buckets
run: |
BUCKETS=$(cargo run --locked --release --manifest-path .scripts/list-buckets/Cargo.toml)
echo "Buckets: $BUCKETS"
i=0
while IFS= read -r line; do
if [ -n "$line" ] && [ $i -lt 22 ]; then
echo "bucket$i=$line" >> "$GITHUB_OUTPUT"
i=$((i+1))
fi
done <<< "$BUCKETS"
get-contracts:
runs-on: ubuntu-latest
needs: list-buckets
outputs:
commit-sha: ${{ steps.commit.outputs.commit-sha }}
steps:
- name: Free disk space
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- uses: actions/checkout@v4
- run: rustup upgrade
- uses: stellar/actions/rust-cache@main
- uses: stellar/stellar-cli@v26.0.0
- name: Install wasm-call-graph (from https://github.com/graydon/wasm-call-graph/pull/4)
run: cargo install --git https://github.com/graydon/wasm-call-graph --rev bd2bc5c61ee075d687c1fea51c6d35b16d623bea wasm-call-graph
- name: Download env.json for wasm-call-graph
run: curl -sL https://raw.githubusercontent.com/stellar/rs-soroban-env/main/soroban-env-common/env.json -o /tmp/env.json
- name: Restore cached bucket0
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket0 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket0 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket0 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket0 }}-
- name: Restore cached bucket1
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket1 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket1 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket1 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket1 }}-
- name: Restore cached bucket2
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket2 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket2 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket2 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket2 }}-
- name: Restore cached bucket3
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket3 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket3 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket3 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket3 }}-
- name: Restore cached bucket4
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket4 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket4 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket4 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket4 }}-
- name: Restore cached bucket5
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket5 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket5 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket5 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket5 }}-
- name: Restore cached bucket6
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket6 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket6 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket6 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket6 }}-
- name: Restore cached bucket7
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket7 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket7 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket7 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket7 }}-
- name: Restore cached bucket8
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket8 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket8 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket8 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket8 }}-
- name: Restore cached bucket9
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket9 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket9 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket9 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket9 }}-
- name: Restore cached bucket10
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket10 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket10 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket10 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket10 }}-
- name: Restore cached bucket11
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket11 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket11 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket11 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket11 }}-
- name: Restore cached bucket12
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket12 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket12 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket12 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket12 }}-
- name: Restore cached bucket13
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket13 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket13 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket13 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket13 }}-
- name: Restore cached bucket14
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket14 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket14 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket14 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket14 }}-
- name: Restore cached bucket15
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket15 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket15 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket15 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket15 }}-
- name: Restore cached bucket16
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket16 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket16 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket16 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket16 }}-
- name: Restore cached bucket17
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket17 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket17 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket17 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket17 }}-
- name: Restore cached bucket18
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket18 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket18 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket18 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket18 }}-
- name: Restore cached bucket19
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket19 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket19 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket19 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket19 }}-
- name: Restore cached bucket20
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket20 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket20 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket20 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket20 }}-
- name: Restore cached bucket21
uses: actions/cache@v4
if: ${{ needs.list-buckets.outputs.bucket21 != '' }}
with:
path: cache/bucket-${{ needs.list-buckets.outputs.bucket21 }}.xdr.gz
key: bucket-gz-${{ needs.list-buckets.outputs.bucket21 }}
restore-keys: |
bucket-gz-${{ needs.list-buckets.outputs.bucket21 }}-
- name: Run get-contracts-from-buckets
run: >
cargo run --locked --release --manifest-path .scripts/get-contracts-from-buckets/Cargo.toml --
${{ needs.list-buckets.outputs.bucket0 }}
${{ needs.list-buckets.outputs.bucket1 }}
${{ needs.list-buckets.outputs.bucket2 }}
${{ needs.list-buckets.outputs.bucket3 }}
${{ needs.list-buckets.outputs.bucket4 }}
${{ needs.list-buckets.outputs.bucket5 }}
${{ needs.list-buckets.outputs.bucket6 }}
${{ needs.list-buckets.outputs.bucket7 }}
${{ needs.list-buckets.outputs.bucket8 }}
${{ needs.list-buckets.outputs.bucket9 }}
${{ needs.list-buckets.outputs.bucket10 }}
${{ needs.list-buckets.outputs.bucket11 }}
${{ needs.list-buckets.outputs.bucket12 }}
${{ needs.list-buckets.outputs.bucket13 }}
${{ needs.list-buckets.outputs.bucket14 }}
${{ needs.list-buckets.outputs.bucket15 }}
${{ needs.list-buckets.outputs.bucket16 }}
${{ needs.list-buckets.outputs.bucket17 }}
${{ needs.list-buckets.outputs.bucket18 }}
${{ needs.list-buckets.outputs.bucket19 }}
${{ needs.list-buckets.outputs.bucket20 }}
${{ needs.list-buckets.outputs.bucket21 }}
- name: Run wat
run: >
cargo run --locked --release --manifest-path .scripts/wat/Cargo.toml contracts/ wat/
- name: Run imports
run: >
cargo run --locked --release --manifest-path .scripts/extract-imports/Cargo.toml contracts/ imports/
- name: Run extract-specs
run: >
cargo run --locked --release --manifest-path .scripts/extract-specs/Cargo.toml contracts/ specs/
- name: Run extract-meta
run: >
cargo run --locked --release --manifest-path .scripts/extract-meta/Cargo.toml contracts/ meta/
- name: Run find sep47 meta script
run: >
cargo run --locked --release --manifest-path .scripts/find-sep47-meta/Cargo.toml contracts/ | tee analysis/find_sep47_meta_results.csv
- name: Run optimize-analysis
run: >
cargo run --locked --release --manifest-path .scripts/optimize-analysis/Cargo.toml contracts/ > analysis/optimize.csv
- name: Run spec-analysis
run: >
cargo run --locked --release --manifest-path .scripts/spec-analysis/Cargo.toml contracts/ > analysis/spec.csv
- name: Run lib-analysis
run: >
cargo run --locked --release --manifest-path .scripts/lib-analysis/Cargo.toml contracts/ > analysis/spec-contracttype-lib-usage.csv
- name: Run dupe-code-analysis
run: >
cargo run --locked --release --manifest-path .scripts/dupe-code-analysis/Cargo.toml contracts/ > analysis/dupe-code.csv
- name: Run dupe-section-analysis
run: >
cargo run --locked --release --manifest-path .scripts/dupe-section-analysis/Cargo.toml contracts/ > analysis/dupe-sections.csv
- name: Run dupe-spec-analysis
run: >
cargo run --locked --release --manifest-path .scripts/dupe-specs-analysis/Cargo.toml contracts/ > analysis/dupe-specs.csv
- name: Run wasm-call-graph
run: |
mkdir -p callgraph
for wasm in contracts/*.wasm; do
hash=$(basename "$wasm" .wasm)
wasm-call-graph --leaves-only --env-symbols /tmp/env.json "$wasm" > "callgraph/${hash}.txt"
done
- name: Run imports-usage
run: >
cargo run --locked --release --manifest-path .scripts/imports-usage/Cargo.toml imports analysis/
- name: Run find rsver 1.91.0 script
run: >
./.scripts/find_rsver_1910.sh | tee analysis/find_rsver_1910_results.txt
- name: Run find event 1679 script
run: >
./.scripts/find_event_1679.sh | tee analysis/find_event_1679_results.csv
- name: Run find rem_euclid script
run: >
./.scripts/find_rem_euclid.sh | tee analysis/find_rem_euclid_results.csv
- name: Run find sdk_version script
run: >
./.scripts/find_sdk_version.sh | tee analysis/find_sdk_version_results.csv
- name: Run find memory_grow script
run: >
./.scripts/find_memory_grow.sh | tee analysis/find_memory_grow_results.csv
- name: Run map instances script
run: >
./.scripts/map_instances.sh | tee analysis/map_instances.csv
- name: Run count instances script
run: >
./.scripts/count_instances.sh | tee analysis/count_instances.txt
- name: Run count instances per wasm script
run: >
./.scripts/count_instances_per_wasm.sh | tee analysis/count_instances_per_wasm.csv
- name: Run find error name collision with sdk script
run: >
./.scripts/find_error_name_collision_with_sdk.sh | tee analysis/find_error_name_collision_with_sdk_results.csv
- name: Run find constructor events script
run: >
./.scripts/find_constructor_events.sh | tee analysis/find_constructor_events_results.csv
- name: Run find sep50 nft contracts token_id types script
run: >
./.scripts/find_sep50_nft_contracts_token_id_types.sh | tee analysis/find_sep50_nft_contracts_token_id_types_results.csv
- name: Commit contracts
id: commit
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add analysis/
git add callgraph/
git add contracts/
git add wat/
git add meta/
git add specs/
git add imports/
git add instances/
git commit -m "Update contracts from buckets" || echo "No changes to commit"
git push
echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
generate-docs:
needs: get-contracts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.get-contracts.outputs.commit-sha }}
- run: rustup upgrade
- uses: stellar/actions/rust-cache@main
- name: Run wikigen
run: >
cargo run --locked --release --manifest-path .scripts/wikigen/Cargo.toml --
--contracts-dir contracts
--meta-dir meta
--spec-dir specs
--wat-dir wat
--imports-dir imports
--instances-dir instances
--output-dir docs
- name: Run imports-usage
run: >
cargo run --locked --release --manifest-path .scripts/imports-usage/Cargo.toml --
imports
analysis
- uses: actions/upload-pages-artifact@v3
with:
path: docs
deploy:
needs: [get-contracts, generate-docs]
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- id: deployment
uses: actions/deploy-pages@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
folder: docs