Skip to content

Commit

Permalink
Add genesis config presets to runtime (#3138)
Browse files Browse the repository at this point in the history
* refactor: ♻️ update deprecated options in command `moonbeam benchmark pallet`

* refactor: ♻️ update deprecated options in both invocations of the command within the script

* feat: ✨ add default preset for RuntimeGenesisConfig

* Revert "feat: ✨ add default preset for RuntimeGenesisConfig"

This reverts commit 52436cb.

* feat: ✨ add genesis builder dummy development preset

* refactor: ♻️ implement GenesisBuilder within each runtime

* refactor: ♻️ move moonbase runtime test config to runtime

* refactor: 🎨 improve structure

* refactor: ♻️ move moonbeam runtime test config to runtime

* refactor: ♻️ move moonriver runtime test config to runtime

* fix: 🔥 remove unused dep

* chore: 📄 add copyright

* refactor: 🔥 complete move of testnet_genesis functions to runtime

* refactor: ⚰️ remove dead functions *_inflation_config

* refactor: ♻️ add get_preset and preset_names functions

* build: ✨

* refactor: ♻️ correctly use with_genesis_config_preset_name in client code

* refactor: ♻️ use with_genesis_config_preset_name in test_spec

* refactor: 🔥 remove serde_json feature

* fix json serialization of GenesisConfig in xcm-transactor

* fix serde_json dependendency in no_std environemnt

* simplify code

* style: 🎨 format comment/tuple

* feat: ✨ add cargo feature to disable genesis builder

* refactor: ⚡ change cargo feature disable-genesis-builder to enable-genesis-builder

* fix: 🐛 correct enable-genesis-builder cargo feature logic and add it to all runtimes

* style: 🎨 rename enable-genesis-config cargo feature to genesis-config

* fix: 🐛 apply renaming of cargo feature enable-genesis-builder

* feat: 🔥 remove genesis-builder from default features

* feat: ⚡ remove genesis-builder and serde_json from default features

* refactor: ♻️ switch back to disable-genesis-builder

* fix: 🐛 remove genesis-builder feature references

* chore(ci): fix wasm-size-check

---------

Co-authored-by: Rodrigo Quelhas <[email protected]>
Co-authored-by: Rodrigo Quelhas <[email protected]>
  • Loading branch information
3 people authored Jan 28, 2025
1 parent aedf6b4 commit 6d6faaf
Show file tree
Hide file tree
Showing 29 changed files with 884 additions and 716 deletions.
38 changes: 27 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ jobs:
name: "Check WASM runtimes with Twiggy"
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
pull-requests: write
if: ${{ github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork }}
Expand All @@ -317,24 +318,47 @@ jobs:
- name: Download Twiggy
run: cargo install twiggy
- name: Lookup for latest target branch build
id: latest-target-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
- name: "Download runtimes from target branch"
uses: actions/download-artifact@v4
with:
name: runtimes
path: runtimes-target-branch
merge-multiple: true
github-token: ${{ github.token }}
run-id: ${{ steps.latest-target-build.outputs.LATEST_TARGET_BRANCH_BUILD }}
- name: "Download uncompressed-runtimes from target branch"
uses: actions/download-artifact@v4
with:
name: uncompressed-runtimes
path: uncompressed-runtimes-target-branch
merge-multiple: true
github-token: ${{ github.token }}
run-id: ${{ steps.latest-target-build.outputs.LATEST_TARGET_BRANCH_BUILD }}
- name: Check Runtimes size for target branch
run: |
gh run -R moonbeam-foundation/moonbeam download $LATEST_TARGET_BRANCH_BUILD -n uncompressed-runtimes --dir uncompressed-runtimes-target-branch
gh run -R moonbeam-foundation/moonbeam download $LATEST_TARGET_BRANCH_BUILD -n runtimes --dir runtimes-target-branch
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
merge-multiple: true
- name: "Download branch built uncompressed-runtimes"
uses: actions/download-artifact@v4
with:
name: uncompressed-runtimes
path: uncompressed-runtimes-current-branch
merge-multiple: true
- name: Check Runtimes size for current branch
run: |
CURRENT_MOONBASE=$(du -k runtimes-current-branch/* | awk '/moonbase_runtime/ {print $1}')
Expand All @@ -360,14 +384,6 @@ jobs:
echo "LATEST_MOONBASE=$LATEST_MOONBASE" >> $GITHUB_ENV
echo "LATEST_MOONBEAM=$LATEST_MOONBEAM" >> $GITHUB_ENV
echo "LATEST_MOONRIVER=$LATEST_MOONRIVER" >> $GITHUB_ENV
- 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: Create Twiggy diff reports
run: |
# Install Twiggy if not already installed
Expand Down
4 changes: 4 additions & 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ parking_lot = "0.12.1"
primitive-types = "0.12.1"
prometheus = { version = "0.13.0", default-features = false }
rand = "0.8.5"
serde_json = { version = "1.0.114" }
serde_json = { version = "1.0.114", default-features = false }
similar-asserts = "1.1.0"
tempfile = "3.8.1"
tiny-bip39 = { version = "0.8", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion client/evm-tracing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ version = "0.1.0"
ethereum-types = { workspace = true, features = [ "std" ] }
hex = { workspace = true, features = [ "serde" ] }
serde = { workspace = true, features = [ "derive", "std" ] }
serde_json = { workspace = true }
serde_json = { workspace = true, default-features = true }

# Moonbeam
evm-tracing-events = { workspace = true, features = [ "std" ] }
Expand Down
2 changes: 1 addition & 1 deletion client/rpc-core/debug/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jsonrpsee = { workspace = true, features = [ "macros", "server" ] }
moonbeam-client-evm-tracing = { workspace = true }
moonbeam-rpc-core-types = { workspace = true }
serde = { workspace = true, features = [ "derive" ] }
serde_json = { workspace = true }
serde_json = { workspace = true, default-features = true }

sp-core = { workspace = true, features = [ "std" ] }
fc-rpc-core = { workspace = true }
2 changes: 1 addition & 1 deletion client/rpc-core/trace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jsonrpsee = { workspace = true, features = [ "macros", "server" ] }
moonbeam-client-evm-tracing = { workspace = true }
moonbeam-rpc-core-types = { workspace = true }
serde = { workspace = true, features = [ "derive" ] }
serde_json = { workspace = true }
serde_json = { workspace = true, default-features = true }
2 changes: 1 addition & 1 deletion client/rpc-core/txpool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ ethereum = { workspace = true, features = [ "std", "with-codec" ] }
ethereum-types = { workspace = true, features = [ "std" ] }
jsonrpsee = { workspace = true, features = [ "macros", "server" ] }
serde = { workspace = true, features = [ "derive" ] }
serde_json = { workspace = true }
serde_json = { workspace = true, default-features = true }

fc-rpc-core = { workspace = true }
2 changes: 1 addition & 1 deletion client/rpc-core/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ version = "0.1.0"
[dependencies]
ethereum-types = { workspace = true, features = [ "std" ] }
serde = { workspace = true, features = [ "derive" ] }
serde_json = { workspace = true }
serde_json = { workspace = true, default-features = true }
2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ assert_cmd = { workspace = true }
hex = { workspace = true, features = [ "std" ] }
nix = { workspace = true }
serde = { workspace = true, features = [ "derive" ] }
serde_json = { workspace = true }
serde_json = { workspace = true, default-features = true }
tempfile = { workspace = true }
tracing-core = { workspace = true }

Expand Down
3 changes: 1 addition & 2 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,8 +866,7 @@ pub fn run() -> Result<()> {
max_retries_per_request: cli.run.lazy_loading_max_retries_per_request,
};

let spec_builder =
chain_spec::test_spec::lazy_loading_spec_builder(Default::default());
let spec_builder = chain_spec::test_spec::lazy_loading_spec_builder();
config.chain_spec = Box::new(spec_builder.build());

// TODO: create a tokio runtime inside offchain_worker thread (otherwise it will panic)
Expand Down
3 changes: 2 additions & 1 deletion node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ log = { workspace = true }
maplit = { workspace = true }
parking_lot = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
serde_json = { workspace = true, default-features = true }
sha3 = { workspace = true }
tiny-bip39 = { workspace = true }
tokio = { workspace = true, features = ["sync", "rt-multi-thread"] }
Expand Down Expand Up @@ -93,6 +93,7 @@ sp-block-builder = { workspace = true, features = ["std"] }
sp-blockchain = { workspace = true }
sp-consensus = { workspace = true }
sp-core = { workspace = true, features = ["std"] }
sp-genesis-builder = { workspace = true, features = ["std"] }
sp-inherents = { workspace = true, features = ["std"] }
sp-io = { workspace = true, features = ["std"] }
sp-keystore = { workspace = true, features = ["std"] }
Expand Down
Loading

0 comments on commit 6d6faaf

Please sign in to comment.