Skip to content

Commit

Permalink
Merge branch 'master' into tarekkma/state_migration
Browse files Browse the repository at this point in the history
  • Loading branch information
TarekkMA committed Aug 27, 2024
2 parents 691c7aa + 84bbe13 commit 420e6cb
Show file tree
Hide file tree
Showing 15 changed files with 453 additions and 16 deletions.
164 changes: 164 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,170 @@ jobs:
name: moonbeam
path: build

check-wasm-size:
name: "Check WASM runtimes with Twiggy"
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
needs: ["set-tags", "build"]
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
# With rustup's nice new toml format, we just need to run rustup show to install the toolchain
# https://github.com/actions-rs/toolchain/issues/126#issuecomment-782989659
- name: Setup Rust toolchain
run: |
rustup override unset
rustup show
- name: Download Twiggy
run: cargo install twiggy
- name: Lookup for latest target branch build
run: |
TARGET_BRANCH=${{ github.event.pull_request.base.ref }}
LATEST_TARGET_BRANCH_BUILD=$(gh run -R moonbeam-foundation/moonbeam list -w Build --limit=100 --json databaseId,url,headBranch,event,status,conclusion,createdAt --jq ".[] | select(.headBranch == \"$TARGET_BRANCH\" and .event == \"push\" and .status == \"completed\" and .conclusion == \"success\") | .databaseId" | head -n 1)
echo "LATEST_TARGET_BRANCH_BUILD=$LATEST_TARGET_BRANCH_BUILD" >> $GITHUB_OUTPUT
- name: Download latest target branch build artifacts
run: |
gh run download $LATEST_TARGET_BRANCH_BUILD -n uncompressed-runtimes --dir uncompressed-runtimes-target-branch
gh run download $LATEST_TARGET_BRANCH_BUILD -n runtimes --dir runtimes-target-branch
- name: Check Runtimes size for target branch
run: |
PREVIOUS_MOONBASE=$(du -k runtimes-target-branch/* | awk '/moonbase_runtime/ {print $1}')
PREVIOUS_MOONBEAM=$(du -k runtimes-target-branch/* | awk '/moonbeam_runtime/ {print $1}')
PREVIOUS_MOONRIVER=$(du -k runtimes-target-branch/* | awk '/moonriver_runtime/ {print $1}')
echo "PREVIOUS_MOONBASE=$PREVIOUS_MOONBASE" >> $GITHUB_ENV
echo "PREVIOUS_MOONBEAM=$PREVIOUS_MOONBEAM" >> $GITHUB_ENV
echo "PREVIOUS_MOONRIVER=$PREVIOUS_MOONRIVER" >> $GITHUB_ENV
- name: "Download branch built runtime"
uses: actions/download-artifact@v4
with:
name: runtimes
path: runtimes-current-branch
- name: "Download branch built uncompressed-runtimes"
uses: actions/download-artifact@v4
with:
name: uncompressed-runtimes
path: uncompressed-runtimes-current-branch
- name: Check Runtimes size for current branch
run: |
CURRENT_MOONBASE=$(du -k runtimes-current-branch/* | awk '/moonbase_runtime/ {print $1}')
CURRENT_MOONBEAM=$(du -k runtimes-current-branch/* | awk '/moonbeam_runtime/ {print $1}')
CURRENT_MOONRIVER=$(du -k runtimes-current-branch/* | awk '/moonriver_runtime/ {print $1}')
echo "CURRENT_MOONBASE=$CURRENT_MOONBASE" >> $GITHUB_ENV
echo "CURRENT_MOONBEAM=$CURRENT_MOONBEAM" >> $GITHUB_ENV
echo "CURRENT_MOONRIVER=$CURRENT_MOONRIVER" >> $GITHUB_ENV
- name: Fetch latest release tag
id: fetch_latest_release
run: |
LATEST_RELEASE_TAG=$(gh api repos/moonbeam-foundation/moonbeam/releases --paginate --jq '.[] | select(.tag_name | test("^runtime-\\d+$")) | .tag_name' | sort -V | tail -n 1)
echo "LATEST_RELEASE_TAG=$LATEST_RELEASE_TAG" >> $GITHUB_ENV
echo $LATEST_RELEASE_TAG
- name: Download latest release runtimes
run: |
gh release download $LATEST_RELEASE_TAG -R moonbeam-foundation/moonbeam -p "moonbeam-runtime-${LATEST_RELEASE_TAG#runtime-}.wasm" -p "moonbase-runtime-${LATEST_RELEASE_TAG#runtime-}.wasm" -p "moonriver-runtime-${LATEST_RELEASE_TAG#runtime-}.wasm" --dir runtimes-latest-release
- name: Check Runtimes size for latest release
run: |
LATEST_MOONBASE=$(du -k runtimes-latest-release/* | awk '/moonbase-runtime/ {print $1}')
LATEST_MOONBEAM=$(du -k runtimes-latest-release/* | awk '/moonbeam-runtime/ {print $1}')
LATEST_MOONRIVER=$(du -k runtimes-latest-release/* | awk '/moonriver-runtime/ {print $1}')
echo "LATEST_MOONBASE=$LATEST_MOONBASE" >> $GITHUB_ENV
echo "LATEST_MOONBEAM=$LATEST_MOONBEAM" >> $GITHUB_ENV
echo "LATEST_MOONRIVER=$LATEST_MOONRIVER" >> $GITHUB_ENV
- name: Create Twiggy diff reports
run: |
# Install Twiggy if not already installed
if ! command -v twiggy &> /dev/null; then
cargo install twiggy
fi
# Generate Twiggy diff reports in JSON format with top 100 entries
mkdir -p twiggy-diff-reports
twiggy diff -n 100 --format json uncompressed-runtimes-target-branch/moonbase_runtime.wasm uncompressed-runtimes-current-branch/moonbase_runtime.wasm > twiggy-diff-reports/twiggy_diff_moonbase.json
twiggy diff -n 100 --format json uncompressed-runtimes-target-branch/moonbeam_runtime.wasm uncompressed-runtimes-current-branch/moonbeam_runtime.wasm > twiggy-diff-reports/twiggy_diff_moonbeam.json
twiggy diff -n 100 --format json uncompressed-runtimes-target-branch/moonriver_runtime.wasm uncompressed-runtimes-current-branch/moonriver_runtime.wasm > twiggy-diff-reports/twiggy_diff_moonriver.json
- name: Upload Twiggy diff reports
uses: actions/upload-artifact@v4
with:
name: twiggy-diff-reports
path: twiggy-diff-reports
- name: Compare Runtimes sizes
run: |
# Create or truncate the file
echo "" > runtime_size_report.md
MOONBASE_DIFF=$((CURRENT_MOONBASE - PREVIOUS_MOONBASE))
MOONBEAM_DIFF=$((CURRENT_MOONBEAM - PREVIOUS_MOONBEAM))
MOONRIVER_DIFF=$((CURRENT_MOONRIVER - PREVIOUS_MOONRIVER))
LATEST_MOONBASE_DIFF=$((CURRENT_MOONBASE - LATEST_MOONBASE))
LATEST_MOONBEAM_DIFF=$((CURRENT_MOONBEAM - LATEST_MOONBEAM))
LATEST_MOONRIVER_DIFF=$((CURRENT_MOONRIVER - LATEST_MOONRIVER))
get_status_emoji() {
local size=$1
local diff=$2
if [ $size -gt 2400 ]; then
echo "🚨"
elif [ $diff -gt 0 ]; then
echo "⚠️"
else
echo "✅"
fi
}
MOONBASE_STATUS=$(get_status_emoji $CURRENT_MOONBASE $MOONBASE_DIFF)
MOONBEAM_STATUS=$(get_status_emoji $CURRENT_MOONBEAM $MOONBEAM_DIFF)
MOONRIVER_STATUS=$(get_status_emoji $CURRENT_MOONRIVER $MOONRIVER_DIFF)
LATEST_MOONBASE_STATUS=$(get_status_emoji $CURRENT_MOONBASE $LATEST_MOONBASE_DIFF)
LATEST_MOONBEAM_STATUS=$(get_status_emoji $CURRENT_MOONBEAM $LATEST_MOONBEAM_DIFF)
LATEST_MOONRIVER_STATUS=$(get_status_emoji $CURRENT_MOONRIVER $LATEST_MOONRIVER_DIFF)
MOONBASE_MSG="Moonbase runtime: ${CURRENT_MOONBASE} KB ($( [ $MOONBASE_DIFF -eq 0 ] && echo "no changes" || echo "$( [ $MOONBASE_DIFF -gt 0 ] && echo "+" )${MOONBASE_DIFF} KB")) ${MOONBASE_STATUS}"
MOONBEAM_MSG="Moonbeam runtime: ${CURRENT_MOONBEAM} KB ($( [ $MOONBEAM_DIFF -eq 0 ] && echo "no changes" || echo "$( [ $MOONBEAM_DIFF -gt 0 ] && echo "+" )${MOONBEAM_DIFF} KB")) ${MOONBEAM_STATUS}"
MOONRIVER_MSG="Moonriver runtime: ${CURRENT_MOONRIVER} KB ($( [ $MOONRIVER_DIFF -eq 0 ] && echo "no changes" || echo "$( [ $MOONRIVER_DIFF -gt 0 ] && echo "+" )${MOONRIVER_DIFF} KB")) ${MOONRIVER_STATUS}"
LATEST_MOONBASE_MSG="Moonbase runtime: ${CURRENT_MOONBASE} KB ($( [ $LATEST_MOONBASE_DIFF -eq 0 ] && echo "no changes" || echo "$( [ $LATEST_MOONBASE_DIFF -gt 0 ] && echo "+" )${LATEST_MOONBASE_DIFF} KB compared to latest release")) ${LATEST_MOONBASE_STATUS}"
LATEST_MOONBEAM_MSG="Moonbeam runtime: ${CURRENT_MOONBEAM} KB ($( [ $LATEST_MOONBEAM_DIFF -eq 0 ] && echo "no changes" || echo "$( [ $LATEST_MOONBEAM_DIFF -gt 0 ] && echo "+" )${LATEST_MOONBEAM_DIFF} KB compared to latest release")) ${LATEST_MOONBEAM_STATUS}"
LATEST_MOONRIVER_MSG="Moonriver runtime: ${CURRENT_MOONRIVER} KB ($( [ $LATEST_MOONRIVER_DIFF -eq 0 ] && echo "no changes" || echo "$( [ $LATEST_MOONRIVER_DIFF -gt 0 ] && echo "+" )${LATEST_MOONRIVER_DIFF} KB compared to latest release")) ${LATEST_MOONRIVER_STATUS}"
echo "### WASM runtime size check:" > runtime_size_report.md
echo "" >> runtime_size_report.md
echo "#### Compared to target branch" >> runtime_size_report.md
echo "" >> runtime_size_report.md
echo "$MOONBASE_MSG" >> runtime_size_report.md
echo "" >> runtime_size_report.md
echo "$MOONBEAM_MSG" >> runtime_size_report.md
echo "" >> runtime_size_report.md
echo "$MOONRIVER_MSG" >> runtime_size_report.md
echo "" >> runtime_size_report.md
echo "#### Compared to latest release (${LATEST_RELEASE_TAG})" >> runtime_size_report.md
echo "" >> runtime_size_report.md
echo "$LATEST_MOONBASE_MSG" >> runtime_size_report.md
echo "" >> runtime_size_report.md
echo "$LATEST_MOONBEAM_MSG" >> runtime_size_report.md
echo "" >> runtime_size_report.md
echo "$LATEST_MOONRIVER_MSG" >> runtime_size_report.md
cat runtime_size_report.md
- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: "WASM runtime size check"
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-path: runtime_size_report.md
edit-mode: replace

rust-test:
runs-on:
labels: bare-metal
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion file_header.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-2022 PureStake Inc.
// Copyright 2024 Moonbeam foundation
// This file is part of Moonbeam.

// Moonbeam is free software: you can redistribute it and/or modify
Expand Down
3 changes: 3 additions & 0 deletions runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ xcm-primitives = { workspace = true }
# Substrate
cumulus-pallet-parachain-system = { workspace = true }
cumulus-pallet-xcmp-queue = { workspace = true }
pallet-message-queue = { workspace = true }
frame-benchmarking = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
Expand Down Expand Up @@ -109,6 +110,7 @@ std = [
"pallet-xcm-transactor/std",
"pallet-moonbeam-lazy-migrations/std",
"pallet-identity/std",
"pallet-message-queue/std",
"parity-scale-codec/std",
"precompile-utils/std",
"sp-consensus-slots/std",
Expand All @@ -126,6 +128,7 @@ std = [
runtime-benchmarks = [
"cumulus-pallet-parachain-system/runtime-benchmarks",
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"pallet-asset-manager/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
Expand Down
72 changes: 72 additions & 0 deletions runtime/common/src/weights/cumulus_pallet_parachain_system.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Copyright 2024 Moonbeam foundation
// This file is part of Moonbeam.

// Moonbeam is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Moonbeam is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.

//! Autogenerated weights for `cumulus_pallet_parachain_system`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-08-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `MacBook-Pro-de-romarq.local`, CPU: `<UNKNOWN>`
//! WASM-EXECUTION: Compiled, CHAIN: Some("moonbase-dev"), DB CACHE: 1024
// Executed Command:
// ./target/release/moonbeam
// benchmark
// pallet
// --chain=moonbase-dev
// --steps=50
// --repeat=20
// --pallet=cumulus_pallet_parachain_system
// --extrinsic=*
// --wasm-execution=compiled
// --header=./file_header.txt
// --template=./benchmarking/frame-weight-template.hbs
// --output=./runtime/common/src/weights/

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]

use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use sp_std::marker::PhantomData;

/// Weights for `cumulus_pallet_parachain_system`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> cumulus_pallet_parachain_system::WeightInfo for WeightInfo<T> {
/// Storage: `ParachainSystem::LastDmqMqcHead` (r:1 w:1)
/// Proof: `ParachainSystem::LastDmqMqcHead` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `MessageQueue::BookStateFor` (r:1 w:1)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
/// Storage: `MessageQueue::ServiceHead` (r:1 w:1)
/// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`)
/// Storage: `ParachainSystem::ProcessedDownwardMessages` (r:0 w:1)
/// Proof: `ParachainSystem::ProcessedDownwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `MessageQueue::Pages` (r:0 w:1000)
/// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(107993), added: 110468, mode: `MaxEncodedLen`)
/// The range of component `n` is `[0, 1000]`.
fn enqueue_inbound_downward_messages(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `82`
// Estimated: `3517`
// Minimum execution time: 2_000_000 picoseconds.
Weight::from_parts(2_000_000, 3517)
// Standard Error: 914_274
.saturating_add(Weight::from_parts(213_425_397, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(4_u64))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into())))
}
}
2 changes: 2 additions & 0 deletions runtime/common/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

//! Moonbeam common weights.
pub mod cumulus_pallet_parachain_system;
pub mod cumulus_pallet_xcmp_queue;
pub mod db;
pub mod pallet_asset_manager;
Expand All @@ -29,6 +30,7 @@ pub mod pallet_conviction_voting;
pub mod pallet_crowdloan_rewards;
pub mod pallet_evm;
pub mod pallet_identity;
pub mod pallet_message_queue;
pub mod pallet_moonbeam_foreign_assets;
pub mod pallet_moonbeam_lazy_migrations;
pub mod pallet_moonbeam_orbiters;
Expand Down
Loading

0 comments on commit 420e6cb

Please sign in to comment.