diff --git a/pallets/funding/src/functions/2_evaluation.rs b/pallets/funding/src/functions/2_evaluation.rs index ab071184d..d619824ca 100644 --- a/pallets/funding/src/functions/2_evaluation.rs +++ b/pallets/funding/src/functions/2_evaluation.rs @@ -85,21 +85,20 @@ impl Pallet { // * Branch in possible project paths * // Successful path - if is_funded { - return Self::transition_project( + return if is_funded { + Self::transition_project( project_id, project_details, ProjectStatus::EvaluationRound, - ProjectStatus::AuctionInitializePeriod, - Some(T::AuctionInitializePeriodDuration::get()), + ProjectStatus::AuctionRound, + Some(T::AuctionRoundDuration::get()), false, ) // Unsuccessful path } else { let issuer_did = project_details.issuer_did.clone(); DidWithActiveProjects::::set(issuer_did, None); - // * Update storage * - return Self::transition_project( + Self::transition_project( project_id, project_details, ProjectStatus::EvaluationRound, diff --git a/pallets/funding/src/functions/3_auction.rs b/pallets/funding/src/functions/3_auction.rs index 1dea0f8da..363b5635f 100644 --- a/pallets/funding/src/functions/3_auction.rs +++ b/pallets/funding/src/functions/3_auction.rs @@ -1,45 +1,6 @@ use super::*; impl Pallet { - /// Called by user extrinsic - /// Starts the auction round for a project. From the next block forward, any professional or - /// institutional user can set bids for a token_amount/token_price pair. - /// Any bids from this point until the auction_closing starts will be considered as valid. - /// - /// # Arguments - /// * `project_id` - The project identifier - /// - /// # Storage access - /// * [`ProjectsDetails`] - Get the project information, and check if the project is in the correct - /// round, and the current block is between the defined start and end blocks of the initialize period. - /// Update the project information with the new round status and transition points in case of success. - /// - /// # Success Path - /// The validity checks pass, and the project is transitioned to the Auction Opening round. - /// The project is scheduled to be transitioned automatically by `on_initialize` at the end of the - /// auction opening round. - /// - /// # Next step - /// Professional and Institutional users set bids for the project using the [`bid`](Self::bid) extrinsic. - /// Later on, `on_initialize` transitions the project into the closing auction round, by calling - /// [`do_auction_closing`](Self::do_auction_closing). - #[transactional] - pub fn do_start_auction(caller: AccountIdOf, project_id: ProjectId) -> DispatchResult { - // * Get variables * - let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; - // issuer_account can start the auction opening round during the Auction Initialize Period. - let skip_round_end_check = caller == project_details.issuer_account; - - Self::transition_project( - project_id, - project_details, - ProjectStatus::AuctionInitializePeriod, - ProjectStatus::AuctionRound, - Some(T::AuctionRoundDuration::get()), - skip_round_end_check, - ) - } - /// Decides which bids are accepted and which are rejected. /// Deletes and refunds the rejected ones, and prepares the project for the WAP calculation the next block #[transactional] diff --git a/pallets/funding/src/instantiator/chain_interactions.rs b/pallets/funding/src/instantiator/chain_interactions.rs index 3be82baf8..0c89f9bd8 100644 --- a/pallets/funding/src/instantiator/chain_interactions.rs +++ b/pallets/funding/src/instantiator/chain_interactions.rs @@ -397,9 +397,6 @@ impl< ProjectStatus::EvaluationRound => { self.execute(|| >::do_end_evaluation(project_id).unwrap()); }, - ProjectStatus::AuctionInitializePeriod => { - self.execute(|| >::do_start_auction(issuer, project_id).unwrap()); - }, ProjectStatus::AuctionRound => { self.execute(|| >::do_end_auction(project_id).unwrap()); }, @@ -503,7 +500,6 @@ impl< self.evaluation_assertions(project_id, expected_remaining_plmc, plmc_eval_deposits, expected_total_supply); - assert_eq!(self.go_to_next_state(project_id), ProjectStatus::AuctionInitializePeriod); assert_eq!(self.go_to_next_state(project_id), ProjectStatus::AuctionRound); project_id diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 5edf000d7..b233b84cc 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -230,10 +230,6 @@ pub mod pallet { + OnIdle> + OnInitialize>; - /// The time window (expressed in number of blocks) that an issuer has to start the auction round. - #[pallet::constant] - type AuctionInitializePeriodDuration: Get>; - /// The inner balance type we will use for all of our outer currency types. (e.g native, funding, CTs) type Balance: Balance + From + FixedPointOperand + MaybeSerializeDeserialize + Into; @@ -873,16 +869,6 @@ pub mod pallet { Self::do_end_evaluation(project_id) } - /// Starts the auction round for a project. From the next block forward, any professional or - /// institutional user can set bids for a token_amount/token_price pair. - /// Any bids from this point until the auction_closing starts, will be considered as valid. - #[pallet::call_index(6)] - #[pallet::weight(WeightInfoOf::::start_auction_manually(1))] - pub fn start_auction(origin: OriginFor, project_id: ProjectId) -> DispatchResult { - let account = ensure_signed(origin)?; - Self::do_start_auction(account, project_id) - } - /// Bid for a project in the Auction round #[pallet::call_index(7)] #[pallet::weight( diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index f1af4d0f5..9a0ef140b 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -295,7 +295,6 @@ pub const HOURS: BlockNumber = 300u64; // We need all durations to use different times to catch bugs in the tests. parameter_types! { pub const EvaluationRoundDuration: BlockNumber = 10u64; - pub const AuctionInitializePeriodDuration: BlockNumber = 12u64; pub const AuctionRoundDuration: BlockNumber = 15u64; pub const CommunityRoundDuration: BlockNumber = 18u64; pub const RemainderRoundDuration: BlockNumber = 6u64; @@ -397,7 +396,6 @@ impl Config for TestRuntime { type AccountId32Conversion = DummyConverter; type AllPalletsWithoutSystem = (Balances, ContributionTokens, ForeignAssets, PolimecFunding, LinearRelease, RandomnessCollectiveFlip); - type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; type AuctionRoundDuration = AuctionRoundDuration; type Balance = Balance; type BlockNumber = BlockNumber; diff --git a/pallets/funding/src/tests/1_application.rs b/pallets/funding/src/tests/1_application.rs index 28cc08451..094ae0f48 100644 --- a/pallets/funding/src/tests/1_application.rs +++ b/pallets/funding/src/tests/1_application.rs @@ -177,7 +177,6 @@ mod create_project_extrinsic { inst.evaluate_for_users(1, default_evaluations()).unwrap(); - assert_eq!(inst.go_to_next_state(1), ProjectStatus::AuctionInitializePeriod); assert_eq!(inst.go_to_next_state(1), ProjectStatus::AuctionRound); inst.bid_for_users(1, failing_bids).unwrap(); @@ -206,7 +205,6 @@ mod create_project_extrinsic { assert_eq!(inst.go_to_next_state(2), ProjectStatus::EvaluationRound); inst.evaluate_for_users(2, default_evaluations()).unwrap(); - assert_eq!(inst.go_to_next_state(2), ProjectStatus::AuctionInitializePeriod); assert_eq!(inst.go_to_next_state(2), ProjectStatus::AuctionRound); inst.bid_for_users(2, default_bids()).unwrap(); diff --git a/pallets/funding/src/tests/2_evaluation.rs b/pallets/funding/src/tests/2_evaluation.rs index a41fc91b4..4b3b1f3f7 100644 --- a/pallets/funding/src/tests/2_evaluation.rs +++ b/pallets/funding/src/tests/2_evaluation.rs @@ -54,7 +54,6 @@ mod round_flow { let old_price = ::PriceProvider::get_price(PLMC_FOREIGN_ID).unwrap(); PRICE_MAP.with_borrow_mut(|map| map.insert(PLMC_FOREIGN_ID, old_price / 2.into())); - assert_eq!(inst.go_to_next_state(project_id), ProjectStatus::AuctionInitializePeriod); assert_eq!(inst.go_to_next_state(project_id), ProjectStatus::AuctionRound); // Increasing the price before the end doesn't make a project under the threshold succeed. @@ -178,7 +177,6 @@ mod round_flow { ))); // The evaluation should succeed when we bond the threshold PLMC amount in total. - assert_eq!(inst.go_to_next_state(project_id), ProjectStatus::AuctionInitializePeriod); assert_eq!(inst.go_to_next_state(project_id), ProjectStatus::AuctionRound); }; @@ -635,7 +633,6 @@ mod evaluate_extrinsic { inst.mint_plmc_to(new_plmc_required.clone()); inst.evaluate_for_users(project_id, new_evaluations).unwrap(); - assert_eq!(inst.go_to_next_state(project_id), ProjectStatus::AuctionInitializePeriod); assert_eq!(inst.go_to_next_state(project_id), ProjectStatus::AuctionRound); assert!(matches!(inst.go_to_next_state(project_id), ProjectStatus::CommunityRound(_))); diff --git a/pallets/funding/src/tests/3_auction.rs b/pallets/funding/src/tests/3_auction.rs index b79c39ce3..3c40d02c3 100644 --- a/pallets/funding/src/tests/3_auction.rs +++ b/pallets/funding/src/tests/3_auction.rs @@ -350,103 +350,6 @@ mod round_flow { } } -#[cfg(test)] -mod start_auction_extrinsic { - use super::*; - - #[cfg(test)] - mod success { - use super::*; - - #[test] - fn anyone_can_start_auction_after_initialize_period() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let project_id = inst.create_evaluating_project(default_project_metadata(ISSUER_1), ISSUER_1, None); - let evaluations = default_evaluations(); - let required_plmc = inst.calculate_evaluation_plmc_spent(evaluations.clone(), true); - - inst.mint_plmc_to(required_plmc); - inst.evaluate_for_users(project_id, evaluations).unwrap(); - - assert_eq!(inst.go_to_next_state(project_id), ProjectStatus::AuctionInitializePeriod); - let end_block = inst.get_project_details(project_id).round_duration.end().unwrap(); - inst.jump_to_block(end_block); - - inst.execute(|| PolimecFunding::start_auction(RuntimeOrigin::signed(420u32), project_id)).unwrap(); - - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AuctionRound); - } - - #[test] - fn issuer_can_start_auction_before_initialize_period_end() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let project_id = inst.create_evaluating_project(default_project_metadata(ISSUER_1), ISSUER_1, None); - let evaluations = default_evaluations(); - let required_plmc = inst.calculate_evaluation_plmc_spent(evaluations.clone(), true); - inst.mint_plmc_to(required_plmc); - inst.evaluate_for_users(project_id, evaluations).unwrap(); - - assert_eq!(inst.go_to_next_state(project_id), ProjectStatus::AuctionInitializePeriod); - - inst.execute(|| Pallet::::start_auction(RuntimeOrigin::signed(ISSUER_1), project_id)).unwrap(); - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AuctionRound); - } - } - - #[cfg(test)] - mod failure { - use super::*; - - #[test] - fn anyone_cannot_start_auction_before_initialize_period() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let project_id = inst.create_evaluating_project(default_project_metadata(ISSUER_1), ISSUER_1, None); - let evaluations = default_evaluations(); - let required_plmc = inst.calculate_evaluation_plmc_spent(evaluations.clone(), true); - - inst.mint_plmc_to(required_plmc); - inst.evaluate_for_users(project_id, evaluations).unwrap(); - - assert_eq!(inst.go_to_next_state(project_id), ProjectStatus::AuctionInitializePeriod); - - inst.execute(|| { - assert_noop!( - PolimecFunding::start_auction(RuntimeOrigin::signed(420u32), project_id), - Error::::TooEarlyForRound - ); - }); - - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AuctionInitializePeriod); - } - - #[test] - fn issuer_cannot_start_auction_manually_before_evaluation_finishes() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let project_id = inst.create_evaluating_project(default_project_metadata(ISSUER_1), ISSUER_1, None); - inst.execute(|| { - assert_noop!( - PolimecFunding::start_auction(RuntimeOrigin::signed(ISSUER_1), project_id), - Error::::IncorrectRound - ); - }); - } - - #[test] - fn cannot_start_auction_manually_if_evaluation_fails() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let project_id = inst.create_evaluating_project(default_project_metadata(ISSUER_1), ISSUER_1, None); - assert_eq!(inst.go_to_next_state(project_id), ProjectStatus::FundingFailed); - - inst.execute(|| { - assert_noop!( - PolimecFunding::start_auction(RuntimeOrigin::signed(ISSUER_1), project_id), - Error::::IncorrectRound - ); - }); - } - } -} - #[cfg(test)] mod bid_extrinsic { use super::*; diff --git a/pallets/funding/src/tests/5_funding_end.rs b/pallets/funding/src/tests/5_funding_end.rs index 943ab35b5..3d27f47d6 100644 --- a/pallets/funding/src/tests/5_funding_end.rs +++ b/pallets/funding/src/tests/5_funding_end.rs @@ -140,7 +140,6 @@ mod end_funding_extrinsic { project_details.funding_end_block, Some( EvaluationRoundDuration::get() + - AuctionInitializePeriodDuration::get() + AuctionRoundDuration::get() + CommunityRoundDuration::get() + RemainderRoundDuration::get() + diff --git a/pallets/funding/src/tests/misc.rs b/pallets/funding/src/tests/misc.rs index 518324bab..0c5a81559 100644 --- a/pallets/funding/src/tests/misc.rs +++ b/pallets/funding/src/tests/misc.rs @@ -394,11 +394,9 @@ fn project_state_transition_event() { let mut desired_transitions = vec![ ProjectStatus::EvaluationRound, - ProjectStatus::AuctionInitializePeriod, ProjectStatus::AuctionRound, ProjectStatus::CommunityRound( EvaluationRoundDuration::get() + - AuctionInitializePeriodDuration::get() + AuctionRoundDuration::get() + CommunityRoundDuration::get() + 1u64, diff --git a/pallets/funding/src/tests/runtime_api.rs b/pallets/funding/src/tests/runtime_api.rs index 4993b530e..3f219f19e 100644 --- a/pallets/funding/src/tests/runtime_api.rs +++ b/pallets/funding/src/tests/runtime_api.rs @@ -546,7 +546,6 @@ fn all_project_participations_by_did() { }); } - assert_eq!(inst.go_to_next_state(project_id), ProjectStatus::AuctionInitializePeriod); assert_eq!(inst.go_to_next_state(project_id), ProjectStatus::AuctionRound); inst.bid_for_users(project_id, bids[..1].to_vec()).unwrap(); diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index ab6f041d7..8c8f85491 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -697,7 +697,6 @@ pub mod inner_types { #[default] Application, EvaluationRound, - AuctionInitializePeriod, AuctionRound, CommunityRound(BlockNumber), FundingFailed, diff --git a/runtimes/polimec/src/lib.rs b/runtimes/polimec/src/lib.rs index 8d5a9bbe6..809a8b825 100644 --- a/runtimes/polimec/src/lib.rs +++ b/runtimes/polimec/src/lib.rs @@ -242,7 +242,6 @@ impl Contains for BaseCallFilter { pallet_funding::Call::start_evaluation { .. } | pallet_funding::Call::evaluate { .. } | pallet_funding::Call::end_evaluation { .. } | - pallet_funding::Call::start_auction { .. } | pallet_funding::Call::bid { .. } | pallet_funding::Call::end_auction { .. } | pallet_funding::Call::contribute { .. } | @@ -1023,7 +1022,6 @@ impl pallet_funding::Config for Runtime { #[cfg(any(test, feature = "runtime-benchmarks", feature = "std"))] type AllPalletsWithoutSystem = (Balances, ContributionTokens, ForeignAssets, Oracle, Funding, LinearRelease, Random); - type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; type AuctionRoundDuration = AuctionRoundDuration; type Balance = Balance; type BlockNumber = BlockNumber; diff --git a/runtimes/shared-configuration/src/funding.rs b/runtimes/shared-configuration/src/funding.rs index e6218b54b..06656372f 100644 --- a/runtimes/shared-configuration/src/funding.rs +++ b/runtimes/shared-configuration/src/funding.rs @@ -86,7 +86,6 @@ pub type ProjectIdentifier = u32; parameter_types! { pub const EvaluationRoundDuration: BlockNumber = EVALUATION_ROUND_DURATION; - pub const AuctionInitializePeriodDuration: BlockNumber = AUCTION_INITIALIZE_PERIOD_DURATION; pub const AuctionRoundDuration: BlockNumber = AUCTION_ROUND_DURATION; pub const CommunityRoundDuration: BlockNumber = COMMUNITY_ROUND_DURATION; pub const RemainderRoundDuration: BlockNumber = REMAINDER_ROUND_DURATION;