diff --git a/.github/workflows/rust-benchmark.yml b/.github/workflows/rust-benchmark.yml index 340549d3f..781fc3912 100644 --- a/.github/workflows/rust-benchmark.yml +++ b/.github/workflows/rust-benchmark.yml @@ -15,7 +15,7 @@ on: jobs: check: # The type of runner that the job will run on - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 # Steps represent a sequence of tasks that will be executed as part of the job steps: diff --git a/.github/workflows/rust-build-benchmarking.yml b/.github/workflows/rust-build-benchmarking.yml deleted file mode 100644 index 7d23d50fd..000000000 --- a/.github/workflows/rust-build-benchmarking.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Metaverse Build Benchmarking - -on: - pull_request: - branches: - - master - push: - branches: - - master - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -jobs: - check: - # The type of runner that the job will run on - runs-on: ubuntu-20.04 - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 - - - name: Set-Up - run: sudo apt install -y protobuf-compiler cmake pkg-config libssl-dev git build-essential clang libclang-dev curl - - - name: Install Rustup - run: | - curl https://sh.rustup.rs -sSf | sh -s -- -y - source ~/.cargo/env - rustup default nightly && rustup update - rustup default nightly-2022-11-15 - rustup target add wasm32-unknown-unknown --toolchain nightly-2022-11-15 - - name: Check Rust version - run: rustup show - - name: Check Format - run: cargo fmt --all -- --check - - name: Build Benchmarking - run: | - SKIP_WASM_BUILD=1 cargo build --release --features runtime-benchmarks \ No newline at end of file diff --git a/pallets/auction/src/lib.rs b/pallets/auction/src/lib.rs index d6279c2f2..8afd48829 100644 --- a/pallets/auction/src/lib.rs +++ b/pallets/auction/src/lib.rs @@ -198,6 +198,11 @@ pub mod pallet { /// Anti-snipe duration #[pallet::constant] type AntiSnipeDuration: Get; + + /// Storage deposit free charged when saving data into the blockchain. + /// The fee will be unreserved after the storage is freed. + #[pallet::constant] + type StorageDepositFee: Get>; } #[pallet::storage] @@ -388,6 +393,13 @@ pub mod pallet { Error::::AuctionTypeIsNotSupported ); + T::Currency::transfer( + &from, + &T::MetaverseInfoSource::get_network_treasury(), + T::StorageDepositFee::get(), + ExistenceRequirement::KeepAlive, + )?; + Self::auction_bid_handler(from, id, value)?; Ok(().into()) @@ -522,6 +534,13 @@ pub mod pallet { listing_fee = T::MetaverseInfoSource::get_metaverse_marketplace_listing_fee(metaverse_id)?; } + T::Currency::transfer( + &from, + &T::MetaverseInfoSource::get_network_treasury(), + T::StorageDepositFee::get(), + ExistenceRequirement::KeepAlive, + )?; + Self::create_auction( AuctionType::BuyNow, item_id, diff --git a/pallets/auction/src/mock.rs b/pallets/auction/src/mock.rs index b1f12f1e0..e91e72bac 100644 --- a/pallets/auction/src/mock.rs +++ b/pallets/auction/src/mock.rs @@ -325,6 +325,7 @@ impl Config for Runtime { type OfferDuration = OfferDuration; type MinimumListingPrice = MinimumListingPrice; type AntiSnipeDuration = AntiSnipeDuration; + type StorageDepositFee = StorageDepositFee; } pub type AdaptedBasicCurrency = currencies::BasicCurrencyAdapter; @@ -365,6 +366,7 @@ parameter_types! { pub MaxBatchTransfer: u32 = 3; pub MaxBatchMinting: u32 = 2000; pub MaxMetadata: u32 = 10; + pub StorageDepositFee: Balance = 1; } impl pallet_nft::Config for Runtime { @@ -381,6 +383,7 @@ impl pallet_nft::Config for Runtime { type MiningResourceId = MiningCurrencyId; type AssetMintingFee = AssetMintingFee; type ClassMintingFee = ClassMintingFee; + type StorageDepositFee = StorageDepositFee; } parameter_types! { diff --git a/pallets/auction/src/tests.rs b/pallets/auction/src/tests.rs index 7c70d0d55..ab4a5b657 100644 --- a/pallets/auction/src/tests.rs +++ b/pallets/auction/src/tests.rs @@ -101,7 +101,7 @@ fn create_new_auction_work() { }) ); assert_eq!(AuctionModule::items_in_auction(ItemId::NFT(0, 0)), Some(true)); - assert_eq!(Balances::free_balance(ALICE), 99996); + assert_eq!(Balances::free_balance(ALICE), 99995); }); } @@ -133,7 +133,7 @@ fn create_new_multicurrency_auction_work() { }) ); assert_eq!(AuctionModule::items_in_auction(ItemId::NFT(0, 0)), Some(true)); - assert_eq!(Balances::free_balance(ALICE), 99996); + assert_eq!(Balances::free_balance(ALICE), 99995); }); } @@ -172,7 +172,7 @@ fn create_new_auction_bundle_work() { AuctionModule::items_in_auction(ItemId::Bundle(tokens.clone())), Some(true) ); - assert_eq!(Balances::free_balance(ALICE), 99990); + assert_eq!(Balances::free_balance(ALICE), 99987); }); } @@ -211,7 +211,7 @@ fn create_new_multicurrency_auction_bundle_work() { AuctionModule::items_in_auction(ItemId::Bundle(tokens.clone())), Some(true) ); - assert_eq!(Balances::free_balance(ALICE), 99990); + assert_eq!(Balances::free_balance(ALICE), 99987); }); } @@ -252,7 +252,7 @@ fn create_new_stackable_nft_auction_work() { AuctionModule::items_in_auction(ItemId::StackableNFT(0, 0, 50u128)), Some(true) ); - assert_eq!(Balances::free_balance(ALICE), 99996); + assert_eq!(Balances::free_balance(ALICE), 99995); assert_eq!( NFTModule::::get_free_stackable_nft_balance(&ALICE, &(0, 0)), 50u128 @@ -344,7 +344,7 @@ fn create_new_buy_now_bundle_work() { AuctionModule::items_in_auction(ItemId::Bundle(tokens.clone())), Some(true) ); - assert_eq!(Balances::free_balance(ALICE), 99990); + assert_eq!(Balances::free_balance(ALICE), 99987); }); } @@ -383,7 +383,7 @@ fn create_new_multicurrency_buy_now_bundle_work() { AuctionModule::items_in_auction(ItemId::Bundle(tokens.clone())), Some(true) ); - assert_eq!(Balances::free_balance(ALICE), 99990); + assert_eq!(Balances::free_balance(ALICE), 99987); }); } @@ -424,7 +424,7 @@ fn create_new_stackable_nft_buy_now_work() { AuctionModule::items_in_auction(ItemId::StackableNFT(0, 0, 30u128)), Some(true) ); - assert_eq!(Balances::free_balance(ALICE), 99996); + assert_eq!(Balances::free_balance(ALICE), 99995); assert_eq!( NFTModule::::get_free_stackable_nft_balance(&ALICE, &(0, 0)), 70u128 @@ -529,7 +529,7 @@ fn create_auction_fail() { )); // ALICE balance is 100000 - 1 (network fee) - 6 (minting fee) = 99993 - assert_eq!(Balances::free_balance(ALICE), 99993); + assert_eq!(Balances::free_balance(ALICE), 99991); assert_noop!( AuctionModule::create_auction( @@ -573,8 +573,8 @@ fn create_new_auction_should_fail_when_exceed_finality_limit() { FungibleTokenId::NativeToken(0) )); - // ALICE balance is 100 000 - 1 (network fee) - 12 (minting fees) = 99987 - assert_eq!(Balances::free_balance(ALICE), 99987); + // ALICE balance is 100 000 - 1 (network fee) - 12 (minting fees) - 4 (class storage fee) = 99983 + assert_eq!(Balances::free_balance(ALICE), 99983); assert_ok!(AuctionModule::create_auction( AuctionType::Auction, @@ -588,8 +588,8 @@ fn create_new_auction_should_fail_when_exceed_finality_limit() { FungibleTokenId::NativeToken(0) )); - // ALICE balance is 99987 - 1 (network fee) = 99986 - assert_eq!(Balances::free_balance(ALICE), 99986); + // ALICE balance is 99983 - 1 (network fee) = 99982 + assert_eq!(Balances::free_balance(ALICE), 99982); assert_ok!(AuctionModule::create_auction( AuctionType::Auction, @@ -603,8 +603,8 @@ fn create_new_auction_should_fail_when_exceed_finality_limit() { FungibleTokenId::NativeToken(0) )); - // ALICE balance is 99986 - 1 (network fee) = 99985 - assert_eq!(Balances::free_balance(ALICE), 99985); + // ALICE balance is 99982 - 1 (network fee) = 99981 + assert_eq!(Balances::free_balance(ALICE), 99981); // Mocking max finality is 3 // 4th auction with new block should fail @@ -638,8 +638,8 @@ fn create_new_auction_should_fail_when_exceed_finality_limit() { FungibleTokenId::NativeToken(0) )); - // ALICE balance is 99985 - 1 (network fee) = 99984 - assert_eq!(Balances::free_balance(ALICE), 99984); + // ALICE balance is 99981 - 1 (network fee) = 99980 + assert_eq!(Balances::free_balance(ALICE), 99980); }); } @@ -1040,7 +1040,7 @@ fn asset_transfers_after_auction() { ); // BOB should have 500 - 1 (network reserve fee) - 3 minting fee = 496 - assert_eq!(Balances::free_balance(BOB), 496); + assert_eq!(Balances::free_balance(BOB), 495); run_to_block(102); // Verify asset transfers to alice after end of auction @@ -1052,8 +1052,8 @@ fn asset_transfers_after_auction() { // Verify transfer of fund (minus gas) // BOB only receive 200 - 2 (1% royalty fee) - 2 (1% network fee) - 4 (minting fee) = 193 // 500 + 193 = 693 - assert_eq!(Balances::free_balance(BOB), 693); - assert_eq!(Balances::free_balance(ALICE), 99800); + assert_eq!(Balances::free_balance(BOB), 692); + assert_eq!(Balances::free_balance(ALICE), 99799); // Verify Alice has the NFT and Bob doesn't assert_eq!(NFTModule::::check_ownership(&ALICE, &(0, 0)), Ok(true)); @@ -1094,7 +1094,7 @@ fn asset_transfers_after_multicurrency_auction() { ); // BOB should have 500 - 1 (network reserve fee) - 3 minting fee = 496 - assert_eq!(Balances::free_balance(BOB), 496); + assert_eq!(Balances::free_balance(BOB), 495); run_to_block(102); // Verify asset transfers to alice after end of auction @@ -1200,7 +1200,7 @@ fn buy_now_work() { // royalty fee 1% for both sales is 8 // network fee 1% for both sales is 8 // 900 - 16 + 7 for deposit minting = 885 - assert_eq!(Balances::free_balance(BOB), 888); + assert_eq!(Balances::free_balance(BOB), 887); // event was triggered let event = mock::RuntimeEvent::AuctionModule(crate::Event::BuyNowFinalised(1, ALICE, 200)); @@ -1286,8 +1286,8 @@ fn buy_now_with_bundle_should_work() { FungibleTokenId::NativeToken(0) )); - // BOB Balance is 500 - 1 (network reserve fee) - 9 (minting fee) = 490 - assert_eq!(Balances::free_balance(BOB), 490); + // BOB Balance is 500 - 1 (network reserve fee) - 9 (minting fee) - 3 (class storage fee) = 487 + assert_eq!(Balances::free_balance(BOB), 487); // buy now successful assert_ok!(AuctionModule::buy_now(buyer.clone(), 0, 200)); @@ -1303,9 +1303,9 @@ fn buy_now_with_bundle_should_work() { // initial BOB balance is 500 // bundle buy now price is 200 - // 200 - 2 (1% royalty_fee) - 2 (1% network fee) - 10 (minting fee) = 186 - // 500 + 186 = 686 - assert_eq!(Balances::free_balance(BOB), 686); + // 200 - 2 (1% royalty_fee) - 2 (1% network fee) - 10 (minting fee) - 3 (class storage fee) = 183 + // 500 + 186 = 683 + assert_eq!(Balances::free_balance(BOB), 683); // event was triggered let event = mock::RuntimeEvent::AuctionModule(crate::Event::BuyNowFinalised(0, ALICE, 200)); @@ -1344,8 +1344,8 @@ fn multicurrency_buy_now_with_bundle_should_work() { FungibleTokenId::MiningResource(0) )); - // BOB Balance is 500 - 1 (network reserve fee) - 9 (minting fee) = 490 - assert_eq!(Balances::free_balance(BOB), 490); + // BOB Balance is 500 - 1 (network reserve fee) - 9 (minting fee) - 3 (class storage fee) = 487 + assert_eq!(Balances::free_balance(BOB), 487); // buy now successful assert_ok!(AuctionModule::buy_now(buyer.clone(), 0, 200)); @@ -1420,8 +1420,8 @@ fn buy_now_stackable_nft_work() { // initial balance is 500 - sold 200 = 700 // royalty fee 1% for both sales is 4 // network fee 1% for both sales is 4 - // 700 - 8 + 1 for deposit minting = 693 - assert_eq!(Balances::free_balance(BOB), 693); + // 700 - 8 + 1 for deposit minting - 1 class storage fee deposit = 692 + assert_eq!(Balances::free_balance(BOB), 692); // event was triggered let event = mock::RuntimeEvent::AuctionModule(crate::Event::BuyNowFinalised(0, ALICE, 200)); @@ -1463,7 +1463,7 @@ fn buy_now_should_fail() { )); // BOB balance is 500 - 1 (network fee) - 3 (minting fee) = 496 - assert_eq!(Balances::free_balance(BOB), 496); + assert_eq!(Balances::free_balance(BOB), 495); // no auction id assert_noop!( @@ -1507,7 +1507,7 @@ fn buy_now_should_fail() { assert_ok!(AuctionModule::buy_now(buyer.clone(), 0, 150)); // BOB balance is 500 + 150 - 1 (royalty fee) - 1 (network fee) - 3 (minting fee) = 645 - assert_eq!(Balances::free_balance(BOB), 645); + assert_eq!(Balances::free_balance(BOB), 644); assert_noop!( AuctionModule::create_auction( @@ -1589,17 +1589,17 @@ fn on_finalize_should_work() { assert_eq!(AuctionModule::items_in_auction(ItemId::NFT(0, 0)), Some(true)); assert_ok!(AuctionModule::bid(bidder, 0, 100)); // BOB's should have 500 - 1 (network reserve fee) - 3 (minting fee) = 496 - assert_eq!(Balances::free_balance(BOB), 496); + assert_eq!(Balances::free_balance(BOB), 495); run_to_block(102); assert_eq!(AuctionModule::auctions(0), None); // check account received asset assert_eq!(NFTModule::::check_ownership(&ALICE, &(0, 0)), Ok(true)); // check balances were transferred - assert_eq!(Balances::free_balance(ALICE), 99900); + assert_eq!(Balances::free_balance(ALICE), 99899); // BOB's initial balance is 500 // 100 - 1 (1% of 100 as royalty fee) - 1 (1% of 100 as network fee) - 3 minting fee = 96 // 500 + 95 = 595 - assert_eq!(Balances::free_balance(BOB), 595); + assert_eq!(Balances::free_balance(BOB), 594); // asset is not longer in auction assert_eq!(AuctionModule::items_in_auction(ItemId::NFT(0, 0)), None); // auction item should not in storage @@ -1618,7 +1618,7 @@ fn on_finalize_with_listing_fee_should_work() { let bidder = RuntimeOrigin::signed(BOB); init_test_nft(owner.clone()); // After minting new NFT, it costs 3 unit - assert_eq!(Balances::free_balance(ALICE), 99997); + assert_eq!(Balances::free_balance(ALICE), 99996); assert_ok!(AuctionModule::create_auction( AuctionType::Auction, ItemId::NFT(0, 0), @@ -1632,19 +1632,19 @@ fn on_finalize_with_listing_fee_should_work() { )); assert_eq!(AuctionModule::items_in_auction(ItemId::NFT(0, 0)), Some(true)); assert_ok!(AuctionModule::bid(bidder, 0, 100)); - // Free balance of Alice is 99997 - 1 = 99996 - assert_eq!(Balances::free_balance(ALICE), 99996); + // Free balance of Alice is 99997 - 1 (minting deposit) - 1 (class strage fee) = 99995 + assert_eq!(Balances::free_balance(ALICE), 99995); run_to_block(102); assert_eq!(AuctionModule::auctions(0), None); // check account received asset assert_eq!(NFTModule::::check_ownership(&BOB, &(0, 0)), Ok(true)); // check balances were transferred - // Bob bid 100 for item, his new balance will be 500 - 100 - assert_eq!(Balances::free_balance(BOB), 400); + // Bob bid 100 for item, his new balance will be 500 - 100 - 1 + assert_eq!(Balances::free_balance(BOB), 399); // Alice only receive 88 for item sold: - // cost breakdown 100 - 10 (listing fee) - 1 (1% network fee) - 1 (1% royalty fee) - // Free balance of Alice is 99997 + 88 = 100085 - assert_eq!(Balances::free_balance(ALICE), 100085); + // cost breakdown 100 - 10 (listing fee) - 1 (1% network fee) - 1 (1% royalty fee) - 1 unit (class + // stroage fee) Free balance of Alice is 99996 + 88 = 100084 + assert_eq!(Balances::free_balance(ALICE), 100084); // asset is not longer in auction assert_eq!(AuctionModule::items_in_auction(ItemId::NFT(0, 0)), None); // event was triggered @@ -1662,7 +1662,7 @@ fn auction_bundle_should_update_new_price_according_new_bid() { init_test_nft(owner.clone()); // After minting new NFTs, it costs 6 unit - assert_eq!(Balances::free_balance(ALICE), 99994); + assert_eq!(Balances::free_balance(ALICE), 99992); let tokens = vec![(0, 0, 100), (0, 1, 100)]; assert_ok!(AuctionModule::create_auction( @@ -1682,7 +1682,7 @@ fn auction_bundle_should_update_new_price_according_new_bid() { ); assert_ok!(AuctionModule::bid(bidder, 0, 300)); // Free balance of Alice is 99994 - 1 (network reserve fee) - assert_eq!(Balances::free_balance(ALICE), 99993); + assert_eq!(Balances::free_balance(ALICE), 99991); let tokens_after_bid = vec![(0, 0, 150), (0, 1, 150)]; let item_updated_after_bid = AuctionModule::items_in_auction(ItemId::Bundle(tokens.clone())); @@ -1701,8 +1701,8 @@ fn on_finalize_with_bundle_with_listing_fee_should_work() { init_test_nft(owner.clone()); init_test_nft(owner.clone()); - // After minting new NFTs, it costs 6 unit - assert_eq!(Balances::free_balance(ALICE), 99994); + // After minting new NFTs, it costs 6 unit + 2 unit for class storage fee + assert_eq!(Balances::free_balance(ALICE), 99992); let tokens = vec![(0, 0, 80), (0, 1, 120)]; assert_ok!(AuctionModule::create_auction( @@ -1731,8 +1731,8 @@ fn on_finalize_with_bundle_with_listing_fee_should_work() { Some(true) ); - // Free balance of Alice is 99994 - 1 (network reserve fee) - assert_eq!(Balances::free_balance(ALICE), 99993); + // Free balance of Alice is 99992 - 1 (network reserve fee) + assert_eq!(Balances::free_balance(ALICE), 99991); run_to_block(102); assert_eq!(AuctionModule::auctions(0), None); // check account received asset @@ -1740,11 +1740,11 @@ fn on_finalize_with_bundle_with_listing_fee_should_work() { assert_eq!(NFTModule::::check_ownership(&BOB, &(0, 1)), Ok(true)); // check balances were transferred // Bob bid 400 for item, his new balance will be 500 - 400 - assert_eq!(Balances::free_balance(BOB), 100); + assert_eq!(Balances::free_balance(BOB), 99); // Alice only receive 176 for item solds // Cost breakdown 400 - 4 (royalty) - 4 (1% network fee) - 40 (listing fee) = 352 - // Free balance of Alice is 99994 + 352 = 100346 - assert_eq!(Balances::free_balance(ALICE), 100346); + // Free balance of Alice is 99992 + 352 = 100344 + assert_eq!(Balances::free_balance(ALICE), 100344); // event was triggered let event = mock::RuntimeEvent::AuctionModule(crate::Event::AuctionFinalized(0, BOB, 400)); assert_eq!(last_event(), event); @@ -2067,7 +2067,7 @@ fn accept_offer_should_work() { assert_eq!(Offers::::get((0, 0), BOB), None); assert_eq!(Balances::free_balance(BOB), 350); - assert_eq!(Balances::free_balance(ALICE), 100147); + assert_eq!(Balances::free_balance(ALICE), 100146); }); } @@ -2159,7 +2159,7 @@ fn cancel_listing_should_work() { Perbill::from_percent(0u32), FungibleTokenId::NativeToken(0) )); - assert_eq!(Balances::free_balance(BOB), 496); + assert_eq!(Balances::free_balance(BOB), 495); assert_eq!(AuctionModule::items_in_auction(ItemId::NFT(0, 0)), Some(true)); assert_eq!( AuctionModule::auctions(0), @@ -2172,7 +2172,7 @@ fn cancel_listing_should_work() { run_to_block(2); assert_ok!(AuctionModule::cancel_listing(RuntimeOrigin::signed(BOB), 0)); - assert_eq!(Balances::free_balance(BOB), 497); + assert_eq!(Balances::free_balance(BOB), 496); assert_eq!(AuctionModule::items_in_auction(ItemId::NFT(0, 0)), None); assert_eq!(AuctionModule::auctions(0), None); diff --git a/pallets/auction/src/weights.rs b/pallets/auction/src/weights.rs index 97ebcd77a..153839116 100644 --- a/pallets/auction/src/weights.rs +++ b/pallets/auction/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for auction //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-06-21, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-07-19, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 // Executed Command: @@ -75,15 +75,17 @@ impl WeightInfo for SubstrateWeight { // Storage: Me // Proof Skipped: Auction Auctions (max_values: None, max_size: None, mode: Measured) fn create_new_auction() -> Weight { // Proof Size summary in bytes: - // Measured: `3359` - // Estimated: `54013` - // Minimum execution time: 75_737 nanoseconds. - Weight::from_parts(83_359_000, 54013) + // Measured: `3695` + // Estimated: `57373` + // Minimum execution time: 59_917 nanoseconds. + Weight::from_parts(61_885_000, 57373) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(7)) } // Storage: Metaverse Metaverses (r:1 w:0) // Proof Skipped: Metaverse Metaverses (max_values: None, max_size: None, mode: Measured) + // Storage: System Account (r:2 w:2) + // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) // Storage: Auction ItemsInAuction (r:1 w:1) // Proof Skipped: Auction ItemsInAuction (max_values: None, max_size: None, mode: Measured) // Storage: OrmlNFT Tokens (r:1 w:1) @@ -96,8 +98,6 @@ impl WeightInfo for SubstrateWeight { // Storage: Me // Proof Skipped: Metaverse MetaverseOwner (max_values: None, max_size: None, mode: Measured) // Storage: Auction AuctionEndTime (r:1 w:1) // Proof Skipped: Auction AuctionEndTime (max_values: None, max_size: None, mode: Measured) - // Storage: System Account (r:1 w:1) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) // Storage: Auction AuctionsIndex (r:1 w:1) // Proof Skipped: Auction AuctionsIndex (max_values: Some(1), max_size: None, mode: Measured) // Storage: Auction AuctionItems (r:0 w:1) @@ -106,15 +106,17 @@ impl WeightInfo for SubstrateWeight { // Storage: Me // Proof Skipped: Auction Auctions (max_values: None, max_size: None, mode: Measured) fn create_new_buy_now() -> Weight { // Proof Size summary in bytes: - // Measured: `3359` - // Estimated: `54013` - // Minimum execution time: 58_587 nanoseconds. - Weight::from_parts(60_938_000, 54013) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(7)) + // Measured: `3868` + // Estimated: `61706` + // Minimum execution time: 72_460 nanoseconds. + Weight::from_parts(74_722_000, 61706) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(8)) } // Storage: Auction AuctionItems (r:1 w:1) // Proof Skipped: Auction AuctionItems (max_values: None, max_size: None, mode: Measured) + // Storage: System Account (r:2 w:2) + // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) // Storage: Auction Auctions (r:1 w:1) // Proof Skipped: Auction Auctions (max_values: None, max_size: None, mode: Measured) // Storage: Tokens Accounts (r:1 w:1) @@ -123,12 +125,12 @@ impl WeightInfo for SubstrateWeight { // Storage: Me // Proof Skipped: Auction AuctionEndTime (max_values: None, max_size: None, mode: Measured) fn bid() -> Weight { // Proof Size summary in bytes: - // Measured: `3236` - // Estimated: `17254` - // Minimum execution time: 50_075 nanoseconds. - Weight::from_parts(52_851_000, 17254) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(5)) + // Measured: `4133` + // Estimated: `25151` + // Minimum execution time: 64_755 nanoseconds. + Weight::from_parts(75_918_000, 25151) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(7)) } // Storage: Auction AuctionItems (r:1 w:1) // Proof Skipped: Auction AuctionItems (max_values: None, max_size: None, mode: Measured) @@ -154,10 +156,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Me // Proof Skipped: OrmlNFT TokensByOwner (max_values: None, max_size: None, mode: Measured) fn buy_now() -> Weight { // Proof Size summary in bytes: - // Measured: `4659` - // Estimated: `74974` - // Minimum execution time: 113_286 nanoseconds. - Weight::from_parts(117_267_000, 74974) + // Measured: `5079` + // Estimated: `78754` + // Minimum execution time: 117_209 nanoseconds. + Weight::from_parts(121_030_000, 78754) .saturating_add(T::DbWeight::get().reads(13)) .saturating_add(T::DbWeight::get().writes(12)) } @@ -175,10 +177,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Me // Proof Skipped: Auction AuctionEndTime (max_values: None, max_size: None, mode: Measured) fn cancel_listing() -> Weight { // Proof Size summary in bytes: - // Measured: `3664` - // Estimated: `28348` - // Minimum execution time: 50_526 nanoseconds. - Weight::from_parts(76_276_000, 28348) + // Measured: `4000` + // Estimated: `30028` + // Minimum execution time: 49_038 nanoseconds. + Weight::from_parts(50_823_000, 30028) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(6)) } @@ -190,8 +192,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Me // Proof Size summary in bytes: // Measured: `1307` // Estimated: `7564` - // Minimum execution time: 30_845 nanoseconds. - Weight::from_parts(35_078_000, 7564) + // Minimum execution time: 21_943 nanoseconds. + Weight::from_parts(23_046_000, 7564) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -203,8 +205,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Me // Proof Size summary in bytes: // Measured: `1360` // Estimated: `7670` - // Minimum execution time: 22_308 nanoseconds. - Weight::from_parts(24_963_000, 7670) + // Minimum execution time: 22_905 nanoseconds. + Weight::from_parts(23_607_000, 7670) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -220,8 +222,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Me // Proof Size summary in bytes: // Measured: `1805` // Estimated: `15443` - // Minimum execution time: 36_403 nanoseconds. - Weight::from_parts(38_021_000, 15443) + // Minimum execution time: 36_625 nanoseconds. + Weight::from_parts(38_079_000, 15443) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -233,8 +235,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Me // Proof Size summary in bytes: // Measured: `1534` // Estimated: `6612` - // Minimum execution time: 28_040 nanoseconds. - Weight::from_parts(29_056_000, 6612) + // Minimum execution time: 27_880 nanoseconds. + Weight::from_parts(28_621_000, 6612) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -256,8 +258,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Me // Proof Size summary in bytes: // Measured: `2326` // Estimated: `31537` - // Minimum execution time: 67_215 nanoseconds. - Weight::from_parts(69_244_000, 31537) + // Minimum execution time: 68_875 nanoseconds. + Weight::from_parts(72_454_000, 31537) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(6)) } @@ -265,63 +267,63 @@ impl WeightInfo for SubstrateWeight { // Storage: Me // Proof Size summary in bytes: // Measured: `774` // Estimated: `0` - // Minimum execution time: 5_355 nanoseconds. - Weight::from_parts(6_116_000, 0) + // Minimum execution time: 5_673 nanoseconds. + Weight::from_parts(7_467_000, 0) } } // For backwards compatibility and tests impl WeightInfo for () { fn create_new_auction() -> Weight { - Weight::from_parts(83_359_000, 54013) + Weight::from_parts(61_885_000, 57373) .saturating_add(RocksDbWeight::get().reads(9)) .saturating_add(RocksDbWeight::get().writes(7)) } fn create_new_buy_now() -> Weight { - Weight::from_parts(60_938_000, 54013) - .saturating_add(RocksDbWeight::get().reads(9)) - .saturating_add(RocksDbWeight::get().writes(7)) + Weight::from_parts(74_722_000, 61706) + .saturating_add(RocksDbWeight::get().reads(10)) + .saturating_add(RocksDbWeight::get().writes(8)) } fn bid() -> Weight { - Weight::from_parts(52_851_000, 17254) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(5)) + Weight::from_parts(75_918_000, 25151) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(7)) } fn buy_now() -> Weight { - Weight::from_parts(117_267_000, 74974) + Weight::from_parts(121_030_000, 78754) .saturating_add(RocksDbWeight::get().reads(13)) .saturating_add(RocksDbWeight::get().writes(12)) } fn cancel_listing() -> Weight { - Weight::from_parts(76_276_000, 28348) + Weight::from_parts(50_823_000, 30028) .saturating_add(RocksDbWeight::get().reads(4)) .saturating_add(RocksDbWeight::get().writes(6)) } fn authorise_metaverse_collection() -> Weight { - Weight::from_parts(35_078_000, 7564) + Weight::from_parts(23_046_000, 7564) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } fn remove_authorise_metaverse_collection() -> Weight { - Weight::from_parts(24_963_000, 7670) + Weight::from_parts(23_607_000, 7670) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } fn make_offer() -> Weight { - Weight::from_parts(38_021_000, 15443) + Weight::from_parts(38_079_000, 15443) .saturating_add(RocksDbWeight::get().reads(4)) .saturating_add(RocksDbWeight::get().writes(2)) } fn withdraw_offer() -> Weight { - Weight::from_parts(29_056_000, 6612) + Weight::from_parts(28_621_000, 6612) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(2)) } fn accept_offer() -> Weight { - Weight::from_parts(69_244_000, 31537) + Weight::from_parts(72_454_000, 31537) .saturating_add(RocksDbWeight::get().reads(7)) .saturating_add(RocksDbWeight::get().writes(6)) } fn on_finalize() -> Weight { - Weight::from_parts(6_116_000, 0) + Weight::from_parts(7_467_000, 0) } } diff --git a/pallets/continuum/src/lib.rs b/pallets/continuum/src/lib.rs index 34b13e11a..e73c0aca7 100644 --- a/pallets/continuum/src/lib.rs +++ b/pallets/continuum/src/lib.rs @@ -48,6 +48,7 @@ use codec::{Decode, Encode}; use frame_support::{ dispatch::DispatchResult, ensure, log, + traits::ExistenceRequirement, traits::{Currency, Get, LockableCurrency, ReservableCurrency}, transactional, PalletId, }; @@ -109,7 +110,6 @@ pub struct AuctionSlot { #[frame_support::pallet] pub mod pallet { - use frame_support::traits::ExistenceRequirement; use frame_support::{dispatch::DispatchResultWithPostInfo, pallet_prelude::*}; use frame_system::pallet_prelude::OriginFor; use sp_arithmetic::traits::UniqueSaturatedInto; @@ -152,6 +152,12 @@ pub mod pallet { + LockableCurrency; /// Source of Metaverse Network Info type MetaverseInfoSource: MetaverseTrait; + + /// Storage deposit free charged when saving data into the blockchain. + /// The fee will be unreserved after the storage is freed. + #[pallet::constant] + type StorageDepositFee: Get>; + /// Weight implementation for estate extrinsics type WeightInfo: WeightInfo; } @@ -432,12 +438,36 @@ pub mod pallet { .get_map_spot_detail() .ok_or(Error::::InvalidSpotAuction)?; + /* // Refund storage fee to the previous bidder (if exist) + match T::AuctionHandler::auction_info(auction_id) { + Some(auction_info) => match auction_info.bid { + Some(last_bid) => { + ::Currency::transfer( + &Self::account_id(), + &last_bid.0, + T::StorageDepositFee::get(), + ExistenceRequirement::KeepAlive, + )?; + } + None => {} + }, + None => {} + } + */ T::AuctionHandler::update_auction_item(auction_id, ItemId::Spot(*spot_detail.0, metaverse_id))?; - T::AuctionHandler::auction_bid_handler(sender, auction_id, value)?; + T::AuctionHandler::auction_bid_handler(sender.clone(), auction_id, value)?; // Remove leading bid of this spot MetaverseLeadingBid::::remove_prefix(spot_detail.0, None); + // Charge storage few to the current bidder + ::Currency::transfer( + &sender, + &Self::account_id(), + T::StorageDepositFee::get(), + ExistenceRequirement::KeepAlive, + )?; + // Add metaverse leading bid MetaverseLeadingBid::::insert(spot_detail.0, metaverse_id, ()); @@ -506,9 +536,17 @@ impl MapTrait for Pallet { spot.owner = to.clone().0; spot.metaverse_id = Some(to.1); - Self::deposit_event(Event::::ContinuumSpotTransferred(from, to.0, spot_id)); + Self::deposit_event(Event::::ContinuumSpotTransferred(from, to.0.clone(), spot_id)); MetaverseMap::::insert(to.1, spot_id); MetaverseLeadingBid::::remove_prefix(spot_id, None); + /* // Storage fee refund + ::Currency::transfer( + &treasury, + &to.0, + T::StorageDepositFee::get(), + ExistenceRequirement::KeepAlive, + )?; + */ Ok(spot_id) }) } diff --git a/pallets/continuum/src/mock.rs b/pallets/continuum/src/mock.rs index 0db2bee17..a49353f1f 100644 --- a/pallets/continuum/src/mock.rs +++ b/pallets/continuum/src/mock.rs @@ -222,6 +222,7 @@ parameter_types! { pub const SessionDuration: BlockNumber = 10; // Default 43200 Blocks pub const SpotAuctionChillingDuration: BlockNumber = 10; + pub StorageDepositFee: Balance = 1; } pub struct MetaverseInfoSource {} @@ -309,6 +310,7 @@ impl Config for Runtime { type ContinuumTreasury = ContinuumTreasuryPalletId; type Currency = Balances; type MetaverseInfoSource = MetaverseInfoSource; + type StorageDepositFee = StorageDepositFee; type WeightInfo = (); } diff --git a/pallets/continuum/src/tests.rs b/pallets/continuum/src/tests.rs index 352d2e730..db3b7c10c 100644 --- a/pallets/continuum/src/tests.rs +++ b/pallets/continuum/src/tests.rs @@ -477,6 +477,7 @@ fn bid_auction_continuum_should_replace_another_leading_bid() { CONTINUUM_MAP_COORDINATE, ALICE_METAVERSE_ID )); + assert_eq!(Balances::free_balance(ALICE), 99999); assert_ok!(ContinuumModule::bid_map_spot( RuntimeOrigin::signed(BOB), @@ -489,6 +490,7 @@ fn bid_auction_continuum_should_replace_another_leading_bid() { CONTINUUM_MAP_COORDINATE, BOB_METAVERSE_ID )); + assert_eq!(Balances::free_balance(BOB), 499); // Alice leading bid should be removed assert!(!MetaverseLeadingBid::::contains_key( @@ -514,6 +516,7 @@ fn bid_auction_continuum_should_replace_another_leading_bid() { CONTINUUM_MAP_COORDINATE, BOB_METAVERSE_ID )); + assert_eq!(Balances::free_balance(ALICE), 99998); let treasury = ::ContinuumTreasury::get().into_account_truncating(); ContinuumModule::transfer_spot(CONTINUUM_MAP_COORDINATE, treasury, (BOB, BOB_METAVERSE_ID)); diff --git a/pallets/continuum/src/types.rs b/pallets/continuum/src/types.rs index 50b9f3f4f..f0df52b2c 100644 --- a/pallets/continuum/src/types.rs +++ b/pallets/continuum/src/types.rs @@ -132,7 +132,11 @@ impl ContinuumSpotTally { } pub fn result(&mut self) -> Option { - let total_nay = self.nays.checked_div(self.turnout).unwrap().saturating_mul(100); + let total_nay = self + .nays + .checked_div(self.turnout) + .unwrap_or(Zero::zero()) + .saturating_mul(100); let approve_threshold = 49; Some(total_nay > approve_threshold) diff --git a/pallets/continuum/src/weights.rs b/pallets/continuum/src/weights.rs index 2d40a3e6b..648284bc8 100644 --- a/pallets/continuum/src/weights.rs +++ b/pallets/continuum/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for continuum //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-06-21, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-07-15, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 // Executed Command: @@ -57,8 +57,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Co // Proof Size summary in bytes: // Measured: `646` // Estimated: `646` - // Minimum execution time: 3_237 nanoseconds. - Weight::from_parts(3_836_000, 646) + // Minimum execution time: 5_488 nanoseconds. + Weight::from_parts(6_650_000, 646) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Continuum MaxBound (r:0 w:1) @@ -67,8 +67,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Co // Proof Size summary in bytes: // Measured: `919` // Estimated: `919` - // Minimum execution time: 9_899 nanoseconds. - Weight::from_parts(10_396_000, 919) + // Minimum execution time: 23_954 nanoseconds. + Weight::from_parts(25_462_000, 919) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Continuum MapSpots (r:1 w:1) @@ -79,8 +79,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Co // Proof Size summary in bytes: // Measured: `1059` // Estimated: `5088` - // Minimum execution time: 15_005 nanoseconds. - Weight::from_parts(15_692_000, 5088) + // Minimum execution time: 23_799 nanoseconds. + Weight::from_parts(24_533_000, 5088) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -102,8 +102,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Co // Proof Size summary in bytes: // Measured: `1617` // Estimated: `20225` - // Minimum execution time: 34_931 nanoseconds. - Weight::from_parts(36_453_000, 20225) + // Minimum execution time: 75_559 nanoseconds. + Weight::from_parts(85_653_000, 20225) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(6)) } @@ -133,8 +133,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Co // Proof Size summary in bytes: // Measured: `3168` // Estimated: `59161` - // Minimum execution time: 106_007 nanoseconds. - Weight::from_parts(172_450_000, 59161) + // Minimum execution time: 146_930 nanoseconds. + Weight::from_parts(170_947_000, 59161) .saturating_add(T::DbWeight::get().reads(11)) .saturating_add(T::DbWeight::get().writes(8)) } @@ -152,44 +152,46 @@ impl WeightInfo for SubstrateWeight { // Storage: Co // Proof Skipped: Auction AuctionItems (max_values: None, max_size: None, mode: Measured) // Storage: Auction Auctions (r:1 w:1) // Proof Skipped: Auction Auctions (max_values: None, max_size: None, mode: Measured) + // Storage: System Account (r:1 w:1) + // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn bid_map_spot() -> Weight { // Proof Size summary in bytes: - // Measured: `3010` - // Estimated: `40870` - // Minimum execution time: 64_888 nanoseconds. - Weight::from_parts(67_164_000, 40870) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(3)) + // Measured: `3145` + // Estimated: `44418` + // Minimum execution time: 113_888 nanoseconds. + Weight::from_parts(120_875_000, 44418) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) } } // For backwards compatibility and tests impl WeightInfo for () { fn set_allow_buy_now() -> Weight { - Weight::from_parts(3_836_000, 646) + Weight::from_parts(6_650_000, 646) .saturating_add(RocksDbWeight::get().writes(1)) } fn set_max_bounds() -> Weight { - Weight::from_parts(10_396_000, 919) + Weight::from_parts(25_462_000, 919) .saturating_add(RocksDbWeight::get().writes(1)) } fn issue_map_slot() -> Weight { - Weight::from_parts(15_692_000, 5088) + Weight::from_parts(24_533_000, 5088) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } fn create_new_auction() -> Weight { - Weight::from_parts(36_453_000, 20225) + Weight::from_parts(85_653_000, 20225) .saturating_add(RocksDbWeight::get().reads(5)) .saturating_add(RocksDbWeight::get().writes(6)) } fn buy_map_spot() -> Weight { - Weight::from_parts(172_450_000, 59161) + Weight::from_parts(170_947_000, 59161) .saturating_add(RocksDbWeight::get().reads(11)) .saturating_add(RocksDbWeight::get().writes(8)) } fn bid_map_spot() -> Weight { - Weight::from_parts(67_164_000, 40870) - .saturating_add(RocksDbWeight::get().reads(8)) - .saturating_add(RocksDbWeight::get().writes(3)) + Weight::from_parts(120_875_000, 44418) + .saturating_add(RocksDbWeight::get().reads(9)) + .saturating_add(RocksDbWeight::get().writes(4)) } } diff --git a/pallets/economy/src/mock.rs b/pallets/economy/src/mock.rs index 7ca3b8a67..f6da3a3ca 100644 --- a/pallets/economy/src/mock.rs +++ b/pallets/economy/src/mock.rs @@ -194,6 +194,7 @@ impl MetaverseStakingTrait for MetaverseStakingHandler { parameter_types! { pub const TreasuryStakingReward: Perbill = Perbill::from_percent(1); + pub StorageDepositFee: Balance = 1; } impl pallet_mining::Config for Runtime { @@ -205,6 +206,9 @@ impl pallet_mining::Config for Runtime { type AdminOrigin = EnsureSignedBy; type MetaverseStakingHandler = MetaverseStakingHandler; type TreasuryStakingReward = TreasuryStakingReward; + type NetworkTreasuryAccount = TreasuryModuleAccount; + type StorageDepositFee = StorageDepositFee; + type Currency = Balances; type WeightInfo = (); } @@ -371,6 +375,7 @@ impl pallet_nft::Config for Runtime { type Treasury = MetaverseNetworkTreasuryPalletId; type AssetMintingFee = AssetMintingFee; type ClassMintingFee = ClassMintingFee; + type StorageDepositFee = StorageDepositFee; } parameter_types! { diff --git a/pallets/estate/src/lib.rs b/pallets/estate/src/lib.rs index 8ba0c98e7..3c124e779 100644 --- a/pallets/estate/src/lib.rs +++ b/pallets/estate/src/lib.rs @@ -27,10 +27,10 @@ use frame_support::{ use frame_system::pallet_prelude::*; use frame_system::{ensure_root, ensure_signed}; use scale_info::TypeInfo; -use sp_runtime::traits::Zero; + use sp_runtime::{ - traits::{AccountIdConversion, Convert, One, Saturating}, - ArithmeticError, DispatchError, + traits::{AccountIdConversion, Convert, One, Saturating, Zero}, + ArithmeticError, DispatchError, Perbill, SaturatedConversion, }; use sp_std::vec::Vec; @@ -141,11 +141,16 @@ pub mod pallet { #[pallet::constant] type LeaseOfferExpiryPeriod: Get; + /// Storage deposit free charged when saving data into the blockchain. + /// The fee will be unreserved after the storage is freed. + #[pallet::constant] + type StorageDepositFee: Get>; + /// Allows converting block numbers into balance type BlockNumberToBalance: Convert>; } - type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; + pub type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; #[pallet::storage] #[pallet::getter(fn all_land_units_count)] @@ -595,7 +600,7 @@ pub mod pallet { /// - `coordinates`: list of land units coordinates /// /// Emits `NewEstateMinted` if successful. - #[pallet::weight(T::WeightInfo::create_estate() * coordinates.len() as u64)] + #[pallet::weight(T::WeightInfo::create_estate().saturating_mul(coordinates.len() as u64))] #[transactional] pub fn create_estate( origin: OriginFor, @@ -621,6 +626,15 @@ pub mod pallet { T::NFTTokenizationSource::mint_token(&who, class_id, token_properties.0, token_properties.1)?; let beneficiary = OwnerId::Token(class_id, token_id); + let storage_fee: BalanceOf = + Perbill::from_percent(100u32.saturating_mul(coordinates.len() as u32)) * T::StorageDepositFee::get(); + T::Currency::transfer( + &who, + &T::MetaverseInfoSource::get_network_treasury(), + storage_fee.saturated_into(), + ExistenceRequirement::KeepAlive, + )?; + // Mint land units for coordinate in coordinates.clone() { Self::mint_land_unit( @@ -1051,6 +1065,15 @@ pub mod pallet { // Mint new land tokens to replace the lands in the dissolved estate let estate_account_id: T::AccountId = T::LandTreasury::get().into_sub_account_truncating(estate_id); + let storage_fee: BalanceOf = + Perbill::from_percent(100u32.saturating_mul(estate_info.land_units.len() as u32)) + * T::StorageDepositFee::get(); + T::Currency::transfer( + &who, + &T::MetaverseInfoSource::get_network_treasury(), + storage_fee.saturated_into(), + ExistenceRequirement::KeepAlive, + )?; for land_unit in estate_info.land_units { // Transfer land unit from treasury to estate owner Self::mint_land_unit( @@ -1106,15 +1129,26 @@ pub mod pallet { let estate_info: EstateInfo = Estates::::get(estate_id).ok_or(Error::::EstateDoesNotExist)?; let estate_account_id: T::AccountId = T::LandTreasury::get().into_sub_account_truncating(estate_id); + + let storage_fee: BalanceOf = + Perbill::from_percent(100u32.saturating_mul(land_units.len() as u32)) + * T::StorageDepositFee::get(); + T::Currency::transfer( + &who, + &T::MetaverseInfoSource::get_network_treasury(), + storage_fee.saturated_into(), + ExistenceRequirement::KeepAlive, + )?; + // Check land unit ownership for land_unit in land_units.clone() { + let metaverse_land_unit = Self::get_land_units(estate_info.metaverse_id, land_unit) + .ok_or(Error::::UndeployedLandBlockNotFound)?; ensure!( - Self::check_if_land_or_estate_owner( - &who, - &Self::get_land_units(estate_info.metaverse_id, land_unit).unwrap(), - ), + Self::check_if_land_or_estate_owner(&who, &metaverse_land_unit,), Error::::LandUnitDoesNotExist ); + // Mint land unit Self::mint_land_unit( estate_info.metaverse_id, @@ -1174,10 +1208,20 @@ pub mod pallet { ); let estate_info: EstateInfo = Estates::::get(estate_id).ok_or(Error::::EstateDoesNotExist)?; let estate_account_id: T::AccountId = T::LandTreasury::get().into_sub_account_truncating(estate_id); + // Mutate estates Estates::::try_mutate_exists(&estate_id, |maybe_estate_info| { let mut mut_estate_info = maybe_estate_info.as_mut().ok_or(Error::::EstateDoesNotExist)?; + let storage_fee: BalanceOf = + Perbill::from_percent(100u32.saturating_mul(land_units.len() as u32)) + * T::StorageDepositFee::get(); + T::Currency::transfer( + &who, + &T::MetaverseInfoSource::get_network_treasury(), + storage_fee.saturated_into(), + ExistenceRequirement::KeepAlive, + )?; // Mutate land unit ownership for land_unit in land_units.clone() { // Transfer land unit from treasury to estate owner @@ -1189,7 +1233,11 @@ pub mod pallet { LandUnitStatus::RemovedFromEstate, )?; // Remove coordinates from estate - let index = mut_estate_info.land_units.iter().position(|x| *x == land_unit).unwrap(); + let index = mut_estate_info + .land_units + .iter() + .position(|x| *x == land_unit) + .ok_or(Error::::LandUnitIsNotAvailable)?; mut_estate_info.land_units.remove(index); } @@ -1320,6 +1368,14 @@ pub mod pallet { lease.start_block = >::block_number(); lease.end_block = lease.start_block + lease.duration.into(); + // 200% storage fee since there are 2 storage inserts + let storage_fee: BalanceOf = Perbill::from_percent(200) * T::StorageDepositFee::get(); + T::Currency::transfer( + &who, + &T::MetaverseInfoSource::get_network_treasury(), + storage_fee.saturated_into(), + ExistenceRequirement::KeepAlive, + )?; EstateLeaseOffers::::remove_prefix(estate_id, None); EstateLeases::::insert(estate_id, lease.clone()); @@ -1566,6 +1622,7 @@ impl Pallet { // Ensure not locked T::NFTTokenizationSource::set_lock_nft((class_id, token_id), false)?; T::NFTTokenizationSource::burn_nft(&a, &(class_id, token_id)); + LandUnits::::insert(metaverse_id, coordinate, token_owner.clone()); } _ => (), @@ -1594,6 +1651,7 @@ impl Pallet { ); owner = token_owner.clone(); + LandUnits::::insert(metaverse_id, coordinate, token_owner.clone()); } LandUnitStatus::RemovedFromEstate => { @@ -1664,6 +1722,15 @@ impl Pallet { to: &T::AccountId, undeployed_land_block_id: UndeployedLandBlockId, ) -> Result { + // 200% storage fee since there are 2 storage inserts + let storage_fee: BalanceOf = Perbill::from_percent(200) * T::StorageDepositFee::get(); + T::Currency::transfer( + &who, + &T::MetaverseInfoSource::get_network_treasury(), + storage_fee.saturated_into(), + ExistenceRequirement::KeepAlive, + )?; + UndeployedLandBlocks::::try_mutate( &undeployed_land_block_id, |undeployed_land_block| -> Result { @@ -1767,6 +1834,18 @@ impl Pallet { ) -> Result, DispatchError> { let mut undeployed_land_block_ids: Vec = Vec::new(); + // 2 inserts per land blocks + let storage_fee: BalanceOf = + Perbill::from_percent(number_of_land_block.saturating_mul(2).saturating_mul(100)) + * T::StorageDepositFee::get(); + + T::Currency::transfer( + beneficiary, + &T::MetaverseInfoSource::get_network_treasury(), + storage_fee.saturated_into(), + ExistenceRequirement::KeepAlive, + )?; + for _ in 0..number_of_land_block { let new_undeployed_land_block_id = Self::get_new_undeployed_land_block_id()?; @@ -2005,10 +2084,10 @@ impl Pallet { let mut vec_axis = land_unit_coordinates.iter().map(|lu| lu.0).collect::>(); let mut vec_yaxis = land_unit_coordinates.iter().map(|lu| lu.1).collect::>(); - let max_axis = vec_axis.iter().max().unwrap(); - let max_yaxis = vec_yaxis.iter().max().unwrap(); - let min_axis = vec_axis.iter().min().unwrap(); - let min_yaxis = vec_yaxis.iter().min().unwrap(); + let max_axis = vec_axis.iter().max().unwrap_or(&i32::MAX); + let max_yaxis = vec_yaxis.iter().max().unwrap_or(&i32::MAX); + let min_axis = vec_axis.iter().min().unwrap_or(&i32::MIN); + let min_yaxis = vec_yaxis.iter().min().unwrap_or(&i32::MIN); let top_left_axis = block_coordinate .0 diff --git a/pallets/estate/src/mock.rs b/pallets/estate/src/mock.rs index b76a87f47..3856a489b 100644 --- a/pallets/estate/src/mock.rs +++ b/pallets/estate/src/mock.rs @@ -548,6 +548,7 @@ parameter_types! { pub const MinLeasePricePerBlock: Balance = 1u128; pub const MaxLeasePeriod: u32 = 9; pub const LeaseOfferExpiryPeriod: u32 = 6; + pub StorageDepositFee: Balance = 1; } impl Config for Runtime { @@ -570,6 +571,7 @@ impl Config for Runtime { type MaxLeasePeriod = MaxLeasePeriod; type LeaseOfferExpiryPeriod = LeaseOfferExpiryPeriod; type BlockNumberToBalance = ConvertInto; + type StorageDepositFee = StorageDepositFee; } construct_runtime!( diff --git a/pallets/estate/src/tests.rs b/pallets/estate/src/tests.rs index b3bc28eec..d597baa73 100644 --- a/pallets/estate/src/tests.rs +++ b/pallets/estate/src/tests.rs @@ -821,7 +821,7 @@ fn create_estate_token_should_work() { }) ); assert_eq!(EstateModule::get_estate_owner(estate_id), Some(OWNER_ESTATE_ASSET_ID)); - assert_eq!(Balances::free_balance(BENEFICIARY_ID), 999999); + assert_eq!(Balances::free_balance(BENEFICIARY_ID), 999998); }); } @@ -864,7 +864,7 @@ fn create_estate_token_after_minting_account_and_token_based_lands_should_give_c 2 ); assert_eq!(EstateModule::all_land_units_count(), 2); - assert_eq!(Balances::free_balance(BENEFICIARY_ID), 999999); + assert_eq!(Balances::free_balance(BENEFICIARY_ID), 999998); }); } @@ -883,7 +883,7 @@ fn create_estate_should_return_none_for_non_exist_estate() { METAVERSE_ID, vec![COORDINATE_IN_1, COORDINATE_IN_2] )); - assert_eq!(Balances::free_balance(BENEFICIARY_ID), 999999); + assert_eq!(Balances::free_balance(BENEFICIARY_ID), 999998); let estate_id: u64 = 0; assert_eq!(EstateModule::all_estates_count(), 1); @@ -1536,7 +1536,7 @@ fn deploy_undeployed_land_block_should_fail_if_freezed() { ), Error::::UndeployedLandBlockFreezed ); - assert_eq!(Balances::free_balance(BOB), 100000); + assert_eq!(Balances::free_balance(BOB), 99999); }); } @@ -1584,7 +1584,7 @@ fn deploy_undeployed_land_block_should_fail_if_already_in_auction() { ), Error::::UndeployedLandBlockAlreadyInAuction ); - assert_eq!(Balances::free_balance(BOB), 100000); + assert_eq!(Balances::free_balance(BOB), 99998); }); } @@ -1635,7 +1635,7 @@ fn deploy_undeployed_land_block_should_work() { assert_eq!(updated_undeployed_land_block, None); assert_eq!(EstateModule::all_land_units_count(), 2); - assert_eq!(Balances::free_balance(BOB), 99999); + assert_eq!(Balances::free_balance(BOB), 99998); }); } @@ -2163,7 +2163,7 @@ fn issue_land_block_and_create_estate_should_work() { LANDBLOCK_COORDINATE, vec![COORDINATE_IN_1, COORDINATE_IN_2] )); - assert_eq!(Balances::free_balance(BOB), 99999); + assert_eq!(Balances::free_balance(BOB), 99998); assert_eq!( EstateModule::get_land_units(BOB_METAVERSE_ID, COORDINATE_IN_1), @@ -2576,7 +2576,7 @@ fn cancel_lease_should_work() { assert_eq!(EstateModule::leasors(ALICE, 0u64), None); assert_eq!(Balances::free_balance(ALICE), 99960); - assert_eq!(Balances::free_balance(BENEFICIARY_ID), 1000040); + assert_eq!(Balances::free_balance(BENEFICIARY_ID), 1000039); }); } @@ -2699,7 +2699,7 @@ fn remove_expired_lease_should_work() { assert_eq!(EstateModule::leasors(ALICE, 0u64), None); assert_eq!(Balances::free_balance(ALICE), 99920); - assert_eq!(Balances::free_balance(BENEFICIARY_ID), 1000080); + assert_eq!(Balances::free_balance(BENEFICIARY_ID), 1000079); }); } @@ -2903,6 +2903,6 @@ fn collect_rent_should_work() { assert_eq!(EstateModule::leasors(ALICE, 0u64), Some(())); assert_eq!(Balances::free_balance(ALICE), 99920); - assert_eq!(Balances::free_balance(BENEFICIARY_ID), 1000030); + assert_eq!(Balances::free_balance(BENEFICIARY_ID), 1000029); }); } diff --git a/pallets/estate/src/weights.rs b/pallets/estate/src/weights.rs index 692e49923..f848ec15c 100644 --- a/pallets/estate/src/weights.rs +++ b/pallets/estate/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for estate //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-06-21, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-07-18, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 // Executed Command: @@ -73,8 +73,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Size summary in bytes: // Measured: `2339` // Estimated: `36660` - // Minimum execution time: 56_310 nanoseconds. - Weight::from_parts(58_455_000, 36660) + // Minimum execution time: 56_882 nanoseconds. + Weight::from_parts(59_273_000, 36660) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(7)) } @@ -100,8 +100,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Size summary in bytes: // Measured: `2339` // Estimated: `41610` - // Minimum execution time: 81_921 nanoseconds. - Weight::from_parts(85_264_000, 41610) + // Minimum execution time: 82_026 nanoseconds. + Weight::from_parts(83_541_000, 41610) .saturating_add(T::DbWeight::get().reads(10)) .saturating_add(T::DbWeight::get().writes(10)) } @@ -123,8 +123,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Size summary in bytes: // Measured: `1915` // Estimated: `28255` - // Minimum execution time: 50_235 nanoseconds. - Weight::from_parts(98_162_000, 28255) + // Minimum execution time: 46_193 nanoseconds. + Weight::from_parts(47_423_000, 28255) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -158,8 +158,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Size summary in bytes: // Measured: `2356` // Estimated: `47210` - // Minimum execution time: 64_807 nanoseconds. - Weight::from_parts(70_956_000, 47210) + // Minimum execution time: 62_931 nanoseconds. + Weight::from_parts(64_479_000, 47210) .saturating_add(T::DbWeight::get().reads(10)) .saturating_add(T::DbWeight::get().writes(11)) } @@ -175,26 +175,26 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Skipped: OrmlNFT Classes (max_values: None, max_size: None, mode: Measured) // Storage: Estate AllEstatesCount (r:1 w:1) // Proof Skipped: Estate AllEstatesCount (max_values: Some(1), max_size: None, mode: Measured) + // Storage: System Account (r:2 w:2) + // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) // Storage: Estate LandUnits (r:1 w:1) // Proof Skipped: Estate LandUnits (max_values: None, max_size: None, mode: Measured) // Storage: Metaverse Metaverses (r:1 w:0) // Proof Skipped: Metaverse Metaverses (max_values: None, max_size: None, mode: Measured) // Storage: Nft LockedCollection (r:1 w:0) // Proof Skipped: Nft LockedCollection (max_values: None, max_size: None, mode: Measured) - // Storage: System Account (r:1 w:1) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) // Storage: OrmlNFT NextTokenId (r:1 w:1) // Proof Skipped: OrmlNFT NextTokenId (max_values: None, max_size: None, mode: Measured) // Storage: OrmlNFT TokensByOwner (r:0 w:2) // Proof Skipped: OrmlNFT TokensByOwner (max_values: None, max_size: None, mode: Measured) fn dissolve_estate() -> Weight { // Proof Size summary in bytes: - // Measured: `2945` - // Estimated: `62718` - // Minimum execution time: 87_459 nanoseconds. - Weight::from_parts(90_916_000, 62718) - .saturating_add(T::DbWeight::get().reads(13)) - .saturating_add(T::DbWeight::get().writes(12)) + // Measured: `3118` + // Estimated: `67224` + // Minimum execution time: 99_063 nanoseconds. + Weight::from_parts(110_008_000, 67224) + .saturating_add(T::DbWeight::get().reads(14)) + .saturating_add(T::DbWeight::get().writes(13)) } // Storage: Estate EstateOwner (r:1 w:0) // Proof Skipped: Estate EstateOwner (max_values: None, max_size: None, mode: Measured) @@ -204,6 +204,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Skipped: OrmlNFT Tokens (max_values: None, max_size: None, mode: Measured) // Storage: Estate Estates (r:1 w:1) // Proof Skipped: Estate Estates (max_values: None, max_size: None, mode: Measured) + // Storage: System Account (r:1 w:1) + // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) // Storage: Estate LandUnits (r:1 w:1) // Proof Skipped: Estate LandUnits (max_values: None, max_size: None, mode: Measured) // Storage: OrmlNFT Classes (r:1 w:1) @@ -212,12 +214,12 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Skipped: OrmlNFT TokensByOwner (max_values: None, max_size: None, mode: Measured) fn add_land_unit_to_estate() -> Weight { // Proof Size summary in bytes: - // Measured: `2028` - // Estimated: `31521` - // Minimum execution time: 55_095 nanoseconds. - Weight::from_parts(57_930_000, 31521) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(5)) + // Measured: `2593` + // Estimated: `38079` + // Minimum execution time: 69_608 nanoseconds. + Weight::from_parts(71_706_000, 38079) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(6)) } // Storage: Estate EstateOwner (r:1 w:0) // Proof Skipped: Estate EstateOwner (max_values: None, max_size: None, mode: Measured) @@ -227,14 +229,14 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Skipped: OrmlNFT Tokens (max_values: None, max_size: None, mode: Measured) // Storage: Estate Estates (r:1 w:1) // Proof Skipped: Estate Estates (max_values: None, max_size: None, mode: Measured) + // Storage: System Account (r:2 w:2) + // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) // Storage: Estate LandUnits (r:1 w:1) // Proof Skipped: Estate LandUnits (max_values: None, max_size: None, mode: Measured) // Storage: Metaverse Metaverses (r:1 w:0) // Proof Skipped: Metaverse Metaverses (max_values: None, max_size: None, mode: Measured) // Storage: Nft LockedCollection (r:1 w:0) // Proof Skipped: Nft LockedCollection (max_values: None, max_size: None, mode: Measured) - // Storage: System Account (r:1 w:1) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) // Storage: OrmlNFT NextTokenId (r:1 w:1) // Proof Skipped: OrmlNFT NextTokenId (max_values: None, max_size: None, mode: Measured) // Storage: OrmlNFT Classes (r:1 w:1) @@ -243,12 +245,12 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Skipped: OrmlNFT TokensByOwner (max_values: None, max_size: None, mode: Measured) fn remove_land_unit_from_estate() -> Weight { // Proof Size summary in bytes: - // Measured: `2854` - // Estimated: `55893` - // Minimum execution time: 167_921 nanoseconds. - Weight::from_parts(172_334_000, 55893) - .saturating_add(T::DbWeight::get().reads(11)) - .saturating_add(T::DbWeight::get().writes(7)) + // Measured: `3027` + // Estimated: `60226` + // Minimum execution time: 86_578 nanoseconds. + Weight::from_parts(90_257_000, 60226) + .saturating_add(T::DbWeight::get().reads(12)) + .saturating_add(T::DbWeight::get().writes(8)) } // Storage: System Account (r:2 w:2) // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) @@ -278,8 +280,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Size summary in bytes: // Measured: `3192` // Estimated: `66058` - // Minimum execution time: 116_718 nanoseconds. - Weight::from_parts(123_103_000, 66058) + // Minimum execution time: 121_302 nanoseconds. + Weight::from_parts(131_741_000, 66058) .saturating_add(T::DbWeight::get().reads(14)) .saturating_add(T::DbWeight::get().writes(17)) } @@ -305,11 +307,13 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Size summary in bytes: // Measured: `2025` // Estimated: `38025` - // Minimum execution time: 52_256 nanoseconds. - Weight::from_parts(54_578_000, 38025) + // Minimum execution time: 52_643 nanoseconds. + Weight::from_parts(54_808_000, 38025) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(4)) } + // Storage: System Account (r:1 w:1) + // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) // Storage: Estate NextUndeployedLandBlockId (r:1 w:1) // Proof Skipped: Estate NextUndeployedLandBlockId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Estate TotalUndeployedLandUnit (r:1 w:1) @@ -320,12 +324,12 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Skipped: Estate UndeployedLandBlocksOwner (max_values: None, max_size: None, mode: Measured) fn issue_undeployed_land_blocks() -> Weight { // Proof Size summary in bytes: - // Measured: `993` - // Estimated: `4962` - // Minimum execution time: 144_048 nanoseconds. - Weight::from_parts(146_607_000, 4962) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(42)) + // Measured: `1558` + // Estimated: `9825` + // Minimum execution time: 159_581 nanoseconds. + Weight::from_parts(162_875_000, 9825) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(43)) } // Storage: Estate UndeployedLandBlocks (r:1 w:1) // Proof Skipped: Estate UndeployedLandBlocks (max_values: None, max_size: None, mode: Measured) @@ -335,8 +339,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Size summary in bytes: // Measured: `1442` // Estimated: `7834` - // Minimum execution time: 20_019 nanoseconds. - Weight::from_parts(21_200_000, 7834) + // Minimum execution time: 21_762 nanoseconds. + Weight::from_parts(22_833_000, 7834) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -348,8 +352,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Size summary in bytes: // Measured: `1442` // Estimated: `7834` - // Minimum execution time: 30_221 nanoseconds. - Weight::from_parts(47_505_000, 7834) + // Minimum execution time: 20_225 nanoseconds. + Weight::from_parts(21_423_000, 7834) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -361,8 +365,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Size summary in bytes: // Measured: `1442` // Estimated: `7834` - // Minimum execution time: 20_262 nanoseconds. - Weight::from_parts(21_983_000, 7834) + // Minimum execution time: 20_246 nanoseconds. + Weight::from_parts(21_819_000, 7834) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -374,25 +378,27 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Size summary in bytes: // Measured: `1475` // Estimated: `7900` - // Minimum execution time: 19_972 nanoseconds. - Weight::from_parts(20_803_000, 7900) + // Minimum execution time: 20_346 nanoseconds. + Weight::from_parts(21_237_000, 7900) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Auction ItemsInAuction (r:1 w:0) // Proof Skipped: Auction ItemsInAuction (max_values: None, max_size: None, mode: Measured) + // Storage: System Account (r:1 w:1) + // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) // Storage: Estate UndeployedLandBlocks (r:1 w:1) // Proof Skipped: Estate UndeployedLandBlocks (max_values: None, max_size: None, mode: Measured) // Storage: Estate UndeployedLandBlocksOwner (r:0 w:2) // Proof Skipped: Estate UndeployedLandBlocksOwner (max_values: None, max_size: None, mode: Measured) fn transfer_undeployed_land_blocks() -> Weight { // Proof Size summary in bytes: - // Measured: `1442` - // Estimated: `9276` - // Minimum execution time: 23_661 nanoseconds. - Weight::from_parts(24_091_000, 9276) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(3)) + // Measured: `2040` + // Estimated: `13673` + // Minimum execution time: 38_679 nanoseconds. + Weight::from_parts(41_173_000, 13673) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(4)) } // Storage: Auction ItemsInAuction (r:1 w:0) // Proof Skipped: Auction ItemsInAuction (max_values: None, max_size: None, mode: Measured) @@ -426,8 +432,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Size summary in bytes: // Measured: `2802` // Estimated: `64897` - // Minimum execution time: 91_231 nanoseconds. - Weight::from_parts(94_020_000, 64897) + // Minimum execution time: 91_163 nanoseconds. + Weight::from_parts(100_659_000, 64897) .saturating_add(T::DbWeight::get().reads(13)) .saturating_add(T::DbWeight::get().writes(11)) } @@ -443,8 +449,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Size summary in bytes: // Measured: `1304` // Estimated: `10661` - // Minimum execution time: 22_390 nanoseconds. - Weight::from_parts(23_737_000, 10661) + // Minimum execution time: 23_162 nanoseconds. + Weight::from_parts(32_196_000, 10661) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -464,8 +470,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Size summary in bytes: // Measured: `1986` // Estimated: `27383` - // Minimum execution time: 42_236 nanoseconds. - Weight::from_parts(43_758_000, 27383) + // Minimum execution time: 94_497 nanoseconds. + Weight::from_parts(98_902_000, 27383) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -479,16 +485,18 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Skipped: OrmlNFT Tokens (max_values: None, max_size: None, mode: Measured) // Storage: Estate EstateLeaseOffers (r:1 w:1) // Proof Skipped: Estate EstateLeaseOffers (max_values: None, max_size: None, mode: Measured) + // Storage: System Account (r:1 w:1) + // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) // Storage: Estate EstateLeasors (r:0 w:1) // Proof Skipped: Estate EstateLeasors (max_values: None, max_size: None, mode: Measured) fn accept_lease_offer() -> Weight { // Proof Size summary in bytes: - // Measured: `1713` - // Estimated: `22653` - // Minimum execution time: 38_241 nanoseconds. - Weight::from_parts(39_408_000, 22653) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) + // Measured: `2311` + // Estimated: `28844` + // Minimum execution time: 53_956 nanoseconds. + Weight::from_parts(57_019_000, 28844) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: Estate EstateLeases (r:1 w:1) // Proof Skipped: Estate EstateLeases (max_values: None, max_size: None, mode: Measured) @@ -502,10 +510,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn cancel_lease() -> Weight { // Proof Size summary in bytes: - // Measured: `3681` - // Estimated: `27227` - // Minimum execution time: 57_388 nanoseconds. - Weight::from_parts(61_047_000, 27227) + // Measured: `4017` + // Estimated: `28571` + // Minimum execution time: 55_907 nanoseconds. + Weight::from_parts(57_720_000, 28571) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -521,10 +529,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn remove_expired_lease() -> Weight { // Proof Size summary in bytes: - // Measured: `3681` - // Estimated: `27227` - // Minimum execution time: 55_702 nanoseconds. - Weight::from_parts(57_210_000, 27227) + // Measured: `4017` + // Estimated: `28571` + // Minimum execution time: 56_789 nanoseconds. + Weight::from_parts(57_681_000, 28571) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -534,10 +542,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn remove_lease_offer() -> Weight { // Proof Size summary in bytes: - // Measured: `2998` - // Estimated: `8076` - // Minimum execution time: 31_098 nanoseconds. - Weight::from_parts(32_044_000, 8076) + // Measured: `3250` + // Estimated: `8328` + // Minimum execution time: 33_999 nanoseconds. + Weight::from_parts(41_923_000, 8328) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -553,10 +561,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn collect_rent() -> Weight { // Proof Size summary in bytes: - // Measured: `3681` - // Estimated: `27227` - // Minimum execution time: 51_101 nanoseconds. - Weight::from_parts(52_885_000, 27227) + // Measured: `4017` + // Estimated: `28571` + // Minimum execution time: 51_821 nanoseconds. + Weight::from_parts(53_171_000, 28571) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -564,128 +572,128 @@ impl WeightInfo for SubstrateWeight { // Storage: Es // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 164 nanoseconds. - Weight::from_parts(181_000, 0) + // Minimum execution time: 176 nanoseconds. + Weight::from_parts(191_000, 0) } } // For backwards compatibility and tests impl WeightInfo for () { fn mint_land() -> Weight { - Weight::from_parts(58_455_000, 36660) + Weight::from_parts(59_273_000, 36660) .saturating_add(RocksDbWeight::get().reads(8)) .saturating_add(RocksDbWeight::get().writes(7)) } fn mint_lands() -> Weight { - Weight::from_parts(85_264_000, 41610) + Weight::from_parts(83_541_000, 41610) .saturating_add(RocksDbWeight::get().reads(10)) .saturating_add(RocksDbWeight::get().writes(10)) } fn transfer_land() -> Weight { - Weight::from_parts(98_162_000, 28255) + Weight::from_parts(47_423_000, 28255) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(4)) } fn mint_estate() -> Weight { - Weight::from_parts(70_956_000, 47210) + Weight::from_parts(64_479_000, 47210) .saturating_add(RocksDbWeight::get().reads(10)) .saturating_add(RocksDbWeight::get().writes(11)) } fn dissolve_estate() -> Weight { - Weight::from_parts(90_916_000, 62718) - .saturating_add(RocksDbWeight::get().reads(13)) - .saturating_add(RocksDbWeight::get().writes(12)) + Weight::from_parts(110_008_000, 67224) + .saturating_add(RocksDbWeight::get().reads(14)) + .saturating_add(RocksDbWeight::get().writes(13)) } fn add_land_unit_to_estate() -> Weight { - Weight::from_parts(57_930_000, 31521) - .saturating_add(RocksDbWeight::get().reads(7)) - .saturating_add(RocksDbWeight::get().writes(5)) + Weight::from_parts(71_706_000, 38079) + .saturating_add(RocksDbWeight::get().reads(8)) + .saturating_add(RocksDbWeight::get().writes(6)) } fn remove_land_unit_from_estate() -> Weight { - Weight::from_parts(172_334_000, 55893) - .saturating_add(RocksDbWeight::get().reads(11)) - .saturating_add(RocksDbWeight::get().writes(7)) + Weight::from_parts(90_257_000, 60226) + .saturating_add(RocksDbWeight::get().reads(12)) + .saturating_add(RocksDbWeight::get().writes(8)) } fn create_estate() -> Weight { - Weight::from_parts(123_103_000, 66058) + Weight::from_parts(131_741_000, 66058) .saturating_add(RocksDbWeight::get().reads(14)) .saturating_add(RocksDbWeight::get().writes(17)) } fn transfer_estate() -> Weight { - Weight::from_parts(54_578_000, 38025) + Weight::from_parts(54_808_000, 38025) .saturating_add(RocksDbWeight::get().reads(8)) .saturating_add(RocksDbWeight::get().writes(4)) } fn issue_undeployed_land_blocks() -> Weight { - Weight::from_parts(146_607_000, 4962) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(42)) + Weight::from_parts(162_875_000, 9825) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().writes(43)) } fn freeze_undeployed_land_blocks() -> Weight { - Weight::from_parts(21_200_000, 7834) + Weight::from_parts(22_833_000, 7834) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } fn unfreeze_undeployed_land_blocks() -> Weight { - Weight::from_parts(47_505_000, 7834) + Weight::from_parts(21_423_000, 7834) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } fn approve_undeployed_land_blocks() -> Weight { - Weight::from_parts(21_983_000, 7834) + Weight::from_parts(21_819_000, 7834) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } fn unapprove_undeployed_land_blocks() -> Weight { - Weight::from_parts(20_803_000, 7900) + Weight::from_parts(21_237_000, 7900) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } fn transfer_undeployed_land_blocks() -> Weight { - Weight::from_parts(24_091_000, 9276) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(3)) + Weight::from_parts(41_173_000, 13673) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().writes(4)) } fn deploy_land_block() -> Weight { - Weight::from_parts(94_020_000, 64897) + Weight::from_parts(100_659_000, 64897) .saturating_add(RocksDbWeight::get().reads(13)) .saturating_add(RocksDbWeight::get().writes(11)) } fn burn_undeployed_land_blocks() -> Weight { - Weight::from_parts(23_737_000, 10661) + Weight::from_parts(32_196_000, 10661) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(3)) } fn create_lease_offer() -> Weight { - Weight::from_parts(43_758_000, 27383) + Weight::from_parts(98_902_000, 27383) .saturating_add(RocksDbWeight::get().reads(7)) .saturating_add(RocksDbWeight::get().writes(2)) } fn accept_lease_offer() -> Weight { - Weight::from_parts(39_408_000, 22653) - .saturating_add(RocksDbWeight::get().reads(5)) - .saturating_add(RocksDbWeight::get().writes(4)) + Weight::from_parts(57_019_000, 28844) + .saturating_add(RocksDbWeight::get().reads(6)) + .saturating_add(RocksDbWeight::get().writes(5)) } fn cancel_lease() -> Weight { - Weight::from_parts(61_047_000, 27227) + Weight::from_parts(57_720_000, 28571) .saturating_add(RocksDbWeight::get().reads(5)) .saturating_add(RocksDbWeight::get().writes(4)) } fn remove_expired_lease() -> Weight { - Weight::from_parts(57_210_000, 27227) + Weight::from_parts(57_681_000, 28571) .saturating_add(RocksDbWeight::get().reads(5)) .saturating_add(RocksDbWeight::get().writes(4)) } fn remove_lease_offer() -> Weight { - Weight::from_parts(32_044_000, 8076) + Weight::from_parts(41_923_000, 8328) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(2)) } fn collect_rent() -> Weight { - Weight::from_parts(52_885_000, 27227) + Weight::from_parts(53_171_000, 28571) .saturating_add(RocksDbWeight::get().reads(5)) .saturating_add(RocksDbWeight::get().writes(2)) } fn on_initialize() -> Weight { - Weight::from_parts(181_000, 0) + Weight::from_parts(191_000, 0) } } diff --git a/pallets/evm-mapping/src/benchmarking.rs b/pallets/evm-mapping/src/benchmarking.rs index dce2d2596..ed7b42160 100644 --- a/pallets/evm-mapping/src/benchmarking.rs +++ b/pallets/evm-mapping/src/benchmarking.rs @@ -26,7 +26,7 @@ fn dollar(d: u32) -> Balance { fn funded_account(name: &'static str, index: u32) -> T::AccountId { let caller: T::AccountId = account(name, index, SEED); - T::Currency::deposit_into_existing(&caller, dollar(100).unique_saturated_into()); + T::Currency::make_free_balance_be(&caller, dollar(30000).unique_saturated_into()); caller } @@ -54,6 +54,7 @@ fn funded_bob() -> T::AccountId { */ benchmarks! { + claim_eth_account { let caller = funded_account::("caller", 0); let eth = funded_account::("eth", 1); diff --git a/pallets/evm-mapping/src/lib.rs b/pallets/evm-mapping/src/lib.rs index 0ade16c97..755008ff9 100644 --- a/pallets/evm-mapping/src/lib.rs +++ b/pallets/evm-mapping/src/lib.rs @@ -31,25 +31,25 @@ use codec::Encode; use frame_support::{ ensure, pallet_prelude::*, - traits::{Currency, IsType, OnKilledAccount}, + traits::{Currency, ExistenceRequirement, IsType, OnKilledAccount}, transactional, }; use frame_system::{ensure_signed, pallet_prelude::*}; use orml_traits::currency::TransferAll; +pub use pallet::*; +use primitives::{AccountIndex, EvmAddress}; use sp_core::crypto::AccountId32; use sp_core::{H160, H256}; use sp_io::{ crypto::secp256k1_ecdsa_recover, hashing::{blake2_256, keccak_256}, }; +use sp_runtime::traits::Saturating; use sp_runtime::{ - traits::{LookupError, StaticLookup, Zero}, + traits::{LookupError, StaticLookup}, MultiAddress, }; use sp_std::{marker::PhantomData, vec::Vec}; - -pub use pallet::*; -use primitives::{AccountIndex, EvmAddress}; pub use weights::WeightInfo; #[cfg(feature = "runtime-benchmarks")] @@ -108,6 +108,9 @@ pub trait AddressMapping { pub mod pallet { use super::*; + pub(crate) type BalanceOf = + <::Currency as Currency<::AccountId>>::Balance; + #[pallet::config] pub trait Config: frame_system::Config { type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -122,9 +125,17 @@ pub mod pallet { #[pallet::constant] type ChainId: Get; + /// The network treasury account + #[pallet::constant] + type NetworkTreasuryAccount: Get; + /// Merge free balance from source to dest. type TransferAll: TransferAll; + /// Storage deposit free charged when saving data into the blockchain. + #[pallet::constant] + type StorageDepositFee: Get>; + /// Weight implementation for evm mapping extrinsics type WeightInfo: WeightInfo; } @@ -210,6 +221,14 @@ pub mod pallet { T::TransferAll::transfer_all(&account_id, &who)?; } + // Transfer storage deposit fee + ::Currency::transfer( + &who, + &T::NetworkTreasuryAccount::get(), + T::StorageDepositFee::get(), + ExistenceRequirement::KeepAlive, + )?; + Accounts::::insert(eth_address, &who); EvmAddresses::::insert(&who, eth_address); @@ -225,12 +244,21 @@ pub mod pallet { /// address based off of those accounts. /// Ensure eth_address has not been mapped #[pallet::weight(T::WeightInfo::claim_default_account())] + #[transactional] pub fn claim_default_account(origin: OriginFor) -> DispatchResult { let who = ensure_signed(origin)?; // ensure account_id has not been mapped ensure!(!EvmAddresses::::contains_key(&who), Error::::AccountIdHasMapped); + // Transfer storage deposit fee + ::Currency::transfer( + &who, + &T::NetworkTreasuryAccount::get(), + T::StorageDepositFee::get(), + ExistenceRequirement::KeepAlive, + )?; + let eth_address = T::AddressMapping::get_or_create_evm_address(&who); Self::deposit_event(Event::ClaimAccount { diff --git a/pallets/evm-mapping/src/mock.rs b/pallets/evm-mapping/src/mock.rs index 08c5311b7..c64efe71a 100644 --- a/pallets/evm-mapping/src/mock.rs +++ b/pallets/evm-mapping/src/mock.rs @@ -30,7 +30,7 @@ use scale_info::TypeInfo; use sp_core::H256; use sp_runtime::{ testing::Header, - traits::{BlakeTwo256, Hash, IdentityLookup}, + traits::{AccountIdConversion, BlakeTwo256, Hash, IdentityLookup}, }; use primitives::{Amount, Balance, FungibleTokenId}; @@ -118,6 +118,9 @@ impl orml_tokens::Config for Runtime { parameter_types! { pub const GetNativeCurrencyId: FungibleTokenId = FungibleTokenId::NativeToken(0); + pub StorageDepositFee: Balance = 1; + pub const MetaverseTreasuryPalletId: PalletId = PalletId(*b"bit/trsy"); + pub TreasuryModuleAccount: AccountId = MetaverseTreasuryPalletId::get().into_account_truncating(); } impl orml_currencies::Config for Runtime { @@ -138,6 +141,8 @@ impl Config for Runtime { type ChainId = (); type AddressMapping = EvmAddressMapping; type TransferAll = Currencies; + type NetworkTreasuryAccount = TreasuryModuleAccount; + type StorageDepositFee = StorageDepositFee; type WeightInfo = (); } @@ -198,7 +203,7 @@ impl ExtBuilder { .unwrap(); pallet_balances::GenesisConfig:: { - balances: vec![(bob_account_id(), 100000)], + balances: vec![(bob_account_id(), 100000), (ALICE, 10000)], } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/evm-mapping/src/weights.rs b/pallets/evm-mapping/src/weights.rs index 88dcd7d22..989b85523 100644 --- a/pallets/evm-mapping/src/weights.rs +++ b/pallets/evm-mapping/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for evm_mapping //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-06-21, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-07-13, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 // Executed Command: @@ -55,41 +55,43 @@ impl WeightInfo for SubstrateWeight { // Storage: Ev // Proof: EvmMapping EvmAddresses (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) // Storage: EvmMapping Accounts (r:1 w:1) // Proof: EvmMapping Accounts (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) - // Storage: System Account (r:1 w:0) + // Storage: System Account (r:3 w:2) // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn claim_eth_account() -> Weight { // Proof Size summary in bytes: - // Measured: `128` - // Estimated: `7673` - // Minimum execution time: 38_594 nanoseconds. - Weight::from_parts(39_571_000, 7673) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(2)) + // Measured: `344` + // Estimated: `12879` + // Minimum execution time: 52_107 nanoseconds. + Weight::from_parts(53_285_000, 12879) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) } // Storage: EvmMapping EvmAddresses (r:1 w:1) // Proof: EvmMapping EvmAddresses (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + // Storage: System Account (r:2 w:2) + // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) // Storage: EvmMapping Accounts (r:0 w:1) // Proof: EvmMapping Accounts (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) fn claim_default_account() -> Weight { // Proof Size summary in bytes: - // Measured: `76` - // Estimated: `2535` - // Minimum execution time: 10_351 nanoseconds. - Weight::from_parts(10_980_000, 2535) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(2)) + // Measured: `344` + // Estimated: `7741` + // Minimum execution time: 23_927 nanoseconds. + Weight::from_parts(24_582_000, 7741) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(4)) } } // For backwards compatibility and tests impl WeightInfo for () { fn claim_eth_account() -> Weight { - Weight::from_parts(39_571_000, 7673) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(2)) + Weight::from_parts(53_285_000, 12879) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(4)) } fn claim_default_account() -> Weight { - Weight::from_parts(10_980_000, 2535) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(2)) + Weight::from_parts(24_582_000, 7741) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().writes(4)) } } diff --git a/pallets/governance/src/lib.rs b/pallets/governance/src/lib.rs index 8cf64fa80..0f748ebf7 100644 --- a/pallets/governance/src/lib.rs +++ b/pallets/governance/src/lib.rs @@ -28,11 +28,12 @@ use frame_support::{ pallet_prelude::*, traits::{ schedule::{DispatchTime, Named as ScheduleNamed}, - Currency, Get, InstanceFilter, LockIdentifier, LockableCurrency, OnUnbalanced, ReservableCurrency, - WithdrawReasons, + Currency, ExistenceRequirement, Get, InstanceFilter, LockIdentifier, LockableCurrency, OnUnbalanced, + ReservableCurrency, WithdrawReasons, }, }; use sp_runtime::traits::{Dispatchable, Hash, Saturating, Zero}; +use sp_runtime::{Perbill, SaturatedConversion}; use sp_std::prelude::*; use metaverse_primitive::MetaverseTrait; @@ -129,6 +130,15 @@ pub mod pallet { /// Metaverse Council which collective of members type MetaverseCouncil: EnsureOrigin; + + /// Storage deposit free charged when saving data into the blockchain. + /// The fee will be unreserved after the storage is freed. + #[pallet::constant] + type StorageDepositFee: Get>; + + /// Network treasury account + #[pallet::constant] + type NetworkTreasury: Get; } #[pallet::pallet] @@ -333,6 +343,12 @@ pub mod pallet { Error::::AccountIsNotMetaverseOwner ); >::remove(metaverse_id); + T::Currency::transfer( + &from, + &T::NetworkTreasury::get(), + T::StorageDepositFee::get(), + ExistenceRequirement::KeepAlive, + )?; >::insert(metaverse_id, new_referendum_parameters); Self::deposit_event(Event::ReferendumParametersUpdated(metaverse_id)); Ok(().into()) @@ -421,6 +437,17 @@ pub mod pallet { }; let proposal_id = Self::get_next_proposal_id()?; + + // 2 storage inserts + let storage_fee: BalanceOf = + Perbill::from_percent(2u32.saturating_mul(100)) * T::StorageDepositFee::get(); + + T::Currency::transfer( + &from, + &T::NetworkTreasury::get(), + storage_fee.saturated_into(), + ExistenceRequirement::KeepAlive, + )?; >::insert(metaverse_id, proposal_id, proposal_info); Self::update_proposals_per_metaverse_number(metaverse_id, true); @@ -521,6 +548,14 @@ pub mod pallet { let current_block_number = >::block_number(); proposal_info.referendum_launch_block = current_block_number + T::OneBlock::get(); + + T::Currency::transfer( + &proposal_info.proposed_by, + &T::NetworkTreasury::get(), + T::StorageDepositFee::get(), + ExistenceRequirement::KeepAlive, + )?; + >::remove(metaverse_id, proposal); >::insert(metaverse_id, proposal, proposal_info); Self::deposit_event(Event::ProposalFastTracked(metaverse_id, proposal)); @@ -626,6 +661,12 @@ pub mod pallet { match info { Some(ReferendumInfo::Ongoing(mut status)) => { status.tally.remove(vote).ok_or(Error::::TallyOverflow)?; + T::Currency::transfer( + &from, + &T::NetworkTreasury::get(), + T::StorageDepositFee::get(), + ExistenceRequirement::KeepAlive, + )?; ReferendumInfoOf::::insert(&metaverse, &referendum, ReferendumInfo::Ongoing(status)); Self::deposit_event(Event::VoteRemoved(from, referendum)); } diff --git a/pallets/governance/src/mock.rs b/pallets/governance/src/mock.rs index 705ba163f..85d0294b0 100644 --- a/pallets/governance/src/mock.rs +++ b/pallets/governance/src/mock.rs @@ -455,12 +455,14 @@ parameter_types! { pub const MaxTokenMetadata: u32 = 1024; pub const MinContribution: Balance = 1; pub const MaxNumberOfStakersPerMetaverse: u32 = 512; + pub StorageDepositFee: Balance = 1; } impl pallet_metaverse::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; type MultiCurrency = Currencies; + type NetworkTreasury = TreasuryModuleAccount; type MetaverseTreasury = MetaverseFundPalletId; type MaxMetaverseMetadata = MaxTokenMetadata; type MinContribution = MinContribution; @@ -470,6 +472,7 @@ impl pallet_metaverse::Config for Runtime { type MaxNumberOfStakersPerMetaverse = MaxNumberOfStakersPerMetaverse; type WeightInfo = (); type NFTHandler = MockNFTHandler; + type StorageDepositFee = StorageDepositFee; } #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen, TypeInfo)] @@ -515,6 +518,8 @@ impl Config for Runtime { type MetaverseLandInfo = MetaverseLandInfo; type MetaverseCouncil = EnsureSignedBy; type ProposalType = ProposalType; + type StorageDepositFee = StorageDepositFee; + type NetworkTreasury = TreasuryModuleAccount; } parameter_type_with_key! { diff --git a/pallets/governance/src/tests.rs b/pallets/governance/src/tests.rs index dc340de33..6433a6905 100644 --- a/pallets/governance/src/tests.rs +++ b/pallets/governance/src/tests.rs @@ -500,7 +500,7 @@ fn emergency_cancel_referendum_work() { BOB_COUNTRY_ID, 0 )); - assert_eq!(Balances::free_balance(&ALICE), 100000); + assert_eq!(Balances::free_balance(&ALICE), 99999); assert_eq!( last_event(), RuntimeEvent::Governance(crate::Event::ReferendumCancelled(0)) @@ -555,6 +555,7 @@ fn referendum_proposal_passes() { hash.clone(), PROPOSAL_DESCRIPTION.to_vec() )); + //assert_eq!(Balances::free_balance(&BOB), 498); run_to_block(16); assert_ok!(GovernanceModule::try_vote( RuntimeOrigin::signed(BOB), @@ -563,7 +564,7 @@ fn referendum_proposal_passes() { VOTE_FOR )); run_to_block(117); - assert_eq!(Balances::free_balance(&ALICE), 100000); + assert_eq!(Balances::free_balance(&ALICE), 99999); assert_eq!( GovernanceModule::referendum_info(BOB_COUNTRY_ID, 0), Some(ReferendumInfo::Finished { @@ -600,7 +601,7 @@ fn referendum_proposal_is_rejected() { VOTE_AGAINST )); run_to_block(117); - assert_eq!(Balances::free_balance(&ALICE), 100000); + assert_eq!(Balances::free_balance(&ALICE), 99999); assert_eq!( GovernanceModule::referendum_info(BOB_COUNTRY_ID, 0), Some(ReferendumInfo::Finished { @@ -694,7 +695,7 @@ fn unlocking_balance_after_removing_vote_works() { BOB_COUNTRY_ID )); assert_ok!(GovernanceModule::unlock_balance(RuntimeOrigin::signed(BOB), BOB)); - assert_eq!(Balances::usable_balance(&BOB), 500); + assert_eq!(Balances::usable_balance(&BOB), 499); }); } @@ -726,7 +727,7 @@ fn unlocking_balance_after_referendum_is_over_works() { BOB_COUNTRY_ID )); assert_ok!(GovernanceModule::unlock_balance(RuntimeOrigin::signed(BOB), BOB)); - assert_eq!(Balances::usable_balance(&BOB), 500); + assert_eq!(Balances::usable_balance(&BOB), 499); }); } diff --git a/pallets/metaverse/src/lib.rs b/pallets/metaverse/src/lib.rs index d0db50fa9..68bca1bce 100644 --- a/pallets/metaverse/src/lib.rs +++ b/pallets/metaverse/src/lib.rs @@ -108,6 +108,9 @@ pub mod pallet { CurrencyId = FungibleTokenId, Balance = BalanceOf, >; + /// The network treasury account + #[pallet::constant] + type NetworkTreasury: Get; /// The metaverse treasury pallet #[pallet::constant] type MetaverseTreasury: Get; @@ -129,6 +132,10 @@ pub mod pallet { type WeightInfo: WeightInfo; /// NFT handler required for minting classes for lands and estates when creating a metaverse type NFTHandler: NFTTrait, ClassId = ClassId, TokenId = TokenId>; + /// Storage deposit free charged when saving data into the blockchain. + /// The fee will be unreserved after the storage is freed. + #[pallet::constant] + type StorageDepositFee: Get>; } #[pallet::storage] @@ -292,6 +299,13 @@ pub mod pallet { metaverse_id: MetaverseId, ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; + + T::Currency::transfer( + &who.clone(), + &T::NetworkTreasury::get(), + T::StorageDepositFee::get(), + ExistenceRequirement::KeepAlive, + )?; // Get owner of the metaverse MetaverseOwner::::try_mutate_exists( &who, @@ -480,7 +494,7 @@ impl Pallet { ); ensure!( - T::Currency::free_balance(who) >= T::MinContribution::get(), + T::Currency::free_balance(who) >= T::MinContribution::get() + T::StorageDepositFee::get(), Error::::InsufficientContribution ); @@ -490,6 +504,14 @@ impl Pallet { T::MinContribution::get(), ExistenceRequirement::KeepAlive, )?; + + T::Currency::transfer( + who, + &T::NetworkTreasury::get(), + T::StorageDepositFee::get(), + ExistenceRequirement::KeepAlive, + )?; + let metaverse_id = Self::new_metaverse(&who, metadata)?; MetaverseOwner::::insert(who.clone(), metaverse_id, ()); diff --git a/pallets/metaverse/src/mock.rs b/pallets/metaverse/src/mock.rs index 24bf6151f..5b12d9bf5 100644 --- a/pallets/metaverse/src/mock.rs +++ b/pallets/metaverse/src/mock.rs @@ -92,6 +92,8 @@ parameter_types! { pub const MinContribution: Balance = 1; pub const MinStakingAmount: Balance = 100; pub const MaxNumberOfStakersPerMetaverse: u32 = 1; + pub StorageDepositFee: Balance = 1; + } fn test_attributes(x: u8) -> Attributes { @@ -318,6 +320,7 @@ impl Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; type MultiCurrency = Currencies; + type NetworkTreasury = TreasuryModuleAccount; type MetaverseTreasury = MetaverseFundPalletId; type MaxMetaverseMetadata = MaxTokenMetadata; type MinContribution = MinContribution; @@ -327,6 +330,7 @@ impl Config for Runtime { type MaxNumberOfStakersPerMetaverse = MaxNumberOfStakersPerMetaverse; type WeightInfo = (); type NFTHandler = MockNFTHandler; + type StorageDepositFee = StorageDepositFee; } parameter_type_with_key! { diff --git a/pallets/metaverse/src/tests.rs b/pallets/metaverse/src/tests.rs index 3481869bd..39ba4822c 100644 --- a/pallets/metaverse/src/tests.rs +++ b/pallets/metaverse/src/tests.rs @@ -265,13 +265,13 @@ fn do_withdraw_from_metaverse_fund_should_work() { metaverse_fund, 100 )); - assert_eq!(free_native_balance(ALICE), 9999999999999999899); + assert_eq!(free_native_balance(ALICE), 9999999999999999898); assert_eq!(free_native_balance(metaverse_fund), 101); assert_ok!(MetaverseModule::withdraw_from_metaverse_fund( origin.clone(), METAVERSE_ID )); - assert_eq!(free_native_balance(ALICE), 9999999999999999999); + assert_eq!(free_native_balance(ALICE), 9999999999999999998); assert_eq!(free_native_balance(metaverse_fund), 1); }) } diff --git a/pallets/metaverse/src/weights.rs b/pallets/metaverse/src/weights.rs index 6d9972e51..d66593ea7 100644 --- a/pallets/metaverse/src/weights.rs +++ b/pallets/metaverse/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for metaverse //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-06-21, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-07-17, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 // Executed Command: @@ -73,23 +73,25 @@ impl WeightInfo for SubstrateWeight { // Storage: Sy // Proof Size summary in bytes: // Measured: `1949` // Estimated: `27361` - // Minimum execution time: 71_106 nanoseconds. - Weight::from_parts(73_237_000, 27361) + // Minimum execution time: 141_186 nanoseconds. + Weight::from_parts(144_874_000, 27361) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(12)) } + // Storage: System Account (r:2 w:2) + // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) // Storage: Metaverse MetaverseOwner (r:1 w:2) // Proof Skipped: Metaverse MetaverseOwner (max_values: None, max_size: None, mode: Measured) // Storage: Metaverse Metaverses (r:1 w:1) // Proof Skipped: Metaverse Metaverses (max_values: None, max_size: None, mode: Measured) fn transfer_metaverse() -> Weight { // Proof Size summary in bytes: - // Measured: `1292` - // Estimated: `7534` - // Minimum execution time: 20_624 nanoseconds. - Weight::from_parts(21_461_000, 7534) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(3)) + // Measured: `1852` + // Estimated: `13860` + // Minimum execution time: 51_299 nanoseconds. + Weight::from_parts(53_412_000, 13860) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: Metaverse Metaverses (r:1 w:1) // Proof Skipped: Metaverse Metaverses (max_values: None, max_size: None, mode: Measured) @@ -97,8 +99,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Sy // Proof Size summary in bytes: // Measured: `1247` // Estimated: `3722` - // Minimum execution time: 15_936 nanoseconds. - Weight::from_parts(18_064_000, 3722) + // Minimum execution time: 25_115 nanoseconds. + Weight::from_parts(26_870_000, 3722) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -108,8 +110,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Sy // Proof Size summary in bytes: // Measured: `1247` // Estimated: `3722` - // Minimum execution time: 16_087 nanoseconds. - Weight::from_parts(16_778_000, 3722) + // Minimum execution time: 25_233 nanoseconds. + Weight::from_parts(27_836_000, 3722) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -121,8 +123,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Sy // Proof Size summary in bytes: // Measured: `1247` // Estimated: `4969` - // Minimum execution time: 17_612 nanoseconds. - Weight::from_parts(18_411_000, 4969) + // Minimum execution time: 27_011 nanoseconds. + Weight::from_parts(28_903_000, 4969) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -134,8 +136,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Sy // Proof Size summary in bytes: // Measured: `1292` // Estimated: `7534` - // Minimum execution time: 18_846 nanoseconds. - Weight::from_parts(19_747_000, 7534) + // Minimum execution time: 28_885 nanoseconds. + Weight::from_parts(30_034_000, 7534) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -147,8 +149,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Sy // Proof Size summary in bytes: // Measured: `1763` // Estimated: `9444` - // Minimum execution time: 32_361 nanoseconds. - Weight::from_parts(34_242_000, 9444) + // Minimum execution time: 46_756 nanoseconds. + Weight::from_parts(47_894_000, 9444) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -156,37 +158,37 @@ impl WeightInfo for SubstrateWeight { // Storage: Sy // For backwards compatibility and tests impl WeightInfo for () { fn create_metaverse() -> Weight { - Weight::from_parts(73_237_000, 27361) + Weight::from_parts(144_874_000, 27361) .saturating_add(RocksDbWeight::get().reads(7)) .saturating_add(RocksDbWeight::get().writes(12)) } fn transfer_metaverse() -> Weight { - Weight::from_parts(21_461_000, 7534) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(3)) + Weight::from_parts(53_412_000, 13860) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(5)) } fn freeze_metaverse() -> Weight { - Weight::from_parts(18_064_000, 3722) + Weight::from_parts(26_870_000, 3722) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(1)) } fn unfreeze_metaverse() -> Weight { - Weight::from_parts(16_778_000, 3722) + Weight::from_parts(27_836_000, 3722) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(1)) } fn destroy_metaverse() -> Weight { - Weight::from_parts(18_411_000, 4969) + Weight::from_parts(28_903_000, 4969) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(2)) } fn update_metaverse_listing_fee() -> Weight { - Weight::from_parts(19_747_000, 7534) + Weight::from_parts(30_034_000, 7534) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } fn withdraw_from_metaverse_fund() -> Weight { - Weight::from_parts(34_242_000, 9444) + Weight::from_parts(47_894_000, 9444) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(2)) } diff --git a/pallets/mining/src/benchmarking.rs b/pallets/mining/src/benchmarking.rs index 8005f3cca..957927ed9 100644 --- a/pallets/mining/src/benchmarking.rs +++ b/pallets/mining/src/benchmarking.rs @@ -46,7 +46,7 @@ const MINING_RESOURCE_RATE_INFO: MiningResourceRateInfo = MiningResourceRateInfo mining_reward: Perbill::from_percent(70u32), }; -fn dollar(d: u32) -> Balance { +fn dollar(d: u64) -> Balance { let d: Balance = d.into(); d.saturating_mul(10) } @@ -55,6 +55,8 @@ fn funded_account(name: &'static str, index: u32) -> T::AccountId { let caller: T::AccountId = account(name, index, SEED); let initial_balance = dollar(100); + T::Currency::make_free_balance_be(&caller, dollar(3_000_000_000_000_000_000).unique_saturated_into()); + T::MiningCurrency::update_balance( FungibleTokenId::MiningResource(0), &caller, @@ -66,7 +68,7 @@ fn funded_account(name: &'static str, index: u32) -> T::AccountId { benchmarks! { // add minting origin add_minting_origin { - let who: T::AccountId = account("target", 0, SEED); + let who: T::AccountId = funded_account::("target", 0); }: _(RawOrigin::Root, who.clone()) verify { assert_eq!(crate::Pallet::::ensure_admin(RawOrigin::Root.into()), Ok(())); @@ -75,7 +77,7 @@ benchmarks! { // remove minting origin remove_minting_origin { - let who: T::AccountId = account("target", 0, SEED); + let who: T::AccountId = funded_account::("target", 0); crate::Pallet::::add_minting_origin(RawOrigin::Root.into(), who.clone()); }: _(RawOrigin::Root, who.clone()) diff --git a/pallets/mining/src/lib.rs b/pallets/mining/src/lib.rs index faa31ff62..1d1b34f55 100644 --- a/pallets/mining/src/lib.rs +++ b/pallets/mining/src/lib.rs @@ -25,6 +25,7 @@ use frame_support::{ dispatch::{DispatchResult, DispatchResultWithPostInfo}, ensure, pallet_prelude::*, + traits::ExistenceRequirement, transactional, Parameter, }; use frame_system::pallet_prelude::*; @@ -108,6 +109,9 @@ pub mod pallet { Balance, ); + pub(crate) type BalanceOf = + <::Currency as Currency<::AccountId>>::Balance; + #[pallet::config] pub trait Config: frame_system::Config { type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -121,6 +125,19 @@ pub mod pallet { type MetaverseStakingHandler: MetaverseStakingTrait; // Mining staking reward for treasury type TreasuryStakingReward: Get; + + /// The network treasury account + #[pallet::constant] + type NetworkTreasuryAccount: Get; + + /// Storage deposit free charged when saving data into the blockchain. + /// The fee will be unreserved after the storage is freed. + #[pallet::constant] + type StorageDepositFee: Get>; + + /// The Currency for managing storage deposits. + type Currency: Currency; + // Weight implementation for mining extrinsics type WeightInfo: WeightInfo; } @@ -448,7 +465,13 @@ impl Pallet { fn do_add_minting_origin(who: T::AccountId) -> DispatchResult { ensure!(!Self::is_mining_origin(&who), Error::::OriginsAlreadyExist); - + // Transfer storage deposit fee + ::Currency::transfer( + &who, + &T::NetworkTreasuryAccount::get(), + T::StorageDepositFee::get(), + ExistenceRequirement::KeepAlive, + )?; MintingOrigins::::insert(who.clone(), ()); Self::deposit_event(Event::AddNewMiningOrigin(who)); Ok(()) @@ -456,6 +479,13 @@ impl Pallet { fn do_remove_minting_origin(who: T::AccountId) -> DispatchResult { ensure!(Self::is_mining_origin(&who), Error::::OriginsIsNotExist); + // Transfer back storage deposit fee + ::Currency::transfer( + &T::NetworkTreasuryAccount::get(), + &who, + T::StorageDepositFee::get(), + ExistenceRequirement::KeepAlive, + )?; MintingOrigins::::remove(who.clone()); Self::deposit_event(Event::RemoveMiningOrigin(who)); diff --git a/pallets/mining/src/mock.rs b/pallets/mining/src/mock.rs index 9d48c8af7..cac0f11ba 100644 --- a/pallets/mining/src/mock.rs +++ b/pallets/mining/src/mock.rs @@ -203,6 +203,7 @@ impl MetaverseStakingTrait for MetaverseStakingHandler { parameter_types! { pub const TreasuryStakingReward: Perbill = Perbill::from_percent(1); + pub StorageDepositFee: Balance = 1; } impl Config for Runtime { @@ -215,6 +216,9 @@ impl Config for Runtime { type MetaverseStakingHandler = MetaverseStakingHandler; type TreasuryStakingReward = TreasuryStakingReward; type WeightInfo = (); + type NetworkTreasuryAccount = TreasuryModuleAccount; + type StorageDepositFee = StorageDepositFee; + type Currency = Balances; } type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -249,7 +253,7 @@ impl ExtBuilder { .unwrap(); pallet_balances::GenesisConfig:: { - balances: vec![(ALICE, 100000)], + balances: vec![(ALICE, 100000), (BOB, 1000), (TreasuryModuleAccount::get(), 100)], } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/mining/src/tests.rs b/pallets/mining/src/tests.rs index c0e33cdfc..52586b8ef 100644 --- a/pallets/mining/src/tests.rs +++ b/pallets/mining/src/tests.rs @@ -185,3 +185,13 @@ fn update_mining_config_should_work() { assert_eq!(last_event(), event); }); } + +#[test] +fn adding_and_removing_mining_origin_should_work() { + ExtBuilder::default().build().execute_with(|| { + assert_ok!(MiningModule::add_minting_origin(RuntimeOrigin::signed(ALICE), BOB)); + assert_eq!(Balances::free_balance(BOB), 999); + assert_ok!(MiningModule::remove_minting_origin(RuntimeOrigin::signed(ALICE), BOB)); + assert_eq!(Balances::free_balance(BOB), 1000); + }); +} diff --git a/pallets/mining/src/weights.rs b/pallets/mining/src/weights.rs index c6afce52f..746f2bcd9 100644 --- a/pallets/mining/src/weights.rs +++ b/pallets/mining/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for mining //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-06-21, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-07-19, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 // Executed Command: @@ -53,25 +53,29 @@ pub trait WeightInfo { fn add_minting_origin() -> Weight; fn remove_minting_orig pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: Mining MintingOrigins (r:1 w:1) // Proof Skipped: Mining MintingOrigins (max_values: None, max_size: None, mode: Measured) + // Storage: System Account (r:2 w:2) + // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn add_minting_origin() -> Weight { // Proof Size summary in bytes: - // Measured: `76` - // Estimated: `2551` - // Minimum execution time: 8_213 nanoseconds. - Weight::from_parts(8_665_000, 2551) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Measured: `346` + // Estimated: `8027` + // Minimum execution time: 22_048 nanoseconds. + Weight::from_parts(47_273_000, 8027) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Mining MintingOrigins (r:1 w:1) // Proof Skipped: Mining MintingOrigins (max_values: None, max_size: None, mode: Measured) + // Storage: System Account (r:2 w:2) + // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn remove_minting_origin() -> Weight { // Proof Size summary in bytes: - // Measured: `150` - // Estimated: `2625` - // Minimum execution time: 9_209 nanoseconds. - Weight::from_parts(9_396_000, 2625) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Measured: `420` + // Estimated: `8101` + // Minimum execution time: 22_042 nanoseconds. + Weight::from_parts(22_628_000, 8101) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Mining Round (r:1 w:1) // Proof Skipped: Mining Round (max_values: Some(1), max_size: None, mode: Measured) @@ -79,8 +83,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Mi // Proof Size summary in bytes: // Measured: `76` // Estimated: `571` - // Minimum execution time: 6_876 nanoseconds. - Weight::from_parts(7_040_000, 571) + // Minimum execution time: 6_888 nanoseconds. + Weight::from_parts(7_119_000, 571) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -92,8 +96,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Mi // Proof Size summary in bytes: // Measured: `76` // Estimated: `647` - // Minimum execution time: 7_741 nanoseconds. - Weight::from_parts(8_115_000, 647) + // Minimum execution time: 7_511 nanoseconds. + Weight::from_parts(7_988_000, 647) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -107,8 +111,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Mi // Proof Size summary in bytes: // Measured: `456` // Estimated: `8043` - // Minimum execution time: 22_058 nanoseconds. - Weight::from_parts(22_826_000, 8043) + // Minimum execution time: 22_754 nanoseconds. + Weight::from_parts(23_623_000, 8043) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -122,8 +126,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Mi // Proof Size summary in bytes: // Measured: `456` // Estimated: `8043` - // Minimum execution time: 23_789 nanoseconds. - Weight::from_parts(24_969_000, 8043) + // Minimum execution time: 24_375 nanoseconds. + Weight::from_parts(24_990_000, 8043) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -135,8 +139,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Mi // Proof Size summary in bytes: // Measured: `420` // Estimated: `10398` - // Minimum execution time: 31_285 nanoseconds. - Weight::from_parts(31_798_000, 10398) + // Minimum execution time: 31_925 nanoseconds. + Weight::from_parts(32_866_000, 10398) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -150,8 +154,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Mi // Proof Size summary in bytes: // Measured: `727` // Estimated: `10997` - // Minimum execution time: 29_256 nanoseconds. - Weight::from_parts(29_933_000, 10997) + // Minimum execution time: 29_949 nanoseconds. + Weight::from_parts(31_275_000, 10997) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -163,8 +167,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Mi // Proof Size summary in bytes: // Measured: `76` // Estimated: `1142` - // Minimum execution time: 7_702 nanoseconds. - Weight::from_parts(8_074_000, 1142) + // Minimum execution time: 19_835 nanoseconds. + Weight::from_parts(20_520_000, 1142) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -176,8 +180,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Mi // Proof Size summary in bytes: // Measured: `100` // Estimated: `1190` - // Minimum execution time: 8_295 nanoseconds. - Weight::from_parts(8_775_000, 1190) + // Minimum execution time: 22_017 nanoseconds. + Weight::from_parts(22_937_000, 1190) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -185,52 +189,52 @@ impl WeightInfo for SubstrateWeight { // Storage: Mi // For backwards compatibility and tests impl WeightInfo for () { fn add_minting_origin() -> Weight { - Weight::from_parts(8_665_000, 2551) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) + Weight::from_parts(47_273_000, 8027) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().writes(3)) } fn remove_minting_origin() -> Weight { - Weight::from_parts(9_396_000, 2625) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) + Weight::from_parts(22_628_000, 8101) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().writes(3)) } fn update_round_length() -> Weight { - Weight::from_parts(7_040_000, 571) + Weight::from_parts(7_119_000, 571) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(1)) } fn update_mining_issuance_config() -> Weight { - Weight::from_parts(8_115_000, 647) + Weight::from_parts(7_988_000, 647) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(1)) } fn mint() -> Weight { - Weight::from_parts(22_826_000, 8043) + Weight::from_parts(23_623_000, 8043) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(2)) } fn burn() -> Weight { - Weight::from_parts(24_969_000, 8043) + Weight::from_parts(24_990_000, 8043) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(2)) } fn deposit() -> Weight { - Weight::from_parts(31_798_000, 10398) + Weight::from_parts(32_866_000, 10398) .saturating_add(RocksDbWeight::get().reads(4)) .saturating_add(RocksDbWeight::get().writes(3)) } fn withdraw() -> Weight { - Weight::from_parts(29_933_000, 10997) + Weight::from_parts(31_275_000, 10997) .saturating_add(RocksDbWeight::get().reads(4)) .saturating_add(RocksDbWeight::get().writes(2)) } fn pause_mining_round() -> Weight { - Weight::from_parts(8_074_000, 1142) + Weight::from_parts(20_520_000, 1142) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } fn unpause_mining_round() -> Weight { - Weight::from_parts(8_775_000, 1190) + Weight::from_parts(22_937_000, 1190) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } diff --git a/pallets/nft/src/lib.rs b/pallets/nft/src/lib.rs index 7f18dd738..b01dbae01 100644 --- a/pallets/nft/src/lib.rs +++ b/pallets/nft/src/lib.rs @@ -131,6 +131,10 @@ pub mod pallet { /// Fungible token id for promotion incentive #[pallet::constant] type MiningResourceId: Get; + /// Storage deposit free charged when saving data into the blockchain. + /// The fee will be unreserved after the storage is freed. + #[pallet::constant] + type StorageDepositFee: Get>; } pub type ClassIdOf = ::ClassId; @@ -670,6 +674,15 @@ pub mod pallet { ExistenceRequirement::KeepAlive, )?; + let network_treasury = T::Treasury::get().into_account_truncating(); + // Transfer storage deposit fee + ::Currency::transfer( + &sender, + &network_treasury, + T::StorageDepositFee::get().into(), + ExistenceRequirement::KeepAlive, + )?; + if AssetSupporters::::contains_key(&asset_id) { AssetSupporters::::try_mutate(asset_id, |supporters| -> DispatchResult { let supporters = supporters.as_mut().ok_or(Error::::EmptySupporters)?; @@ -1096,9 +1109,11 @@ impl Pallet { last_token_id = token_id; } + let first_token_id = last_token_id.saturating_sub(quantity.into()); + Self::deposit_event(Event::::NewNftMinted( - *new_asset_ids.first().unwrap(), - *new_asset_ids.last().unwrap(), + (class_id, first_token_id), + (class_id, last_token_id), sender.clone(), class_id, quantity, @@ -1159,6 +1174,15 @@ impl Pallet { }; NftModule::::create_class(&sender, metadata, class_data)?; + + let network_treasury = T::Treasury::get().into_account_truncating(); + // Transfer storage deposit fee + ::Currency::transfer( + sender, + &network_treasury, + T::StorageDepositFee::get(), + ExistenceRequirement::KeepAlive, + )?; ClassDataCollection::::insert(next_class_id, collection_id); Self::deposit_event(Event::::NewNftClassCreated(sender.clone(), next_class_id)); diff --git a/pallets/nft/src/mock.rs b/pallets/nft/src/mock.rs index 436a7e48a..d98b5bb3f 100644 --- a/pallets/nft/src/mock.rs +++ b/pallets/nft/src/mock.rs @@ -234,6 +234,7 @@ parameter_types! { pub AssetMintingFee: Balance = 1; pub ClassMintingFee: Balance = 2; pub const MetaverseNetworkTreasuryPalletId: PalletId = PalletId(*b"bit/trsy"); + pub StorageDepositFee: Balance = 1; } impl Config for Runtime { @@ -250,6 +251,7 @@ impl Config for Runtime { type MiningResourceId = MiningCurrencyId; type AssetMintingFee = AssetMintingFee; type ClassMintingFee = ClassMintingFee; + type StorageDepositFee = StorageDepositFee; } parameter_types! { diff --git a/pallets/nft/src/tests.rs b/pallets/nft/src/tests.rs index 2c52d3240..d91e41ad5 100644 --- a/pallets/nft/src/tests.rs +++ b/pallets/nft/src/tests.rs @@ -173,7 +173,11 @@ fn create_class_should_work() { let event = mock::RuntimeEvent::Nft(crate::Event::NewNftClassCreated(ALICE, CLASS_ID)); assert_eq!(last_event(), event); - assert_eq!(free_native_balance(class_id_account()), class_deposit); + assert_eq!( + free_native_balance(class_id_account()), + class_deposit + ::StorageDepositFee::get() + ); + assert_eq!(Balances::free_balance(ALICE), 99997); }); } @@ -213,7 +217,11 @@ fn create_class_with_royalty_fee_should_work() { let event = mock::RuntimeEvent::Nft(crate::Event::NewNftClassCreated(ALICE, CLASS_ID)); assert_eq!(last_event(), event); - assert_eq!(free_native_balance(class_id_account()), class_deposit); + assert_eq!( + free_native_balance(class_id_account()), + class_deposit + ::StorageDepositFee::get() + ); + assert_eq!(Balances::free_balance(ALICE), 99997); }); } @@ -224,7 +232,7 @@ fn mint_asset_should_work() { assert_ok!(Nft::enable_promotion(RuntimeOrigin::root(), true)); init_test_nft(origin.clone()); - assert_eq!(free_native_balance(class_id_account()), 3); + assert_eq!(free_native_balance(class_id_account()), 4); assert_eq!(OrmlNft::tokens_by_owner((ALICE, 0, 0)), ()); let event = mock::RuntimeEvent::Nft(crate::Event::NewNftMinted((0, 0), (0, 0), ALICE, CLASS_ID, 1, 0)); @@ -273,7 +281,7 @@ fn mint_stackable_asset_should_work() { assert_ok!(Nft::enable_promotion(RuntimeOrigin::root(), true)); init_test_stackable_nft(origin.clone()); - assert_eq!(free_native_balance(class_id_account()), 3); + assert_eq!(free_native_balance(class_id_account()), 4); assert_eq!(OrmlNft::tokens_by_owner((ALICE, 0, 0)), ()); assert_eq!( @@ -696,10 +704,10 @@ fn do_withdraw_funds_from_class_fund_should_work() { init_test_nft(origin.clone()); let class_fund: AccountId = ::PalletId::get().into_sub_account_truncating(CLASS_ID); assert_ok!(::Currency::transfer(origin.clone(), class_fund, 100)); - assert_eq!(free_native_balance(ALICE), 99897); + assert_eq!(free_native_balance(ALICE), 99896); assert_eq!(free_native_balance(class_fund), 100); assert_ok!(Nft::withdraw_funds_from_class_fund(origin.clone(), CLASS_ID)); - assert_eq!(free_native_balance(ALICE), 99996); + assert_eq!(free_native_balance(ALICE), 99995); assert_eq!(free_native_balance(class_fund), 1); }) } diff --git a/pallets/nft/src/weights.rs b/pallets/nft/src/weights.rs index c85102d27..1111bfbde 100644 --- a/pallets/nft/src/weights.rs +++ b/pallets/nft/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for nft //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-06-21, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-07-16, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 // Executed Command: @@ -61,8 +61,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Nf // Proof Size summary in bytes: // Measured: `109` // Estimated: `1317` - // Minimum execution time: 11_400 nanoseconds. - Weight::from_parts(12_179_000, 1317) + // Minimum execution time: 11_475 nanoseconds. + Weight::from_parts(12_117_000, 1317) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -80,8 +80,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Nf // Proof Size summary in bytes: // Measured: `461` // Estimated: `7417` - // Minimum execution time: 26_854 nanoseconds. - Weight::from_parts(27_797_000, 7417) + // Minimum execution time: 35_571 nanoseconds. + Weight::from_parts(37_465_000, 7417) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -101,8 +101,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Nf // Proof Size summary in bytes: // Measured: `784` // Estimated: `23976` - // Minimum execution time: 52_673 nanoseconds. - Weight::from_parts(54_185_000, 23976) + // Minimum execution time: 63_219 nanoseconds. + Weight::from_parts(69_706_000, 23976) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(10)) } @@ -124,8 +124,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Nf // Proof Size summary in bytes: // Measured: `550` // Estimated: `15931` - // Minimum execution time: 39_871 nanoseconds. - Weight::from_parts(41_846_000, 15931) + // Minimum execution time: 46_695 nanoseconds. + Weight::from_parts(111_946_000, 15931) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(8)) } @@ -145,8 +145,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Nf // Proof Size summary in bytes: // Measured: `802` // Estimated: `17187` - // Minimum execution time: 30_774 nanoseconds. - Weight::from_parts(32_122_000, 17187) + // Minimum execution time: 31_317 nanoseconds. + Weight::from_parts(33_226_000, 17187) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -160,8 +160,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Nf // Proof Size summary in bytes: // Measured: `630` // Estimated: `11790` - // Minimum execution time: 26_888 nanoseconds. - Weight::from_parts(28_373_000, 11790) + // Minimum execution time: 27_633 nanoseconds. + Weight::from_parts(28_946_000, 11790) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -181,25 +181,25 @@ impl WeightInfo for SubstrateWeight { // Storage: Nf // Proof Size summary in bytes: // Measured: `980` // Estimated: `25680` - // Minimum execution time: 109_148 nanoseconds. - Weight::from_parts(112_127_000, 25680) + // Minimum execution time: 54_804 nanoseconds. + Weight::from_parts(63_183_000, 25680) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(6)) } // Storage: OrmlNFT Tokens (r:1 w:0) // Proof Skipped: OrmlNFT Tokens (max_values: None, max_size: None, mode: Measured) - // Storage: System Account (r:2 w:2) + // Storage: System Account (r:3 w:3) // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) // Storage: Nft AssetSupporters (r:1 w:1) // Proof Skipped: Nft AssetSupporters (max_values: None, max_size: None, mode: Measured) fn sign_asset() -> Weight { // Proof Size summary in bytes: - // Measured: `867` - // Estimated: `11890` - // Minimum execution time: 35_431 nanoseconds. - Weight::from_parts(38_782_000, 11890) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) + // Measured: `1002` + // Estimated: `14763` + // Minimum execution time: 79_688 nanoseconds. + Weight::from_parts(115_994_000, 14763) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) } // Storage: OrmlNFT Classes (r:1 w:1) // Proof Skipped: OrmlNFT Classes (max_values: None, max_size: None, mode: Measured) @@ -207,8 +207,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Nf // Proof Size summary in bytes: // Measured: `282` // Estimated: `2757` - // Minimum execution time: 11_687 nanoseconds. - Weight::from_parts(15_065_000, 2757) + // Minimum execution time: 12_053 nanoseconds. + Weight::from_parts(23_425_000, 2757) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -220,8 +220,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Nf // Proof Size summary in bytes: // Measured: `587` // Estimated: `8268` - // Minimum execution time: 24_825 nanoseconds. - Weight::from_parts(25_576_000, 8268) + // Minimum execution time: 56_702 nanoseconds. + Weight::from_parts(61_491_000, 8268) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -231,8 +231,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Nf // Proof Size summary in bytes: // Measured: `282` // Estimated: `2757` - // Minimum execution time: 10_502 nanoseconds. - Weight::from_parts(11_211_000, 2757) + // Minimum execution time: 10_855 nanoseconds. + Weight::from_parts(27_207_000, 2757) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -240,57 +240,57 @@ impl WeightInfo for SubstrateWeight { // Storage: Nf // For backwards compatibility and tests impl WeightInfo for () { fn create_group() -> Weight { - Weight::from_parts(12_179_000, 1317) + Weight::from_parts(12_117_000, 1317) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(3)) } fn create_class() -> Weight { - Weight::from_parts(27_797_000, 7417) + Weight::from_parts(37_465_000, 7417) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(4)) } fn mint() -> Weight { - Weight::from_parts(54_185_000, 23976) + Weight::from_parts(69_706_000, 23976) .saturating_add(RocksDbWeight::get().reads(8)) .saturating_add(RocksDbWeight::get().writes(10)) } fn mint_stackable_nft() -> Weight { - Weight::from_parts(41_846_000, 15931) + Weight::from_parts(111_946_000, 15931) .saturating_add(RocksDbWeight::get().reads(5)) .saturating_add(RocksDbWeight::get().writes(8)) } fn transfer() -> Weight { - Weight::from_parts(32_122_000, 17187) + Weight::from_parts(33_226_000, 17187) .saturating_add(RocksDbWeight::get().reads(5)) .saturating_add(RocksDbWeight::get().writes(3)) } fn transfer_stackable_nft() -> Weight { - Weight::from_parts(28_373_000, 11790) + Weight::from_parts(28_946_000, 11790) .saturating_add(RocksDbWeight::get().reads(4)) .saturating_add(RocksDbWeight::get().writes(2)) } fn transfer_batch() -> Weight { - Weight::from_parts(112_127_000, 25680) + Weight::from_parts(63_183_000, 25680) .saturating_add(RocksDbWeight::get().reads(8)) .saturating_add(RocksDbWeight::get().writes(6)) } fn sign_asset() -> Weight { - Weight::from_parts(38_782_000, 11890) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(3)) + Weight::from_parts(115_994_000, 14763) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(4)) } fn set_hard_limit() -> Weight { - Weight::from_parts(15_065_000, 2757) + Weight::from_parts(23_425_000, 2757) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(1)) } fn withdraw_funds_from_class_fund() -> Weight { - Weight::from_parts(25_576_000, 8268) + Weight::from_parts(61_491_000, 8268) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(2)) } fn force_update_total_issuance() -> Weight { - Weight::from_parts(11_211_000, 2757) + Weight::from_parts(27_207_000, 2757) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(1)) } diff --git a/pallets/reward/src/lib.rs b/pallets/reward/src/lib.rs index a64da9b08..28681399c 100644 --- a/pallets/reward/src/lib.rs +++ b/pallets/reward/src/lib.rs @@ -133,6 +133,11 @@ pub mod pallet { /// NFT trait type that handler NFT implementation type NFTHandler: NFTTrait, ClassId = ClassId, TokenId = TokenId>; + /// Storage deposit free charged when saving data into the blockchain. + /// The fee will be unreserved after the storage is freed. + #[pallet::constant] + type StorageDepositFee: Get>; + /// Weight info type WeightInfo: WeightInfo; } @@ -325,6 +330,17 @@ pub mod pallet { let next_campaign_id = campaign_id.checked_add(1).ok_or(ArithmeticError::Overflow)?; + // 3 storage inserts + let storage_fee: BalanceOf = + Perbill::from_percent(3u32.saturating_mul(100)) * T::StorageDepositFee::get(); + + T::Currency::transfer( + &depositor, + &Self::network_treasury_account_id(), + storage_fee.saturated_into(), + ExistenceRequirement::KeepAlive, + )?; + Campaigns::::insert( campaign_id, CampaignInfo { @@ -363,7 +379,7 @@ pub mod pallet { /// - `properties`: information relevant for the campaign. /// /// Emits `NewRewardCampaignCreated` if successful. - #[pallet::weight(T::WeightInfo::create_campaign() * (1u64 + reward.len() as u64))] + #[pallet::weight(T::WeightInfo::create_campaign().saturating_mul((1u64.saturating_add(reward.len() as u64))))] #[transactional] pub fn create_nft_campaign( origin: OriginFor, @@ -412,6 +428,17 @@ pub mod pallet { T::Currency::transfer(&depositor, &fund_account, T::CampaignDeposit::get(), AllowDeath)?; + // 3 storage inserts + let storage_fee: BalanceOf = + Perbill::from_percent(3u32.saturating_mul(100)) * T::StorageDepositFee::get(); + + T::Currency::transfer( + &depositor, + &Self::network_treasury_account_id(), + storage_fee.saturated_into(), + ExistenceRequirement::KeepAlive, + )?; + Campaigns::::insert( campaign_id, CampaignInfo { @@ -457,7 +484,7 @@ pub mod pallet { ensure!(campaign.end < now, Error::::CampaignStillActive); ensure!( - campaign.end + campaign.cooling_off_duration >= now, + campaign.end.saturating_add(campaign.cooling_off_duration) >= now, Error::::CampaignExpired ); @@ -491,7 +518,7 @@ pub mod pallet { /// - `leaf_nodes`: list of the merkle tree nodes required for merkle-proof calculation. /// /// Emits `RewardClaimed` if successful. - #[pallet::weight(T::WeightInfo::claim_reward_root() * (1u64 + leaf_nodes.len() as u64))] + #[pallet::weight(T::WeightInfo::claim_reward_root().saturating_mul((1u64.saturating_add(leaf_nodes.len() as u64))))] #[transactional] pub fn claim_reward_root( origin: OriginFor, @@ -508,7 +535,7 @@ pub mod pallet { ensure!(campaign.end < now, Error::::CampaignStillActive); ensure!( - campaign.end + campaign.cooling_off_duration >= now, + campaign.end.saturating_add(campaign.cooling_off_duration) >= now, Error::::CampaignExpired ); @@ -555,7 +582,7 @@ pub mod pallet { /// - `amount`: the amount of NFTs that the account is going to claim /// /// Emits `RewardClaimed` if successful. - #[pallet::weight(T::WeightInfo::claim_nft_reward() * (1u64 + amount))] + #[pallet::weight(T::WeightInfo::claim_nft_reward().saturating_mul((1u64.saturating_add(*amount))))] #[transactional] pub fn claim_nft_reward(origin: OriginFor, id: CampaignId, amount: u64) -> DispatchResult { let who = ensure_signed(origin)?; @@ -567,7 +594,7 @@ pub mod pallet { ensure!(campaign.end < now, Error::::CampaignStillActive); ensure!( - campaign.end + campaign.cooling_off_duration >= now, + campaign.end.saturating_add(campaign.cooling_off_duration) >= now, Error::::CampaignExpired ); @@ -614,7 +641,7 @@ pub mod pallet { /// - `leaf_nodes`: list of the merkle tree nodes required for merkle-proof calculation. /// /// Emits `RewardClaimed` if successful. - #[pallet::weight(T::WeightInfo::claim_nft_reward_root() * (1u64 + reward_tokens.len() as u64))] + #[pallet::weight(T::WeightInfo::claim_nft_reward_root().saturating_mul((1u64.saturating_add(reward_tokens.len() as u64))))] #[transactional] pub fn claim_nft_reward_root( origin: OriginFor, @@ -631,7 +658,7 @@ pub mod pallet { ensure!(campaign.end < now, Error::::CampaignStillActive); ensure!( - campaign.end + campaign.cooling_off_duration >= now, + campaign.end.saturating_add(campaign.cooling_off_duration) >= now, Error::::CampaignExpired ); @@ -682,7 +709,7 @@ pub mod pallet { /// - `rewards`: vector of account IDs and their's reward balances pairs. /// /// Emits `SetReward` if successful. - #[pallet::weight(T::WeightInfo::set_reward() * rewards.len() as u64)] + #[pallet::weight(T::WeightInfo::set_reward().saturating_mul(rewards.len() as u64))] #[transactional] pub fn set_reward( origin: OriginFor, @@ -703,7 +730,7 @@ pub mod pallet { let mut campaign = campaign.as_mut().ok_or(Error::::CampaignIsNotFound)?; ensure!( - campaign.end + campaign.cooling_off_duration >= now, + campaign.end.saturating_add(campaign.cooling_off_duration) >= now, Error::::CampaignExpired ); @@ -757,7 +784,7 @@ pub mod pallet { let mut campaign = campaign.as_mut().ok_or(Error::::CampaignIsNotFound)?; ensure!( - campaign.end + campaign.cooling_off_duration >= now, + campaign.end.saturating_add(campaign.cooling_off_duration) >= now, Error::::CampaignExpired ); @@ -797,7 +824,7 @@ pub mod pallet { /// - `total_nfts_amount`: the total number of NFTs that will be rewrad. /// /// Emits `SetReward` if successful. - #[pallet::weight(T::WeightInfo::set_nft_reward() * total_nfts_amount)] + #[pallet::weight(T::WeightInfo::set_nft_reward().saturating_mul(*total_nfts_amount))] #[transactional] pub fn set_nft_reward( origin: OriginFor, @@ -819,7 +846,7 @@ pub mod pallet { let mut campaign = campaign.as_mut().ok_or(Error::::CampaignIsNotFound)?; ensure!( - campaign.end + campaign.cooling_off_duration >= now, + campaign.end.saturating_add(campaign.cooling_off_duration) >= now, Error::::CampaignExpired ); @@ -873,11 +900,18 @@ pub mod pallet { let now = frame_system::Pallet::::block_number(); + T::Currency::transfer( + &who, + &Self::network_treasury_account_id(), + T::StorageDepositFee::get(), + ExistenceRequirement::KeepAlive, + )?; + >::try_mutate_exists(id, |campaign| -> DispatchResult { let mut campaign = campaign.as_mut().ok_or(Error::::CampaignIsNotFound)?; ensure!( - campaign.end + campaign.cooling_off_duration >= now, + campaign.end.saturating_add(campaign.cooling_off_duration) >= now, Error::::CampaignExpired ); @@ -911,7 +945,7 @@ pub mod pallet { /// - `merkle_roots_quanity`: the amount of merkle roots that were used for setting rewards. /// /// Emits `RewardCampaignClosed` and/or `RewardCampaignRootClosed` if successful. - #[pallet::weight(T::WeightInfo::close_campaign() * (1u64 + merkle_roots_quantity))] + #[pallet::weight(T::WeightInfo::close_campaign().saturating_mul((1u64.saturating_add(*merkle_roots_quantity))))] #[transactional] pub fn close_campaign(origin: OriginFor, id: CampaignId, merkle_roots_quantity: u64) -> DispatchResult { let who = ensure_signed(origin)?; @@ -922,7 +956,7 @@ pub mod pallet { ensure!(who == campaign.creator, Error::::NotCampaignCreator); ensure!( - campaign.end + campaign.cooling_off_duration < now, + campaign.end.saturating_add(campaign.cooling_off_duration) < now, Error::::CampaignStillActive ); @@ -972,7 +1006,7 @@ pub mod pallet { /// - `left_nfts`: the amount of unclaimed NFTs in the reward pool. /// /// Emits `RewardCampaignClosed` and/or `RewardCampaignRootClosed` if successful. - #[pallet::weight(T::WeightInfo::close_nft_campaign() * (1u64 + left_nfts))] + #[pallet::weight(T::WeightInfo::close_nft_campaign().saturating_mul(1u64.saturating_add(*left_nfts)))] #[transactional] pub fn close_nft_campaign(origin: OriginFor, id: CampaignId, left_nfts: u64) -> DispatchResult { let who = ensure_signed(origin)?; @@ -983,7 +1017,7 @@ pub mod pallet { ensure!(who == campaign.creator, Error::::NotCampaignCreator); ensure!( - campaign.end + campaign.cooling_off_duration < now, + campaign.end.saturating_add(campaign.cooling_off_duration) < now, Error::::CampaignStillActive ); @@ -1061,7 +1095,7 @@ pub mod pallet { /// - `left_nfts`: the size of the NFT reward pool. /// /// Emits `RewardCampaignCanceled` if successful. - #[pallet::weight(T::WeightInfo::cancel_nft_campaign() * (1u64 + left_nfts))] + #[pallet::weight(T::WeightInfo::cancel_nft_campaign().saturating_mul(1u64.saturating_add(*left_nfts)))] pub fn cancel_nft_campaign(origin: OriginFor, id: CampaignId, left_nfts: u64) -> DispatchResult { T::AdminOrigin::ensure_origin(origin)?; let now = frame_system::Pallet::::block_number(); @@ -1103,6 +1137,13 @@ pub mod pallet { Error::::SetRewardOriginAlreadyAdded ); + T::Currency::transfer( + &account, + &Self::network_treasury_account_id(), + T::StorageDepositFee::get(), + ExistenceRequirement::KeepAlive, + )?; + SetRewardOrigins::::insert(account.clone(), ()); Self::deposit_event(Event::::SetRewardOriginAdded(account)); @@ -1163,6 +1204,11 @@ impl Pallet { T::PalletId::get().into_sub_account_truncating(id) } + /// The account ID of the network treasury + pub fn network_treasury_account_id() -> T::AccountId { + T::PalletId::get().into_account_truncating() + } + /// Generate unique ChildInfo IDs pub fn id_from_index(index: TrieIndex) -> child::ChildInfo { let mut buf = Vec::new(); diff --git a/pallets/reward/src/mock.rs b/pallets/reward/src/mock.rs index 3db4e05f9..ac67ad3c5 100644 --- a/pallets/reward/src/mock.rs +++ b/pallets/reward/src/mock.rs @@ -97,6 +97,7 @@ parameter_types! { pub const MinimumCampaignDuration: BlockNumber = 5; pub const MaxLeafNodes: u64 = 30; pub const MaxSetRewardsListLength: u64 = 2; + pub StorageDepositFee: Balance = 1; } impl Config for Runtime { @@ -114,6 +115,7 @@ impl Config for Runtime { type NFTHandler = NFTModule; type MaxLeafNodes = MaxLeafNodes; type WeightInfo = (); + type StorageDepositFee = StorageDepositFee; } parameter_type_with_key! { @@ -259,6 +261,7 @@ impl pallet_nft::Config for Runtime { type Treasury = MetaverseNetworkTreasuryPalletId; type AssetMintingFee = AssetMintingFee; type ClassMintingFee = ClassMintingFee; + type StorageDepositFee = StorageDepositFee; } parameter_types! { diff --git a/pallets/reward/src/tests.rs b/pallets/reward/src/tests.rs index a34dc744b..323fb03eb 100644 --- a/pallets/reward/src/tests.rs +++ b/pallets/reward/src/tests.rs @@ -149,7 +149,7 @@ fn create_campaign_works() { cap: RewardType::FungibleTokens(FungibleTokenId::NativeToken(0), 10), }; assert_eq!(Reward::campaigns(campaign_id), Some(campaign_info)); - assert_eq!(Balances::free_balance(ALICE), 9989); + assert_eq!(Balances::free_balance(ALICE), 9988); let event = mock::RuntimeEvent::Reward(crate::Event::NewRewardCampaignCreated(campaign_id, ALICE)); assert_eq!(last_event(), event) @@ -183,7 +183,7 @@ fn create_nft_campaign_works() { cap: RewardType::NftAssets(vec![(0u32, 1u64)]), }; assert_eq!(Reward::campaigns(campaign_id), Some(campaign_info)); - assert_eq!(Balances::free_balance(ALICE), 9993); + assert_eq!(Balances::free_balance(ALICE), 9990); assert_eq!(OrmlNft::tokens(0u32, 1u64).unwrap().data.is_locked, true); let event = mock::RuntimeEvent::Reward(crate::Event::NewRewardCampaignCreated(campaign_id, ALICE)); @@ -216,7 +216,7 @@ fn create_multicurrency_campaign_works() { cap: RewardType::FungibleTokens(FungibleTokenId::MiningResource(0), 10), }; assert_eq!(Reward::campaigns(campaign_id), Some(campaign_info)); - assert_eq!(Balances::free_balance(ALICE), 9999); + assert_eq!(Balances::free_balance(ALICE), 9998); assert_eq!(Tokens::accounts(ALICE, FungibleTokenId::MiningResource(0)).free, 9990); let event = mock::RuntimeEvent::Reward(crate::Event::NewRewardCampaignCreated(campaign_id, ALICE)); @@ -423,6 +423,7 @@ fn set_nft_reward_works() { ExtBuilder::default().build().execute_with(|| { let campaign_id = 0; assert_ok!(Reward::add_set_reward_origin(RuntimeOrigin::signed(ALICE), ALICE)); + assert_eq!(Balances::free_balance(ALICE), 9999); init_test_nft(RuntimeOrigin::signed(ALICE)); init_test_nft(RuntimeOrigin::signed(ALICE)); @@ -446,7 +447,7 @@ fn set_nft_reward_works() { cap: RewardType::NftAssets(vec![(0u32, 1u64)]), }; assert_eq!(Reward::campaigns(campaign_id), Some(campaign_info)); - assert_eq!(Balances::free_balance(ALICE), 9993); + assert_eq!(Balances::free_balance(ALICE), 9989); assert_eq!(OrmlNft::tokens(0u32, 1u64).unwrap().data.is_locked, true); assert_ok!(Reward::set_nft_reward( @@ -480,6 +481,7 @@ fn set_nft_reward_root_works() { ExtBuilder::default().build().execute_with(|| { let campaign_id = 0; assert_ok!(Reward::add_set_reward_origin(RuntimeOrigin::signed(ALICE), ALICE)); + assert_eq!(Balances::free_balance(ALICE), 9999); init_test_nft(RuntimeOrigin::signed(ALICE)); init_test_nft(RuntimeOrigin::signed(ALICE)); init_test_nft(RuntimeOrigin::signed(ALICE)); @@ -504,7 +506,7 @@ fn set_nft_reward_root_works() { cap: RewardType::NftAssets(vec![(0u32, 2u64), (0u32, 1u64)]), }; assert_eq!(Reward::campaigns(campaign_id), Some(campaign_info)); - assert_eq!(Balances::free_balance(ALICE), 9990); + assert_eq!(Balances::free_balance(ALICE), 9985); assert_eq!(OrmlNft::tokens(0u32, 1u64).unwrap().data.is_locked, true); assert_ok!(Reward::set_nft_reward_root( @@ -512,6 +514,7 @@ fn set_nft_reward_root_works() { 0, test_hash(1u64) )); + assert_eq!(Balances::free_balance(ALICE), 9984); let campaign_info_2 = CampaignInfo { creator: ALICE, @@ -975,6 +978,7 @@ fn claim_nft_reward_works() { ExtBuilder::default().build().execute_with(|| { let campaign_id = 0; assert_ok!(Reward::add_set_reward_origin(RuntimeOrigin::signed(ALICE), ALICE)); + assert_eq!(Balances::free_balance(ALICE), 9999); init_test_nft(RuntimeOrigin::signed(ALICE)); init_test_nft(RuntimeOrigin::signed(ALICE)); @@ -998,7 +1002,7 @@ fn claim_nft_reward_works() { cap: RewardType::NftAssets(vec![(0u32, 1u64)]), }; assert_eq!(Reward::campaigns(campaign_id), Some(campaign_info)); - assert_eq!(Balances::free_balance(ALICE), 9993); + assert_eq!(Balances::free_balance(ALICE), 9989); assert_eq!(OrmlNft::tokens(0u32, 1u64).unwrap().data.is_locked, true); assert_ok!(Reward::set_nft_reward( @@ -1036,6 +1040,7 @@ fn claim_nft_reward_root_works() { ExtBuilder::default().build().execute_with(|| { let campaign_id = 0; assert_ok!(Reward::add_set_reward_origin(RuntimeOrigin::signed(ALICE), ALICE)); + assert_eq!(Balances::free_balance(ALICE), 9999); init_test_nft(RuntimeOrigin::signed(ALICE)); init_test_nft(RuntimeOrigin::signed(ALICE)); @@ -1059,7 +1064,7 @@ fn claim_nft_reward_root_works() { cap: RewardType::NftAssets(vec![(0u32, 1u64)]), }; assert_eq!(Reward::campaigns(campaign_id), Some(campaign_info)); - assert_eq!(Balances::free_balance(ALICE), 9993); + assert_eq!(Balances::free_balance(ALICE), 9989); assert_eq!(OrmlNft::tokens(0u32, 1u64).unwrap().data.is_locked, true); assert_ok!(Reward::set_nft_reward_root( @@ -1067,6 +1072,7 @@ fn claim_nft_reward_root_works() { 0, test_claim_nft_hash(BOB, (0u32, 1u64)) )); + assert_eq!(Balances::free_balance(ALICE), 9988); run_to_block(17); @@ -1617,14 +1623,14 @@ fn close_nft_campaign_works() { vec![1], )); - assert_eq!(Balances::free_balance(ALICE), 9993); + assert_eq!(Balances::free_balance(ALICE), 9990); assert_eq!(OrmlNft::tokens(0u32, 1u64).unwrap().data.is_locked, true); run_to_block(100); assert_ok!(Reward::close_nft_campaign(RuntimeOrigin::signed(ALICE), 0, 1)); - assert_eq!(Balances::free_balance(ALICE), 9994); + assert_eq!(Balances::free_balance(ALICE), 9991); assert_eq!(OrmlNft::tokens(0u32, 1u64).unwrap().data.is_locked, false); assert_eq!(Campaigns::::get(campaign_id), None); @@ -1638,10 +1644,11 @@ fn close_nft_campaign_works() { fn close_nft_campaign_with_merkle_root_works() { ExtBuilder::default().build().execute_with(|| { let campaign_id = 0; + assert_ok!(Reward::add_set_reward_origin(RuntimeOrigin::signed(ALICE), ALICE)); + assert_eq!(Balances::free_balance(ALICE), 9999); init_test_nft(RuntimeOrigin::signed(ALICE)); init_test_nft(RuntimeOrigin::signed(ALICE)); - assert_ok!(Reward::add_set_reward_origin(RuntimeOrigin::signed(ALICE), ALICE)); assert_ok!(Reward::create_nft_campaign( RuntimeOrigin::signed(ALICE), @@ -1652,20 +1659,21 @@ fn close_nft_campaign_with_merkle_root_works() { vec![1], )); - assert_eq!(Balances::free_balance(ALICE), 9993); + assert_eq!(Balances::free_balance(ALICE), 9989); assert_eq!(OrmlNft::tokens(0u32, 1u64).unwrap().data.is_locked, true); assert_ok!(Reward::set_nft_reward_root( RuntimeOrigin::signed(ALICE), 0, test_hash(1u64) )); + assert_eq!(Balances::free_balance(ALICE), 9988); assert_eq!(CampaignMerkleRoots::::get(campaign_id), vec![test_hash(1u64)]); run_to_block(100); assert_ok!(Reward::close_nft_campaign(RuntimeOrigin::signed(ALICE), 0, 1)); - assert_eq!(Balances::free_balance(ALICE), 9994); + assert_eq!(Balances::free_balance(ALICE), 9989); assert_eq!(OrmlNft::tokens(0u32, 1u64).unwrap().data.is_locked, false); assert_eq!(Campaigns::::get(campaign_id), None); @@ -1690,13 +1698,13 @@ fn close_campaign_works() { FungibleTokenId::NativeToken(0) )); - assert_eq!(Balances::free_balance(ALICE), 9989); + assert_eq!(Balances::free_balance(ALICE), 9988); run_to_block(100); assert_ok!(Reward::close_campaign(RuntimeOrigin::signed(BOB), 0, 0)); - assert_eq!(Balances::free_balance(ALICE), 9989); + assert_eq!(Balances::free_balance(ALICE), 9988); assert_eq!(Balances::free_balance(BOB), 20011); assert_eq!(Campaigns::::get(campaign_id), None); @@ -1711,6 +1719,7 @@ fn close_campaign_using_merkle_root_works() { ExtBuilder::default().build().execute_with(|| { let campaign_id = 0; assert_ok!(Reward::add_set_reward_origin(RuntimeOrigin::signed(ALICE), ALICE)); + assert_eq!(Balances::free_balance(ALICE), 9999); assert_ok!(Reward::create_campaign( RuntimeOrigin::signed(ALICE), BOB, @@ -1721,7 +1730,7 @@ fn close_campaign_using_merkle_root_works() { FungibleTokenId::NativeToken(0) )); - assert_eq!(Balances::free_balance(ALICE), 9989); + assert_eq!(Balances::free_balance(ALICE), 9987); assert_ok!(Reward::set_reward_root( RuntimeOrigin::signed(ALICE), 0, @@ -1742,7 +1751,7 @@ fn close_campaign_using_merkle_root_works() { assert_ok!(Reward::close_campaign(RuntimeOrigin::signed(BOB), 0, 2)); - assert_eq!(Balances::free_balance(ALICE), 9989); + assert_eq!(Balances::free_balance(ALICE), 9987); assert_eq!(Balances::free_balance(BOB), 20011); assert_eq!(Campaigns::::get(campaign_id), None); @@ -1768,14 +1777,14 @@ fn close_multicurrency_campaign_works() { FungibleTokenId::MiningResource(0) )); - assert_eq!(Balances::free_balance(ALICE), 9999); + assert_eq!(Balances::free_balance(ALICE), 9998); assert_eq!(Tokens::accounts(ALICE, FungibleTokenId::MiningResource(0)).free, 9990); run_to_block(100); assert_ok!(Reward::close_campaign(RuntimeOrigin::signed(BOB), 0, 0)); - assert_eq!(Balances::free_balance(ALICE), 9999); + assert_eq!(Balances::free_balance(ALICE), 9998); assert_eq!(Tokens::accounts(ALICE, FungibleTokenId::MiningResource(0)).free, 9990); assert_eq!(Balances::free_balance(BOB), 20001); assert_eq!(Tokens::accounts(BOB, FungibleTokenId::MiningResource(0)).free, 5010); @@ -1999,14 +2008,14 @@ fn cancel_nft_campaign_works() { vec![1], )); - assert_eq!(Balances::free_balance(ALICE), 9993); + assert_eq!(Balances::free_balance(ALICE), 9990); assert_eq!(OrmlNft::tokens(0u32, 1u64).unwrap().data.is_locked, true); run_to_block(5); assert_ok!(Reward::cancel_nft_campaign(RuntimeOrigin::signed(ALICE), 0, 1)); - assert_eq!(Balances::free_balance(ALICE), 9994); + assert_eq!(Balances::free_balance(ALICE), 9991); assert_eq!(OrmlNft::tokens(0u32, 1u64).unwrap().data.is_locked, false); assert_eq!(Campaigns::::get(campaign_id), None); @@ -2030,13 +2039,13 @@ fn cancel_campaign_works() { FungibleTokenId::NativeToken(0) )); - assert_eq!(Balances::free_balance(ALICE), 9989); + assert_eq!(Balances::free_balance(ALICE), 9988); run_to_block(5); assert_ok!(Reward::cancel_campaign(RuntimeOrigin::signed(ALICE), 0)); - assert_eq!(Balances::free_balance(ALICE), 9989); + assert_eq!(Balances::free_balance(ALICE), 9988); assert_eq!(Balances::free_balance(BOB), 20011); assert_eq!(Campaigns::::get(campaign_id), None); @@ -2060,14 +2069,14 @@ fn cancel_multicurrency_campaign_works() { FungibleTokenId::MiningResource(0) )); - assert_eq!(Balances::free_balance(ALICE), 9999); + assert_eq!(Balances::free_balance(ALICE), 9998); assert_eq!(Tokens::accounts(ALICE, FungibleTokenId::MiningResource(0)).free, 9990); run_to_block(5); assert_ok!(Reward::cancel_campaign(RuntimeOrigin::signed(ALICE), 0)); - assert_eq!(Balances::free_balance(ALICE), 9999); + assert_eq!(Balances::free_balance(ALICE), 9998); assert_eq!(Tokens::accounts(ALICE, FungibleTokenId::MiningResource(0)).free, 9990); assert_eq!(Balances::free_balance(BOB), 20001); assert_eq!(Tokens::accounts(BOB, FungibleTokenId::MiningResource(0)).free, 5010); diff --git a/pallets/reward/src/weights.rs b/pallets/reward/src/weights.rs index 959589e28..25798ba8a 100644 --- a/pallets/reward/src/weights.rs +++ b/pallets/reward/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for reward //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-06-21, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-07-18, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 // Executed Command: @@ -67,8 +67,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Re // Proof Size summary in bytes: // Measured: `1755` // Estimated: `12368` - // Minimum execution time: 46_892 nanoseconds. - Weight::from_parts(47_856_000, 12368) + // Minimum execution time: 54_579 nanoseconds. + Weight::from_parts(56_713_000, 12368) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(6)) } @@ -90,10 +90,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Re // Proof Skipped: Reward Campaigns (max_values: None, max_size: None, mode: Measured) fn create_nft_campaign() -> Weight { // Proof Size summary in bytes: - // Measured: `2541` - // Estimated: `26330` - // Minimum execution time: 49_867 nanoseconds. - Weight::from_parts(51_776_000, 26330) + // Measured: `2625` + // Estimated: `26918` + // Minimum execution time: 57_748 nanoseconds. + Weight::from_parts(58_468_000, 26918) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(7)) } @@ -105,10 +105,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Re // Proof Skipped: unknown `0xd861ea1ebf4800d4b89f4ff787ad79ee96d9a708c85b57da7eb8f9ddeda61291` (r:1 w:1) fn claim_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `2848` - // Estimated: `13249` - // Minimum execution time: 42_198 nanoseconds. - Weight::from_parts(43_780_000, 13249) + // Measured: `3016` + // Estimated: `13585` + // Minimum execution time: 42_264 nanoseconds. + Weight::from_parts(42_927_000, 13585) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -124,10 +124,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Re // Proof Skipped: unknown `0xb7200f59aadbf6d1b9256342e6991416affd964ad90df566106c806d3c5eb1a6` (r:1 w:0) fn claim_reward_root() -> Weight { // Proof Size summary in bytes: - // Measured: `2914` - // Estimated: `24159` - // Minimum execution time: 48_659 nanoseconds. - Weight::from_parts(50_524_000, 24159) + // Measured: `3082` + // Estimated: `24831` + // Minimum execution time: 49_248 nanoseconds. + Weight::from_parts(51_031_000, 24831) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -145,10 +145,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Re // Proof Skipped: unknown `0xd861ea1ebf4800d4b89f4ff787ad79ee96d9a708c85b57da7eb8f9ddeda61291` (r:1 w:1) fn claim_nft_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `3098` - // Estimated: `33438` - // Minimum execution time: 51_345 nanoseconds. - Weight::from_parts(52_709_000, 33438) + // Measured: `3350` + // Estimated: `34950` + // Minimum execution time: 50_168 nanoseconds. + Weight::from_parts(53_120_000, 34950) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -168,10 +168,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Re // Proof Skipped: unknown `0xf79f59badead8bbd60eff30f639305d784f04c0804fe566c4a5749fc98362b8c` (r:1 w:0) fn claim_nft_reward_root() -> Weight { // Proof Size summary in bytes: - // Measured: `3510` - // Estimated: `41895` - // Minimum execution time: 109_467 nanoseconds. - Weight::from_parts(118_897_000, 41895) + // Measured: `3930` + // Estimated: `44835` + // Minimum execution time: 73_753 nanoseconds. + Weight::from_parts(79_172_000, 44835) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -183,10 +183,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Re // Proof Skipped: unknown `0xd861ea1ebf4800d4b89f4ff787ad79ee96d9a708c85b57da7eb8f9ddeda61291` (r:1 w:1) fn set_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `2175` - // Estimated: `13950` - // Minimum execution time: 27_665 nanoseconds. - Weight::from_parts(30_996_000, 13950) + // Measured: `2343` + // Estimated: `14454` + // Minimum execution time: 35_698 nanoseconds. + Weight::from_parts(40_981_000, 14454) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -200,10 +200,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Re // Proof Skipped: unknown `0x0000000000000000000000000000000000000000000000000000000000000001` (r:1 w:1) fn set_reward_root() -> Weight { // Proof Size summary in bytes: - // Measured: `2175` - // Estimated: `18600` - // Minimum execution time: 27_737 nanoseconds. - Weight::from_parts(31_147_000, 18600) + // Measured: `2343` + // Estimated: `19272` + // Minimum execution time: 35_361 nanoseconds. + Weight::from_parts(42_695_000, 19272) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -215,15 +215,17 @@ impl WeightInfo for SubstrateWeight { // Storage: Re // Proof Skipped: unknown `0xd861ea1ebf4800d4b89f4ff787ad79ee96d9a708c85b57da7eb8f9ddeda61291` (r:1 w:1) fn set_nft_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `2246` - // Estimated: `14163` - // Minimum execution time: 30_507 nanoseconds. - Weight::from_parts(32_853_000, 14163) + // Measured: `2498` + // Estimated: `14919` + // Minimum execution time: 30_391 nanoseconds. + Weight::from_parts(44_297_000, 14919) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Reward SetRewardOrigins (r:1 w:0) // Proof Skipped: Reward SetRewardOrigins (max_values: None, max_size: None, mode: Measured) + // Storage: System Account (r:1 w:1) + // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) // Storage: Reward Campaigns (r:1 w:1) // Proof Skipped: Reward Campaigns (max_values: None, max_size: None, mode: Measured) // Storage: Reward CampaignMerkleRoots (r:1 w:1) @@ -232,12 +234,12 @@ impl WeightInfo for SubstrateWeight { // Storage: Re // Proof Skipped: unknown `0x0000000000000000000000000000000000000000000000000000000000000001` (r:0 w:1) fn set_nft_reward_root() -> Weight { // Proof Size summary in bytes: - // Measured: `2525` - // Estimated: `17525` - // Minimum execution time: 28_447 nanoseconds. - Weight::from_parts(32_100_000, 17525) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) + // Measured: `3388` + // Estimated: `23580` + // Minimum execution time: 43_705 nanoseconds. + Weight::from_parts(51_800_000, 23580) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } // Storage: Reward Campaigns (r:1 w:1) // Proof Skipped: Reward Campaigns (max_values: None, max_size: None, mode: Measured) @@ -253,10 +255,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Re // Proof Skipped: unknown `0xd861ea1ebf4800d4b89f4ff787ad79ee96d9a708c85b57da7eb8f9ddeda61291` (r:0 w:1) fn close_campaign() -> Weight { // Proof Size summary in bytes: - // Measured: `2822` - // Estimated: `21663` - // Minimum execution time: 58_441 nanoseconds. - Weight::from_parts(67_727_000, 21663) + // Measured: `2990` + // Estimated: `22503` + // Minimum execution time: 65_125 nanoseconds. + Weight::from_parts(68_700_000, 22503) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(6)) } @@ -274,10 +276,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Re // Proof Skipped: unknown `0xd861ea1ebf4800d4b89f4ff787ad79ee96d9a708c85b57da7eb8f9ddeda61291` (r:0 w:1) fn close_nft_campaign() -> Weight { // Proof Size summary in bytes: - // Measured: `3630` - // Estimated: `30653` - // Minimum execution time: 56_085 nanoseconds. - Weight::from_parts(61_669_000, 30653) + // Measured: `4050` + // Estimated: `32753` + // Minimum execution time: 58_319 nanoseconds. + Weight::from_parts(61_489_000, 32753) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(7)) } @@ -287,10 +289,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Re // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn cancel_campaign() -> Weight { // Proof Size summary in bytes: - // Measured: `2362` - // Estimated: `7440` - // Minimum execution time: 45_290 nanoseconds. - Weight::from_parts(46_849_000, 7440) + // Measured: `2446` + // Estimated: `7524` + // Minimum execution time: 45_410 nanoseconds. + Weight::from_parts(45_875_000, 7524) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -302,23 +304,25 @@ impl WeightInfo for SubstrateWeight { // Storage: Re // Proof Skipped: OrmlNFT Tokens (max_values: None, max_size: None, mode: Measured) fn cancel_nft_campaign() -> Weight { // Proof Size summary in bytes: - // Measured: `2789` - // Estimated: `13131` - // Minimum execution time: 40_938 nanoseconds. - Weight::from_parts(42_579_000, 13131) + // Measured: `2957` + // Estimated: `13467` + // Minimum execution time: 40_537 nanoseconds. + Weight::from_parts(41_755_000, 13467) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Reward SetRewardOrigins (r:1 w:1) // Proof Skipped: Reward SetRewardOrigins (max_values: None, max_size: None, mode: Measured) + // Storage: System Account (r:1 w:1) + // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn add_set_reward_origin() -> Weight { // Proof Size summary in bytes: - // Measured: `961` - // Estimated: `3436` - // Minimum execution time: 13_783 nanoseconds. - Weight::from_parts(15_236_000, 3436) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Measured: `1488` + // Estimated: `6566` + // Minimum execution time: 27_982 nanoseconds. + Weight::from_parts(29_035_000, 6566) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Reward SetRewardOrigins (r:1 w:1) // Proof Skipped: Reward SetRewardOrigins (max_values: None, max_size: None, mode: Measured) @@ -326,8 +330,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Re // Proof Size summary in bytes: // Measured: `1035` // Estimated: `3510` - // Minimum execution time: 15_136 nanoseconds. - Weight::from_parts(15_816_000, 3510) + // Minimum execution time: 20_051 nanoseconds. + Weight::from_parts(21_305_000, 3510) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -335,97 +339,97 @@ impl WeightInfo for SubstrateWeight { // Storage: Re // Proof Skipped: Reward Campaigns (max_values: None, max_size: None, mode: Measured) fn on_finalize() -> Weight { // Proof Size summary in bytes: - // Measured: `1803` - // Estimated: `6753` - // Minimum execution time: 18_647 nanoseconds. - Weight::from_parts(19_256_000, 6753) + // Measured: `1887` + // Estimated: `6837` + // Minimum execution time: 32_231 nanoseconds. + Weight::from_parts(35_303_000, 6837) .saturating_add(T::DbWeight::get().reads(2)) } } // For backwards compatibility and tests impl WeightInfo for () { fn create_campaign() -> Weight { - Weight::from_parts(47_856_000, 12368) + Weight::from_parts(56_713_000, 12368) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(6)) } fn create_nft_campaign() -> Weight { - Weight::from_parts(51_776_000, 26330) + Weight::from_parts(58_468_000, 26918) .saturating_add(RocksDbWeight::get().reads(5)) .saturating_add(RocksDbWeight::get().writes(7)) } fn claim_reward() -> Weight { - Weight::from_parts(43_780_000, 13249) + Weight::from_parts(42_927_000, 13585) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(3)) } fn claim_reward_root() -> Weight { - Weight::from_parts(50_524_000, 24159) + Weight::from_parts(51_031_000, 24831) .saturating_add(RocksDbWeight::get().reads(5)) .saturating_add(RocksDbWeight::get().writes(3)) } fn claim_nft_reward() -> Weight { - Weight::from_parts(52_709_000, 33438) + Weight::from_parts(53_120_000, 34950) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } fn claim_nft_reward_root() -> Weight { - Weight::from_parts(118_897_000, 41895) + Weight::from_parts(79_172_000, 44835) .saturating_add(RocksDbWeight::get().reads(7)) .saturating_add(RocksDbWeight::get().writes(2)) } fn set_reward() -> Weight { - Weight::from_parts(30_996_000, 13950) + Weight::from_parts(40_981_000, 14454) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(2)) } fn set_reward_root() -> Weight { - Weight::from_parts(31_147_000, 18600) + Weight::from_parts(42_695_000, 19272) .saturating_add(RocksDbWeight::get().reads(4)) .saturating_add(RocksDbWeight::get().writes(3)) } fn set_nft_reward() -> Weight { - Weight::from_parts(32_853_000, 14163) + Weight::from_parts(44_297_000, 14919) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(2)) } fn set_nft_reward_root() -> Weight { - Weight::from_parts(32_100_000, 17525) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(3)) + Weight::from_parts(51_800_000, 23580) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(4)) } fn close_campaign() -> Weight { - Weight::from_parts(67_727_000, 21663) + Weight::from_parts(68_700_000, 22503) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(6)) } fn close_nft_campaign() -> Weight { - Weight::from_parts(61_669_000, 30653) + Weight::from_parts(61_489_000, 32753) .saturating_add(RocksDbWeight::get().reads(5)) .saturating_add(RocksDbWeight::get().writes(7)) } fn cancel_campaign() -> Weight { - Weight::from_parts(46_849_000, 7440) + Weight::from_parts(45_875_000, 7524) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(2)) } fn cancel_nft_campaign() -> Weight { - Weight::from_parts(42_579_000, 13131) + Weight::from_parts(41_755_000, 13467) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(3)) } fn add_set_reward_origin() -> Weight { - Weight::from_parts(15_236_000, 3436) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) + Weight::from_parts(29_035_000, 6566) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) } fn remove_set_reward_origin() -> Weight { - Weight::from_parts(15_816_000, 3510) + Weight::from_parts(21_305_000, 3510) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(1)) } fn on_finalize() -> Weight { - Weight::from_parts(19_256_000, 6753) + Weight::from_parts(35_303_000, 6837) .saturating_add(RocksDbWeight::get().reads(2)) } } diff --git a/runtime/common/src/mock.rs b/runtime/common/src/mock.rs index 8d71b2460..7d99dbf43 100644 --- a/runtime/common/src/mock.rs +++ b/runtime/common/src/mock.rs @@ -390,6 +390,7 @@ impl CheckAuctionItemHandler for MockAuctionManager { parameter_types! { pub MaxClassMetadata: u32 = 1024; pub MaxTokenMetadata: u32 = 1024; + pub StorageDepositFee: Balance = 1; } impl orml_nft::Config for Runtime { @@ -409,6 +410,8 @@ impl evm_mapping::Config for Runtime { type ChainId = (); type TransferAll = OrmlCurrencies; type WeightInfo = (); + type StorageDepositFee = StorageDepositFee; + type NetworkTreasuryAccount = TreasuryModuleAccount; } parameter_types! { @@ -435,6 +438,7 @@ impl nft_pallet::Config for Runtime { type MiningResourceId = MiningCurrencyId; type AssetMintingFee = AssetMintingFee; type ClassMintingFee = ClassMintingFee; + type StorageDepositFee = StorageDepositFee; } // Configure a mock runtime to test the pallet. diff --git a/runtime/common/src/tests/currencies.rs b/runtime/common/src/tests/currencies.rs index 7d4c403b3..8ab5cf926 100644 --- a/runtime/common/src/tests/currencies.rs +++ b/runtime/common/src/tests/currencies.rs @@ -210,27 +210,30 @@ fn total_supply_of_native_currencies_works() { #[test] fn balance_of_foreign_currencies_works() { - ExtBuilder::default().build().execute_with(|| { - Currencies::update_balance( - RuntimeOrigin::root(), - alice_account_id(), - FungibleTokenId::MiningResource(0), - 100000, - ); - EvmMapping::claim_default_account(RuntimeOrigin::signed(alice_account_id())); + ExtBuilder::default() + .with_balances(vec![(alice_account_id(), 10000)]) + .build() + .execute_with(|| { + Currencies::update_balance( + RuntimeOrigin::root(), + alice_account_id(), + FungibleTokenId::MiningResource(0), + 100000, + ); + EvmMapping::claim_default_account(RuntimeOrigin::signed(alice_account_id())); - precompiles() - .prepare_test( - alice_evm_addr(), - bit_evm_address(), - EvmDataWriter::new_with_selector(Action::BalanceOf) - .write(Address::from(alice_evm_addr())) - .build(), - ) - .expect_cost(0) - .expect_no_logs() - .execute_returns(EvmDataWriter::new().write(U256::from(100000u64)).build()); - }); + precompiles() + .prepare_test( + alice_evm_addr(), + bit_evm_address(), + EvmDataWriter::new_with_selector(Action::BalanceOf) + .write(Address::from(alice_evm_addr())) + .build(), + ) + .expect_cost(0) + .expect_no_logs() + .execute_returns(EvmDataWriter::new().write(U256::from(100000u64)).build()); + }); } #[test] @@ -251,7 +254,7 @@ fn balance_of_native_currencies_works() { ) .expect_cost(0) .expect_no_logs() - .execute_returns(EvmDataWriter::new().write(U256::from(100000u64)).build()); + .execute_returns(EvmDataWriter::new().write(U256::from(99999u64)).build()); }); } @@ -334,11 +337,11 @@ fn transfer_native_currencies_works() { assert_eq!( ::NativeCurrency::free_balance(&bob_account_id()), - 151000 + 150999 ); assert_eq!( ::NativeCurrency::free_balance(&alice_account_id()), - 99000 + 98999 ); }); } diff --git a/runtime/common/src/tests/nft.rs b/runtime/common/src/tests/nft.rs index a470dcf19..e17f1cc46 100644 --- a/runtime/common/src/tests/nft.rs +++ b/runtime/common/src/tests/nft.rs @@ -212,7 +212,7 @@ fn mint_nft_works() { #[test] fn transfer_nft_works() { ExtBuilder::default() - .with_balances(vec![(alice_account_id(), 100000)]) + .with_balances(vec![(alice_account_id(), 100000), (bob_account_id(), 15000)]) .build() .execute_with(|| { init_test_nft(RuntimeOrigin::signed(alice_account_id())); diff --git a/runtime/continuum/src/lib.rs b/runtime/continuum/src/lib.rs index c8f71f46c..395a5d14c 100644 --- a/runtime/continuum/src/lib.rs +++ b/runtime/continuum/src/lib.rs @@ -99,6 +99,9 @@ mod weights; /// Constant values used within the runtime. pub mod constants; +/// Base storage fee +pub const BASE_STORAGE_FEE: Balance = 1 * DOLLARS; + /// Alias to 512-bit hash when used in the context of a transaction signature on the chain. pub type Signature = MultiSignature; @@ -679,7 +682,7 @@ impl pallet_democracy::Config for Runtime { parameter_type_with_key! { pub ExistentialDeposits: |_currency_id: FungibleTokenId| -> Balance { - Zero::zero() + EXISTENTIAL_DEPOSIT }; } @@ -1407,6 +1410,7 @@ parameter_types! { //Mining Resource Currency Id pub const MiningResourceCurrencyId: FungibleTokenId = FungibleTokenId::MiningResource(0); pub const TreasuryStakingReward: Perbill = Perbill::from_percent(1); + pub MiningStorageDeposit: Balance = BASE_STORAGE_FEE; } impl mining::Config for Runtime { @@ -1418,6 +1422,9 @@ impl mining::Config for Runtime { type AdminOrigin = EnsureRootOrMetaverseTreasury; type MetaverseStakingHandler = Metaverse; type TreasuryStakingReward = TreasuryStakingReward; + type NetworkTreasuryAccount = TreasuryModuleAccount; + type StorageDepositFee = MiningStorageDeposit; + type Currency = Balances; type WeightInfo = weights::module_mining::WeightInfo; } @@ -1427,6 +1434,7 @@ parameter_types! { pub MaxBatchTransfer: u32 = 100; pub MaxBatchMinting: u32 = 1000; pub MaxNftMetadata: u32 = 1024; + pub StorageDepositFee: Balance = BASE_STORAGE_FEE; } impl nft::Config for Runtime { @@ -1443,6 +1451,7 @@ impl nft::Config for Runtime { type MiningResourceId = MiningResourceCurrencyId; type AssetMintingFee = AssetMintingFee; type ClassMintingFee = ClassMintingFee; + type StorageDepositFee = StorageDepositFee; } parameter_types! { @@ -1464,10 +1473,12 @@ parameter_types! { pub MaxMetaverseMetadata: u32 = 1024; pub MinContribution: Balance = 50 * DOLLARS; pub MaxNumberOfStakersPerMetaverse: u32 = 512; + pub MetaverseStorageFee: Balance = 2 * BASE_STORAGE_FEE; } impl metaverse::Config for Runtime { type RuntimeEvent = RuntimeEvent; + type NetworkTreasury = TreasuryModuleAccount; type MetaverseTreasury = LocalMetaverseFundPalletId; type Currency = Balances; type MaxMetaverseMetadata = MaxMetaverseMetadata; @@ -1479,6 +1490,7 @@ impl metaverse::Config for Runtime { type MaxNumberOfStakersPerMetaverse = MaxNumberOfStakersPerMetaverse; type MultiCurrency = Currencies; type NFTHandler = Nft; + type StorageDepositFee = MetaverseStorageFee; } parameter_types! { @@ -1493,6 +1505,7 @@ parameter_types! { pub const MinLeasePricePerBlock: Balance = 1 * CENTS; pub const MaxLeasePeriod: u32 = 1000000; pub const LeaseOfferExpiryPeriod: u32 = 10000; + pub const EstateStorageFee: Balance = BASE_STORAGE_FEE; } impl estate::Config for Runtime { @@ -1515,6 +1528,7 @@ impl estate::Config for Runtime { type MaxLeasePeriod = MaxLeasePeriod; type LeaseOfferExpiryPeriod = LeaseOfferExpiryPeriod; type BlockNumberToBalance = ConvertInto; + type StorageDepositFee = EstateStorageFee; } parameter_types! { @@ -1529,6 +1543,7 @@ parameter_types! { pub const OfferDuration: BlockNumber = 100800; // Default 100800 Blocks pub const MinimumListingPrice: Balance = DOLLARS; pub const AntiSnipeDuration: BlockNumber = 50; // Minimum anti snipe duration is 50 blocks + pub const AuctionStorageFee: Balance = 3 * BASE_STORAGE_FEE; } impl auction::Config for Runtime { @@ -1550,8 +1565,12 @@ impl auction::Config for Runtime { type OfferDuration = OfferDuration; type MinimumListingPrice = MinimumListingPrice; type AntiSnipeDuration = AntiSnipeDuration; + type StorageDepositFee = AuctionStorageFee; } +parameter_types! { + pub const ContinuumStorageDeposit: Balance = BASE_STORAGE_FEE; +} impl continuum::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SessionDuration = ContinuumSessionDuration; @@ -1562,6 +1581,7 @@ impl continuum::Config for Runtime { type ContinuumTreasury = MetaverseNetworkTreasuryPalletId; type Currency = Balances; type MetaverseInfoSource = Metaverse; + type StorageDepositFee = ContinuumStorageDeposit; type WeightInfo = weights::module_continuum::WeightInfo; } @@ -1728,6 +1748,7 @@ parameter_types! { pub const MinimumCampaignDuration: BlockNumber = 30 * MINUTES; pub const MaxSetRewardsListLength: u64 = 200; pub const MaxLeafNodes: u32 = 30; + pub const RewardStorageFee: Balance = BASE_STORAGE_FEE; } impl reward::Config for Runtime { @@ -1744,6 +1765,7 @@ impl reward::Config for Runtime { type MaxSetRewardsListLength = MaxSetRewardsListLength; type AdminOrigin = EnsureRootOrMetaverseTreasury; type NFTHandler = Nft; + type StorageDepositFee = RewardStorageFee; type WeightInfo = weights::module_reward::WeightInfo; } diff --git a/runtime/continuum/src/weights/module_auction.rs b/runtime/continuum/src/weights/module_auction.rs index d83fe09af..fefdcf436 100644 --- a/runtime/continuum/src/weights/module_auction.rs +++ b/runtime/continuum/src/weights/module_auction.rs @@ -12,56 +12,56 @@ pub struct WeightInfo(PhantomData); impl auction::WeightInfo for WeightInfo { fn create_new_auction() -> Weight { - Weight::from_parts(83_359_000, 54013) + Weight::from_parts(61_885_000, 57373) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(7)) } fn create_new_buy_now() -> Weight { - Weight::from_parts(60_938_000, 54013) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(7)) + Weight::from_parts(74_722_000, 61706) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(8)) } fn bid() -> Weight { - Weight::from_parts(52_851_000, 17254) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(5)) + Weight::from_parts(75_918_000, 25151) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(7)) } fn buy_now() -> Weight { - Weight::from_parts(117_267_000, 74974) + Weight::from_parts(121_030_000, 78754) .saturating_add(T::DbWeight::get().reads(13)) .saturating_add(T::DbWeight::get().writes(12)) } fn cancel_listing() -> Weight { - Weight::from_parts(76_276_000, 28348) + Weight::from_parts(50_823_000, 30028) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(6)) } fn authorise_metaverse_collection() -> Weight { - Weight::from_parts(35_078_000, 7564) + Weight::from_parts(23_046_000, 7564) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn remove_authorise_metaverse_collection() -> Weight { - Weight::from_parts(24_963_000, 7670) + Weight::from_parts(23_607_000, 7670) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn make_offer() -> Weight { - Weight::from_parts(38_021_000, 15443) + Weight::from_parts(38_079_000, 15443) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } fn withdraw_offer() -> Weight { - Weight::from_parts(29_056_000, 6612) + Weight::from_parts(28_621_000, 6612) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } fn accept_offer() -> Weight { - Weight::from_parts(69_244_000, 31537) + Weight::from_parts(72_454_000, 31537) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(6)) } fn on_finalize() -> Weight { - Weight::from_parts(6_116_000, 0) + Weight::from_parts(7_467_000, 0) } } diff --git a/runtime/continuum/src/weights/module_continuum.rs b/runtime/continuum/src/weights/module_continuum.rs index 6fe4da508..73259bb20 100644 --- a/runtime/continuum/src/weights/module_continuum.rs +++ b/runtime/continuum/src/weights/module_continuum.rs @@ -9,29 +9,29 @@ pub struct WeightInfo(PhantomData); impl continuum::WeightInfo for WeightInfo { fn set_allow_buy_now() -> Weight { - Weight::from_parts(3_836_000, 646).saturating_add(T::DbWeight::get().writes(1)) + Weight::from_parts(6_650_000, 646).saturating_add(T::DbWeight::get().writes(1)) } fn set_max_bounds() -> Weight { - Weight::from_parts(10_396_000, 919).saturating_add(T::DbWeight::get().writes(1)) + Weight::from_parts(25_462_000, 919).saturating_add(T::DbWeight::get().writes(1)) } fn issue_map_slot() -> Weight { - Weight::from_parts(15_692_000, 5088) + Weight::from_parts(24_533_000, 5088) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn create_new_auction() -> Weight { - Weight::from_parts(36_453_000, 20225) + Weight::from_parts(85_653_000, 20225) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(6)) } fn buy_map_spot() -> Weight { - Weight::from_parts(172_450_000, 59161) + Weight::from_parts(170_947_000, 59161) .saturating_add(T::DbWeight::get().reads(11)) .saturating_add(T::DbWeight::get().writes(8)) } fn bid_map_spot() -> Weight { - Weight::from_parts(67_164_000, 40870) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(3)) + Weight::from_parts(120_875_000, 44418) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) } } diff --git a/runtime/continuum/src/weights/module_estate.rs b/runtime/continuum/src/weights/module_estate.rs index 5490c5349..49d8f7f85 100644 --- a/runtime/continuum/src/weights/module_estate.rs +++ b/runtime/continuum/src/weights/module_estate.rs @@ -48,121 +48,121 @@ pub struct WeightInfo(PhantomData); impl estate::WeightInfo for WeightInfo { fn mint_land() -> Weight { - Weight::from_parts(58_455_000, 36660) + Weight::from_parts(59_273_000, 36660) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(7)) } fn mint_lands() -> Weight { - Weight::from_parts(85_264_000, 41610) + Weight::from_parts(83_541_000, 41610) .saturating_add(T::DbWeight::get().reads(10)) .saturating_add(T::DbWeight::get().writes(10)) } fn transfer_land() -> Weight { - Weight::from_parts(98_162_000, 28255) + Weight::from_parts(47_423_000, 28255) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } fn mint_estate() -> Weight { - Weight::from_parts(70_956_000, 47210) + Weight::from_parts(64_479_000, 47210) .saturating_add(T::DbWeight::get().reads(10)) .saturating_add(T::DbWeight::get().writes(11)) } fn dissolve_estate() -> Weight { - Weight::from_parts(90_916_000, 62718) - .saturating_add(T::DbWeight::get().reads(13)) - .saturating_add(T::DbWeight::get().writes(12)) + Weight::from_parts(110_008_000, 67224) + .saturating_add(T::DbWeight::get().reads(14)) + .saturating_add(T::DbWeight::get().writes(13)) } fn add_land_unit_to_estate() -> Weight { - Weight::from_parts(57_930_000, 31521) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(5)) + Weight::from_parts(71_706_000, 38079) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(6)) } fn remove_land_unit_from_estate() -> Weight { - Weight::from_parts(172_334_000, 55893) - .saturating_add(T::DbWeight::get().reads(11)) - .saturating_add(T::DbWeight::get().writes(7)) + Weight::from_parts(90_257_000, 60226) + .saturating_add(T::DbWeight::get().reads(12)) + .saturating_add(T::DbWeight::get().writes(8)) } fn create_estate() -> Weight { - Weight::from_parts(123_103_000, 66058) + Weight::from_parts(131_741_000, 66058) .saturating_add(T::DbWeight::get().reads(14)) .saturating_add(T::DbWeight::get().writes(17)) } fn transfer_estate() -> Weight { - Weight::from_parts(54_578_000, 38025) + Weight::from_parts(54_808_000, 38025) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(4)) } fn issue_undeployed_land_blocks() -> Weight { - Weight::from_parts(146_607_000, 4962) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(42)) + Weight::from_parts(162_875_000, 9825) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(43)) } fn freeze_undeployed_land_blocks() -> Weight { - Weight::from_parts(21_200_000, 7834) + Weight::from_parts(22_833_000, 7834) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn unfreeze_undeployed_land_blocks() -> Weight { - Weight::from_parts(47_505_000, 7834) + Weight::from_parts(21_423_000, 7834) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn approve_undeployed_land_blocks() -> Weight { - Weight::from_parts(21_983_000, 7834) + Weight::from_parts(21_819_000, 7834) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn unapprove_undeployed_land_blocks() -> Weight { - Weight::from_parts(20_803_000, 7900) + Weight::from_parts(21_237_000, 7900) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn transfer_undeployed_land_blocks() -> Weight { - Weight::from_parts(24_091_000, 9276) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(3)) + Weight::from_parts(41_173_000, 13673) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(4)) } fn deploy_land_block() -> Weight { - Weight::from_parts(94_020_000, 64897) + Weight::from_parts(100_659_000, 64897) .saturating_add(T::DbWeight::get().reads(13)) .saturating_add(T::DbWeight::get().writes(11)) } fn burn_undeployed_land_blocks() -> Weight { - Weight::from_parts(23_737_000, 10661) + Weight::from_parts(32_196_000, 10661) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } fn create_lease_offer() -> Weight { - Weight::from_parts(43_758_000, 27383) + Weight::from_parts(98_902_000, 27383) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(2)) } fn accept_lease_offer() -> Weight { - Weight::from_parts(39_408_000, 22653) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) + Weight::from_parts(57_019_000, 28844) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) } fn cancel_lease() -> Weight { - Weight::from_parts(61_047_000, 27227) + Weight::from_parts(57_720_000, 28571) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } fn remove_expired_lease() -> Weight { - Weight::from_parts(57_210_000, 27227) + Weight::from_parts(57_681_000, 28571) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } fn remove_lease_offer() -> Weight { - Weight::from_parts(32_044_000, 8076) + Weight::from_parts(41_923_000, 8328) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } fn collect_rent() -> Weight { - Weight::from_parts(52_885_000, 27227) + Weight::from_parts(53_171_000, 28571) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } fn on_initialize() -> Weight { - Weight::from_parts(181_000, 0) + Weight::from_parts(191_000, 0) } } \ No newline at end of file diff --git a/runtime/continuum/src/weights/module_metaverse.rs b/runtime/continuum/src/weights/module_metaverse.rs index 5764ff2aa..6540fec1a 100644 --- a/runtime/continuum/src/weights/module_metaverse.rs +++ b/runtime/continuum/src/weights/module_metaverse.rs @@ -47,37 +47,37 @@ pub struct WeightInfo(PhantomData); impl metaverse::WeightInfo for WeightInfo{ fn create_metaverse() -> Weight { - Weight::from_parts(73_237_000, 27361) + Weight::from_parts(144_874_000, 27361) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(12)) } fn transfer_metaverse() -> Weight { - Weight::from_parts(21_461_000, 7534) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(3)) + Weight::from_parts(53_412_000, 13860) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(5)) } fn freeze_metaverse() -> Weight { - Weight::from_parts(18_064_000, 3722) + Weight::from_parts(26_870_000, 3722) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } fn unfreeze_metaverse() -> Weight { - Weight::from_parts(16_778_000, 3722) + Weight::from_parts(27_836_000, 3722) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } fn destroy_metaverse() -> Weight { - Weight::from_parts(18_411_000, 4969) + Weight::from_parts(28_903_000, 4969) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } fn update_metaverse_listing_fee() -> Weight { - Weight::from_parts(19_747_000, 7534) + Weight::from_parts(30_034_000, 7534) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn withdraw_from_metaverse_fund() -> Weight { - Weight::from_parts(34_242_000, 9444) + Weight::from_parts(47_894_000, 9444) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } diff --git a/runtime/continuum/src/weights/module_mining.rs b/runtime/continuum/src/weights/module_mining.rs index 58b9dbe3c..4b5aba1a0 100644 --- a/runtime/continuum/src/weights/module_mining.rs +++ b/runtime/continuum/src/weights/module_mining.rs @@ -9,52 +9,52 @@ pub struct WeightInfo(PhantomData); impl mining::WeightInfo for WeightInfo { fn add_minting_origin() -> Weight { - Weight::from_parts(8_665_000, 2551) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + Weight::from_parts(47_273_000, 8027) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } fn remove_minting_origin() -> Weight { - Weight::from_parts(9_396_000, 2625) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + Weight::from_parts(22_628_000, 8101) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } fn update_round_length() -> Weight { - Weight::from_parts(7_040_000, 571) + Weight::from_parts(7_119_000, 571) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } fn update_mining_issuance_config() -> Weight { - Weight::from_parts(8_115_000, 647) + Weight::from_parts(7_988_000, 647) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } fn mint() -> Weight { - Weight::from_parts(22_826_000, 8043) + Weight::from_parts(23_623_000, 8043) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } fn burn() -> Weight { - Weight::from_parts(24_969_000, 8043) + Weight::from_parts(24_990_000, 8043) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } fn deposit() -> Weight { - Weight::from_parts(31_798_000, 10398) + Weight::from_parts(32_866_000, 10398) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } fn withdraw() -> Weight { - Weight::from_parts(29_933_000, 10997) + Weight::from_parts(31_275_000, 10997) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } fn pause_mining_round() -> Weight { - Weight::from_parts(8_074_000, 1142) + Weight::from_parts(20_520_000, 1142) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn unpause_mining_round() -> Weight { - Weight::from_parts(8_775_000, 1190) + Weight::from_parts(22_937_000, 1190) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/runtime/continuum/src/weights/module_nft.rs b/runtime/continuum/src/weights/module_nft.rs index d0883c585..86909c591 100644 --- a/runtime/continuum/src/weights/module_nft.rs +++ b/runtime/continuum/src/weights/module_nft.rs @@ -12,57 +12,57 @@ pub struct WeightInfo(PhantomData); impl nft::WeightInfo for WeightInfo { fn create_group() -> Weight { - Weight::from_parts(12_179_000, 1317) + Weight::from_parts(12_117_000, 1317) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(3)) } fn create_class() -> Weight { - Weight::from_parts(27_797_000, 7417) + Weight::from_parts(37_465_000, 7417) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } fn mint() -> Weight { - Weight::from_parts(54_185_000, 23976) + Weight::from_parts(69_706_000, 23976) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(10)) } fn mint_stackable_nft() -> Weight { - Weight::from_parts(41_846_000, 15931) + Weight::from_parts(111_946_000, 15931) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(8)) } fn transfer() -> Weight { - Weight::from_parts(32_122_000, 17187) + Weight::from_parts(33_226_000, 17187) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } fn transfer_stackable_nft() -> Weight { - Weight::from_parts(28_373_000, 11790) + Weight::from_parts(28_946_000, 11790) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } fn transfer_batch() -> Weight { - Weight::from_parts(112_127_000, 25680) + Weight::from_parts(63_183_000, 25680) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(6)) } fn sign_asset() -> Weight { - Weight::from_parts(38_782_000, 11890) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) + Weight::from_parts(115_994_000, 14763) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) } fn set_hard_limit() -> Weight { - Weight::from_parts(15_065_000, 2757) + Weight::from_parts(23_425_000, 2757) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } fn withdraw_funds_from_class_fund() -> Weight { - Weight::from_parts(25_576_000, 8268) + Weight::from_parts(61_491_000, 8268) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } fn force_update_total_issuance() -> Weight { - Weight::from_parts(11_211_000, 2757) + Weight::from_parts(27_207_000, 2757) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/runtime/continuum/src/weights/module_reward.rs b/runtime/continuum/src/weights/module_reward.rs index 3e6372d47..d2e58c58d 100644 --- a/runtime/continuum/src/weights/module_reward.rs +++ b/runtime/continuum/src/weights/module_reward.rs @@ -11,86 +11,86 @@ use sp_std::marker::PhantomData; pub struct WeightInfo(PhantomData); impl reward::WeightInfo for WeightInfo { fn create_campaign() -> Weight { - Weight::from_parts(47_856_000, 12368) + Weight::from_parts(56_713_000, 12368) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(6)) } fn create_nft_campaign() -> Weight { - Weight::from_parts(51_776_000, 26330) + Weight::from_parts(58_468_000, 26918) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(7)) } fn claim_reward() -> Weight { - Weight::from_parts(43_780_000, 13249) + Weight::from_parts(42_927_000, 13585) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } fn claim_reward_root() -> Weight { - Weight::from_parts(50_524_000, 24159) + Weight::from_parts(51_031_000, 24831) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } fn claim_nft_reward() -> Weight { - Weight::from_parts(52_709_000, 33438) + Weight::from_parts(53_120_000, 34950) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } fn claim_nft_reward_root() -> Weight { - Weight::from_parts(118_897_000, 41895) + Weight::from_parts(79_172_000, 44835) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(2)) } fn set_reward() -> Weight { - Weight::from_parts(30_996_000, 13950) + Weight::from_parts(40_981_000, 14454) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } fn set_reward_root() -> Weight { - Weight::from_parts(31_147_000, 18600) + Weight::from_parts(42_695_000, 19272) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } fn set_nft_reward() -> Weight { - Weight::from_parts(32_853_000, 14163) + Weight::from_parts(44_297_000, 14919) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } fn set_nft_reward_root() -> Weight { - Weight::from_parts(32_100_000, 17525) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) + Weight::from_parts(51_800_000, 23580) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } fn close_campaign() -> Weight { - Weight::from_parts(67_727_000, 21663) + Weight::from_parts(68_700_000, 22503) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(6)) } fn close_nft_campaign() -> Weight { - Weight::from_parts(61_669_000, 30653) + Weight::from_parts(61_489_000, 32753) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(7)) } fn cancel_campaign() -> Weight { - Weight::from_parts(46_849_000, 7440) + Weight::from_parts(45_875_000, 7524) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } fn cancel_nft_campaign() -> Weight { - Weight::from_parts(42_579_000, 13131) + Weight::from_parts(41_755_000, 13467) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } fn add_set_reward_origin() -> Weight { - Weight::from_parts(15_236_000, 3436) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + Weight::from_parts(29_035_000, 6566) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } fn remove_set_reward_origin() -> Weight { - Weight::from_parts(15_816_000, 3510) + Weight::from_parts(21_305_000, 3510) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } fn on_finalize() -> Weight { - Weight::from_parts(19_256_000, 6753).saturating_add(T::DbWeight::get().reads(2)) + Weight::from_parts(35_303_000, 6837).saturating_add(T::DbWeight::get().reads(2)) } } diff --git a/runtime/metaverse/src/benchmarking/estate.rs b/runtime/metaverse/src/benchmarking/estate.rs index 064b58f8d..38466d5cd 100644 --- a/runtime/metaverse/src/benchmarking/estate.rs +++ b/runtime/metaverse/src/benchmarking/estate.rs @@ -230,7 +230,8 @@ runtime_benchmarks! { let caller_lookup = ::Lookup::unlookup(caller.clone()); set_balance(CURRENCY_ID, &caller, dollar(1000)); create_nft_group(); - issue_new_undeployed_land_block(5)?; + set_metaverse_treasury_initial_balance(); + issue_new_undeployed_land_block(caller, 5)?; }: _(RawOrigin::Root, Default::default()) verify { let issued_undeployed_land_block = Estate::get_undeployed_land_block(0); @@ -252,7 +253,8 @@ runtime_benchmarks! { let caller_lookup = ::Lookup::unlookup(caller.clone()); set_balance(CURRENCY_ID, &caller, dollar(1000)); create_nft_group(); - issue_new_undeployed_land_block(5)?; + set_metaverse_treasury_initial_balance(); + issue_new_undeployed_land_block(caller, 5)?; Estate::freeze_undeployed_land_blocks(RawOrigin::Root.into(), Default::default()); }: _(RawOrigin::Root, Default::default()) verify { @@ -277,7 +279,7 @@ runtime_benchmarks! { let target: AccountId = account("target", 0, SEED); let target_lookup = ::Lookup::unlookup(target.clone()); - set_balance(CURRENCY_ID, &target, dollar(10)); + set_balance(CURRENCY_ID, &target, dollar(1000)); create_nft_group(); Estate::issue_undeployed_land_blocks(RawOrigin::Root.into(), caller.clone(), 5, 100, UndeployedLandBlockType::BoundToAddress); }: _(RawOrigin::Signed(caller.clone()), target.clone(), Default::default()) @@ -302,7 +304,7 @@ runtime_benchmarks! { set_balance(CURRENCY_ID, &caller, dollar(1000)); let target: AccountId = account("target", 0, SEED); let target_lookup = ::Lookup::unlookup(target.clone()); - set_balance(CURRENCY_ID, &target, dollar(10)); + set_balance(CURRENCY_ID, &target, dollar(1000)); create_nft_group(); Estate::issue_undeployed_land_blocks(RawOrigin::Root.into(), caller.clone(), 5, 100, UndeployedLandBlockType::BoundToAddress); Estate::approve_undeployed_land_blocks(RawOrigin::Signed(caller.clone()).into(), target.clone(), Default::default()); @@ -329,7 +331,7 @@ runtime_benchmarks! { let target: AccountId = account("target", 0, SEED); let target_lookup = ::Lookup::unlookup(target.clone()); - set_balance(CURRENCY_ID, &target, dollar(10)); + set_balance(CURRENCY_ID, &target, dollar(1000)); create_nft_group(); Estate::issue_undeployed_land_blocks(RawOrigin::Root.into(), caller.clone(), 5, 100, UndeployedLandBlockType::Transferable); @@ -498,7 +500,11 @@ runtime_benchmarks! { max: 100_000_000, }; // Pre issue 5 land blocks x 100 land units - issue_new_undeployed_land_block(5)?; + let caller: AccountId = whitelisted_caller(); + let caller_lookup = ::Lookup::unlookup(caller.clone()); + set_balance(CURRENCY_ID, &caller, dollar(1000)); + set_metaverse_treasury_initial_balance(); + issue_new_undeployed_land_block(caller, 5)?; let min_block_per_round = 5u32; let new_round = RoundInfo::new(1u32, 0u32.into(), min_block_per_round.into()); diff --git a/runtime/metaverse/src/benchmarking/utils.rs b/runtime/metaverse/src/benchmarking/utils.rs index 2da105ad3..1aeef8e6d 100644 --- a/runtime/metaverse/src/benchmarking/utils.rs +++ b/runtime/metaverse/src/benchmarking/utils.rs @@ -67,9 +67,7 @@ pub fn create_nft_group() { assert_ok!(Nft::create_group(RawOrigin::Root.into(), vec![1], vec![1])); } -pub fn issue_new_undeployed_land_block(n: u32) -> Result { - let caller: AccountId = account("caller", 0, SEED); - set_balance(FungibleTokenId::NativeToken(0), &caller, 10000); +pub fn issue_new_undeployed_land_block(caller: AccountId, n: u32) -> Result { assert_ok!(Estate::issue_undeployed_land_blocks( RawOrigin::Root.into(), caller, diff --git a/runtime/metaverse/src/lib.rs b/runtime/metaverse/src/lib.rs index d4f4e8296..7da3a3aa7 100644 --- a/runtime/metaverse/src/lib.rs +++ b/runtime/metaverse/src/lib.rs @@ -123,6 +123,9 @@ mod weights; /// Constant values used within the runtime. pub mod constants; +/// Base storage fee +pub const BASE_STORAGE_FEE: Balance = 10 * CENTS; + /// Alias to 512-bit hash when used in the context of a transaction signature on the chain. pub type Signature = MultiSignature; @@ -567,6 +570,7 @@ parameter_types! { pub MaxBatchTransfer: u32 = 100; pub MaxBatchMinting: u32 = 1000; pub MaxNftMetadata: u32 = 1024; + pub const StorageDepositFee: Balance = BASE_STORAGE_FEE; } impl nft::Config for Runtime { @@ -583,6 +587,7 @@ impl nft::Config for Runtime { type MiningResourceId = MiningResourceCurrencyId; type AssetMintingFee = AssetMintingFee; type ClassMintingFee = ClassMintingFee; + type StorageDepositFee = StorageDepositFee; } parameter_types! { @@ -604,11 +609,13 @@ parameter_types! { pub MaxMetaverseMetadata: u32 = 1024; pub MinContribution: Balance = 50 * DOLLARS; pub MaxNumberOfStakerPerMetaverse: u32 = 512; + pub MetaverseStorageFee: Balance = 2 * BASE_STORAGE_FEE; } impl metaverse::Config for Runtime { type RuntimeEvent = RuntimeEvent; type MetaverseTreasury = LocalMetaverseFundPalletId; + type NetworkTreasury = TreasuryModuleAccount; type Currency = Balances; type MaxMetaverseMetadata = MaxMetaverseMetadata; type MinContribution = MinContribution; @@ -619,6 +626,7 @@ impl metaverse::Config for Runtime { type MaxNumberOfStakersPerMetaverse = MaxNumberOfStakerPerMetaverse; type MultiCurrency = Currencies; type NFTHandler = Nft; + type StorageDepositFee = MetaverseStorageFee; } parameter_types! { @@ -634,6 +642,7 @@ parameter_types! { pub const MaxLeasePeriod: u32 = 1000000; pub const LeaseOfferExpiryPeriod: u32 = 10000; pub const MaximumEstateStake: Balance = 1000 * DOLLARS; + pub const EstateStorageFee: Balance = BASE_STORAGE_FEE; } impl estate::Config for Runtime { @@ -656,6 +665,7 @@ impl estate::Config for Runtime { type MaxLeasePeriod = MaxLeasePeriod; type LeaseOfferExpiryPeriod = LeaseOfferExpiryPeriod; type BlockNumberToBalance = ConvertInto; + type StorageDepositFee = EstateStorageFee; } parameter_types! { @@ -670,6 +680,7 @@ parameter_types! { pub const OfferDuration: BlockNumber = 100800; // Default 100800 Blocks pub const MinimumListingPrice: Balance = DOLLARS; pub const AntiSnipeDuration: BlockNumber = 50; // Minimum anti snipe duration is 50 blocks + pub const AuctionStorageFee: Balance = 3 * BASE_STORAGE_FEE; } impl auction::Config for Runtime { @@ -691,8 +702,12 @@ impl auction::Config for Runtime { type OfferDuration = OfferDuration; type MinimumListingPrice = MinimumListingPrice; type AntiSnipeDuration = AntiSnipeDuration; + type StorageDepositFee = AuctionStorageFee; } +parameter_types! { + pub const ContinuumStorageDeposit: Balance = BASE_STORAGE_FEE; +} impl continuum::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SessionDuration = ContinuumSessionDuration; @@ -703,6 +718,7 @@ impl continuum::Config for Runtime { type ContinuumTreasury = MetaverseNetworkTreasuryPalletId; type Currency = Balances; type MetaverseInfoSource = Metaverse; + type StorageDepositFee = ContinuumStorageDeposit; type WeightInfo = weights::module_continuum::WeightInfo; } @@ -753,6 +769,7 @@ parameter_types! { //Mining Resource Currency Id pub const MiningResourceCurrencyId: FungibleTokenId = FungibleTokenId::MiningResource(0); pub const TreasuryStakingReward: Perbill = Perbill::from_percent(1); + pub MiningStorageDeposit: Balance = BASE_STORAGE_FEE; } impl mining::Config for Runtime { @@ -764,6 +781,9 @@ impl mining::Config for Runtime { type AdminOrigin = EnsureRootOrMetaverseTreasury; type MetaverseStakingHandler = Metaverse; type TreasuryStakingReward = TreasuryStakingReward; + type NetworkTreasuryAccount = TreasuryModuleAccount; + type StorageDepositFee = MiningStorageDeposit; + type Currency = Balances; type WeightInfo = weights::module_mining::WeightInfo; } @@ -1026,6 +1046,10 @@ impl InstanceFilter for ProposalType { } } +parameter_types! { + pub GovernanceStorageFee: Balance = BASE_STORAGE_FEE; +} + impl governance::Config for Runtime { type RuntimeEvent = RuntimeEvent; type DefaultPreimageByteDeposit = DefaultPreimageByteDeposit; @@ -1045,6 +1069,8 @@ impl governance::Config for Runtime { type MetaverseLandInfo = Estate; type MetaverseCouncil = EnsureRootOrMetaverseTreasury; type ProposalType = ProposalType; + type NetworkTreasury = TreasuryModuleAccount; + type StorageDepositFee = GovernanceStorageFee; } impl crowdloan::Config for Runtime { @@ -1347,6 +1373,7 @@ parameter_types! { pub const MinimumCampaignDuration: BlockNumber = 1; // 7 * 7200 Around a week in blocktime pub const MaxLeafNodes: u64 = 30; pub const MaxSetRewardsListLength: u64 = 500; + pub const RewardStorageFee: Balance = BASE_STORAGE_FEE; } impl reward::Config for Runtime { @@ -1363,6 +1390,7 @@ impl reward::Config for Runtime { type AdminOrigin = EnsureRootOrMetaverseTreasury; type NFTHandler = Nft; type MaxLeafNodes = MaxLeafNodes; + type StorageDepositFee = StorageDepositFee; type WeightInfo = weights::module_reward::WeightInfo; } @@ -1381,12 +1409,19 @@ impl orml_currencies::Config for Runtime { type WeightInfo = (); } +parameter_types! { + pub EvmMappingStorageFee: Balance = 2 * BASE_STORAGE_FEE; // Each extrinsic in the pallet has exactly 2 storage inserts + +} + impl evm_mapping::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; type AddressMapping = EvmAddressMapping; type ChainId = ChainId; type TransferAll = OrmlCurrencies; + type NetworkTreasuryAccount = TreasuryModuleAccount; + type StorageDepositFee = EvmMappingStorageFee; type WeightInfo = weights::module_evm_mapping::WeightInfo; } diff --git a/runtime/metaverse/src/weights/module_auction.rs b/runtime/metaverse/src/weights/module_auction.rs index d83fe09af..fefdcf436 100644 --- a/runtime/metaverse/src/weights/module_auction.rs +++ b/runtime/metaverse/src/weights/module_auction.rs @@ -12,56 +12,56 @@ pub struct WeightInfo(PhantomData); impl auction::WeightInfo for WeightInfo { fn create_new_auction() -> Weight { - Weight::from_parts(83_359_000, 54013) + Weight::from_parts(61_885_000, 57373) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(7)) } fn create_new_buy_now() -> Weight { - Weight::from_parts(60_938_000, 54013) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(7)) + Weight::from_parts(74_722_000, 61706) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(8)) } fn bid() -> Weight { - Weight::from_parts(52_851_000, 17254) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(5)) + Weight::from_parts(75_918_000, 25151) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(7)) } fn buy_now() -> Weight { - Weight::from_parts(117_267_000, 74974) + Weight::from_parts(121_030_000, 78754) .saturating_add(T::DbWeight::get().reads(13)) .saturating_add(T::DbWeight::get().writes(12)) } fn cancel_listing() -> Weight { - Weight::from_parts(76_276_000, 28348) + Weight::from_parts(50_823_000, 30028) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(6)) } fn authorise_metaverse_collection() -> Weight { - Weight::from_parts(35_078_000, 7564) + Weight::from_parts(23_046_000, 7564) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn remove_authorise_metaverse_collection() -> Weight { - Weight::from_parts(24_963_000, 7670) + Weight::from_parts(23_607_000, 7670) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn make_offer() -> Weight { - Weight::from_parts(38_021_000, 15443) + Weight::from_parts(38_079_000, 15443) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } fn withdraw_offer() -> Weight { - Weight::from_parts(29_056_000, 6612) + Weight::from_parts(28_621_000, 6612) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } fn accept_offer() -> Weight { - Weight::from_parts(69_244_000, 31537) + Weight::from_parts(72_454_000, 31537) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(6)) } fn on_finalize() -> Weight { - Weight::from_parts(6_116_000, 0) + Weight::from_parts(7_467_000, 0) } } diff --git a/runtime/metaverse/src/weights/module_continuum.rs b/runtime/metaverse/src/weights/module_continuum.rs index 6fe4da508..73259bb20 100644 --- a/runtime/metaverse/src/weights/module_continuum.rs +++ b/runtime/metaverse/src/weights/module_continuum.rs @@ -9,29 +9,29 @@ pub struct WeightInfo(PhantomData); impl continuum::WeightInfo for WeightInfo { fn set_allow_buy_now() -> Weight { - Weight::from_parts(3_836_000, 646).saturating_add(T::DbWeight::get().writes(1)) + Weight::from_parts(6_650_000, 646).saturating_add(T::DbWeight::get().writes(1)) } fn set_max_bounds() -> Weight { - Weight::from_parts(10_396_000, 919).saturating_add(T::DbWeight::get().writes(1)) + Weight::from_parts(25_462_000, 919).saturating_add(T::DbWeight::get().writes(1)) } fn issue_map_slot() -> Weight { - Weight::from_parts(15_692_000, 5088) + Weight::from_parts(24_533_000, 5088) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn create_new_auction() -> Weight { - Weight::from_parts(36_453_000, 20225) + Weight::from_parts(85_653_000, 20225) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(6)) } fn buy_map_spot() -> Weight { - Weight::from_parts(172_450_000, 59161) + Weight::from_parts(170_947_000, 59161) .saturating_add(T::DbWeight::get().reads(11)) .saturating_add(T::DbWeight::get().writes(8)) } fn bid_map_spot() -> Weight { - Weight::from_parts(67_164_000, 40870) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(3)) + Weight::from_parts(120_875_000, 44418) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) } } diff --git a/runtime/metaverse/src/weights/module_estate.rs b/runtime/metaverse/src/weights/module_estate.rs index 5490c5349..49d8f7f85 100644 --- a/runtime/metaverse/src/weights/module_estate.rs +++ b/runtime/metaverse/src/weights/module_estate.rs @@ -48,121 +48,121 @@ pub struct WeightInfo(PhantomData); impl estate::WeightInfo for WeightInfo { fn mint_land() -> Weight { - Weight::from_parts(58_455_000, 36660) + Weight::from_parts(59_273_000, 36660) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(7)) } fn mint_lands() -> Weight { - Weight::from_parts(85_264_000, 41610) + Weight::from_parts(83_541_000, 41610) .saturating_add(T::DbWeight::get().reads(10)) .saturating_add(T::DbWeight::get().writes(10)) } fn transfer_land() -> Weight { - Weight::from_parts(98_162_000, 28255) + Weight::from_parts(47_423_000, 28255) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } fn mint_estate() -> Weight { - Weight::from_parts(70_956_000, 47210) + Weight::from_parts(64_479_000, 47210) .saturating_add(T::DbWeight::get().reads(10)) .saturating_add(T::DbWeight::get().writes(11)) } fn dissolve_estate() -> Weight { - Weight::from_parts(90_916_000, 62718) - .saturating_add(T::DbWeight::get().reads(13)) - .saturating_add(T::DbWeight::get().writes(12)) + Weight::from_parts(110_008_000, 67224) + .saturating_add(T::DbWeight::get().reads(14)) + .saturating_add(T::DbWeight::get().writes(13)) } fn add_land_unit_to_estate() -> Weight { - Weight::from_parts(57_930_000, 31521) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(5)) + Weight::from_parts(71_706_000, 38079) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(6)) } fn remove_land_unit_from_estate() -> Weight { - Weight::from_parts(172_334_000, 55893) - .saturating_add(T::DbWeight::get().reads(11)) - .saturating_add(T::DbWeight::get().writes(7)) + Weight::from_parts(90_257_000, 60226) + .saturating_add(T::DbWeight::get().reads(12)) + .saturating_add(T::DbWeight::get().writes(8)) } fn create_estate() -> Weight { - Weight::from_parts(123_103_000, 66058) + Weight::from_parts(131_741_000, 66058) .saturating_add(T::DbWeight::get().reads(14)) .saturating_add(T::DbWeight::get().writes(17)) } fn transfer_estate() -> Weight { - Weight::from_parts(54_578_000, 38025) + Weight::from_parts(54_808_000, 38025) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(4)) } fn issue_undeployed_land_blocks() -> Weight { - Weight::from_parts(146_607_000, 4962) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(42)) + Weight::from_parts(162_875_000, 9825) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(43)) } fn freeze_undeployed_land_blocks() -> Weight { - Weight::from_parts(21_200_000, 7834) + Weight::from_parts(22_833_000, 7834) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn unfreeze_undeployed_land_blocks() -> Weight { - Weight::from_parts(47_505_000, 7834) + Weight::from_parts(21_423_000, 7834) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn approve_undeployed_land_blocks() -> Weight { - Weight::from_parts(21_983_000, 7834) + Weight::from_parts(21_819_000, 7834) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn unapprove_undeployed_land_blocks() -> Weight { - Weight::from_parts(20_803_000, 7900) + Weight::from_parts(21_237_000, 7900) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn transfer_undeployed_land_blocks() -> Weight { - Weight::from_parts(24_091_000, 9276) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(3)) + Weight::from_parts(41_173_000, 13673) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(4)) } fn deploy_land_block() -> Weight { - Weight::from_parts(94_020_000, 64897) + Weight::from_parts(100_659_000, 64897) .saturating_add(T::DbWeight::get().reads(13)) .saturating_add(T::DbWeight::get().writes(11)) } fn burn_undeployed_land_blocks() -> Weight { - Weight::from_parts(23_737_000, 10661) + Weight::from_parts(32_196_000, 10661) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } fn create_lease_offer() -> Weight { - Weight::from_parts(43_758_000, 27383) + Weight::from_parts(98_902_000, 27383) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(2)) } fn accept_lease_offer() -> Weight { - Weight::from_parts(39_408_000, 22653) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) + Weight::from_parts(57_019_000, 28844) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) } fn cancel_lease() -> Weight { - Weight::from_parts(61_047_000, 27227) + Weight::from_parts(57_720_000, 28571) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } fn remove_expired_lease() -> Weight { - Weight::from_parts(57_210_000, 27227) + Weight::from_parts(57_681_000, 28571) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } fn remove_lease_offer() -> Weight { - Weight::from_parts(32_044_000, 8076) + Weight::from_parts(41_923_000, 8328) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } fn collect_rent() -> Weight { - Weight::from_parts(52_885_000, 27227) + Weight::from_parts(53_171_000, 28571) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } fn on_initialize() -> Weight { - Weight::from_parts(181_000, 0) + Weight::from_parts(191_000, 0) } } \ No newline at end of file diff --git a/runtime/metaverse/src/weights/module_evm_mapping.rs b/runtime/metaverse/src/weights/module_evm_mapping.rs index fe09269a3..7a4b156da 100644 --- a/runtime/metaverse/src/weights/module_evm_mapping.rs +++ b/runtime/metaverse/src/weights/module_evm_mapping.rs @@ -23,13 +23,11 @@ pub struct WeightInfo(PhantomData); impl evm_mapping::WeightInfo for WeightInfo { fn claim_eth_account() -> Weight { - Weight::from_parts(39_571_000, 7673) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(2)) + Weight::from_parts(53_285_000, 12879) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) } fn claim_default_account() -> Weight { - Weight::from_parts(10_980_000, 2535) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(2)) + Weight::from_parts(24_582_000, 7741).saturating_add(T::DbWeight::get().reads(3)) } } diff --git a/runtime/metaverse/src/weights/module_metaverse.rs b/runtime/metaverse/src/weights/module_metaverse.rs index 5764ff2aa..6540fec1a 100644 --- a/runtime/metaverse/src/weights/module_metaverse.rs +++ b/runtime/metaverse/src/weights/module_metaverse.rs @@ -47,37 +47,37 @@ pub struct WeightInfo(PhantomData); impl metaverse::WeightInfo for WeightInfo{ fn create_metaverse() -> Weight { - Weight::from_parts(73_237_000, 27361) + Weight::from_parts(144_874_000, 27361) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(12)) } fn transfer_metaverse() -> Weight { - Weight::from_parts(21_461_000, 7534) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(3)) + Weight::from_parts(53_412_000, 13860) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(5)) } fn freeze_metaverse() -> Weight { - Weight::from_parts(18_064_000, 3722) + Weight::from_parts(26_870_000, 3722) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } fn unfreeze_metaverse() -> Weight { - Weight::from_parts(16_778_000, 3722) + Weight::from_parts(27_836_000, 3722) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } fn destroy_metaverse() -> Weight { - Weight::from_parts(18_411_000, 4969) + Weight::from_parts(28_903_000, 4969) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } fn update_metaverse_listing_fee() -> Weight { - Weight::from_parts(19_747_000, 7534) + Weight::from_parts(30_034_000, 7534) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn withdraw_from_metaverse_fund() -> Weight { - Weight::from_parts(34_242_000, 9444) + Weight::from_parts(47_894_000, 9444) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } diff --git a/runtime/metaverse/src/weights/module_mining.rs b/runtime/metaverse/src/weights/module_mining.rs index 58b9dbe3c..4b5aba1a0 100644 --- a/runtime/metaverse/src/weights/module_mining.rs +++ b/runtime/metaverse/src/weights/module_mining.rs @@ -9,52 +9,52 @@ pub struct WeightInfo(PhantomData); impl mining::WeightInfo for WeightInfo { fn add_minting_origin() -> Weight { - Weight::from_parts(8_665_000, 2551) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + Weight::from_parts(47_273_000, 8027) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } fn remove_minting_origin() -> Weight { - Weight::from_parts(9_396_000, 2625) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + Weight::from_parts(22_628_000, 8101) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } fn update_round_length() -> Weight { - Weight::from_parts(7_040_000, 571) + Weight::from_parts(7_119_000, 571) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } fn update_mining_issuance_config() -> Weight { - Weight::from_parts(8_115_000, 647) + Weight::from_parts(7_988_000, 647) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } fn mint() -> Weight { - Weight::from_parts(22_826_000, 8043) + Weight::from_parts(23_623_000, 8043) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } fn burn() -> Weight { - Weight::from_parts(24_969_000, 8043) + Weight::from_parts(24_990_000, 8043) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } fn deposit() -> Weight { - Weight::from_parts(31_798_000, 10398) + Weight::from_parts(32_866_000, 10398) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } fn withdraw() -> Weight { - Weight::from_parts(29_933_000, 10997) + Weight::from_parts(31_275_000, 10997) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } fn pause_mining_round() -> Weight { - Weight::from_parts(8_074_000, 1142) + Weight::from_parts(20_520_000, 1142) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn unpause_mining_round() -> Weight { - Weight::from_parts(8_775_000, 1190) + Weight::from_parts(22_937_000, 1190) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/runtime/metaverse/src/weights/module_nft.rs b/runtime/metaverse/src/weights/module_nft.rs index d0883c585..86909c591 100644 --- a/runtime/metaverse/src/weights/module_nft.rs +++ b/runtime/metaverse/src/weights/module_nft.rs @@ -12,57 +12,57 @@ pub struct WeightInfo(PhantomData); impl nft::WeightInfo for WeightInfo { fn create_group() -> Weight { - Weight::from_parts(12_179_000, 1317) + Weight::from_parts(12_117_000, 1317) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(3)) } fn create_class() -> Weight { - Weight::from_parts(27_797_000, 7417) + Weight::from_parts(37_465_000, 7417) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } fn mint() -> Weight { - Weight::from_parts(54_185_000, 23976) + Weight::from_parts(69_706_000, 23976) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(10)) } fn mint_stackable_nft() -> Weight { - Weight::from_parts(41_846_000, 15931) + Weight::from_parts(111_946_000, 15931) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(8)) } fn transfer() -> Weight { - Weight::from_parts(32_122_000, 17187) + Weight::from_parts(33_226_000, 17187) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } fn transfer_stackable_nft() -> Weight { - Weight::from_parts(28_373_000, 11790) + Weight::from_parts(28_946_000, 11790) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } fn transfer_batch() -> Weight { - Weight::from_parts(112_127_000, 25680) + Weight::from_parts(63_183_000, 25680) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(6)) } fn sign_asset() -> Weight { - Weight::from_parts(38_782_000, 11890) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) + Weight::from_parts(115_994_000, 14763) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) } fn set_hard_limit() -> Weight { - Weight::from_parts(15_065_000, 2757) + Weight::from_parts(23_425_000, 2757) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } fn withdraw_funds_from_class_fund() -> Weight { - Weight::from_parts(25_576_000, 8268) + Weight::from_parts(61_491_000, 8268) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } fn force_update_total_issuance() -> Weight { - Weight::from_parts(11_211_000, 2757) + Weight::from_parts(27_207_000, 2757) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/runtime/metaverse/src/weights/module_reward.rs b/runtime/metaverse/src/weights/module_reward.rs index 3e6372d47..d2e58c58d 100644 --- a/runtime/metaverse/src/weights/module_reward.rs +++ b/runtime/metaverse/src/weights/module_reward.rs @@ -11,86 +11,86 @@ use sp_std::marker::PhantomData; pub struct WeightInfo(PhantomData); impl reward::WeightInfo for WeightInfo { fn create_campaign() -> Weight { - Weight::from_parts(47_856_000, 12368) + Weight::from_parts(56_713_000, 12368) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(6)) } fn create_nft_campaign() -> Weight { - Weight::from_parts(51_776_000, 26330) + Weight::from_parts(58_468_000, 26918) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(7)) } fn claim_reward() -> Weight { - Weight::from_parts(43_780_000, 13249) + Weight::from_parts(42_927_000, 13585) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } fn claim_reward_root() -> Weight { - Weight::from_parts(50_524_000, 24159) + Weight::from_parts(51_031_000, 24831) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } fn claim_nft_reward() -> Weight { - Weight::from_parts(52_709_000, 33438) + Weight::from_parts(53_120_000, 34950) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } fn claim_nft_reward_root() -> Weight { - Weight::from_parts(118_897_000, 41895) + Weight::from_parts(79_172_000, 44835) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(2)) } fn set_reward() -> Weight { - Weight::from_parts(30_996_000, 13950) + Weight::from_parts(40_981_000, 14454) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } fn set_reward_root() -> Weight { - Weight::from_parts(31_147_000, 18600) + Weight::from_parts(42_695_000, 19272) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } fn set_nft_reward() -> Weight { - Weight::from_parts(32_853_000, 14163) + Weight::from_parts(44_297_000, 14919) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } fn set_nft_reward_root() -> Weight { - Weight::from_parts(32_100_000, 17525) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) + Weight::from_parts(51_800_000, 23580) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } fn close_campaign() -> Weight { - Weight::from_parts(67_727_000, 21663) + Weight::from_parts(68_700_000, 22503) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(6)) } fn close_nft_campaign() -> Weight { - Weight::from_parts(61_669_000, 30653) + Weight::from_parts(61_489_000, 32753) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(7)) } fn cancel_campaign() -> Weight { - Weight::from_parts(46_849_000, 7440) + Weight::from_parts(45_875_000, 7524) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } fn cancel_nft_campaign() -> Weight { - Weight::from_parts(42_579_000, 13131) + Weight::from_parts(41_755_000, 13467) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } fn add_set_reward_origin() -> Weight { - Weight::from_parts(15_236_000, 3436) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + Weight::from_parts(29_035_000, 6566) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } fn remove_set_reward_origin() -> Weight { - Weight::from_parts(15_816_000, 3510) + Weight::from_parts(21_305_000, 3510) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } fn on_finalize() -> Weight { - Weight::from_parts(19_256_000, 6753).saturating_add(T::DbWeight::get().reads(2)) + Weight::from_parts(35_303_000, 6837).saturating_add(T::DbWeight::get().reads(2)) } } diff --git a/runtime/pioneer/src/lib.rs b/runtime/pioneer/src/lib.rs index 426757ba8..ec66d3f43 100644 --- a/runtime/pioneer/src/lib.rs +++ b/runtime/pioneer/src/lib.rs @@ -99,6 +99,9 @@ mod weights; /// Constant values used within the runtime. pub mod constants; +/// Base storage fee +pub const BASE_STORAGE_FEE: Balance = 1 * DOLLARS; + /// Alias to 512-bit hash when used in the context of a transaction signature on the chain. pub type Signature = MultiSignature; @@ -679,7 +682,7 @@ impl pallet_democracy::Config for Runtime { parameter_type_with_key! { pub ExistentialDeposits: |_currency_id: FungibleTokenId| -> Balance { - Zero::zero() + EXISTENTIAL_DEPOSIT }; } @@ -1407,6 +1410,7 @@ parameter_types! { //Mining Resource Currency Id pub const MiningResourceCurrencyId: FungibleTokenId = FungibleTokenId::MiningResource(0); pub const TreasuryStakingReward: Perbill = Perbill::from_percent(1); + pub MiningStorageDeposit: Balance = BASE_STORAGE_FEE; } impl mining::Config for Runtime { @@ -1418,6 +1422,9 @@ impl mining::Config for Runtime { type AdminOrigin = EnsureRootOrMetaverseTreasury; type MetaverseStakingHandler = Metaverse; type TreasuryStakingReward = TreasuryStakingReward; + type NetworkTreasuryAccount = TreasuryModuleAccount; + type StorageDepositFee = MiningStorageDeposit; + type Currency = Balances; type WeightInfo = weights::module_mining::WeightInfo; } @@ -1427,6 +1434,7 @@ parameter_types! { pub MaxBatchTransfer: u32 = 100; pub MaxBatchMinting: u32 = 1000; pub MaxNftMetadata: u32 = 1024; + pub StorageDepositFee: Balance = BASE_STORAGE_FEE; } impl nft::Config for Runtime { @@ -1443,6 +1451,7 @@ impl nft::Config for Runtime { type MiningResourceId = MiningResourceCurrencyId; type AssetMintingFee = AssetMintingFee; type ClassMintingFee = ClassMintingFee; + type StorageDepositFee = StorageDepositFee; } parameter_types! { @@ -1464,10 +1473,12 @@ parameter_types! { pub MaxMetaverseMetadata: u32 = 1024; pub MinContribution: Balance = 50 * DOLLARS; pub MaxNumberOfStakersPerMetaverse: u32 = 512; + pub MetaverseStorageFee: Balance = 2 * BASE_STORAGE_FEE; } impl metaverse::Config for Runtime { type RuntimeEvent = RuntimeEvent; + type NetworkTreasury = TreasuryModuleAccount; type MetaverseTreasury = LocalMetaverseFundPalletId; type Currency = Balances; type MaxMetaverseMetadata = MaxMetaverseMetadata; @@ -1479,6 +1490,7 @@ impl metaverse::Config for Runtime { type MaxNumberOfStakersPerMetaverse = MaxNumberOfStakersPerMetaverse; type MultiCurrency = Currencies; type NFTHandler = Nft; + type StorageDepositFee = MetaverseStorageFee; } parameter_types! { @@ -1493,6 +1505,7 @@ parameter_types! { pub const MinLeasePricePerBlock: Balance = 1 * CENTS; pub const MaxLeasePeriod: u32 = 1000000; pub const LeaseOfferExpiryPeriod: u32 = 10000; + pub const EstateStorageFee: Balance = BASE_STORAGE_FEE; } impl estate::Config for Runtime { @@ -1515,6 +1528,7 @@ impl estate::Config for Runtime { type MaxLeasePeriod = MaxLeasePeriod; type LeaseOfferExpiryPeriod = LeaseOfferExpiryPeriod; type BlockNumberToBalance = ConvertInto; + type StorageDepositFee = EstateStorageFee; } parameter_types! { @@ -1529,6 +1543,7 @@ parameter_types! { pub const OfferDuration: BlockNumber = 100800; // Default 100800 Blocks pub const MinimumListingPrice: Balance = DOLLARS; pub const AntiSnipeDuration: BlockNumber = 50; // Minimum anti snipe duration is 50 blocks + pub const AuctionStorageFee: Balance = 3 * BASE_STORAGE_FEE; } impl auction::Config for Runtime { @@ -1550,8 +1565,12 @@ impl auction::Config for Runtime { type OfferDuration = OfferDuration; type MinimumListingPrice = MinimumListingPrice; type AntiSnipeDuration = AntiSnipeDuration; + type StorageDepositFee = AuctionStorageFee; } +parameter_types! { + pub const ContinuumStorageDeposit: Balance = BASE_STORAGE_FEE; +} impl continuum::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SessionDuration = ContinuumSessionDuration; @@ -1562,6 +1581,7 @@ impl continuum::Config for Runtime { type ContinuumTreasury = MetaverseNetworkTreasuryPalletId; type Currency = Balances; type MetaverseInfoSource = Metaverse; + type StorageDepositFee = ContinuumStorageDeposit; type WeightInfo = weights::module_continuum::WeightInfo; } @@ -1728,6 +1748,7 @@ parameter_types! { pub const MinimumCampaignDuration: BlockNumber = 30 * MINUTES; pub const MaxSetRewardsListLength: u64 = 200; pub const MaxLeafNodes: u32 = 30; + pub const RewardStorageFee: Balance = BASE_STORAGE_FEE; } impl reward::Config for Runtime { @@ -1744,6 +1765,7 @@ impl reward::Config for Runtime { type MaxSetRewardsListLength = MaxSetRewardsListLength; type AdminOrigin = EnsureRootOrMetaverseTreasury; type NFTHandler = Nft; + type StorageDepositFee = RewardStorageFee; type WeightInfo = weights::module_reward::WeightInfo; } diff --git a/runtime/pioneer/src/weights/module_auction.rs b/runtime/pioneer/src/weights/module_auction.rs index d83fe09af..fefdcf436 100644 --- a/runtime/pioneer/src/weights/module_auction.rs +++ b/runtime/pioneer/src/weights/module_auction.rs @@ -12,56 +12,56 @@ pub struct WeightInfo(PhantomData); impl auction::WeightInfo for WeightInfo { fn create_new_auction() -> Weight { - Weight::from_parts(83_359_000, 54013) + Weight::from_parts(61_885_000, 57373) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(7)) } fn create_new_buy_now() -> Weight { - Weight::from_parts(60_938_000, 54013) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(7)) + Weight::from_parts(74_722_000, 61706) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(8)) } fn bid() -> Weight { - Weight::from_parts(52_851_000, 17254) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(5)) + Weight::from_parts(75_918_000, 25151) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(7)) } fn buy_now() -> Weight { - Weight::from_parts(117_267_000, 74974) + Weight::from_parts(121_030_000, 78754) .saturating_add(T::DbWeight::get().reads(13)) .saturating_add(T::DbWeight::get().writes(12)) } fn cancel_listing() -> Weight { - Weight::from_parts(76_276_000, 28348) + Weight::from_parts(50_823_000, 30028) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(6)) } fn authorise_metaverse_collection() -> Weight { - Weight::from_parts(35_078_000, 7564) + Weight::from_parts(23_046_000, 7564) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn remove_authorise_metaverse_collection() -> Weight { - Weight::from_parts(24_963_000, 7670) + Weight::from_parts(23_607_000, 7670) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn make_offer() -> Weight { - Weight::from_parts(38_021_000, 15443) + Weight::from_parts(38_079_000, 15443) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } fn withdraw_offer() -> Weight { - Weight::from_parts(29_056_000, 6612) + Weight::from_parts(28_621_000, 6612) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } fn accept_offer() -> Weight { - Weight::from_parts(69_244_000, 31537) + Weight::from_parts(72_454_000, 31537) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(6)) } fn on_finalize() -> Weight { - Weight::from_parts(6_116_000, 0) + Weight::from_parts(7_467_000, 0) } } diff --git a/runtime/pioneer/src/weights/module_continuum.rs b/runtime/pioneer/src/weights/module_continuum.rs index 6fe4da508..73259bb20 100644 --- a/runtime/pioneer/src/weights/module_continuum.rs +++ b/runtime/pioneer/src/weights/module_continuum.rs @@ -9,29 +9,29 @@ pub struct WeightInfo(PhantomData); impl continuum::WeightInfo for WeightInfo { fn set_allow_buy_now() -> Weight { - Weight::from_parts(3_836_000, 646).saturating_add(T::DbWeight::get().writes(1)) + Weight::from_parts(6_650_000, 646).saturating_add(T::DbWeight::get().writes(1)) } fn set_max_bounds() -> Weight { - Weight::from_parts(10_396_000, 919).saturating_add(T::DbWeight::get().writes(1)) + Weight::from_parts(25_462_000, 919).saturating_add(T::DbWeight::get().writes(1)) } fn issue_map_slot() -> Weight { - Weight::from_parts(15_692_000, 5088) + Weight::from_parts(24_533_000, 5088) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn create_new_auction() -> Weight { - Weight::from_parts(36_453_000, 20225) + Weight::from_parts(85_653_000, 20225) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(6)) } fn buy_map_spot() -> Weight { - Weight::from_parts(172_450_000, 59161) + Weight::from_parts(170_947_000, 59161) .saturating_add(T::DbWeight::get().reads(11)) .saturating_add(T::DbWeight::get().writes(8)) } fn bid_map_spot() -> Weight { - Weight::from_parts(67_164_000, 40870) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(3)) + Weight::from_parts(120_875_000, 44418) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) } } diff --git a/runtime/pioneer/src/weights/module_estate.rs b/runtime/pioneer/src/weights/module_estate.rs index 5490c5349..49d8f7f85 100644 --- a/runtime/pioneer/src/weights/module_estate.rs +++ b/runtime/pioneer/src/weights/module_estate.rs @@ -48,121 +48,121 @@ pub struct WeightInfo(PhantomData); impl estate::WeightInfo for WeightInfo { fn mint_land() -> Weight { - Weight::from_parts(58_455_000, 36660) + Weight::from_parts(59_273_000, 36660) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(7)) } fn mint_lands() -> Weight { - Weight::from_parts(85_264_000, 41610) + Weight::from_parts(83_541_000, 41610) .saturating_add(T::DbWeight::get().reads(10)) .saturating_add(T::DbWeight::get().writes(10)) } fn transfer_land() -> Weight { - Weight::from_parts(98_162_000, 28255) + Weight::from_parts(47_423_000, 28255) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } fn mint_estate() -> Weight { - Weight::from_parts(70_956_000, 47210) + Weight::from_parts(64_479_000, 47210) .saturating_add(T::DbWeight::get().reads(10)) .saturating_add(T::DbWeight::get().writes(11)) } fn dissolve_estate() -> Weight { - Weight::from_parts(90_916_000, 62718) - .saturating_add(T::DbWeight::get().reads(13)) - .saturating_add(T::DbWeight::get().writes(12)) + Weight::from_parts(110_008_000, 67224) + .saturating_add(T::DbWeight::get().reads(14)) + .saturating_add(T::DbWeight::get().writes(13)) } fn add_land_unit_to_estate() -> Weight { - Weight::from_parts(57_930_000, 31521) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(5)) + Weight::from_parts(71_706_000, 38079) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(6)) } fn remove_land_unit_from_estate() -> Weight { - Weight::from_parts(172_334_000, 55893) - .saturating_add(T::DbWeight::get().reads(11)) - .saturating_add(T::DbWeight::get().writes(7)) + Weight::from_parts(90_257_000, 60226) + .saturating_add(T::DbWeight::get().reads(12)) + .saturating_add(T::DbWeight::get().writes(8)) } fn create_estate() -> Weight { - Weight::from_parts(123_103_000, 66058) + Weight::from_parts(131_741_000, 66058) .saturating_add(T::DbWeight::get().reads(14)) .saturating_add(T::DbWeight::get().writes(17)) } fn transfer_estate() -> Weight { - Weight::from_parts(54_578_000, 38025) + Weight::from_parts(54_808_000, 38025) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(4)) } fn issue_undeployed_land_blocks() -> Weight { - Weight::from_parts(146_607_000, 4962) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(42)) + Weight::from_parts(162_875_000, 9825) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(43)) } fn freeze_undeployed_land_blocks() -> Weight { - Weight::from_parts(21_200_000, 7834) + Weight::from_parts(22_833_000, 7834) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn unfreeze_undeployed_land_blocks() -> Weight { - Weight::from_parts(47_505_000, 7834) + Weight::from_parts(21_423_000, 7834) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn approve_undeployed_land_blocks() -> Weight { - Weight::from_parts(21_983_000, 7834) + Weight::from_parts(21_819_000, 7834) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn unapprove_undeployed_land_blocks() -> Weight { - Weight::from_parts(20_803_000, 7900) + Weight::from_parts(21_237_000, 7900) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn transfer_undeployed_land_blocks() -> Weight { - Weight::from_parts(24_091_000, 9276) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(3)) + Weight::from_parts(41_173_000, 13673) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(4)) } fn deploy_land_block() -> Weight { - Weight::from_parts(94_020_000, 64897) + Weight::from_parts(100_659_000, 64897) .saturating_add(T::DbWeight::get().reads(13)) .saturating_add(T::DbWeight::get().writes(11)) } fn burn_undeployed_land_blocks() -> Weight { - Weight::from_parts(23_737_000, 10661) + Weight::from_parts(32_196_000, 10661) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } fn create_lease_offer() -> Weight { - Weight::from_parts(43_758_000, 27383) + Weight::from_parts(98_902_000, 27383) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(2)) } fn accept_lease_offer() -> Weight { - Weight::from_parts(39_408_000, 22653) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) + Weight::from_parts(57_019_000, 28844) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) } fn cancel_lease() -> Weight { - Weight::from_parts(61_047_000, 27227) + Weight::from_parts(57_720_000, 28571) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } fn remove_expired_lease() -> Weight { - Weight::from_parts(57_210_000, 27227) + Weight::from_parts(57_681_000, 28571) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } fn remove_lease_offer() -> Weight { - Weight::from_parts(32_044_000, 8076) + Weight::from_parts(41_923_000, 8328) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } fn collect_rent() -> Weight { - Weight::from_parts(52_885_000, 27227) + Weight::from_parts(53_171_000, 28571) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } fn on_initialize() -> Weight { - Weight::from_parts(181_000, 0) + Weight::from_parts(191_000, 0) } } \ No newline at end of file diff --git a/runtime/pioneer/src/weights/module_metaverse.rs b/runtime/pioneer/src/weights/module_metaverse.rs index 5764ff2aa..6540fec1a 100644 --- a/runtime/pioneer/src/weights/module_metaverse.rs +++ b/runtime/pioneer/src/weights/module_metaverse.rs @@ -47,37 +47,37 @@ pub struct WeightInfo(PhantomData); impl metaverse::WeightInfo for WeightInfo{ fn create_metaverse() -> Weight { - Weight::from_parts(73_237_000, 27361) + Weight::from_parts(144_874_000, 27361) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(12)) } fn transfer_metaverse() -> Weight { - Weight::from_parts(21_461_000, 7534) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(3)) + Weight::from_parts(53_412_000, 13860) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(5)) } fn freeze_metaverse() -> Weight { - Weight::from_parts(18_064_000, 3722) + Weight::from_parts(26_870_000, 3722) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } fn unfreeze_metaverse() -> Weight { - Weight::from_parts(16_778_000, 3722) + Weight::from_parts(27_836_000, 3722) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } fn destroy_metaverse() -> Weight { - Weight::from_parts(18_411_000, 4969) + Weight::from_parts(28_903_000, 4969) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } fn update_metaverse_listing_fee() -> Weight { - Weight::from_parts(19_747_000, 7534) + Weight::from_parts(30_034_000, 7534) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn withdraw_from_metaverse_fund() -> Weight { - Weight::from_parts(34_242_000, 9444) + Weight::from_parts(47_894_000, 9444) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } diff --git a/runtime/pioneer/src/weights/module_mining.rs b/runtime/pioneer/src/weights/module_mining.rs index 58b9dbe3c..4b5aba1a0 100644 --- a/runtime/pioneer/src/weights/module_mining.rs +++ b/runtime/pioneer/src/weights/module_mining.rs @@ -9,52 +9,52 @@ pub struct WeightInfo(PhantomData); impl mining::WeightInfo for WeightInfo { fn add_minting_origin() -> Weight { - Weight::from_parts(8_665_000, 2551) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + Weight::from_parts(47_273_000, 8027) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } fn remove_minting_origin() -> Weight { - Weight::from_parts(9_396_000, 2625) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + Weight::from_parts(22_628_000, 8101) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } fn update_round_length() -> Weight { - Weight::from_parts(7_040_000, 571) + Weight::from_parts(7_119_000, 571) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } fn update_mining_issuance_config() -> Weight { - Weight::from_parts(8_115_000, 647) + Weight::from_parts(7_988_000, 647) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } fn mint() -> Weight { - Weight::from_parts(22_826_000, 8043) + Weight::from_parts(23_623_000, 8043) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } fn burn() -> Weight { - Weight::from_parts(24_969_000, 8043) + Weight::from_parts(24_990_000, 8043) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } fn deposit() -> Weight { - Weight::from_parts(31_798_000, 10398) + Weight::from_parts(32_866_000, 10398) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } fn withdraw() -> Weight { - Weight::from_parts(29_933_000, 10997) + Weight::from_parts(31_275_000, 10997) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } fn pause_mining_round() -> Weight { - Weight::from_parts(8_074_000, 1142) + Weight::from_parts(20_520_000, 1142) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } fn unpause_mining_round() -> Weight { - Weight::from_parts(8_775_000, 1190) + Weight::from_parts(22_937_000, 1190) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/runtime/pioneer/src/weights/module_nft.rs b/runtime/pioneer/src/weights/module_nft.rs index d0883c585..86909c591 100644 --- a/runtime/pioneer/src/weights/module_nft.rs +++ b/runtime/pioneer/src/weights/module_nft.rs @@ -12,57 +12,57 @@ pub struct WeightInfo(PhantomData); impl nft::WeightInfo for WeightInfo { fn create_group() -> Weight { - Weight::from_parts(12_179_000, 1317) + Weight::from_parts(12_117_000, 1317) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(3)) } fn create_class() -> Weight { - Weight::from_parts(27_797_000, 7417) + Weight::from_parts(37_465_000, 7417) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } fn mint() -> Weight { - Weight::from_parts(54_185_000, 23976) + Weight::from_parts(69_706_000, 23976) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(10)) } fn mint_stackable_nft() -> Weight { - Weight::from_parts(41_846_000, 15931) + Weight::from_parts(111_946_000, 15931) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(8)) } fn transfer() -> Weight { - Weight::from_parts(32_122_000, 17187) + Weight::from_parts(33_226_000, 17187) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } fn transfer_stackable_nft() -> Weight { - Weight::from_parts(28_373_000, 11790) + Weight::from_parts(28_946_000, 11790) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } fn transfer_batch() -> Weight { - Weight::from_parts(112_127_000, 25680) + Weight::from_parts(63_183_000, 25680) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(6)) } fn sign_asset() -> Weight { - Weight::from_parts(38_782_000, 11890) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) + Weight::from_parts(115_994_000, 14763) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) } fn set_hard_limit() -> Weight { - Weight::from_parts(15_065_000, 2757) + Weight::from_parts(23_425_000, 2757) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } fn withdraw_funds_from_class_fund() -> Weight { - Weight::from_parts(25_576_000, 8268) + Weight::from_parts(61_491_000, 8268) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } fn force_update_total_issuance() -> Weight { - Weight::from_parts(11_211_000, 2757) + Weight::from_parts(27_207_000, 2757) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/runtime/pioneer/src/weights/module_reward.rs b/runtime/pioneer/src/weights/module_reward.rs index 3e6372d47..d2e58c58d 100644 --- a/runtime/pioneer/src/weights/module_reward.rs +++ b/runtime/pioneer/src/weights/module_reward.rs @@ -11,86 +11,86 @@ use sp_std::marker::PhantomData; pub struct WeightInfo(PhantomData); impl reward::WeightInfo for WeightInfo { fn create_campaign() -> Weight { - Weight::from_parts(47_856_000, 12368) + Weight::from_parts(56_713_000, 12368) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(6)) } fn create_nft_campaign() -> Weight { - Weight::from_parts(51_776_000, 26330) + Weight::from_parts(58_468_000, 26918) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(7)) } fn claim_reward() -> Weight { - Weight::from_parts(43_780_000, 13249) + Weight::from_parts(42_927_000, 13585) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } fn claim_reward_root() -> Weight { - Weight::from_parts(50_524_000, 24159) + Weight::from_parts(51_031_000, 24831) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } fn claim_nft_reward() -> Weight { - Weight::from_parts(52_709_000, 33438) + Weight::from_parts(53_120_000, 34950) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } fn claim_nft_reward_root() -> Weight { - Weight::from_parts(118_897_000, 41895) + Weight::from_parts(79_172_000, 44835) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(2)) } fn set_reward() -> Weight { - Weight::from_parts(30_996_000, 13950) + Weight::from_parts(40_981_000, 14454) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } fn set_reward_root() -> Weight { - Weight::from_parts(31_147_000, 18600) + Weight::from_parts(42_695_000, 19272) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } fn set_nft_reward() -> Weight { - Weight::from_parts(32_853_000, 14163) + Weight::from_parts(44_297_000, 14919) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } fn set_nft_reward_root() -> Weight { - Weight::from_parts(32_100_000, 17525) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) + Weight::from_parts(51_800_000, 23580) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } fn close_campaign() -> Weight { - Weight::from_parts(67_727_000, 21663) + Weight::from_parts(68_700_000, 22503) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(6)) } fn close_nft_campaign() -> Weight { - Weight::from_parts(61_669_000, 30653) + Weight::from_parts(61_489_000, 32753) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(7)) } fn cancel_campaign() -> Weight { - Weight::from_parts(46_849_000, 7440) + Weight::from_parts(45_875_000, 7524) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } fn cancel_nft_campaign() -> Weight { - Weight::from_parts(42_579_000, 13131) + Weight::from_parts(41_755_000, 13467) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } fn add_set_reward_origin() -> Weight { - Weight::from_parts(15_236_000, 3436) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + Weight::from_parts(29_035_000, 6566) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } fn remove_set_reward_origin() -> Weight { - Weight::from_parts(15_816_000, 3510) + Weight::from_parts(21_305_000, 3510) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } fn on_finalize() -> Weight { - Weight::from_parts(19_256_000, 6753).saturating_add(T::DbWeight::get().reads(2)) + Weight::from_parts(35_303_000, 6837).saturating_add(T::DbWeight::get().reads(2)) } }