Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

bug: fix build-spec #1037

Merged
merged 4 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/madara-commands.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Task - Test Madara Commands

on:
workflow_dispatch:
workflow_call:

jobs:
build-spec:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
fail-on-cache-miss: true
- name: Create build-spec (plain)
run: |
target/release/madara build-spec --chain local > chain-plain.json
- name: Create build-spec (raw)
run: |
target/release/madara build-spec --chain chain-plain.json --raw > chain-raw.json

# TODO: add remaining commands
5 changes: 5 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ jobs:
uses: ./.github/workflows/rust-build.yml
needs: changelog

madara_commands:
name: Test Madara commands
uses: ./.github/workflows/madara-commands.yml
needs: rust_build

linters_cargo:
name: Run Cargo linters
uses: ./.github/workflows/linters-cargo.yml
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Next release

- ci: add verification if build-spec is working
- bug: fix build-spec not working by setting the madara-path always and fetching
relevant files
- fix: RPC getClassAt cairo legacy program code encoding
- ci: added wasm to test
- docs: added translation of madara beast article.md to portuguese
Expand Down
122 changes: 61 additions & 61 deletions crates/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,67 @@ impl SubstrateCli for Cli {
pub fn run() -> sc_cli::Result<()> {
let mut cli = Cli::from_args();

// alias madara_path <> base_path
// TODO also alias tmp (tmp generates random base_paths that are not specified within
// the command)
let madara_path = match (cli.run.madara_path.clone(), cli.run.run_cmd.shared_params.base_path.clone()) {
(Some(madara_path), _) => {
cli.run.run_cmd.shared_params.base_path = Some(madara_path.clone());
madara_path.to_str().unwrap().to_string()
}
(_, Some(base_path)) => {
cli.run.madara_path = Some(base_path.clone());
base_path.to_str().unwrap().to_string()
}
_ => {
let home_path = std::env::var("HOME").unwrap_or(std::env::var("USERPROFILE").unwrap_or(".".into()));
let path = format!("{}/.madara", home_path);
cli.run.run_cmd.shared_params.base_path = Some((path.clone()).into());
cli.run.madara_path = Some((path.clone()).into());
path
}
};

if let Some(genesis_url) = cli.run.genesis_url.clone() {
// can't copy extra genesis-assets atm
// we can reuse #982 to create the standard to fetch relevant files
utils::fetch_from_url(genesis_url, madara_path.clone() + "/configs/genesis-assets")?;
} else {
// TODO confirm with the CI that we are fetching all and fetch dynamically
// Issue #982
for file in constants::GENESIS_ASSETS_FILES {
let src_path = utils::get_project_path();
if let Ok(src_path) = src_path {
let src_path = src_path + "/configs/genesis-assets/" + file;
utils::copy_from_filesystem(src_path, madara_path.clone() + "/genesis-assets")?;
} else {
utils::fetch_from_url(
constants::GENESIS_ASSETS_URL.to_string() + file,
madara_path.clone() + "/genesis-assets",
)?;
}
}
}

// TODO confirm with the CI that we are fetching all and fetch dynamically
// Issue #982
for file in constants::CAIRO_CONTRACTS_FILES {
let src_path = utils::get_project_path();
if let Ok(src_path) = src_path {
let src_path = src_path + "/configs/cairo-contracts/" + file;
utils::copy_from_filesystem(src_path, madara_path.clone() + "/cairo-contracts")?;
} else {
utils::fetch_from_url(
constants::CAIRO_CONTRACTS_URL.to_string() + file,
madara_path.clone() + "/cairo-contracts",
)?;
}
}

if let (Some(chain_spec_url), None) = (cli.run.chain_spec_url.clone(), cli.run.testnet) {
utils::fetch_from_url(chain_spec_url, madara_path.clone() + "/chain-specs")?;
}

match &cli.subcommand {
Some(Subcommand::Key(cmd)) => cmd.run(&cli),
Some(Subcommand::BuildSpec(cmd)) => {
Expand Down Expand Up @@ -189,70 +250,9 @@ pub fn run() -> sc_cli::Result<()> {
cli.run.run_cmd.rpc_methods = RpcMethods::Unsafe;
}

// alias madara_path <> base_path
// TODO also alias tmp (tmp generates random base_paths that are not specified within
// the command)
let madara_path = match (cli.run.madara_path.clone(), cli.run.run_cmd.shared_params.base_path.clone()) {
(Some(madara_path), _) => {
cli.run.run_cmd.shared_params.base_path = Some(madara_path.clone());
madara_path.to_str().unwrap().to_string()
}
(_, Some(base_path)) => {
cli.run.madara_path = Some(base_path.clone());
base_path.to_str().unwrap().to_string()
}
_ => {
let home_path = std::env::var("HOME").unwrap_or(std::env::var("USERPROFILE").unwrap_or(".".into()));
let path = format!("{}/.madara", home_path);
cli.run.run_cmd.shared_params.base_path = Some((path.clone()).into());
cli.run.madara_path = Some((path.clone()).into());
path
}
};

cli.run.run_cmd.network_params.node_key_params.node_key_file =
Some((madara_path.clone() + "/p2p-key.ed25519").into());

if let Some(genesis_url) = cli.run.genesis_url.clone() {
// can't copy extra genesis-assets atm
// we can reuse #982 to create the standard to fetch relevant files
utils::fetch_from_url(genesis_url, madara_path.clone() + "/configs/genesis-assets")?;
} else {
// TODO confirm with the CI that we are fetching all and fetch dynamically
// Issue #982
for file in constants::GENESIS_ASSETS_FILES {
let src_path = utils::get_project_path();
if let Ok(src_path) = src_path {
let src_path = src_path + "/configs/genesis-assets/" + file;
utils::copy_from_filesystem(src_path, madara_path.clone() + "/genesis-assets")?;
} else {
utils::fetch_from_url(
constants::GENESIS_ASSETS_URL.to_string() + file,
madara_path.clone() + "/genesis-assets",
)?;
}
}
}

// TODO confirm with the CI that we are fetching all and fetch dynamically
// Issue #982
for file in constants::CAIRO_CONTRACTS_FILES {
let src_path = utils::get_project_path();
if let Ok(src_path) = src_path {
let src_path = src_path + "/configs/cairo-contracts/" + file;
utils::copy_from_filesystem(src_path, madara_path.clone() + "/cairo-contracts")?;
} else {
utils::fetch_from_url(
constants::CAIRO_CONTRACTS_URL.to_string() + file,
madara_path.clone() + "/cairo-contracts",
)?;
}
}

if let (Some(chain_spec_url), None) = (cli.run.chain_spec_url.clone(), cli.run.testnet) {
utils::fetch_from_url(chain_spec_url, madara_path.clone() + "/chain-specs")?;
}

if let Some(Testnet::Sharingan) = cli.run.testnet {
let src_path = utils::get_project_path();
if let Ok(src_path) = src_path {
Expand Down
Loading