Skip to content

Commit

Permalink
Merge branch 'main' of github.com:ImbueNetwork/imbue into eoa-field
Browse files Browse the repository at this point in the history
  • Loading branch information
f-gate committed Dec 6, 2023
2 parents 85f3e4a + b232698 commit 4d7810d
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 19 deletions.
25 changes: 14 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build-on-self-hosted-runner
name: test-features
on:
workflow_dispatch:
push:
Expand All @@ -9,13 +9,23 @@ on:
pull_request:
branches:
- main
- staging
paths-ignore:
- "**.md"
env:
CARGO_TERM_COLOR: always
GCP_ZONE: europe-west3-a

jobs:
check_branch:
runs-on: ubuntu-latest
steps:
- name: Check branch
if: github.base_ref == 'main' && github.head_ref != 'staging'
run: |
echo "ERROR: You can only merge to main from staging."
exit 1
create-runner:
runs-on: ubuntu-latest
outputs:
Expand All @@ -35,9 +45,9 @@ jobs:
ephemeral: true

test-features:
needs: create-runner
runs-on: ${{ needs.create-runner.outputs.label }}
steps:
needs: create-runner
runs-on: ${{ needs.create-runner.outputs.label }}
steps:
- uses: actions/checkout@v4

- name: Set HOME
Expand All @@ -50,16 +60,9 @@ jobs:
toolchain: nightly-2023-05-22
target: wasm32-unknown-unknown
override: true
components: rustfmt, clippy

- name: Install Dependencies
run: sudo apt install protobuf-compiler clang build-essential -y

- name: 🫠 rustfmt 🫠
uses: actions-rs/cargo@v1
with:
command: fmt
args: --check

- name: Run tests with benchmarks
run: cargo test --features runtime-benchmarks
37 changes: 37 additions & 0 deletions .github/workflows/fmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: cargo-fmt
on:
workflow_dispatch:
push:
branches:
- main
paths-ignore:
- "**.md"
pull_request:
branches:
- main
paths-ignore:
- "**.md"

jobs:
cargo-fmt:
runs-on: ${{ needs.create-runner.outputs.label }}
steps:
- uses: actions/checkout@v4

- name: Set HOME
run: echo "HOME=/home/ubuntu" >> ${GITHUB_ENV}

- name: Install minimal nightly Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2023-05-22
target: wasm32-unknown-unknown
override: true
components: rustfmt, clippy

- name: 🫠 rustfmt 🫠
uses: actions-rs/cargo@v1
with:
command: fmt
args: --check
1 change: 1 addition & 0 deletions pallets/fellowship/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ pub mod v0 {
weight = weight.saturating_add(T::DbWeight::get().reads_writes(2, 1));
} else {
log::warn!("Skipping v1, should be removed from Executive");
log::warn!("on_chain = {:?}, current = {:?}", onchain, current);
weight = weight.saturating_add(T::DbWeight::get().reads(1));
}

Expand Down
2 changes: 1 addition & 1 deletion pallets/proposals/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub mod pallet {
type AssetSignerOrigin: EnsureOrigin<Self::RuntimeOrigin>;
}

const STORAGE_VERSION: StorageVersion = StorageVersion::new(6);
const STORAGE_VERSION: StorageVersion = StorageVersion::new(7);

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
Expand Down
16 changes: 12 additions & 4 deletions pallets/proposals/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,8 @@ pub mod v7 {
let onchain = <Pallet<T> as GetStorageVersion>::on_chain_storage_version();

ensure!(
<T as Config>::MaxJuryMembers::get() < u8::MAX as u32,
<<T as Config>::JurySelector as SelectJury<AccountIdOf<T>>>::JurySize::get()
< u8::MAX as u32,
"Max jury members must be smaller than u8"
);

Expand Down Expand Up @@ -770,6 +771,9 @@ pub mod v7 {
#[cfg(feature = "try-runtime")]
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
log::warn!( target: "pallet-proposals", "Running post_upgrade()");
Projects::<T>::iter().for_each(|(_k, project)| {
assert!(project.jury.len() > 0, "jury size must be > 0");
});

ensure!(
Pallet::<T>::current_storage_version() == 7,
Expand All @@ -793,8 +797,6 @@ pub mod v7 {
v5::FundingType::Grant(_) => crate::FundingPath::WaitForFunding,
};

let jury = <T::JurySelector as SelectJury<AccountIdOf<T>>>::select_jury();

let refund_locations: BoundedVec<(Locality<AccountIdOf<T>>, Percent), T::MaximumContributorsPerProject> = match project.funding_type {
v5::FundingType::Proposal => crate::Pallet::<T>::convert_contributions_to_refund_locations(&project.contributions),
v5::FundingType::Brief => crate::Pallet::<T>::convert_contributions_to_refund_locations(&project.contributions),
Expand All @@ -812,6 +814,12 @@ pub mod v7 {
},
};

let jury = match project.funding_type {
v5::FundingType::Grant(_) => project.contributions.keys().cloned().collect::<Vec<AccountIdOf<T>>>(),
v5::FundingType::Brief => <T::JurySelector as SelectJury<AccountIdOf<T>>>::select_jury().to_vec(),
_ => <T::JurySelector as SelectJury<AccountIdOf<T>>>::select_jury().to_vec(),
};

let mut new_milestones: BoundedBTreeMilestones<T> = BoundedBTreeMap::new();
project.milestones.iter().for_each(|(_ms_key, ms): (&MilestoneKey, &v6::V6Milestone)| {
// assume that if its approved then its been withdrawn.
Expand Down Expand Up @@ -844,7 +852,7 @@ pub mod v7 {
cancelled: project.cancelled,
deposit_id: project.deposit_id,
refund_locations,
jury,
jury: jury.try_into().expect("contributions bound is larger than jury bound, reduce contribution bound or increase jury bound."),
on_creation_funding,
refunded_funds: Zero::zero(),
external_owned_address: None,
Expand Down
7 changes: 4 additions & 3 deletions runtime/imbue-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("imbue"),
impl_name: create_runtime_str!("imbue"),
authoring_version: 2,
spec_version: 1_000_000,
spec_version: 1_000_001,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
Expand Down Expand Up @@ -182,12 +182,13 @@ pub mod migrations {
/// Unreleased migrations. Add new ones here:
pub type Unreleased = (
pallet_briefs::migration::v3::MigrateToV3<Runtime>,
pallet_proposals::migration::v7::MigrateToV7<Runtime>,
pallet_fellowship::migration::v0::MigrateInitial<Runtime>,
pallet_balances::migration::MigrateToTrackInactive<Runtime, xcm_config::CheckingAccount>,
pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,
pallet_xcm::migration::v1::VersionUncheckedMigrateToV1<Runtime>,
pallet_fellowship::migration::v0::MigrateInitial<Runtime>,
orml_unknown_tokens::Migration<Runtime>,
// PROPOSALS MIGRATION MUST BE RUN AFTER FELLOWSHIP MIGRATION
pallet_proposals::migration::v7::MigrateToV7<Runtime>,
);
}

Expand Down

0 comments on commit 4d7810d

Please sign in to comment.