diff --git a/.github/workflows/runtime-upgrade.yml b/.github/workflows/runtime-upgrade.yml index 6ef0418f2b..1a89196e9b 100644 --- a/.github/workflows/runtime-upgrade.yml +++ b/.github/workflows/runtime-upgrade.yml @@ -70,9 +70,9 @@ jobs: name: ${{ steps.compute_shasum.outputs.shasum }}-joystream-node-docker-image.tar.gz path: joystream-node-docker-image.tar.gz - runtime_upgrade_from_olympia: + runtime_upgrade: # if: ${{ false }} - name: Runtime Upgrade From Olypia + name: Runtime Upgrade From Rhodes Spec 6 needs: build_images runs-on: ubuntu-latest steps: @@ -101,7 +101,7 @@ jobs: export HOME=${PWD} mkdir -p ${HOME}/.local/share/joystream-cli yarn joystream-cli api:setUri ws://localhost:9944 - # Olympia release production runtime profile - export RUNTIME_TAG=6740a4ae2bf40fe7c670fb49943cbbe290277601 + # Rhodes release (spec 6) production runtime profile + export RUNTIME_TAG=8c2e70abcb34a6892991355b61e804b7c1492290 export TARGET_RUNTIME_TAG=latest tests/network-tests/run-migration-tests.sh \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index c54bbd0a0f..bcc6d5d017 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -722,7 +722,7 @@ dependencies = [ [[package]] name = "chain-spec-builder" -version = "6.6.0" +version = "6.7.0" dependencies = [ "ansi_term 0.12.1", "enum-utils", @@ -2278,7 +2278,7 @@ dependencies = [ [[package]] name = "joystream-node" -version = "6.6.0" +version = "6.7.0" dependencies = [ "frame-benchmarking", "frame-benchmarking-cli", @@ -2339,7 +2339,7 @@ dependencies = [ [[package]] name = "joystream-node-runtime" -version = "10.6.0" +version = "10.7.0" dependencies = [ "frame-benchmarking", "frame-executive", diff --git a/node/Cargo.toml b/node/Cargo.toml index ed47a5c92d..69067b456d 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -3,7 +3,7 @@ authors = ['Joystream contributors'] build = 'build.rs' edition = '2018' name = 'joystream-node' -version = '6.6.0' +version = '6.7.0' default-run = "joystream-node" [[bin]] diff --git a/runtime-modules/content/src/lib.rs b/runtime-modules/content/src/lib.rs index 4bfff099b7..67b3e5d75a 100644 --- a/runtime-modules/content/src/lib.rs +++ b/runtime-modules/content/src/lib.rs @@ -1275,7 +1275,7 @@ decl_module! { ) -> DispatchResult { let channel = Self::ensure_channel_exists(&item.channel_id)?; - let reward_account = Self::ensure_reward_account(&channel)?; + let reward_account = Self::ensure_channel_has_beneficiary_account(&channel)?; ensure_actor_authorized_to_claim_payment::(origin, &actor, &channel.owner)?; @@ -1662,7 +1662,7 @@ decl_module! { let royalty_payment = Self::build_royalty_payment(&video, nft.creator_royalty); let updated_nft = Self::complete_auction( nft, - video.in_channel, + &video, royalty_payment, participant_id, buy_now_price, @@ -1770,7 +1770,7 @@ decl_module! { let royalty_payment = Self::build_royalty_payment(&video, nft.creator_royalty); let updated_nft = Self::complete_auction( nft, - video.in_channel, + &video, royalty_payment, participant_id, buy_now_price, @@ -1882,7 +1882,7 @@ decl_module! { let royalty_payment = Self::build_royalty_payment(&video, nft.creator_royalty); let updated_nft = Self::complete_auction( nft, - video.in_channel, + &video, royalty_payment, top_bidder_id, top_bid.amount @@ -1935,7 +1935,7 @@ decl_module! { let royalty_payment = Self::build_royalty_payment(&video, nft.creator_royalty); let updated_nft = Self::complete_auction( nft, - video.in_channel, + &video, royalty_payment, winner_id, bid.amount, @@ -2046,7 +2046,7 @@ decl_module! { Self::ensure_new_pending_offer_available_to_proceed(&nft, &receiver_account_id)?; // account_id where the nft offer price is deposited - let nft_owner_account = Self::ensure_owner_account_id(video.in_channel, &nft).ok(); + let nft_owner_account = Self::ensure_nft_owner_has_beneficiary_account(&video, &nft).ok(); // // == MUTATION SAFE == // @@ -2122,7 +2122,7 @@ decl_module! { Self::ensure_can_buy_now(&nft, &participant_account_id, price_commit)?; // seller account - let old_nft_owner_account_id = Self::ensure_owner_account_id(video.in_channel, &nft).ok(); + let old_nft_owner_account_id = Self::ensure_nft_owner_has_beneficiary_account(&video, &nft).ok(); // // == MUTATION SAFE == @@ -2428,7 +2428,7 @@ impl Module { Ok(()) } - pub(crate) fn ensure_reward_account( + pub(crate) fn ensure_channel_has_beneficiary_account( channel: &Channel, ) -> Result { if let Some(reward_account) = &channel.reward_account { diff --git a/runtime-modules/content/src/nft/mod.rs b/runtime-modules/content/src/nft/mod.rs index 1540dd1573..3ededcc2ec 100644 --- a/runtime-modules/content/src/nft/mod.rs +++ b/runtime-modules/content/src/nft/mod.rs @@ -363,12 +363,12 @@ impl Module { pub(crate) fn complete_auction( nft: Nft, - in_channel: T::ChannelId, + video: &Video, royalty_payment: Option<(Royalty, T::AccountId)>, winner_id: T::MemberId, amount: BalanceOf, ) -> Nft { - let account_deposit_into = Self::ensure_owner_account_id(in_channel, &nft).ok(); + let account_deposit_into = Self::ensure_nft_owner_has_beneficiary_account(video, &nft).ok(); let account_withdraw_from = ContentTreasury::::module_account_id(); Self::complete_payment( @@ -382,15 +382,25 @@ impl Module { .with_member_owner(winner_id) } - pub(crate) fn ensure_owner_account_id( - channel_id: T::ChannelId, + /// NFT owned by: + /// - Member: member controller account is used + /// - Channel: then if reward account is: + /// - `Some(acc)` -> use `acc` as reward account + /// - `None` -> then if channel owner is: + /// - `Member` -> use member controller account + /// - `CuratorGroup` -> Error + /// In order to statically guarantee that `video.in_channel` exists, by leveraging the + /// Runtime invariant: `video` exists => `video.in_channel` exists + pub(crate) fn ensure_nft_owner_has_beneficiary_account( + video: &Video, nft: &Nft, ) -> Result { match nft.owner { NftOwner::Member(member_id) => T::MemberAuthenticator::controller_account_id(member_id), - NftOwner::ChannelOwner => Self::channel_by_id(channel_id) - .reward_account - .ok_or_else(|| Error::::RewardAccountIsNotSet.into()), + NftOwner::ChannelOwner => { + let channel = Self::channel_by_id(&video.in_channel); + Self::ensure_channel_has_beneficiary_account(&channel) + } } } @@ -462,20 +472,9 @@ impl Module { // payment is none if there is no royalty if let Some(royalty) = creator_royalty { let channel = Self::channel_by_id(&video.in_channel); - // use reward account if specified - if let Some(creator_reward_account) = channel.reward_account { - Some((royalty, creator_reward_account)) - } else { - // otherwise resort to controller account for member owned channels - if let ChannelOwner::Member(member_id) = channel.owner { - T::MemberAuthenticator::controller_account_id(member_id) - .ok() - .map(|reward_account| (royalty, reward_account)) - } else { - // no royalty paid for curator owned channel with unspecified reward account - None - } - } + Self::ensure_channel_has_beneficiary_account(&channel) + .ok() + .map(|reward_acc| (royalty, reward_acc)) } else { None } diff --git a/runtime-modules/content/src/tests/fixtures.rs b/runtime-modules/content/src/tests/fixtures.rs index c61422c15e..8b2ce2d571 100644 --- a/runtime-modules/content/src/tests/fixtures.rs +++ b/runtime-modules/content/src/tests/fixtures.rs @@ -1374,7 +1374,8 @@ impl ClaimChannelRewardFixture { pub fn call_and_assert(&self, expected_result: DispatchResult) { let origin = Origin::signed(self.sender.clone()); let channel = Content::channel_by_id(self.item.channel_id); - let reward_account = Content::ensure_reward_account(&channel).unwrap_or_default(); + let reward_account = + Content::ensure_channel_has_beneficiary_account(&channel).unwrap_or_default(); let balance_pre = Balances::::usable_balance(&reward_account); let payout_earned_pre = Content::channel_by_id(self.item.channel_id).cumulative_payout_earned; diff --git a/runtime-modules/content/src/tests/nft/accept_incoming_offer.rs b/runtime-modules/content/src/tests/nft/accept_incoming_offer.rs index f2d3691731..b670b09021 100644 --- a/runtime-modules/content/src/tests/nft/accept_incoming_offer.rs +++ b/runtime-modules/content/src/tests/nft/accept_incoming_offer.rs @@ -1,7 +1,8 @@ #![cfg(test)] +use crate::tests::curators; use crate::tests::fixtures::{ create_default_member_owned_channel_with_video, create_initial_storage_buckets_helper, - increase_account_balance_helper, UpdateChannelFixture, + increase_account_balance_helper, CreateChannelFixture, CreateVideoFixture, }; use crate::tests::mock::*; use crate::*; @@ -180,23 +181,21 @@ fn accept_incoming_offer_no_incoming_offers() { } #[test] -fn accept_incoming_offer_reward_account_is_not_set_succeeds_with_member_owner_channel() { +fn accept_incoming_offer_ok_with_reward_account_not_set_succeeds_with_member_owner_channel() { + let video_id = 1u64; with_default_mock_builder(|| { // Run to block one to see emitted events run_to_block(1); - - let video_id = NextVideoId::::get(); - create_initial_storage_buckets_helper(); - increase_account_balance_helper(DEFAULT_MEMBER_ACCOUNT_ID, INITIAL_BALANCE); - create_default_member_owned_channel_with_video(); - - UpdateChannelFixture::default() + // channel with no reward account + CreateChannelFixture::default() + .with_sender(DEFAULT_MEMBER_ACCOUNT_ID) + .with_actor(ContentActor::Member(DEFAULT_MEMBER_ID)) + .call(); + CreateVideoFixture::default() .with_sender(DEFAULT_MEMBER_ACCOUNT_ID) .with_actor(ContentActor::Member(DEFAULT_MEMBER_ID)) - .with_reward_account(Some(None)) - .call_and_assert(Ok(())); + .call(); - // Issue nft assert_ok!(Content::issue_nft( Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID), ContentActor::Member(DEFAULT_MEMBER_ID), @@ -204,21 +203,28 @@ fn accept_incoming_offer_reward_account_is_not_set_succeeds_with_member_owner_ch NftIssuanceParameters::::default(), )); + increase_account_balance_helper(SECOND_MEMBER_ACCOUNT_ID, DEFAULT_NFT_PRICE); + // Offer nft assert_ok!(Content::offer_nft( Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID), video_id, ContentActor::Member(DEFAULT_MEMBER_ID), SECOND_MEMBER_ID, - None, + Some(100u64), // price )); // Make an attempt to accept incoming nft offer if sender is owner and reward account is not set - let accept_incoming_offer_result = - Content::accept_incoming_offer(Origin::signed(SECOND_MEMBER_ACCOUNT_ID), video_id); + assert_ok!(Content::accept_incoming_offer( + Origin::signed(SECOND_MEMBER_ACCOUNT_ID), + video_id + )); - // Failure checked - assert_ok!(accept_incoming_offer_result,); + // check owner balance increased by net profit + assert_eq!( + Balances::::usable_balance(DEFAULT_MEMBER_ACCOUNT_ID), + 100u64 - (Content::platform_fee_percentage() * 100u64) + ); }) } @@ -228,31 +234,31 @@ fn accept_incoming_offer_reward_account_burns_token_with_curator_owner_channel() // Run to block one to see emitted events run_to_block(1); - let video_id = NextVideoId::::get(); - create_initial_storage_buckets_helper(); - increase_account_balance_helper(DEFAULT_MEMBER_ACCOUNT_ID, INITIAL_BALANCE); - increase_account_balance_helper(SECOND_MEMBER_ACCOUNT_ID, DEFAULT_NFT_PRICE); - create_default_member_owned_channel_with_video(); + let curator_group_id = curators::add_curator_to_new_group(DEFAULT_CURATOR_ID); + let video_id = Content::next_video_id(); + let curator_actor = ContentActor::Curator(curator_group_id, DEFAULT_CURATOR_ID); + CreateChannelFixture::default() + .with_sender(DEFAULT_CURATOR_ACCOUNT_ID) + .with_actor(curator_actor) + .call(); + CreateVideoFixture::default() + .with_sender(DEFAULT_CURATOR_ACCOUNT_ID) + .with_actor(ContentActor::Curator(curator_group_id, DEFAULT_CURATOR_ID)) + .call(); - UpdateChannelFixture::default() - .with_sender(DEFAULT_MEMBER_ACCOUNT_ID) - .with_actor(ContentActor::Member(DEFAULT_MEMBER_ID)) - .with_reward_account(Some(None)) - .call_and_assert(Ok(())); - - // Issue nft assert_ok!(Content::issue_nft( - Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID), - ContentActor::Member(DEFAULT_MEMBER_ID), + Origin::signed(DEFAULT_CURATOR_ACCOUNT_ID), + curator_actor, video_id, NftIssuanceParameters::::default(), )); + increase_account_balance_helper(SECOND_MEMBER_ACCOUNT_ID, DEFAULT_NFT_PRICE); // Offer nft assert_ok!(Content::offer_nft( - Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID), + Origin::signed(DEFAULT_CURATOR_ACCOUNT_ID), video_id, - ContentActor::Member(DEFAULT_MEMBER_ID), + curator_actor, SECOND_MEMBER_ID, Some(DEFAULT_NFT_PRICE), )); diff --git a/runtime-modules/content/src/tests/nft/buy_nft.rs b/runtime-modules/content/src/tests/nft/buy_nft.rs index f2ee37d029..ffa31e4e52 100644 --- a/runtime-modules/content/src/tests/nft/buy_nft.rs +++ b/runtime-modules/content/src/tests/nft/buy_nft.rs @@ -463,28 +463,35 @@ fn buy_now_ok_with_nft_owner_member_credited_with_payment() { } #[test] -fn buy_now_ok_with_nft_owner_member_owned_channel_credited_with_payment() { +fn buy_now_ok_with_nft_owner_member_owned_channel_and_no_reward_account_credited_with_payment() { with_default_mock_builder(|| { // Run to block one to see emitted events - let starting_block = 1; - let video_id = Content::next_video_id(); - run_to_block(starting_block); - setup_nft_on_sale_scenario(); - increase_account_balance_helper(SECOND_MEMBER_ACCOUNT_ID, DEFAULT_NFT_PRICE); - let platform_fee = Content::platform_fee_percentage().mul_floor(DEFAULT_NFT_PRICE); - let balance_pre = Balances::::usable_balance(DEFAULT_MEMBER_ACCOUNT_ID); + run_to_block(1u64); + let video_id = 1u64; + CreateChannelFixture::default() + .with_sender(DEFAULT_MEMBER_ACCOUNT_ID) + .with_actor(ContentActor::Member(DEFAULT_MEMBER_ID)) + .call_and_assert(Ok(())); + + CreateVideoFixture::default() + .with_sender(DEFAULT_MEMBER_ACCOUNT_ID) + .with_actor(ContentActor::Member(DEFAULT_MEMBER_ID)) + .with_channel_id(1u64) + .with_nft_in_sale(100u64) + .call_and_assert(Ok(())); + + increase_account_balance_helper(SECOND_MEMBER_ACCOUNT_ID, 100u64); assert_ok!(Content::buy_nft( Origin::signed(SECOND_MEMBER_ACCOUNT_ID), video_id, SECOND_MEMBER_ID, - DEFAULT_NFT_PRICE, + 100u64, )); assert_eq!( Balances::::usable_balance(DEFAULT_MEMBER_ACCOUNT_ID), - // balance_pre - platform fee (since channel owner it retains royalty) - balance_pre + DEFAULT_NFT_PRICE - platform_fee, + 100u64 - (Content::platform_fee_percentage() * 100u64), ) }) } @@ -508,7 +515,6 @@ fn buy_now_ok_with_nft_owner_curator_group_owned_channel_and_non_set_account_and CreateVideoFixture::default() .with_sender(DEFAULT_CURATOR_ACCOUNT_ID) .with_actor(ContentActor::Curator(group_id, DEFAULT_CURATOR_ID)) - .with_channel_id(NextChannelId::::get() - 1) .call_and_assert(Ok(())); assert_ok!(Content::issue_nft( @@ -578,7 +584,38 @@ pub fn proceeds_are_burned_if_nft_owned_by_curator_channel_with_no_reward_accoun } #[test] -pub fn nft_channel_member_owner_is_correctly_credited_after_sale() { +pub fn proceeds_are_correctly_credited_if_nft_owned_by_member_channel_with_no_reward_account_and_royalty_specified( +) { + with_default_mock_builder(|| { + increase_account_balance_helper(SECOND_MEMBER_ACCOUNT_ID, 100u64); + // channel with no reward account + CreateChannelFixture::default() + .with_sender(DEFAULT_MEMBER_ACCOUNT_ID) + .with_actor(ContentActor::Member(DEFAULT_MEMBER_ID)) + .call(); + CreateVideoFixture::default() + .with_sender(DEFAULT_MEMBER_ACCOUNT_ID) + .with_actor(ContentActor::Member(DEFAULT_MEMBER_ID)) + .with_nft_in_sale(100u64) + .with_nft_royalty(1) + .call(); + + assert_ok!(Content::buy_nft( + Origin::signed(SECOND_MEMBER_ACCOUNT_ID), + 1u64, + SECOND_MEMBER_ID, + 100u64, + )); + + assert_eq!( + Balances::::usable_balance(DEFAULT_MEMBER_ACCOUNT_ID), + 100u64 - (Content::platform_fee_percentage() * 100u64) + ); + }) +} + +#[test] +pub fn nft_channel_member_owner_with_reward_account_set_is_correctly_credited_after_sale() { with_default_mock_builder(|| { increase_account_balance_helper(SECOND_MEMBER_ACCOUNT_ID, 100u64); CreateChannelFixture::default() diff --git a/runtime-modules/content/src/tests/nft/pick_open_auction_winner.rs b/runtime-modules/content/src/tests/nft/pick_open_auction_winner.rs index e1bff9974d..011409b036 100644 --- a/runtime-modules/content/src/tests/nft/pick_open_auction_winner.rs +++ b/runtime-modules/content/src/tests/nft/pick_open_auction_winner.rs @@ -605,3 +605,71 @@ fn auction_proceeds_are_burned_in_case_of_curator_owned_channel_is_auctioneer() assert_eq!(Balances::::total_issuance(), issuance_pre - bid); }) } + +#[test] +fn auction_proceeds_ok_in_case_of_member_owned_channel_with_no_reward_account_is_auctioneer() { + with_default_mock_builder(|| { + let video_id = Content::next_video_id(); + CreateChannelFixture::default() + .with_sender(DEFAULT_MEMBER_ACCOUNT_ID) + .with_actor(ContentActor::Member(DEFAULT_MEMBER_ID)) + .call(); + CreateVideoFixture::default() + .with_sender(DEFAULT_MEMBER_ACCOUNT_ID) + .with_actor(ContentActor::Member(DEFAULT_MEMBER_ID)) + .call(); + + assert_ok!(Content::issue_nft( + Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID), + ContentActor::Member(DEFAULT_MEMBER_ID), + video_id, + NftIssuanceParameters::::default(), + )); + + let bid_lock_duration = Content::min_bid_lock_duration(); + + let auction_params = OpenAuctionParams:: { + starting_price: Content::min_starting_price(), + buy_now_price: None, + bid_lock_duration, + starts_at: None, + whitelist: BTreeSet::new(), + }; + + // Start nft auction + assert_ok!(Content::start_open_auction( + Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID), + ContentActor::Member(DEFAULT_MEMBER_ID), + video_id, + auction_params.clone(), + )); + + // deposit initial balance + let bid = Content::min_starting_price(); + let platform_fee = Content::platform_fee_percentage().mul_floor(bid); + + let _ = balances::Module::::deposit_creating(&SECOND_MEMBER_ACCOUNT_ID, bid); + + // Make nft auction bid + assert_ok!(Content::make_open_auction_bid( + Origin::signed(SECOND_MEMBER_ACCOUNT_ID), + SECOND_MEMBER_ID, + video_id, + bid, + )); + + // Pick open auction winner + assert_ok!(Content::pick_open_auction_winner( + Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID), + ContentActor::Member(DEFAULT_MEMBER_ID), + video_id, + SECOND_MEMBER_ID, + bid, + )); + + assert_eq!( + Balances::::usable_balance(DEFAULT_MEMBER_ACCOUNT_ID), + bid - platform_fee + ); + }) +} diff --git a/runtime/CHANGELOG.md b/runtime/CHANGELOG.md index 8e480c856c..162d234e72 100644 --- a/runtime/CHANGELOG.md +++ b/runtime/CHANGELOG.md @@ -1,3 +1,25 @@ +### Version 10.7.0 - upgrade +- NFT channel proceeds bug fix [#3763](https://github.com/Joystream/joystream/pull/3763) + - Fix logic in dispatch calls: `content::claim_channel_reward()`, `content::pick_open_auction_winner()` +- No runtime types changed + +### Version 10.6.0 - Rhodes - upgrade +- Enable NFT functionality +- Types updated - types pacakge version v0.19.3 +- Modified some runtime constants and initial [values](https://github.com/Joystream/joystream/pull/3678): + - Changed NFT parameters `MaxStartingPrice` and `MaxBidStep` + - Changed inflation curve, to reduce validator rewards + - Changed grace period for proposal types Set council budget increment + - Changed forum `MaxSubcategories` and `MaxCategories` + +### Version 10.5.0 - Olympia - new chain +- New feature new Membership system +- New feature Improved Council and Election system +- New feature Bounties +- New NFT feature - Disabled to simplify next update +- Forum improvements +- New types package - version v0.18.3 + ### Version 9.14.0 - Giza - upgrade - New storage and distribution runtime module - Renaming of working groups and adding new working group for distributor role diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 5fa87a4271..9df2c68c81 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -4,7 +4,7 @@ edition = '2018' name = 'joystream-node-runtime' # Follow convention: https://github.com/Joystream/substrate-runtime-joystream/issues/1 # {Authoring}.{Spec}.{Impl} of the RuntimeVersion -version = '10.6.0' +version = '10.7.0' [dependencies] # Third-party dependencies diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index b7049f957b..fa37e4308a 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -98,7 +98,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("joystream-node"), impl_name: create_runtime_str!("joystream-node"), authoring_version: 10, - spec_version: 6, + spec_version: 7, impl_version: 0, apis: crate::runtime_api::EXPORTED_RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/runtime/src/runtime_api.rs b/runtime/src/runtime_api.rs index 078d0c9608..56682bef0b 100644 --- a/runtime/src/runtime_api.rs +++ b/runtime/src/runtime_api.rs @@ -1,5 +1,4 @@ use frame_support::inherent::{CheckInherentsResult, InherentData}; -use frame_support::storage::StorageValue; use frame_support::traits::{KeyOwnerProofSystem, OnRuntimeUpgrade, Randomness}; use frame_support::unsigned::{TransactionSource, TransactionValidity}; use pallet_grandpa::fg_primitives; @@ -83,9 +82,6 @@ pub struct CustomOnRuntimeUpgrade; impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade { fn on_runtime_upgrade() -> Weight { ProposalsEngine::cancel_active_and_pending_proposals(); - // Set NFT values - >::put(Balance::from(1_000_000_000_000u64)); - >::put(Balance::from(1_000_000_000_000u64)); 10_000_000 // TODO: adjust weight } diff --git a/tests/network-tests/src/misc/assertPostUpgradeConsts.ts b/tests/network-tests/src/misc/assertPostUpgradeConsts.ts deleted file mode 100644 index 919b18a735..0000000000 --- a/tests/network-tests/src/misc/assertPostUpgradeConsts.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { assert } from 'chai' -import { FlowProps } from '../Flow' -import { extendDebug } from '../Debugger' -import { CreateProposalsFixture } from '../fixtures/proposals/CreateProposalsFixture' -import { BuyMembershipHappyCaseFixture } from '../fixtures/membership/BuyMembershipHappyCaseFixture' -import { FixtureRunner } from '../Fixture' -import BN from 'bn.js' - -export default async function assertValues({ api, query }: FlowProps): Promise { - const debug = extendDebug('flow:postMigrationAssertions') - debug('Started') - - debug('Check runtime spec version') - const version = await api.rpc.state.getRuntimeVersion() - assert.equal(version.specVersion.toNumber(), 6) - - debug('Check that post migration NFT value are updated') - - const maxNftStartingPrice = (await api.query.content.maxStartingPrice()).toNumber() - const maxNftBidStep = (await api.query.content.maxBidStep()).toNumber() - - // These values are expected on production runtime profile - assert.equal(maxNftStartingPrice, 1000000000000) - assert.equal(maxNftBidStep, 1000000000000) - - debug('Check that post migration Forum values are updated') - - const maxForumCategories = api.consts.forum.maxCategories.toNumber() - const maxForumSubCategories = api.consts.forum.maxSubcategories.toNumber() - - assert.equal(maxForumCategories, 40) - assert.equal(maxForumSubCategories, 40) - - debug('Check set_council_budget_increment_proposal grace period') - - // Grant treasury account large balance to transfer to new member for buying membership - // and staking. From a forked state there is no guarantee the account has sufficient funds. - await api.grantTreasuryWorkingBalance() - - debug('creating new member') - const [memberControllerAcc] = (await api.createKeyPairs(1)).map(({ key }) => key.address) - const buyMembershipFixture = new BuyMembershipHappyCaseFixture(api, query, [memberControllerAcc]) - await new FixtureRunner(buyMembershipFixture).run() - const [memberId] = buyMembershipFixture.getCreatedMembers() - - debug('creating proposal') - const createProposal = new CreateProposalsFixture(api, query, [ - { - asMember: memberId, - title: 'test proposal', - description: 'testing council budget increment proposal grace period', - exactExecutionBlock: undefined, - type: 'SetCouncilBudgetIncrement', - details: 1_000_000, - }, - ]) - - await new FixtureRunner(createProposal).run() - debug('checking proposal parameters') - const proposalId = createProposal.getCreatedProposalsIds()[0] - const proposal = await api.query.proposalsEngine.proposals(proposalId) - assert.equal(proposal.parameters.gracePeriod.toNumber(), 14400) - - debug('Done') -} diff --git a/tests/network-tests/src/misc/postRuntimUpdateChecks.ts b/tests/network-tests/src/misc/postRuntimUpdateChecks.ts new file mode 100644 index 0000000000..2d8c6c2d07 --- /dev/null +++ b/tests/network-tests/src/misc/postRuntimUpdateChecks.ts @@ -0,0 +1,14 @@ +import { assert } from 'chai' +import { FlowProps } from '../Flow' +import { extendDebug } from '../Debugger' + +export default async function assertValues({ api }: FlowProps): Promise { + const debug = extendDebug('flow:postMigrationAssertions') + debug('Started') + + debug('Check runtime spec version') + const version = await api.rpc.state.getRuntimeVersion() + assert.equal(version.specVersion.toNumber(), 7) + + debug('Done') +} diff --git a/tests/network-tests/src/scenarios/postRuntimeUpdate.ts b/tests/network-tests/src/scenarios/postRuntimeUpdate.ts index 96043327b9..e449553848 100644 --- a/tests/network-tests/src/scenarios/postRuntimeUpdate.ts +++ b/tests/network-tests/src/scenarios/postRuntimeUpdate.ts @@ -1,7 +1,7 @@ import { scenario } from '../Scenario' -import assertValues from '../misc/assertPostUpgradeConsts' +import postRuntimeUpdateChecks from '../misc/postRuntimUpdateChecks' scenario('Post Runtime Upgrade', async ({ job }) => { // Verify constants - job('Verify Values', assertValues) + job('Run Checks', postRuntimeUpdateChecks) }) diff --git a/utils/chain-spec-builder/Cargo.toml b/utils/chain-spec-builder/Cargo.toml index a4b39ef297..63948a3a07 100644 --- a/utils/chain-spec-builder/Cargo.toml +++ b/utils/chain-spec-builder/Cargo.toml @@ -3,7 +3,7 @@ authors = ['Joystream contributors'] build = 'build.rs' edition = '2018' name = 'chain-spec-builder' -version = '6.6.0' +version = '6.7.0' [dependencies] enum-utils = "0.1.2"